Search in sources :

Example 6 with MessageDrivenComponentDescription

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

the class MessageDrivenComponentDescriptionFactory method processMessageBeans.

private void processMessageBeans(final DeploymentUnit deploymentUnit, final Collection<AnnotationInstance> messageBeanAnnotations, final CompositeIndex compositeIndex) throws DeploymentUnitProcessingException {
    if (messageBeanAnnotations.isEmpty())
        return;
    final EjbJarDescription ejbJarDescription = getEjbJarDescription(deploymentUnit);
    final PropertyReplacer propertyReplacer = EJBAnnotationPropertyReplacement.propertyReplacer(deploymentUnit);
    final ServiceName deploymentUnitServiceName = deploymentUnit.getServiceName();
    DeploymentDescriptorEnvironment deploymentDescriptorEnvironment = null;
    for (final AnnotationInstance messageBeanAnnotation : messageBeanAnnotations) {
        final AnnotationTarget target = messageBeanAnnotation.target();
        final ClassInfo beanClassInfo = (ClassInfo) target;
        if (!assertMDBClassValidity(beanClassInfo)) {
            continue;
        }
        final String ejbName = beanClassInfo.name().local();
        final AnnotationValue nameValue = messageBeanAnnotation.value("name");
        final String beanName = (nameValue == null || nameValue.asString().isEmpty()) ? ejbName : propertyReplacer.replaceProperties(nameValue.asString());
        final MessageDrivenBeanMetaData beanMetaData = getEnterpriseBeanMetaData(deploymentUnit, beanName, MessageDrivenBeanMetaData.class);
        final String beanClassName;
        final String messageListenerInterfaceName;
        final Properties activationConfigProperties = getActivationConfigProperties(messageBeanAnnotation, propertyReplacer);
        final String messagingType;
        if (beanMetaData != null) {
            beanClassName = override(beanClassInfo.name().toString(), beanMetaData.getEjbClass());
            deploymentDescriptorEnvironment = new DeploymentDescriptorEnvironment("java:comp/env/", beanMetaData);
            if (beanMetaData instanceof MessageDrivenBeanMetaData) {
                //It may actually be GenericBeanMetadata instance
                final MessageDrivenBeanMetaData mdb = (MessageDrivenBeanMetaData) beanMetaData;
                messagingType = mdb.getMessagingType();
                final ActivationConfigMetaData activationConfigMetaData = mdb.getActivationConfig();
                if (activationConfigMetaData != null) {
                    final ActivationConfigPropertiesMetaData propertiesMetaData = activationConfigMetaData.getActivationConfigProperties();
                    if (propertiesMetaData != null) {
                        for (final ActivationConfigPropertyMetaData propertyMetaData : propertiesMetaData) {
                            activationConfigProperties.put(propertyMetaData.getKey(), propertyMetaData.getValue());
                        }
                    }
                }
            } else if (beanMetaData instanceof JBossGenericBeanMetaData) {
                //TODO: fix the hierarchy so this is not needed
                final JBossGenericBeanMetaData mdb = (JBossGenericBeanMetaData) beanMetaData;
                messagingType = mdb.getMessagingType();
                final ActivationConfigMetaData activationConfigMetaData = mdb.getActivationConfig();
                if (activationConfigMetaData != null) {
                    final ActivationConfigPropertiesMetaData propertiesMetaData = activationConfigMetaData.getActivationConfigProperties();
                    if (propertiesMetaData != null) {
                        for (final ActivationConfigPropertyMetaData propertyMetaData : propertiesMetaData) {
                            activationConfigProperties.put(propertyMetaData.getKey(), propertyMetaData.getValue());
                        }
                    }
                }
            } else {
                messagingType = null;
            }
            messageListenerInterfaceName = messagingType != null ? messagingType : getMessageListenerInterface(compositeIndex, messageBeanAnnotation);
        } else {
            beanClassName = beanClassInfo.name().toString();
            messageListenerInterfaceName = getMessageListenerInterface(compositeIndex, messageBeanAnnotation);
        }
        final String defaultResourceAdapterName = this.getDefaultResourceAdapterName(deploymentUnit.getServiceRegistry());
        final MessageDrivenComponentDescription beanDescription = new MessageDrivenComponentDescription(beanName, beanClassName, ejbJarDescription, deploymentUnitServiceName, messageListenerInterfaceName, activationConfigProperties, defaultResourceAdapterName, beanMetaData);
        beanDescription.setDeploymentDescriptorEnvironment(deploymentDescriptorEnvironment);
        addComponent(deploymentUnit, beanDescription);
    }
    EjbDeploymentMarker.mark(deploymentUnit);
}
Also used : AnnotationTarget(org.jboss.jandex.AnnotationTarget) MessageDrivenBeanMetaData(org.jboss.metadata.ejb.spec.MessageDrivenBeanMetaData) ActivationConfigPropertyMetaData(org.jboss.metadata.ejb.spec.ActivationConfigPropertyMetaData) ActivationConfigMetaData(org.jboss.metadata.ejb.spec.ActivationConfigMetaData) Properties(java.util.Properties) ActivationConfigPropertiesMetaData(org.jboss.metadata.ejb.spec.ActivationConfigPropertiesMetaData) JBossGenericBeanMetaData(org.jboss.metadata.ejb.jboss.ejb3.JBossGenericBeanMetaData) ServiceName(org.jboss.msc.service.ServiceName) MessageDrivenComponentDescription(org.jboss.as.ejb3.component.messagedriven.MessageDrivenComponentDescription) DeploymentDescriptorEnvironment(org.jboss.as.ee.component.DeploymentDescriptorEnvironment) EjbJarDescription(org.jboss.as.ejb3.deployment.EjbJarDescription) AbstractDeploymentUnitProcessor.getEjbJarDescription(org.jboss.as.ejb3.deployment.processors.AbstractDeploymentUnitProcessor.getEjbJarDescription) AnnotationValue(org.jboss.jandex.AnnotationValue) PropertyReplacer(org.jboss.metadata.property.PropertyReplacer) AnnotationInstance(org.jboss.jandex.AnnotationInstance) ClassInfo(org.jboss.jandex.ClassInfo)

