/** Publishes the endpoints declared to the provided WSEndpointDeploymentUnit */ public List<Endpoint> publish(ServiceTarget target, WSEndpointDeploymentUnit unit) throws Exception { List<DeploymentAspect> aspects = DeploymentAspectsProvider.getSortedDeploymentAspects(); ClassLoader origClassLoader = SecurityActions.getContextClassLoader(); Deployment dep = null; try { SecurityActions.setContextClassLoader( ClassLoaderProvider.getDefaultProvider().getServerIntegrationClassLoader()); WSDeploymentBuilder.getInstance().build(unit); dep = unit.getAttachment(WSAttachmentKeys.DEPLOYMENT_KEY); dep.addAttachment(ServiceTarget.class, target); DeploymentAspectManager dam = new DeploymentAspectManagerImpl(); dam.setDeploymentAspects(aspects); dam.deploy(dep); } finally { if (dep != null) { dep.removeAttachment(ServiceTarget.class); } SecurityActions.setContextClassLoader(origClassLoader); } Deployment deployment = unit.getAttachment(WSAttachmentKeys.DEPLOYMENT_KEY); deployment.addAttachment( StandardContext.class, startWebApp(host, unit)); // TODO simplify and use findChild later in destroy()/stopWebApp() return deployment.getService().getEndpoints(); }
@Override public void destroy(Context context) throws Exception { List<Endpoint> eps = context.getEndpoints(); if (eps == null || eps.isEmpty()) { return; } Deployment deployment = eps.get(0).getService().getDeployment(); List<DeploymentAspect> aspects = DeploymentAspectsProvider.getSortedDeploymentAspects(); try { stopWebApp(deployment.getAttachment(StandardContext.class)); } finally { ClassLoader origClassLoader = SecurityActions.getContextClassLoader(); try { SecurityActions.setContextClassLoader( ClassLoaderProvider.getDefaultProvider().getServerIntegrationClassLoader()); DeploymentAspectManager dam = new DeploymentAspectManagerImpl(); dam.setDeploymentAspects(aspects); dam.undeploy(deployment); } finally { SecurityActions.setContextClassLoader(origClassLoader); } } }