Search in sources :

Example 1 with MessageDrivenComponentDescription

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

the class DeploymentDescriptorMethodProcessor method deploy.

@Override
public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    final EEModuleDescription eeModuleDescription = deploymentUnit.getAttachment(org.jboss.as.ee.component.Attachments.EE_MODULE_DESCRIPTION);
    final DeploymentReflectionIndex reflectionIndex = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.REFLECTION_INDEX);
    final Module module = deploymentUnit.getAttachment(Attachments.MODULE);
    if (eeModuleDescription != null) {
        for (final ComponentDescription component : eeModuleDescription.getComponentDescriptions()) {
            if (component instanceof EJBComponentDescription) {
                try {
                    if (component instanceof SessionBeanComponentDescription || component instanceof MessageDrivenComponentDescription)
                        handleSessionBean((EJBComponentDescription) component, module, reflectionIndex);
                    if (component instanceof StatelessComponentDescription || component instanceof MessageDrivenComponentDescription) {
                        handleStatelessSessionBean((EJBComponentDescription) component, module, reflectionIndex);
                    }
                } catch (ClassNotFoundException e) {
                    throw EjbLogger.ROOT_LOGGER.failToLoadComponentClass(e, component.getComponentName());
                }
            }
        }
    }
}
Also used : StatelessComponentDescription(org.jboss.as.ejb3.component.stateless.StatelessComponentDescription) EJBComponentDescription(org.jboss.as.ejb3.component.EJBComponentDescription) SessionBeanComponentDescription(org.jboss.as.ejb3.component.session.SessionBeanComponentDescription) MessageDrivenComponentDescription(org.jboss.as.ejb3.component.messagedriven.MessageDrivenComponentDescription) ComponentDescription(org.jboss.as.ee.component.ComponentDescription) EEModuleDescription(org.jboss.as.ee.component.EEModuleDescription) MessageDrivenComponentDescription(org.jboss.as.ejb3.component.messagedriven.MessageDrivenComponentDescription) StatelessComponentDescription(org.jboss.as.ejb3.component.stateless.StatelessComponentDescription) Module(org.jboss.modules.Module) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit) DeploymentReflectionIndex(org.jboss.as.server.deployment.reflect.DeploymentReflectionIndex) EJBComponentDescription(org.jboss.as.ejb3.component.EJBComponentDescription) SessionBeanComponentDescription(org.jboss.as.ejb3.component.session.SessionBeanComponentDescription)

Example 2 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 3 with MessageDrivenComponentDescription

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

the class TransactionAttributeMergingProcessor method handleDeploymentDescriptor.

