/*
 * See the NOTICE file distributed with this work for additional
 * information regarding copyright ownership.
 *
 * This is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; either version 2.1 of
 * the License, or (at your option) any later version.
 *
 * This software is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this software; if not, write to the Free
 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
 */

package org.xwiki.extension.handler.internal;

import java.util.Collections;
import java.util.List;

import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Singleton;

import org.xwiki.component.annotation.Component;
import org.xwiki.extension.handler.ExtensionInitializer;
import org.xwiki.observation.EventListener;
import org.xwiki.observation.event.ApplicationStartedEvent;
import org.xwiki.observation.event.Event;

/**
 * An application started listener to initialize extensions.
 *
 * @version $Id$
 * @since 4.0M1
 */
@Component
@Singleton
@Named("ExtensionApplicationStartedListener")
public class ExtensionApplicationStartedListener implements EventListener
{
    /**
     * The list of events observed.
     */
    private static final List<Event> EVENTS = Collections.<Event> singletonList(new ApplicationStartedEvent());

    /**
     * The extension initializer.
     */
    @Inject
    private ExtensionInitializer extensionInitializer;

    @Override
    public List<Event> getEvents()
    {
        return EVENTS;
    }

    @Override
    public String getName()
    {
        return "ExtensionApplicationStartedListener";
    }

    @Override
    public void onEvent(Event arg0, Object arg1, Object arg2)
    {
        extensionInitializer.initialize();
    }
}

@@ -1044,16 +1044,46 @@
 .Named;%0A
+import javax.inject.Provider;%0A
 import j
@@ -1422,24 +1422,25 @@
 tensions.%0A *
+ 
 %0A * @version
@@ -1816,16 +1816,103 @@
 alizer.%0A
+     * %3Cp%3E%0A     * Use it only when receiving an %7B@link ApplicationStartedEvent%7D event.%0A
      */%0A
@@ -1935,16 +1935,25 @@
 private 
+Provider%3C
 Extensio
@@ -1964,16 +1964,17 @@
 tializer
+%3E
  extensi
@@ -2273,16 +2273,21 @@
         
+this.
 extensio
@@ -2299,16 +2299,22 @@
 ializer.
+get().
 initiali

Load core/local extension when explicitely asking for it