use of org.eclipse.jetty.deploy.App in project jetty.project by eclipse.
the class ServiceContextProvider method serviceRemoved.
/* ------------------------------------------------------------ */
public boolean serviceRemoved(ServiceReference serviceRef, ContextHandler context) {
if (context == null || serviceRef == null)
return false;
String watermark = (String) serviceRef.getProperty(OSGiWebappConstants.WATERMARK);
if (watermark != null && !"".equals(watermark))
//this service represents a contexthandler that will be deregistered as a service by another of our deployers
return false;
App app = _serviceMap.remove(serviceRef);
if (app != null) {
getDeploymentManager().removeApp(app);
return true;
}
return false;
}
use of org.eclipse.jetty.deploy.App in project jetty.project by eclipse.
the class OverlayedAppProvider method redeploy.
/* ------------------------------------------------------------ */
/**
* Walks the defined webapps, templates, nodes and instances to
* determine what should be deployed, then adjust reality to match.
*/
protected void redeploy() {
Map<String, Template> templates = new ConcurrentHashMap<String, Template>();
// Check for duplicate templates
for (Template template : _templates.values()) {
Template other = templates.get(template.getTemplateName());
if (other != null) {
__log.warn("Multiple Templates: {} & {}", template.getName(), other.getName());
if (other.getName().compareToIgnoreCase(template.getName()) <= 0)
continue;
}
templates.put(template.getTemplateName(), template);
}
// Match webapps to templates
for (Template template : templates.values()) {
String webappname = template.getClassifier();
if (webappname == null)
continue;
Webapp webapp = _webapps.get(webappname);
if (webapp == null) {
__log.warn("No webapp found for template: {}", template.getName());
templates.remove(template.getTemplateName());
} else {
template.setWebapp(webapp);
}
}
// Match instance to templates and check if what needs to be deployed or undeployed.
Set<String> deployed = new HashSet<String>();
List<Instance> deploy = new ArrayList<Instance>();
for (Instance instance : _instances.values()) {
Template template = templates.get(instance.getTemplateName());
instance.setTemplate(template);
if (template != null) {
String key = instance.getInstanceKey();
App app = _deployed.get(key);
if (app == null)
deploy.add(instance);
else
deployed.add(key);
}
}
// Look for deployed apps that need to be undeployed
List<String> undeploy = new ArrayList<String>();
for (String key : _deployed.keySet()) {
if (!deployed.contains(key))
undeploy.add(key);
}
// Do the undeploys
for (String key : undeploy) {
App app = _deployed.remove(key);
if (app != null) {
__log.info("Undeploy {}", key);
_deploymentManager.removeApp(app);
}
}
// ready the deploys
for (Instance instance : deploy) {
String key = instance.getInstanceKey();
OverlayedApp app = new OverlayedApp(_deploymentManager, this, key, instance);
_deployed.put(key, app);
}
// Remove unused Shared stuff
Set<String> sharedKeys = new HashSet<String>(_shared.keySet());
for (OverlayedApp app : _deployed.values()) {
Instance instance = app.getInstance();
sharedKeys.remove(instance.getSharedKey());
}
for (String sharedKey : sharedKeys) {
__log.debug("Remove " + sharedKey);
TemplateContext shared = _shared.remove(sharedKey);
if (shared != null) {
try {
shared.stop();
} catch (Exception e) {
__log.warn(e);
}
shared.destroy();
}
}
// Do the deploys
for (Instance instance : deploy) {
String key = instance.getInstanceKey();
OverlayedApp app = _deployed.get(key);
__log.info("Deploy {}", key);
_deploymentManager.addApp(app);
}
}
use of org.eclipse.jetty.deploy.App in project jetty.project by eclipse.
the class BundleContextProvider method bundleRemoved.
/* ------------------------------------------------------------ */
/**
* Bundle has been removed. If it was a context we deployed, undeploy it.
*
* @param bundle the bundle
* @return true if this was a context we had deployed, false otherwise
*/
public boolean bundleRemoved(Bundle bundle) throws Exception {
List<App> apps = _bundleMap.remove(bundle);
boolean removed = false;
if (apps != null) {
for (App app : apps) {
_appMap.remove(app.getOriginId());
getDeploymentManager().removeApp(app);
removed = true;
}
}
//true if even 1 context was removed associated with this bundle
return removed;
}
use of org.eclipse.jetty.deploy.App in project jetty.project by eclipse.
the class ServiceWebAppProvider method serviceRemoved.
/* ------------------------------------------------------------ */
/**
* @param context the webapp
*/
public boolean serviceRemoved(ServiceReference serviceRef, ContextHandler context) {
if (context == null || !(context instanceof WebAppContext))
return false;
String watermark = (String) serviceRef.getProperty(OSGiWebappConstants.WATERMARK);
if (watermark != null && !"".equals(watermark))
//this service represents a contexthandler that will be deregistered as a service by another of our deployers
return false;
App app = _serviceMap.remove(serviceRef);
if (app != null) {
getDeploymentManager().removeApp(app);
return true;
}
return false;
}
use of org.eclipse.jetty.deploy.App in project jetty.project by eclipse.
the class OverlayedAppProvider method doStop.
/* ------------------------------------------------------------ */
/**
* @see org.eclipse.jetty.util.component.AbstractLifeCycle#doStop()
*/
@Override
protected void doStop() throws Exception {
_scanner.removeListener(_listener);
_scanner.stop();
if (_deploymentManager.isRunning()) {
for (App app : _deployed.values()) _deploymentManager.removeApp(app);
}
_deployed.clear();
for (Layer layer : _webapps.values()) layer.release();
_webapps.clear();
for (Layer layer : _templates.values()) layer.release();
_templates.clear();
if (_node != null)
_node.release();
for (Layer layer : _instances.values()) layer.release();
_instances.clear();
super.doStop();
}
Aggregations