private void installManagementResource(ComponentConfiguration configuration, DeploymentUnit deploymentUnit) { final EJBComponentType type = EJBComponentType.getComponentType(configuration); PathAddress addr = getComponentAddress(type, configuration, deploymentUnit); final AbstractEJBComponentRuntimeHandler<?> handler = type.getRuntimeHandler(); handler.registerComponent(addr, configuration.getComponentDescription().getStartServiceName()); deploymentUnit.addToAttachmentList(EjbDeploymentAttachmentKeys.MANAGED_COMPONENTS, new InstalledComponent(type, addr)); final DeploymentResourceSupport deploymentResourceSupport = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_RESOURCE_SUPPORT); deploymentResourceSupport.getDeploymentSubModel(EJB3Extension.SUBSYSTEM_NAME, addr.getLastElement()); final EJBComponentDescription description = (EJBComponentDescription) configuration.getComponentDescription(); if (description.isTimerServiceRequired()) { final PathAddress timerServiceAddress = PathAddress.pathAddress(addr.getLastElement(), EJB3SubsystemModel.TIMER_SERVICE_PATH); final TimerServiceResource timerServiceResource = ((TimerServiceImpl) description.getTimerService()).getResource(); deploymentResourceSupport.registerDeploymentSubResource(EJB3Extension.SUBSYSTEM_NAME, timerServiceAddress, timerServiceResource); } }
@Override public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException { final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit(); if (deploymentUnit.hasAttachment(Attachments.MODULE) && !DeploymentTypeMarker.isType(DeploymentType.EAR, deploymentUnit) && deploymentUnit.hasAttachment(Attachments.DEPLOYMENT_ROOT)) { BatchLogger.LOGGER.tracef("Processing deployment '%s' for the batch deployment resources.", deploymentUnit.getName()); final DeploymentResourceSupport deploymentResourceSupport = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_RESOURCE_SUPPORT); // Add the job operator service used interact with a deployments batch job final WildFlyJobOperator jobOperator = deploymentUnit.getAttachment(BatchAttachments.JOB_OPERATOR); // Process each job XML file for (String jobName : jobOperator.getAllJobNames()) { try { // Add the job information to the service BatchLogger.LOGGER.debugf("Added job %s to allowed jobs for deployment %s", jobName, deploymentUnit.getName()); // Register the a resource for each job found final PathAddress jobAddress = PathAddress.pathAddress(BatchJobResourceDefinition.JOB, jobName); if (!deploymentResourceSupport.hasDeploymentSubModel(subsystemName, jobAddress)) { deploymentResourceSupport.registerDeploymentSubResource(subsystemName, jobAddress, new BatchJobExecutionResource(jobOperator, jobName)); } } catch (Exception e) { // The deployment shouldn't fail in this case, just the specific resource registration should be skipped // Log a debug message so the error is not lost BatchLogger.LOGGER.debugf(e, "Batch jobs as an error occurred will not be registered for runtime views on the deployment (%s).", jobName, deploymentUnit.getName()); } } } }
/** * Registers the resource to the parent deployment resource. The model returned is that of the resource parameter. * * @param subsystemName the subsystem name * @param resource the resource to be used for the subsystem on the deployment * * @return the model * * @throws java.lang.IllegalStateException if the subsystem resource already exists */ public ModelNode registerDeploymentSubsystemResource(final String subsystemName, final Resource resource) { assert subsystemName != null : "The subsystemName cannot be null"; assert resource != null : "The resource cannot be null"; return registerDeploymentSubResource(subsystemName, PathAddress.EMPTY_ADDRESS, resource); }
/** * Registers the resource to the parent deployment resource. The model returned is that of the resource parameter. * * @param subsystemName the subsystem name * @param resource the resource to be used for the subsystem on the deployment * * @return the model * * @throws java.lang.IllegalStateException if the subsystem resource already exists */ public ModelNode registerDeploymentSubsystemResource(final String subsystemName, final Resource resource) { assert subsystemName != null : "The subsystemName cannot be null"; assert resource != null : "The resource cannot be null"; return registerDeploymentSubResource(subsystemName, PathAddress.EMPTY_ADDRESS, resource); }
@Override public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException { final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit(); if (deploymentUnit.hasAttachment(Attachments.MODULE) && !DeploymentTypeMarker.isType(DeploymentType.EAR, deploymentUnit) && deploymentUnit.hasAttachment(Attachments.DEPLOYMENT_ROOT)) { BatchLogger.LOGGER.tracef("Processing deployment '%s' for the batch deployment resources.", deploymentUnit.getName()); final DeploymentResourceSupport deploymentResourceSupport = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_RESOURCE_SUPPORT); // Add the job operator service used interact with a deployments batch job final WildFlyJobOperator jobOperator = deploymentUnit.getAttachment(BatchAttachments.JOB_OPERATOR); // Process each job XML file for (String jobName : jobOperator.getAllJobNames()) { try { // Add the job information to the service BatchLogger.LOGGER.debugf("Added job %s to allowed jobs for deployment %s", jobName, deploymentUnit.getName()); // Register the a resource for each job found final PathAddress jobAddress = PathAddress.pathAddress(BatchJobResourceDefinition.JOB, jobName); if (!deploymentResourceSupport.hasDeploymentSubModel(subsystemName, jobAddress)) { deploymentResourceSupport.registerDeploymentSubResource(subsystemName, jobAddress, new BatchJobExecutionResource(jobOperator, jobName)); } } catch (Exception e) { // The deployment shouldn't fail in this case, just the specific resource registration should be skipped // Log a debug message so the error is not lost BatchLogger.LOGGER.debugf(e, "Batch jobs as an error occurred will not be registered for runtime views on the deployment (%s).", jobName, deploymentUnit.getName()); } } } }