* 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);
// TODO: [JBWS-3426] fix this. START workaround
if (target == null) {
SPIProvider spiProvider = SPIProviderResolver.getInstance().getProvider();
EndpointRegistryFactory factory = spiProvider.getSPI(EndpointRegistryFactory.class);
EndpointRegistry registry = factory.getEndpointRegistry();
for (final Endpoint endpoint : dep.getService().getEndpoints()) {
registry.register(endpoint);
}
}
// END workaround
} 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();
}