public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException { final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit(); final List<ResourceRoot> childRoots = deploymentUnit.getAttachment(Attachments.RESOURCE_ROOTS); if (childRoots != null) { final ServiceTarget serviceTarget = phaseContext.getServiceTarget(); for (final ResourceRoot childRoot : childRoots) { if (!SubDeploymentMarker.isSubDeployment(childRoot)) { continue; } final SubDeploymentUnitService service = new SubDeploymentUnitService(childRoot, deploymentUnit); final ServiceName serviceName = deploymentUnit.getServiceName().append(childRoot.getRootName()); serviceTarget .addService(serviceName, service) .addDependency( Services.JBOSS_DEPLOYMENT_CHAINS, DeployerChains.class, service.getDeployerChainsInjector()) .setInitialMode(ServiceController.Mode.ACTIVE) .install(); phaseContext.addDeploymentDependency(serviceName, Attachments.SUB_DEPLOYMENTS); } } }
public void undeploy(DeploymentUnit deploymentUnit) { final List<ResourceRoot> childRoots = deploymentUnit.getAttachment(Attachments.RESOURCE_ROOTS); if (childRoots != null) { final ServiceRegistry serviceRegistry = deploymentUnit.getServiceRegistry(); for (final ResourceRoot childRoot : childRoots) { if (!SubDeploymentMarker.isSubDeployment(childRoot)) { continue; } final ServiceName serviceName = deploymentUnit.getServiceName().append(childRoot.getRootName()); final ServiceController<?> serviceController = serviceRegistry.getService(serviceName); if (serviceController != null) { serviceController.setMode(ServiceController.Mode.REMOVE); } } } }