* @param unit
* @return
* @throws Exception
*/
protected Context doPublish(ServiceTarget target, DeploymentUnit unit) throws Exception {
Deployment deployment = unit.getAttachment(WSAttachmentKeys.DEPLOYMENT_KEY);
List<Endpoint> endpoints = deployment.getService().getEndpoints();
//If we're running in a Service, that will already have proper dependencies set on the installed endpoint services,
//otherwise we need to explicitly wait for the endpoint services to be started before creating the webapp.
if (!runningInService) {
final ServiceRegistry registry = unit.getServiceRegistry();
for (Endpoint ep : endpoints) {
final ServiceName serviceName = EndpointService.getServiceName(unit, ep.getShortName());
registry.getRequiredService(serviceName).awaitValue();
}
}
deployment.addAttachment(WebDeploymentController.class, startWebApp(host, unit)); //TODO simplify and use findChild later in destroy()/stopWebApp()
return new Context(unit.getAttachment(WSAttachmentKeys.JBOSSWEB_METADATA_KEY).getContextRoot(), endpoints);
}