@Override
protected void handleDeploymentDescriptor(final DeploymentUnit deploymentUnit, final DeploymentReflectionIndex deploymentReflectionIndex, final Class<?> componentClass, final EJBComponentDescription componentDescription) throws DeploymentUnitProcessingException {
    // CMT Tx attributes
    //DO NOT USE componentConfiguration.getDescriptorData()
    //It will return null if there is no <enterprise-beans/> declaration even if there is an assembly descriptor entry
    EjbJarMetaData ejbJarMetadata = deploymentUnit.getAttachment(EjbDeploymentAttachmentKeys.EJB_JAR_METADATA);
    if (ejbJarMetadata != null) {
        boolean wildcardAttributeSet = false;
        boolean wildcardTimeoutSet = false;
        ContainerTransactionMetaData global = null;
        final AssemblyDescriptorMetaData assemblyDescriptor = ejbJarMetadata.getAssemblyDescriptor();
        if (assemblyDescriptor != null) {
            final ContainerTransactionsMetaData globalTransactions = assemblyDescriptor.getContainerTransactionsByEjbName("*");
            if (globalTransactions != null) {
                if (globalTransactions.size() > 1) {
                    throw EjbLogger.ROOT_LOGGER.mustOnlyBeSingleContainerTransactionElementWithWildcard();
                }
                global = globalTransactions.iterator().next();
                for (MethodMetaData method : global.getMethods()) {
                    if (!method.getMethodName().equals("*")) {
                        throw EjbLogger.ROOT_LOGGER.wildcardContainerTransactionElementsMustHaveWildcardMethodName();
                    }
                }
            }
            final ContainerTransactionsMetaData containerTransactions = assemblyDescriptor.getContainerTransactionsByEjbName(componentDescription.getEJBName());
            if (containerTransactions != null) {
                for (final ContainerTransactionMetaData containerTx : containerTransactions) {
                    final TransactionAttributeType txAttr = containerTx.getTransAttribute();
                    final Integer timeout = timeout(containerTx);
                    final MethodsMetaData methods = containerTx.getMethods();
                    for (final MethodMetaData method : methods) {
                        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("*")) {
                            if (txAttr != null) {
                                wildcardAttributeSet = true;
                                componentDescription.getTransactionAttributes().setAttribute(methodIntf, null, txAttr);
                            }
                            if (timeout != null) {
                                wildcardTimeoutSet = true;
                                componentDescription.getTransactionTimeouts().setAttribute(methodIntf, null, timeout);
                            }
                        } else {
                            final MethodParametersMetaData methodParams = method.getMethodParams();
                            // update the session bean description with the tx attribute info
                            if (methodParams == null) {
                                if (txAttr != null)
                                    componentDescription.getTransactionAttributes().setAttribute(methodIntf, txAttr, methodName);
                                if (timeout != null)
                                    componentDescription.getTransactionTimeouts().setAttribute(methodIntf, timeout, methodName);
                            } else {
                                if (txAttr != null)
                                    componentDescription.getTransactionAttributes().setAttribute(methodIntf, txAttr, null, methodName, this.getMethodParams(methodParams));
                                if (timeout != null)
                                    componentDescription.getTransactionTimeouts().setAttribute(methodIntf, timeout, null, methodName, this.getMethodParams(methodParams));
                            }
                        }
                    }
                }
            }
        }
        if (global != null) {
            if (!wildcardAttributeSet && global.getTransAttribute() != null) {
                for (MethodMetaData method : global.getMethods()) {
                    final MethodIntf defaultMethodIntf = (componentDescription instanceof MessageDrivenComponentDescription) ? MethodIntf.MESSAGE_ENDPOINT : MethodIntf.BEAN;
                    final MethodIntf methodIntf = this.getMethodIntf(method.getMethodIntf(), defaultMethodIntf);
                    componentDescription.getTransactionAttributes().setAttribute(methodIntf, null, global.getTransAttribute());
                }
            }
            final Integer timeout = timeout(global);
            if (!wildcardTimeoutSet && timeout != null) {
                for (MethodMetaData method : global.getMethods()) {
                    final MethodIntf defaultMethodIntf = (componentDescription instanceof MessageDrivenComponentDescription) ? MethodIntf.MESSAGE_ENDPOINT : MethodIntf.BEAN;
                    final MethodIntf methodIntf = this.getMethodIntf(method.getMethodIntf(), defaultMethodIntf);
                    componentDescription.getTransactionTimeouts().setAttribute(methodIntf, null, timeout);
                }
            }
        }
    }
}
Also used : EjbJarMetaData(org.jboss.metadata.ejb.spec.EjbJarMetaData) MethodMetaData(org.jboss.metadata.ejb.spec.MethodMetaData) MethodParametersMetaData(org.jboss.metadata.ejb.spec.MethodParametersMetaData) MethodIntf(org.jboss.as.ejb3.component.MethodIntf) ContainerTransactionMetaData(org.jboss.metadata.ejb.spec.ContainerTransactionMetaData) MessageDrivenComponentDescription(org.jboss.as.ejb3.component.messagedriven.MessageDrivenComponentDescription) ContainerTransactionsMetaData(org.jboss.metadata.ejb.spec.ContainerTransactionsMetaData) AssemblyDescriptorMetaData(org.jboss.metadata.ejb.spec.AssemblyDescriptorMetaData) MethodsMetaData(org.jboss.metadata.ejb.spec.MethodsMetaData) TransactionAttributeType(javax.ejb.TransactionAttributeType)

Example 4 with MessageDrivenComponentDescription

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

the class ClusteredSingletonMergingProcessor method handleDeploymentDescriptor.

