use of org.eclipse.jetty.osgi.boot.OSGiUndeployer 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);
}
}
}
Aggregations