Search in sources :

Example 1 with JBossGenericBeanMetaData

use of org.jboss.metadata.ejb.jboss.ejb3.JBossGenericBeanMetaData 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)

Aggregations

Properties (java.util.Properties)1 DeploymentDescriptorEnvironment (org.jboss.as.ee.component.DeploymentDescriptorEnvironment)1 MessageDrivenComponentDescription (org.jboss.as.ejb3.component.messagedriven.MessageDrivenComponentDescription)1 EjbJarDescription (org.jboss.as.ejb3.deployment.EjbJarDescription)1 AbstractDeploymentUnitProcessor.getEjbJarDescription (org.jboss.as.ejb3.deployment.processors.AbstractDeploymentUnitProcessor.getEjbJarDescription)1 AnnotationInstance (org.jboss.jandex.AnnotationInstance)1 AnnotationTarget (org.jboss.jandex.AnnotationTarget)1 AnnotationValue (org.jboss.jandex.AnnotationValue)1 ClassInfo (org.jboss.jandex.ClassInfo)1 JBossGenericBeanMetaData (org.jboss.metadata.ejb.jboss.ejb3.JBossGenericBeanMetaData)1 ActivationConfigMetaData (org.jboss.metadata.ejb.spec.ActivationConfigMetaData)1 ActivationConfigPropertiesMetaData (org.jboss.metadata.ejb.spec.ActivationConfigPropertiesMetaData)1 ActivationConfigPropertyMetaData (org.jboss.metadata.ejb.spec.ActivationConfigPropertyMetaData)1 MessageDrivenBeanMetaData (org.jboss.metadata.ejb.spec.MessageDrivenBeanMetaData)1 PropertyReplacer (org.jboss.metadata.property.PropertyReplacer)1 ServiceName (org.jboss.msc.service.ServiceName)1