void addManagementWebsocket(final DeploymentUnit unit, Class endpoint, String path) { try { final DeploymentResourceSupport deploymentResourceSupport = unit.getAttachment(Attachments.DEPLOYMENT_RESOURCE_SUPPORT); //websockets don't have the concept of a name, however the path much be unique final ModelNode node = deploymentResourceSupport.getDeploymentSubModel(UndertowExtension.SUBSYSTEM_NAME, PathElement.pathElement("websocket", path)); node.get("endpoint-class").set(endpoint.getName()); node.get("path").set(path); } catch (Exception e) { UndertowLogger.ROOT_LOGGER.failedToRegisterWebsocket(endpoint, path, e); } }
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); } }
final ModelNode node = deploymentResourceSupport.getDeploymentSubsystemModel(UndertowExtension.SUBSYSTEM_NAME); node.get(DeploymentDefinition.CONTEXT_ROOT.getName()).set("".equals(pathName) ? "/" : pathName); node.get(DeploymentDefinition.VIRTUAL_HOST.getName()).set(hostName);
@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); }
@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); }
private void installManagementModel(final DataSource ds, final DeploymentUnit deploymentUnit, final PathAddress addr) { XMLDataSourceRuntimeHandler.INSTANCE.registerDataSource(addr, ds); final DeploymentResourceSupport deploymentResourceSupport = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_RESOURCE_SUPPORT); deploymentResourceSupport.getDeploymentSubModel(DataSourcesExtension.SUBSYSTEM_NAME, addr.getLastElement()); if (ds.getConnectionProperties() != null) { for (final Map.Entry<String, String> prop : ds.getConnectionProperties().entrySet()) { PathAddress registration = PathAddress.pathAddress(addr.getLastElement(), PathElement.pathElement(CONNECTION_PROPERTIES, prop.getKey())); deploymentResourceSupport.getDeploymentSubModel(DataSourcesExtension.SUBSYSTEM_NAME, registration); } } }
@Override public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException { DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit(); CamelDeploymentSettings depSettings = deploymentUnit.getAttachment(CamelDeploymentSettings.ATTACHMENT_KEY); if (!depSettings.isEnabled()) { return; } final WarMetaData warMetaData = deploymentUnit.getAttachment(WarMetaData.ATTACHMENT_KEY); if (warMetaData == null) { /* ignore non-war deployments */ CamelLogger.LOGGER.debug("{} ignores non-WAR deployment {}", CamelEndpointDeployerProcessor.class.getSimpleName(), deploymentUnit.getName()); return; } final DeploymentResourceSupport deploymentResourceSupport = deploymentUnit .getAttachment(Attachments.DEPLOYMENT_RESOURCE_SUPPORT); final ModelNode node = deploymentResourceSupport.getDeploymentSubsystemModel(UndertowExtension.SUBSYSTEM_NAME); final String hostName = node.get(DeploymentDefinition.VIRTUAL_HOST.getName()).asString(); final String serverName = node.get(DeploymentDefinition.SERVER.getName()).asString(); final String path = node.get(DeploymentDefinition.CONTEXT_ROOT.getName()).asString(); final ServiceName deploymentServiceName = UndertowService.deploymentServiceName(serverName, hostName, path); final ServiceName deploymentInfoServiceName = deploymentServiceName .append(UndertowDeploymentInfoService.SERVICE_NAME); final ServiceName hostServiceName = UndertowService.virtualHostName(serverName, hostName); CamelEndpointDeployerService.addService(deploymentUnit, phaseContext.getServiceTarget(), deploymentInfoServiceName, hostServiceName); }
void processManagement(final DeploymentUnit unit, JBossWebMetaData metaData) { final DeploymentResourceSupport deploymentResourceSupport = unit.getAttachment(Attachments.DEPLOYMENT_RESOURCE_SUPPORT); for (final JBossServletMetaData servlet : metaData.getServlets()) { try { final String name = servlet.getName(); final ModelNode node = deploymentResourceSupport.getDeploymentSubModel(UndertowExtension.SUBSYSTEM_NAME, PathElement.pathElement("servlet", name)); node.get("servlet-class").set(servlet.getServletClass()); node.get("servlet-name").set(servlet.getServletName()); } catch (Exception e) { // Should a failure in creating the mgmt view also make to the deployment to fail? continue; } } }
@Override public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException { DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit(); CamelDeploymentSettings depSettings = deploymentUnit.getAttachment(CamelDeploymentSettings.ATTACHMENT_KEY); if (!depSettings.isEnabled()) { return; } final WarMetaData warMetaData = deploymentUnit.getAttachment(WarMetaData.ATTACHMENT_KEY); if (warMetaData == null) { /* ignore non-war deployments */ CamelLogger.LOGGER.debug("{} ignores non-WAR deployment {}", CamelEndpointDeployerProcessor.class.getSimpleName(), deploymentUnit.getName()); return; } final DeploymentResourceSupport deploymentResourceSupport = deploymentUnit .getAttachment(Attachments.DEPLOYMENT_RESOURCE_SUPPORT); final ModelNode node = deploymentResourceSupport.getDeploymentSubsystemModel(UndertowExtension.SUBSYSTEM_NAME); final String hostName = node.get(DeploymentDefinition.VIRTUAL_HOST.getName()).asString(); final String serverName = node.get(DeploymentDefinition.SERVER.getName()).asString(); final String path = node.get(DeploymentDefinition.CONTEXT_ROOT.getName()).asString(); final ServiceName deploymentServiceName = UndertowService.deploymentServiceName(serverName, hostName, path); final ServiceName deploymentInfoServiceName = deploymentServiceName .append(UndertowDeploymentInfoService.SERVICE_NAME); final ServiceName hostServiceName = UndertowService.virtualHostName(serverName, hostName); CamelEndpointDeployerService.addService(deploymentUnit, phaseContext.getServiceTarget(), deploymentInfoServiceName, hostServiceName); }
private void installManagementModel(final XaDataSource ds, final DeploymentUnit deploymentUnit, final PathAddress addr) { XMLXaDataSourceRuntimeHandler.INSTANCE.registerDataSource(addr, ds); final DeploymentResourceSupport deploymentResourceSupport = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_RESOURCE_SUPPORT); deploymentResourceSupport.getDeploymentSubModel(DataSourcesExtension.SUBSYSTEM_NAME, addr.getLastElement()); if (ds.getXaDataSourceProperty() != null) { for (final Map.Entry<String, String> prop : ds.getXaDataSourceProperty().entrySet()) { PathAddress registration = PathAddress.pathAddress(addr.getLastElement(), PathElement.pathElement(XA_CONNECTION_PROPERTIES, prop.getKey())); deploymentResourceSupport.getDeploymentSubModel(DataSourcesExtension.SUBSYSTEM_NAME, registration); } } }
final ModelNode node = deploymentResourceSupport.getDeploymentSubsystemModel(UndertowExtension.SUBSYSTEM_NAME); node.get(DeploymentDefinition.CONTEXT_ROOT.getName()).set("".equals(pathName) ? "/" : pathName); node.get(DeploymentDefinition.VIRTUAL_HOST.getName()).set(hostName);
@Override public ModelNode createDeploymentSubModel(final String subsystemName, final PathElement address) { // Using the getDeploymentSubModel results in the previous behavior return DeploymentResourceSupport.getDeploymentSubModel(subsystemName, address, this); }
final ModelNode node = deploymentResourceSupport.getDeploymentSubsystemModel(UndertowExtension.SUBSYSTEM_NAME); node.get(DeploymentDefinition.CONTEXT_ROOT.getName()).set("".equals(pathName) ? "/" : pathName); node.get(DeploymentDefinition.VIRTUAL_HOST.getName()).set(hostName);
@Override public ModelNode createDeploymentSubModel(String subsystemName, PathAddress address, Resource resource) { // Using the getDeploymentSubModel results in the previous behavior return DeploymentResourceSupport.getDeploymentSubModel(subsystemName, address, resource, this); } }
@Override public ModelNode createDeploymentSubModel(final String subsystemName, final PathElement address) { // Using the getDeploymentSubModel results in the previous behavior return DeploymentResourceSupport.getDeploymentSubModel(subsystemName, address, this); }
@Override public ModelNode getDeploymentSubsystemModel(final String subsystemName) { return DeploymentResourceSupport.getDeploymentSubModel(subsystemName, null, this); }
@Override public ModelNode createDeploymentSubModel(String subsystemName, PathAddress address, Resource resource) { // Using the getDeploymentSubModel results in the previous behavior return DeploymentResourceSupport.getDeploymentSubModel(subsystemName, address, resource, this); } }
@Override public ModelNode getDeploymentSubsystemModel(final String subsystemName) { return DeploymentResourceSupport.getDeploymentSubModel(subsystemName, null, this); }