Example 7 with MessageDrivenComponentDescription

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

the class MethodPermissionsMergingProcessor method handleExcludeMethods.

private void handleExcludeMethods(final EJBComponentDescription componentDescription, final ExcludeListMetaData excludeList) {
    for (final MethodMetaData method : excludeList.getMethods()) {
        final String methodName = method.getMethodName();
        final MethodIntf defaultMethodIntf = (componentDescription instanceof MessageDrivenComponentDescription) ? MethodIntf.MESSAGE_ENDPOINT : MethodIntf.BEAN;
        final MethodIntf methodIntf = this.getMethodIntf(method.getMethodIntf(), defaultMethodIntf);
        if (methodName.equals("*")) {
            componentDescription.getDescriptorMethodPermissions().setAttribute(methodIntf, null, EJBMethodSecurityAttribute.denyAll());
        } else {
            final MethodParametersMetaData methodParams = method.getMethodParams();
            // update the session bean description with the tx attribute info
            if (methodParams == null) {
                componentDescription.getDescriptorMethodPermissions().setAttribute(methodIntf, EJBMethodSecurityAttribute.denyAll(), methodName);
            } else {
                componentDescription.getDescriptorMethodPermissions().setAttribute(methodIntf, EJBMethodSecurityAttribute.denyAll(), null, methodName, this.getMethodParams(methodParams));
            }
        }
    }
}
Also used : MessageDrivenComponentDescription(org.jboss.as.ejb3.component.messagedriven.MessageDrivenComponentDescription) MethodMetaData(org.jboss.metadata.ejb.spec.MethodMetaData) MethodParametersMetaData(org.jboss.metadata.ejb.spec.MethodParametersMetaData) MethodIntf(org.jboss.as.ejb3.component.MethodIntf)

