Search in sources :

Example 6 with EEModuleConfiguration

use of org.jboss.as.ee.component.EEModuleConfiguration 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)6 EEModuleConfiguration (org.jboss.as.ee.component.EEModuleConfiguration)6 DeploymentUnit (org.jboss.as.server.deployment.DeploymentUnit)5 ComponentDescription (org.jboss.as.ee.component.ComponentDescription)4 ServiceName (org.jboss.msc.service.ServiceName)4 Module (org.jboss.modules.Module)3 HashSet (java.util.HashSet)2 EEModuleDescription (org.jboss.as.ee.component.EEModuleDescription)2 MessageDrivenComponentDescription (org.jboss.as.ejb3.component.messagedriven.MessageDrivenComponentDescription)2 DeploymentUnitProcessingException (org.jboss.as.server.deployment.DeploymentUnitProcessingException)2 HashMap (java.util.HashMap)1 BindingConfiguration (org.jboss.as.ee.component.BindingConfiguration)1 ComponentConfigurator (org.jboss.as.ee.component.ComponentConfigurator)1 ComponentRegistry (org.jboss.as.ee.component.ComponentRegistry)1 EEApplicationClasses (org.jboss.as.ee.component.EEApplicationClasses)1 InterceptorDescription (org.jboss.as.ee.component.InterceptorDescription)1 ContextInjectionSource (org.jboss.as.ee.naming.ContextInjectionSource)1 EJBComponentDescription (org.jboss.as.ejb3.component.EJBComponentDescription)1 MdbDeliveryControllerService (org.jboss.as.ejb3.component.messagedriven.MdbDeliveryControllerService)1 MessageDrivenComponent (org.jboss.as.ejb3.component.messagedriven.MessageDrivenComponent)1