final ServiceRegistry serviceRegistry = context.getOperationContext().getServiceRegistry(false); final Set<Resource.ResourceEntry> deploymentResource = context.getOperationContext().readResourceFromRoot(PathAddress.EMPTY_ADDRESS, false).getChildren(DEPLOYMENT); for (final Resource.ResourceEntry entry : deploymentResource) { final ServiceController<?> deploymentUnitServiceController = serviceRegistry.getService(ServiceName.JBOSS.append("deployment", "unit", entry.getName())); if (deploymentUnitServiceController != null) { final ModelNode deploymentNode = applicationsNode.get(entry.getName()); final DeploymentUnit deploymentUnit = DeploymentUnit.class.cast(deploymentUnitServiceController.getValue()); final String appName = cleanName(deploymentUnit.getName()); final NamingStore appStore = NamingStore.class.cast(appContextController.getValue()); try { context.addEntries(deploymentNode.get("java:app"), new NamingContext(appStore, null)); final List<ResourceRoot> roots = deploymentUnit.getAttachmentList(org.jboss.as.server.deployment.Attachments.RESOURCE_ROOTS); if(roots != null) for(ResourceRoot root : roots) { if(SubDeploymentMarker.isSubDeployment(root)) { final ResourceRoot parentRoot = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.DEPLOYMENT_ROOT); final String relativePath = root.getRoot().getPathNameRelativeTo(parentRoot.getRoot()); final ServiceName subDeploymentServiceName = Services.deploymentUnitName(deploymentUnit.getName(), relativePath); final ServiceController<?> subDeploymentController = serviceRegistry.getService(subDeploymentServiceName); if(subDeploymentController != null) { final DeploymentUnit subDeploymentUnit = DeploymentUnit.class.cast(subDeploymentController.getValue()); handleModule(context, subDeploymentUnit, deploymentNode.get("modules"), serviceRegistry);
@Override public void execute(OperationContext context, ModelNode operation) { final ServiceName deploymentUnitServiceName = Services.deploymentUnitName(runtimeName); context.removeService(deploymentUnitServiceName); context.removeService(deploymentUnitServiceName.append("contents")); context.completeStep(new OperationContext.ResultHandler() { @Override public void handleResult(OperationContext.ResultAction resultAction, OperationContext context, ModelNode operation) { if(resultAction == OperationContext.ResultAction.ROLLBACK) { final ModelNode model = context.readResource(PathAddress.EMPTY_ADDRESS).getModel(); final DeploymentHandlerUtil.ContentItem[] contents = getContents(model.require(CONTENT)); doDeploy(context, runtimeName, managementName, deployment, registration, mutableRegistration, vaultReader, contents); if (context.hasFailureDescription()) { ServerLogger.ROOT_LOGGER.undeploymentRolledBack(runtimeName, getFormattedFailureDescription(context)); } else { ServerLogger.ROOT_LOGGER.undeploymentRolledBackWithNoMessage(runtimeName); } } else { ServerLogger.ROOT_LOGGER.deploymentUndeployed(managementName, runtimeName); } } }); } }, OperationContext.Stage.RUNTIME);
@SuppressWarnings("unchecked") public synchronized void start(final StartContext context) throws StartException { if(runOnce.get()) { ServerLogger.DEPLOYMENT_LOGGER.deploymentRestartDetected(deploymentUnit.getName()); if(deploymentUnit.getParent() == null) { serviceName = deploymentUnit.getServiceName(); } else { serviceName = deploymentUnit.getParent().getServiceName(); ServiceController<?> controller = context.getController().getServiceContainer().getRequiredService(serviceName); controller.addListener(new LifecycleListener() { @Override public void handleEvent(final ServiceController<?> controller, final LifecycleEvent event) { controller.setMode(Mode.NEVER); return; phaseServiceBuilder.requires(Services.deploymentUnitName(parent.getName(), nextPhase)); List<DeploymentUnit> subDeployments = deploymentUnit.getAttachmentList(Attachments.SUB_DEPLOYMENTS); for (DeploymentUnit du : subDeployments) { phaseServiceBuilder.requires(du.getServiceName().append(phase.name()));
@Override public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException { final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit(); final ResourceRoot deploymentResourceRoot = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_ROOT); final ServiceVerificationHandler serviceVerificationHandler = deploymentUnit.getAttachment(Attachments.SERVICE_VERIFICATION_HANDLER); final ServiceTarget serviceTarget = phaseContext.getServiceTarget(); final List<ResourceRoot> childRoots = deploymentUnit.getAttachmentList(Attachments.RESOURCE_ROOTS); for (final ResourceRoot childRoot : childRoots) { if (childRoot == deploymentResourceRoot || !SubDeploymentMarker.isSubDeployment(childRoot)) { continue; } final Resource resource = DeploymentModelUtils.createSubDeployment(childRoot.getRootName(), deploymentUnit); final ImmutableManagementResourceRegistration registration = deploymentUnit.getAttachment(DeploymentModelUtils.REGISTRATION_ATTACHMENT); final ManagementResourceRegistration mutableRegistration = deploymentUnit.getAttachment(DeploymentModelUtils.MUTABLE_REGISTRATION_ATTACHMENT); final AbstractVaultReader vaultReader = deploymentUnit.getAttachment(Attachments.VAULT_READER_ATTACHMENT_KEY); final SubDeploymentUnitService service = new SubDeploymentUnitService(childRoot, deploymentUnit, registration, mutableRegistration, resource, serviceVerificationHandler, vaultReader); final ResourceRoot parentRoot = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_ROOT); final String relativePath = childRoot.getRoot().getPathNameRelativeTo(parentRoot.getRoot()); final ServiceName serviceName = Services.deploymentUnitName(deploymentUnit.getName(), relativePath); serviceTarget.addService(serviceName, service) .addDependency(Services.JBOSS_DEPLOYMENT_CHAINS, DeployerChains.class, service.getDeployerChainsInjector()) .setInitialMode(ServiceController.Mode.ACTIVE) .install(); phaseContext.addDeploymentDependency(serviceName, Attachments.SUB_DEPLOYMENTS); //we also need a dep on the first phase of the sub deployments phaseContext.addToAttachmentList(Attachments.NEXT_PHASE_DEPS, serviceName.append(ServiceName.of(Phase.STRUCTURE.name()))); } }
@Override public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException { final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit(); final DeploymentUnit parent = deploymentUnit.getParent(); if (parent == null) { return; final EarMetaData earConfig = parent.getAttachment(Attachments.EAR_METADATA); if (earConfig != null) { final boolean inOrder = earConfig.getInitializeInOrder(); for (final DeploymentUnit subDeployment : parent.getAttachment(org.jboss.as.server.deployment.Attachments.SUB_DEPLOYMENTS)) { final ResourceRoot deploymentRoot = subDeployment.getAttachment(org.jboss.as.server.deployment.Attachments.DEPLOYMENT_ROOT); final ServiceName serviceName = Services.deploymentUnitName(parent.getName(), previous.getFileName()); phaseContext.addToAttachmentList(org.jboss.as.server.deployment.Attachments.NEXT_PHASE_DEPS, serviceName.append(Phase.INSTALL.name())); final DeploymentUnit prevDeployment = deploymentUnitMap.get(previous.getFileName());
final ServiceRegistry serviceRegistry = context.getOperationContext().getServiceRegistry(false); final Set<Resource.ResourceEntry> deploymentResource = context.getOperationContext().getRootResource().getChildren(DEPLOYMENT); for (final Resource.ResourceEntry entry : deploymentResource) { final ServiceController<?> deploymentUnitServiceController = serviceRegistry.getService(ServiceName.JBOSS.append("deployment", "unit", entry.getName())); if (deploymentUnitServiceController != null) { final ModelNode deploymentNode = applicationsNode.get(entry.getName()); final DeploymentUnit deploymentUnit = DeploymentUnit.class.cast(deploymentUnitServiceController.getValue()); final String appName = cleanName(deploymentUnit.getName()); final NamingStore appStore = NamingStore.class.cast(appContextController.getValue()); try { context.addEntries(deploymentNode.get("java:app"), new NamingContext(appStore, null)); final List<ResourceRoot> roots = deploymentUnit.getAttachmentList(org.jboss.as.server.deployment.Attachments.RESOURCE_ROOTS); if(roots != null) for(ResourceRoot root : roots) { if(SubDeploymentMarker.isSubDeployment(root)) { final ResourceRoot parentRoot = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.DEPLOYMENT_ROOT); final String relativePath = root.getRoot().getPathNameRelativeTo(parentRoot.getRoot()); final ServiceName subDeploymentServiceName = Services.deploymentUnitName(deploymentUnit.getName(), relativePath); final ServiceController<?> subDeploymentController = serviceRegistry.getService(subDeploymentServiceName); if(subDeploymentController != null) { final DeploymentUnit subDeploymentUnit = DeploymentUnit.class.cast(subDeploymentController.getValue()); handleModule(context, subDeploymentUnit, deploymentNode.get("modules"), serviceRegistry);
public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { final ServiceName replacedDeploymentUnitServiceName = Services.deploymentUnitName(replacedDeploymentUnitName); final ServiceName replacedContentsServiceName = replacedDeploymentUnitServiceName.append("contents"); context.removeService(replacedContentsServiceName); context.removeService(replacedDeploymentUnitServiceName); ModelNode notificationData = new ModelNode(); notificationData.get(NAME).set(managementName); notificationData.get(SERVER_BOOTING).set(context.isBooting()); if (operation.hasDefined(OWNER.getName())) { try {
public void execute(OperationContext context, ModelNode operation) { final ServiceName deploymentUnitServiceName = Services.deploymentUnitName(deploymentUnitName); final ServiceRegistry serviceRegistry = context.getServiceRegistry(true); final ServiceController<?> deploymentController = serviceRegistry.getService(deploymentUnitServiceName); if (deploymentController != null) { final ServiceVerificationHandler verificationHandler = new ServiceVerificationHandler(); deploymentController.addListener(verificationHandler); deploymentController.setMode(ServiceController.Mode.ACTIVE); context.addStep(verificationHandler, OperationContext.Stage.VERIFY); context.completeStep(new OperationContext.RollbackHandler() { @Override public void handleRollback(OperationContext context, ModelNode operation) {
@Override public void undeploy(final DeploymentUnit deploymentUnit) { final ServiceRegistry serviceRegistry = deploymentUnit.getServiceRegistry(); final List<ResourceRoot> childRoots = deploymentUnit.getAttachmentList(Attachments.RESOURCE_ROOTS); for (final ResourceRoot childRoot : childRoots) { if (!SubDeploymentMarker.isSubDeployment(childRoot)) { continue; } final ServiceName serviceName = Services.deploymentUnitName(deploymentUnit.getName(), childRoot.getRootName()); final ServiceController<?> serviceController = serviceRegistry.getService(serviceName); if (serviceController != null) { serviceController.setMode(ServiceController.Mode.REMOVE); } } deploymentUnit.removeAttachment(Attachments.SUB_DEPLOYMENTS); } }
final ManagementResourceRegistration mutableRegistration, final AbstractVaultReader vaultReader, final ContentItem... contents) { final ServiceName deploymentUnitServiceName = Services.deploymentUnitName(deploymentUnitName); final ServiceTarget serviceTarget = context.getServiceTarget(); final ServiceController<?> contentService; final ServiceName contentsServiceName = deploymentUnitServiceName.append("contents"); boolean isExplodedContent = false; if (contents[0].hash != null) { registration, mutableRegistration, deploymentResource, context.getCapabilityServiceSupport(), vaultReader, overlays, isExplodedContent); final ServiceController<DeploymentUnit> deploymentUnitController = serviceTarget.addService(deploymentUnitServiceName, service) .addDependency(Services.JBOSS_DEPLOYMENT_CHAINS, DeployerChains.class, service.getDeployerChainsInjector()) .addDependency(DeploymentMountProvider.SERVICE_NAME, DeploymentMountProvider.class, service.getServerDeploymentRepositoryInjector()) .addDependency(context.getCapabilityServiceName("org.wildfly.management.path-manager", PathManager.class), PathManager.class, service.getPathManagerInjector()) .addDependency(contentsServiceName, VirtualFile.class, service.getContentsInjector()) .setInitialMode(ServiceController.Mode.ACTIVE) .install(); contentService.addListener(new LifecycleListener() { @Override public void handleEvent(final ServiceController<?> controller, final LifecycleEvent event) {
/** * Creates the service name used for the job operator registered for the deployment. * * @param deploymentRuntimeName the runtime name for the deployment * * @return the service name */ public static ServiceName jobOperatorServiceName(final String deploymentRuntimeName) { return Services.deploymentUnitName(deploymentRuntimeName).append("batch").append("job-operator"); }
@Override public void execute(final OperationContext context, final ModelNode operation) throws OperationFailedException { final ModelNode result = context.getResult(); if (!isEnabled) { result.set(AbstractDeploymentUnitService.DeploymentStatus.STOPPED.toString()); } else { final ServiceController<?> controller = context.getServiceRegistry(false).getService(Services.deploymentUnitName(runtimeName)); if (controller != null) { if (controller.getSubstate() == ServiceController.Substate.WONT_START && controller.getState() == ServiceController.State.DOWN) { result.set(AbstractDeploymentUnitService.DeploymentStatus.STOPPED.toString()); } else { result.set(((AbstractDeploymentUnitService) controller.getService()).getStatus().toString()); } } else { result.set(NO_METRICS); } } context.stepCompleted(); } }, OperationContext.Stage.RUNTIME);
public static Collection<ServiceController<?>> doDeploy(final OperationContext context, final String deploymentUnitName, final String managementName, final ServiceVerificationHandler verificationHandler, final Resource deploymentResource, final ImmutableManagementResourceRegistration registration, final ManagementResourceRegistration mutableRegistration, final AbstractVaultReader vaultReader, final ContentItem... contents) { final ServiceName deploymentUnitServiceName = Services.deploymentUnitName(deploymentUnitName); final List<ServiceController<?>> controllers = new ArrayList<ServiceController<?>>(); final ServiceTarget serviceTarget = context.getServiceTarget(); final ServiceController<?> contentService; final ServiceName contentsServiceName = deploymentUnitServiceName.append("contents"); if (contents[0].hash != null) contentService = ContentServitor.addService(serviceTarget, contentsServiceName, contents[0].hash, verificationHandler); controllers.add(deploymentUnitController); contentService.addListener(new AbstractServiceListener<Object>() { @Override public void transition(final ServiceController<?> controller, final ServiceController.Transition transition) {
@Override public void execute(final OperationContext context, final ModelNode operation) { final ModelNode result = context.getResult(); if (!isEnabled) { result.set(AbstractDeploymentUnitService.DeploymentStatus.STOPPED.toString()); } else { final ServiceController<?> controller = context.getServiceRegistry(false).getService(Services.deploymentUnitName(runtimeName)); if (controller != null) { if (controller.getState() == ServiceController.State.DOWN && controller.getUnavailableDependencies().size() == 0) { result.set(AbstractDeploymentUnitService.DeploymentStatus.STOPPED.toString()); } else { result.set(((AbstractDeploymentUnitService) controller.getService()).getStatus().toString()); } } else { result.set(NO_METRICS); } } } }, OperationContext.Stage.RUNTIME);
public InitialDeploymentTracker(OperationContext context) { super(InitialDeploymentTracker.class.getSimpleName()); serviceTarget = context.getServiceTarget(); deploymentNames = getDeploymentNames(context); // Track the persistent DEPENDENCIES services. This makes sure that Bundle.INSTALL services have completed // and that all dependencies of the persistent bundles have been configured for (String name : deploymentNames) { expectedServices.add(Services.deploymentUnitName(name, Phase.DEPENDENCIES)); } // Register this tracker with the server controller if (expectedServices.isEmpty() == false) { ServiceRegistry serviceRegistry = context.getServiceRegistry(false); listenerTarget = serviceRegistry.getService(JBOSS_SERVER_CONTROLLER).getServiceContainer(); listenerTarget.addListener(this); } // Check the tracker for completeness checkAndComplete(); }
if (enabled) { runtimeName = RUNTIME_NAME.resolveModelAttribute(context, model).asString(); final ServiceName deploymentUnitServiceName = Services.deploymentUnitName(runtimeName); context.removeService(deploymentUnitServiceName); context.removeService(deploymentUnitServiceName.append("contents")); } else { runtimeName = null;
public void execute(OperationContext context, ModelNode operation) { final ServiceName deploymentUnitServiceName = Services.deploymentUnitName(deploymentUnitName); final ServiceRegistry serviceRegistry = context.getServiceRegistry(true); final ServiceController<?> deploymentController = serviceRegistry.getService(deploymentUnitServiceName); if (deploymentController != null) { deploymentController.setMode(ServiceController.Mode.ACTIVE); context.completeStep(new OperationContext.RollbackHandler() { @Override public void handleRollback(OperationContext context, ModelNode operation) { doDeploy(context, deploymentUnitName, managementName, deployment, registration, mutableRegistration, vaultReader, contents); context.completeStep(new OperationContext.ResultHandler() { @Override public void handleResult(OperationContext.ResultAction resultAction, OperationContext context, ModelNode operation) {
private static ServiceName getServiceName(final OperationContext context) { String deploymentName = null; String subdeploymentName = null; final PathAddress address = context.getCurrentAddress(); for (PathElement element : address) { if (ModelDescriptionConstants.DEPLOYMENT.equals(element.getKey())) { deploymentName = getRuntimeName(context, element); //deploymentName = element.getValue(); } else if (ModelDescriptionConstants.SUBDEPLOYMENT.endsWith(element.getKey())) { subdeploymentName = element.getValue(); } } if (deploymentName == null) { throw LoggingLogger.ROOT_LOGGER.deploymentNameNotFound(address); } final ServiceName result; if (subdeploymentName == null) { result = Services.deploymentUnitName(deploymentName); } else { result = Services.deploymentUnitName(deploymentName, subdeploymentName); } return result.append("logging", "configuration"); }
public static ServiceName getDeploymentUnitPhaseServiceName(final DeploymentUnit depUnit, final Phase phase) { DeploymentUnit parent = depUnit.getParent(); if (parent == null) { return Services.deploymentUnitName(depUnit.getName(), phase); } else { return Services.deploymentUnitName(parent.getName(), depUnit.getName(), phase); } }
public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException { if (phaseContext.getAttachment(Attachments.DEPLOYMENT_TYPE) == DeploymentType.EAR) { final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit(); // Make sure the next phase of this EAR depends on this phase of not just the EAR but also all subdeployments for (DeploymentUnit subdeployment : deploymentUnit.getAttachmentList(SUB_DEPLOYMENTS)) { phaseContext.addToAttachmentList(NEXT_PHASE_DEPS, Services.deploymentUnitName(deploymentUnit.getName(), subdeployment.getName(), phaseContext.getPhase())); } } }