Example 8 with MessageDrivenComponentDescription

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

the class MethodPermissionsMergingProcessor method handleMethodPermissions.

private void handleMethodPermissions(final EJBComponentDescription componentDescription, final MethodPermissionsMetaData methodPermissions) {
    for (final MethodPermissionMetaData methodPermissionMetaData : methodPermissions) {
        final MethodsMetaData methods = methodPermissionMetaData.getMethods();
        for (final MethodMetaData method : methods) {
            EJBMethodSecurityAttribute ejbMethodSecurityMetaData;
            // EJB 3.1 FR 17.3.2.2 The unchecked element is used instead of a role name in the method-permission element to indicate that all roles are permitted.
            if (methodPermissionMetaData.isNotChecked()) {
                ejbMethodSecurityMetaData = EJBMethodSecurityAttribute.permitAll();
            } else {
                ejbMethodSecurityMetaData = EJBMethodSecurityAttribute.rolesAllowed(methodPermissionMetaData.getRoles());
            }
            final String methodName = method.getMethodName();
            final MethodIntf defaultMethodIntf = (componentDescription instanceof MessageDrivenComponentDescription) ? MethodIntf.MESSAGE_ENDPOINT : MethodIntf.BEAN;
            final MethodIntf methodIntf = this.getMethodIntf(method.getMethodIntf(), defaultMethodIntf);
            if (methodName.equals("*")) {
                final EJBMethodSecurityAttribute existingRoles = componentDescription.getDescriptorMethodPermissions().getAttributeStyle1(methodIntf, null);
                ejbMethodSecurityMetaData = mergeExistingRoles(ejbMethodSecurityMetaData, existingRoles);
                componentDescription.getDescriptorMethodPermissions().setAttribute(methodIntf, null, ejbMethodSecurityMetaData);
            } else {
                final MethodParametersMetaData methodParams = method.getMethodParams();
                // update the session bean description with the tx attribute info
                if (methodParams == null) {
                    final EJBMethodSecurityAttribute existingRoles = componentDescription.getDescriptorMethodPermissions().getAttributeStyle2(methodIntf, methodName);
                    ejbMethodSecurityMetaData = mergeExistingRoles(ejbMethodSecurityMetaData, existingRoles);
                    componentDescription.getDescriptorMethodPermissions().setAttribute(methodIntf, ejbMethodSecurityMetaData, methodName);
                } else {
                    final EJBMethodSecurityAttribute existingRoles = componentDescription.getDescriptorMethodPermissions().getAttributeStyle3(methodIntf, null, methodName, this.getMethodParams(methodParams));
                    ejbMethodSecurityMetaData = mergeExistingRoles(ejbMethodSecurityMetaData, existingRoles);
                    componentDescription.getDescriptorMethodPermissions().setAttribute(methodIntf, ejbMethodSecurityMetaData, null, methodName, this.getMethodParams(methodParams));
                }
            }
        }
    }
}
Also used : MessageDrivenComponentDescription(org.jboss.as.ejb3.component.messagedriven.MessageDrivenComponentDescription) EJBMethodSecurityAttribute(org.jboss.as.ejb3.security.EJBMethodSecurityAttribute) MethodsMetaData(org.jboss.metadata.ejb.spec.MethodsMetaData) MethodMetaData(org.jboss.metadata.ejb.spec.MethodMetaData) MethodParametersMetaData(org.jboss.metadata.ejb.spec.MethodParametersMetaData) MethodPermissionMetaData(org.jboss.metadata.ejb.spec.MethodPermissionMetaData) MethodIntf(org.jboss.as.ejb3.component.MethodIntf)

Example 9 with MessageDrivenComponentDescription

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

the class MdbDeliveryDependenciesProcessor method undeploy.

