Search in sources :

Example 1 with StartupHandler

use of org.apache.sling.launchpad.api.StartupHandler in project sling by apache.

the class ServicesListener method notifyChange.

/**
     * Notify of service changes from the listeners.
     * If all services are available, register listener and pass resources
     * to the OSGi installer.
     */
public synchronized void notifyChange() {
    // check if all services are available
    final OsgiInstaller installer = (OsgiInstaller) this.installerListener.getService();
    final LaunchpadContentProvider lcp = (LaunchpadContentProvider) this.providerListener.getService();
    final StartupHandler handler = (StartupHandler) this.startupListener.getService();
    final SlingSettingsService settings = (SlingSettingsService) this.settingsListener.getService();
    if (installer != null && lcp != null && handler != null && settings != null) {
        if (!this.installed) {
            this.installed = true;
            this.launchpadListener = new LaunchpadListener(handler);
            final Dictionary<String, Object> props = new Hashtable<String, Object>();
            props.put(Constants.SERVICE_DESCRIPTION, "Apache Sling Launchpad Startup Listener");
            props.put(Constants.SERVICE_VENDOR, "The Apache Software Foundation");
            this.launchpadListenerReg = this.bundleContext.registerService(InstallationListener.class.getName(), launchpadListener, props);
            LaunchpadConfigInstaller.install(installer, lcp, settings.getRunModes());
        }
    }
}
Also used : LaunchpadContentProvider(org.apache.sling.launchpad.api.LaunchpadContentProvider) Hashtable(java.util.Hashtable) StartupHandler(org.apache.sling.launchpad.api.StartupHandler) OsgiInstaller(org.apache.sling.installer.api.OsgiInstaller) SlingSettingsService(org.apache.sling.settings.SlingSettingsService)

Example 2 with StartupHandler

use of org.apache.sling.launchpad.api.StartupHandler in project sling by apache.

the class SlingSetupTest method setup.

@Before
public void setup() {
    // In Sling launchpad 7 the SlingSettings service
    // requires a StartupHandler, and that's usually provided
    // by the launchpad bootstrap code. Supply our own so that
    // everything starts properly.
    // TODO should be provided by a utility/bootstrap bundle
    final StartupHandler h = new StartupHandler() {

        public void waitWithStartup(boolean b) {
        }

        public boolean isFinished() {
            return true;
        }

        public StartupMode getMode() {
            return StartupMode.INSTALL;
        }
    };
    startupHandlerRegistration = bundleContext.registerService(StartupHandler.class.getName(), h, null);
}
Also used : StartupHandler(org.apache.sling.launchpad.api.StartupHandler) Before(org.junit.Before)

Example 3 with StartupHandler

use of org.apache.sling.launchpad.api.StartupHandler in project sling by apache.

the class ContentBundleTestBase method registerStartupHandler.

private void registerStartupHandler() {
    // SLING-4917 (org.apache.sling.paxexam.util.SlingSetupTest)
    // In Sling launchpad 7 the SlingSettings service
    // requires a StartupHandler, and that's usually provided
    // by the launchpad bootstrap code. Supply our own so that
    // everything starts properly.
    // TODO should be provided by a utility/bootstrap bundle
    final StartupHandler h = new StartupHandler() {

        public void waitWithStartup(boolean b) {
        }

        public boolean isFinished() {
            return true;
        }

        public StartupMode getMode() {
            return StartupMode.INSTALL;
        }
    };
    bundleContext.registerService(StartupHandler.class.getName(), h, null);
}
Also used : StartupHandler(org.apache.sling.launchpad.api.StartupHandler)

Aggregations

StartupHandler (org.apache.sling.launchpad.api.StartupHandler)3 Hashtable (java.util.Hashtable)1 OsgiInstaller (org.apache.sling.installer.api.OsgiInstaller)1 LaunchpadContentProvider (org.apache.sling.launchpad.api.LaunchpadContentProvider)1 SlingSettingsService (org.apache.sling.settings.SlingSettingsService)1 Before (org.junit.Before)1