@Override
protected void handleDeploymentDescriptor(DeploymentUnit deploymentUnit, DeploymentReflectionIndex deploymentReflectionIndex, Class<?> componentClass, MessageDrivenComponentDescription componentDescription) throws DeploymentUnitProcessingException {
    final EjbJarMetaData ejbJarMetaData = deploymentUnit.getAttachment(EjbDeploymentAttachmentKeys.EJB_JAR_METADATA);
    Boolean allBeansClusteredSingleton = null;
    if (ejbJarMetaData != null) {
        final AssemblyDescriptorMetaData assemblyMetadata = ejbJarMetaData.getAssemblyDescriptor();
        if (assemblyMetadata != null) {
            final List<EJBBoundClusteringMetaData> clusteringMetaDatas = assemblyMetadata.getAny(EJBBoundClusteringMetaData.class);
            if (clusteringMetaDatas != null) {
                for (final EJBBoundClusteringMetaData clusteringMetaData : clusteringMetaDatas) {
                    if ("*".equals(clusteringMetaData.getEjbName())) {
                        allBeansClusteredSingleton = clusteringMetaData.isClusteredSingleton();
                    } else if (componentDescription.getComponentName().equals(clusteringMetaData.getEjbName())) {
                        componentDescription.setClusteredSingleton(clusteringMetaData.isClusteredSingleton());
                        return;
                    }
                }
            }
        }
    }
    if (allBeansClusteredSingleton != null && allBeansClusteredSingleton) {
        componentDescription.setClusteredSingleton(true);
    }
}
Also used : EjbJarMetaData(org.jboss.metadata.ejb.spec.EjbJarMetaData) AssemblyDescriptorMetaData(org.jboss.metadata.ejb.spec.AssemblyDescriptorMetaData) EJBBoundClusteringMetaData(org.jboss.as.ejb3.clustering.EJBBoundClusteringMetaData)

Example 5 with MessageDrivenComponentDescription

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

the class MdbDeliveryMergingProcessor method handleDeploymentDescriptor.

@Override
protected void handleDeploymentDescriptor(final DeploymentUnit deploymentUnit, final DeploymentReflectionIndex deploymentReflectionIndex, final Class<?> componentClass, final MessageDrivenComponentDescription componentConfiguration) throws DeploymentUnitProcessingException {
    final String ejbName = componentConfiguration.getEJBName();
    final EjbJarMetaData metaData = deploymentUnit.getAttachment(EjbDeploymentAttachmentKeys.EJB_JAR_METADATA);
    if (metaData == null) {
        return;
    }
    final AssemblyDescriptorMetaData assemblyDescriptor = metaData.getAssemblyDescriptor();
    if (assemblyDescriptor == null) {
        return;
    }
    Boolean deliveryActive = null;
    String deliveryGroup = null;
    final List<EJBBoundMdbDeliveryMetaData> deliveryMetaDataList = assemblyDescriptor.getAny(EJBBoundMdbDeliveryMetaData.class);
    if (deliveryMetaDataList != null) {
        for (EJBBoundMdbDeliveryMetaData deliveryMetaData : deliveryMetaDataList) {
            if ("*".equals(deliveryMetaData.getEjbName()) && deliveryActive == null && deliveryGroup == null) {
                deliveryActive = deliveryMetaData.isDeliveryActive();
                deliveryGroup = deliveryMetaData.getDeliveryGroup();
            } else if (ejbName.equals(deliveryMetaData.getEjbName())) {
                deliveryActive = deliveryMetaData.isDeliveryActive();
                deliveryGroup = deliveryMetaData.getDeliveryGroup();
            }
        }
    }
    // delivery group configuration has precedence over deliveryActive
    if (deliveryGroup != null) {
        componentConfiguration.setDeliveryGroup(deliveryGroup);
    } else if (deliveryActive != null) {
        componentConfiguration.setDeliveryActive(deliveryActive);
    }
}
Also used : EjbJarMetaData(org.jboss.metadata.ejb.spec.EjbJarMetaData) EJBBoundMdbDeliveryMetaData(org.jboss.as.ejb3.deliveryactive.metadata.EJBBoundMdbDeliveryMetaData) AssemblyDescriptorMetaData(org.jboss.metadata.ejb.spec.AssemblyDescriptorMetaData)

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