@Override
public void undeploy(DeploymentUnit deploymentUnit) {
    final EEModuleConfiguration moduleConfiguration = deploymentUnit.getAttachment(EE_MODULE_CONFIGURATION);
    if (moduleConfiguration == null) {
        return;
    }
    final ServiceRegistry serviceRegistry = deploymentUnit.getServiceRegistry();
    boolean clusteredSingletonFound = false;
    for (final ComponentConfiguration configuration : moduleConfiguration.getComponentConfigurations()) {
        final ComponentDescription description = configuration.getComponentDescription();
        if (description instanceof MessageDrivenComponentDescription) {
            MessageDrivenComponentDescription mdbDescription = (MessageDrivenComponentDescription) description;
            clusteredSingletonFound = clusteredSingletonFound || mdbDescription.isClusteredSingleton();
            if (mdbDescription.isClusteredSingleton() || mdbDescription.getDeliveryGroup() != null) {
                serviceRegistry.getRequiredService(mdbDescription.getDeliveryControllerName()).setMode(Mode.REMOVE);
            }
        }
    }
    if (clusteredSingletonFound) {
        serviceRegistry.getRequiredService(createClusteredSingletonDemanderServiceName(deploymentUnit)).setMode(Mode.REMOVE);
    }
}
Also used : ComponentConfiguration(org.jboss.as.ee.component.ComponentConfiguration) MessageDrivenComponentDescription(org.jboss.as.ejb3.component.messagedriven.MessageDrivenComponentDescription) ComponentDescription(org.jboss.as.ee.component.ComponentDescription) MessageDrivenComponentDescription(org.jboss.as.ejb3.component.messagedriven.MessageDrivenComponentDescription) EEModuleConfiguration(org.jboss.as.ee.component.EEModuleConfiguration) ServiceRegistry(org.jboss.msc.service.ServiceRegistry)

Example 10 with MessageDrivenComponentDescription

use of org.jboss.as.ejb3.component.messagedriven.MessageDrivenComponentDescription 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

MessageDrivenComponentDescription (org.jboss.as.ejb3.component.messagedriven.MessageDrivenComponentDescription)9 ComponentConfiguration (org.jboss.as.ee.component.ComponentConfiguration)4 ComponentDescription (org.jboss.as.ee.component.ComponentDescription)4 AssemblyDescriptorMetaData (org.jboss.metadata.ejb.spec.AssemblyDescriptorMetaData)4 EjbJarMetaData (org.jboss.metadata.ejb.spec.EjbJarMetaData)4 MethodIntf (org.jboss.as.ejb3.component.MethodIntf)3 MethodMetaData (org.jboss.metadata.ejb.spec.MethodMetaData)3 MethodParametersMetaData (org.jboss.metadata.ejb.spec.MethodParametersMetaData)3 Properties (java.util.Properties)2 TransactionAttributeType (javax.ejb.TransactionAttributeType)2 DeploymentDescriptorEnvironment (org.jboss.as.ee.component.DeploymentDescriptorEnvironment)2 EEModuleConfiguration (org.jboss.as.ee.component.EEModuleConfiguration)2 EJBComponentDescription (org.jboss.as.ejb3.component.EJBComponentDescription)2 EjbJarDescription (org.jboss.as.ejb3.deployment.EjbJarDescription)2 AbstractDeploymentUnitProcessor.getEjbJarDescription (org.jboss.as.ejb3.deployment.processors.AbstractDeploymentUnitProcessor.getEjbJarDescription)2 DeploymentPhaseContext (org.jboss.as.server.deployment.DeploymentPhaseContext)2 DeploymentUnit (org.jboss.as.server.deployment.DeploymentUnit)2 DeploymentUnitProcessingException (org.jboss.as.server.deployment.DeploymentUnitProcessingException)2 ImmediateInterceptorFactory (org.jboss.invocation.ImmediateInterceptorFactory)2 MethodsMetaData (org.jboss.metadata.ejb.spec.MethodsMetaData)2