Search in sources :

Example 1 with MdbDeliveryControllerService

use of org.jboss.as.ejb3.component.messagedriven.MdbDeliveryControllerService in project wildfly by wildfly.

the class MdbDeliveryDependenciesProcessor method deploy.

@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    final EEModuleConfiguration moduleConfiguration = deploymentUnit.getAttachment(EE_MODULE_CONFIGURATION);
    if (moduleConfiguration == null) {
        return;
    }
    final ServiceTarget serviceTarget = phaseContext.getServiceTarget();
    boolean clusteredSingletonFound = false;
    for (final ComponentConfiguration configuration : moduleConfiguration.getComponentConfigurations()) {
        ComponentDescription description = configuration.getComponentDescription();
        if (description instanceof MessageDrivenComponentDescription) {
            final MessageDrivenComponentDescription mdbDescription = (MessageDrivenComponentDescription) description;
            if (mdbDescription.isDeliveryControlled()) {
                final MdbDeliveryControllerService mdbDeliveryControllerService = new MdbDeliveryControllerService();
                final ServiceBuilder<MdbDeliveryControllerService> builder = serviceTarget.addService(mdbDescription.getDeliveryControllerName(), mdbDeliveryControllerService).addDependency(description.getCreateServiceName(), MessageDrivenComponent.class, mdbDeliveryControllerService.getMdbComponent()).setInitialMode(Mode.PASSIVE);
                if (mdbDescription.isClusteredSingleton()) {
                    clusteredSingletonFound = true;
                    builder.addDependency(CLUSTERED_SINGLETON_CAPABILITY.getCapabilityServiceName().append("primary"));
                }
                if (mdbDescription.getDeliveryGroup() != null) {
                    final ServiceName deliveyGroupServiceName = MdbDeliveryGroupResourceDefinition.getDeliveryGroupServiceName(mdbDescription.getDeliveryGroup());
                    if (phaseContext.getServiceRegistry().getService(deliveyGroupServiceName) == null) {
                        throw EjbLogger.DEPLOYMENT_LOGGER.missingMdbDeliveryGroup(mdbDescription.getDeliveryGroup());
                    }
                    builder.addDependency(deliveyGroupServiceName);
                }
                builder.install();
            }
        }
    }
    if (clusteredSingletonFound) {
        // trigger the start of the clustered singleton capability, since our service above is PASSIVE, and not ACTIVE
        // (the MDB delivery controller won't demand the clustered singleton service to start)
        serviceTarget.addService(createClusteredSingletonDemanderServiceName(deploymentUnit), Service.NULL).addDependency(CLUSTERED_SINGLETON_CAPABILITY.getCapabilityServiceName()).install();
    }
}
Also used : ComponentConfiguration(org.jboss.as.ee.component.ComponentConfiguration) MessageDrivenComponentDescription(org.jboss.as.ejb3.component.messagedriven.MessageDrivenComponentDescription) ComponentDescription(org.jboss.as.ee.component.ComponentDescription) MessageDrivenComponent(org.jboss.as.ejb3.component.messagedriven.MessageDrivenComponent) MessageDrivenComponentDescription(org.jboss.as.ejb3.component.messagedriven.MessageDrivenComponentDescription) ServiceName(org.jboss.msc.service.ServiceName) ServiceTarget(org.jboss.msc.service.ServiceTarget) EEModuleConfiguration(org.jboss.as.ee.component.EEModuleConfiguration) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit) MdbDeliveryControllerService(org.jboss.as.ejb3.component.messagedriven.MdbDeliveryControllerService)

Aggregations

ComponentConfiguration (org.jboss.as.ee.component.ComponentConfiguration)1 ComponentDescription (org.jboss.as.ee.component.ComponentDescription)1 EEModuleConfiguration (org.jboss.as.ee.component.EEModuleConfiguration)1 MdbDeliveryControllerService (org.jboss.as.ejb3.component.messagedriven.MdbDeliveryControllerService)1 MessageDrivenComponent (org.jboss.as.ejb3.component.messagedriven.MessageDrivenComponent)1 MessageDrivenComponentDescription (org.jboss.as.ejb3.component.messagedriven.MessageDrivenComponentDescription)1 DeploymentUnit (org.jboss.as.server.deployment.DeploymentUnit)1 ServiceName (org.jboss.msc.service.ServiceName)1 ServiceTarget (org.jboss.msc.service.ServiceTarget)1