Search in sources :

Example 1 with AppProvider

use of org.eclipse.jetty.deploy.AppProvider in project jetty.project by eclipse.

the class ServerInstanceWrapper method init.

/* ------------------------------------------------------------ */
/**
     * Must be called after the server is configured. 
     * 
     * It is assumed the server has already been configured with the ContextHandlerCollection structure.
     * 
     */
private void init() {
    // Get the context handler
    _ctxtCollection = (ContextHandlerCollection) _server.getChildHandlerByClass(ContextHandlerCollection.class);
    if (_ctxtCollection == null)
        throw new IllegalStateException("ERROR: No ContextHandlerCollection configured in Server");
    List<String> providerClassNames = new ArrayList<String>();
    // get a deployerManager and some providers
    Collection<DeploymentManager> deployers = _server.getBeans(DeploymentManager.class);
    if (deployers != null && !deployers.isEmpty()) {
        _deploymentManager = deployers.iterator().next();
        for (AppProvider provider : _deploymentManager.getAppProviders()) {
            providerClassNames.add(provider.getClass().getName());
        }
    } else {
        //add some kind of default
        _deploymentManager = new DeploymentManager();
        _deploymentManager.setContexts(_ctxtCollection);
        _server.addBean(_deploymentManager);
    }
    _deploymentManager.setUseStandardBindings(false);
    List<AppLifeCycle.Binding> deploymentLifeCycleBindings = new ArrayList<AppLifeCycle.Binding>();
    deploymentLifeCycleBindings.add(new OSGiDeployer(this));
    deploymentLifeCycleBindings.add(new StandardStarter());
    deploymentLifeCycleBindings.add(new StandardStopper());
    deploymentLifeCycleBindings.add(new OSGiUndeployer(this));
    _deploymentManager.setLifeCycleBindings(deploymentLifeCycleBindings);
    if (!providerClassNames.contains(BundleWebAppProvider.class.getName())) {
        // create it on the fly with reasonable default values.
        try {
            BundleWebAppProvider webAppProvider = new BundleWebAppProvider(this);
            _deploymentManager.addAppProvider(webAppProvider);
        } catch (Exception e) {
            LOG.warn(e);
        }
    }
    if (!providerClassNames.contains(ServiceWebAppProvider.class.getName())) {
        // create it on the fly with reasonable default values.
        try {
            ServiceWebAppProvider webAppProvider = new ServiceWebAppProvider(this);
            _deploymentManager.addAppProvider(webAppProvider);
        } catch (Exception e) {
            LOG.warn(e);
        }
    }
    if (!providerClassNames.contains(BundleContextProvider.class.getName())) {
        try {
            BundleContextProvider contextProvider = new BundleContextProvider(this);
            _deploymentManager.addAppProvider(contextProvider);
        } catch (Exception e) {
            LOG.warn(e);
        }
    }
    if (!providerClassNames.contains(ServiceContextProvider.class.getName())) {
        try {
            ServiceContextProvider contextProvider = new ServiceContextProvider(this);
            _deploymentManager.addAppProvider(contextProvider);
        } catch (Exception e) {
            LOG.warn(e);
        }
    }
}
Also used : StandardStopper(org.eclipse.jetty.deploy.bindings.StandardStopper) BundleContextProvider(org.eclipse.jetty.osgi.boot.BundleContextProvider) DeploymentManager(org.eclipse.jetty.deploy.DeploymentManager) ServiceContextProvider(org.eclipse.jetty.osgi.boot.ServiceContextProvider) ArrayList(java.util.ArrayList) OSGiDeployer(org.eclipse.jetty.osgi.boot.OSGiDeployer) StandardStarter(org.eclipse.jetty.deploy.bindings.StandardStarter) OSGiUndeployer(org.eclipse.jetty.osgi.boot.OSGiUndeployer) BundleWebAppProvider(org.eclipse.jetty.osgi.boot.BundleWebAppProvider) ServiceWebAppProvider(org.eclipse.jetty.osgi.boot.ServiceWebAppProvider) AppProvider(org.eclipse.jetty.deploy.AppProvider) BundleWebAppProvider(org.eclipse.jetty.osgi.boot.BundleWebAppProvider) ServiceWebAppProvider(org.eclipse.jetty.osgi.boot.ServiceWebAppProvider) AppLifeCycle(org.eclipse.jetty.deploy.AppLifeCycle)

Example 2 with AppProvider

use of org.eclipse.jetty.deploy.AppProvider in project jetty.project by eclipse.

the class ScanningAppProviderRuntimeUpdatesTest method setupEnvironment.

@Before
public void setupEnvironment() throws Exception {
    testdir.ensureEmpty();
    Resource.setDefaultUseCaches(false);
    jetty = new XmlConfiguredJetty(testdir);
    jetty.addConfiguration("jetty.xml");
    jetty.addConfiguration("jetty-http.xml");
    jetty.addConfiguration("jetty-deploymgr-contexts.xml");
    // Should not throw an Exception
    jetty.load();
    // Start it
    jetty.start();
    // monitor tick
    DeploymentManager dm = jetty.getServer().getBean(DeploymentManager.class);
    for (AppProvider provider : dm.getAppProviders()) {
        if (provider instanceof ScanningAppProvider) {
            _providers++;
            ((ScanningAppProvider) provider).addScannerListener(new Scanner.ScanListener() {

                public void scan() {
                    _scans.incrementAndGet();
                }
            });
        }
    }
}
Also used : Scanner(org.eclipse.jetty.util.Scanner) AppProvider(org.eclipse.jetty.deploy.AppProvider) DeploymentManager(org.eclipse.jetty.deploy.DeploymentManager) XmlConfiguredJetty(org.eclipse.jetty.deploy.test.XmlConfiguredJetty) Before(org.junit.Before)

Aggregations

AppProvider (org.eclipse.jetty.deploy.AppProvider)2 DeploymentManager (org.eclipse.jetty.deploy.DeploymentManager)2 ArrayList (java.util.ArrayList)1 AppLifeCycle (org.eclipse.jetty.deploy.AppLifeCycle)1 StandardStarter (org.eclipse.jetty.deploy.bindings.StandardStarter)1 StandardStopper (org.eclipse.jetty.deploy.bindings.StandardStopper)1 XmlConfiguredJetty (org.eclipse.jetty.deploy.test.XmlConfiguredJetty)1 BundleContextProvider (org.eclipse.jetty.osgi.boot.BundleContextProvider)1 BundleWebAppProvider (org.eclipse.jetty.osgi.boot.BundleWebAppProvider)1 OSGiDeployer (org.eclipse.jetty.osgi.boot.OSGiDeployer)1 OSGiUndeployer (org.eclipse.jetty.osgi.boot.OSGiUndeployer)1 ServiceContextProvider (org.eclipse.jetty.osgi.boot.ServiceContextProvider)1 ServiceWebAppProvider (org.eclipse.jetty.osgi.boot.ServiceWebAppProvider)1 Scanner (org.eclipse.jetty.util.Scanner)1 Before (org.junit.Before)1