Search in sources :

Example 6 with DeploymentDescriptorEnvironment

use of org.jboss.as.ee.component.DeploymentDescriptorEnvironment in project wildfly by wildfly.

the class DescriptorEnvironmentLifecycleMethodProcessor 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 DeploymentDescriptorEnvironment environment = deploymentUnit.getAttachment(Attachments.MODULE_DEPLOYMENT_DESCRIPTOR_ENVIRONMENT);
    if (environment != null) {
        handleMethods(environment, eeModuleDescription, null);
    }
}
Also used : EEModuleDescription(org.jboss.as.ee.component.EEModuleDescription) DeploymentDescriptorEnvironment(org.jboss.as.ee.component.DeploymentDescriptorEnvironment) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit)

Example 7 with DeploymentDescriptorEnvironment

use of org.jboss.as.ee.component.DeploymentDescriptorEnvironment in project wildfly by wildfly.

the class AbstractDeploymentDescriptorBindingsProcessor method deploy.

@Override
public final void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    final DeploymentDescriptorEnvironment environment = deploymentUnit.getAttachment(Attachments.MODULE_DEPLOYMENT_DESCRIPTOR_ENVIRONMENT);
    final EEApplicationClasses applicationClasses = deploymentUnit.getAttachment(Attachments.EE_APPLICATION_CLASSES_DESCRIPTION);
    final Module module = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.MODULE);
    final DeploymentReflectionIndex deploymentReflectionIndex = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.REFLECTION_INDEX);
    final EEModuleDescription description = deploymentUnit.getAttachment(Attachments.EE_MODULE_DESCRIPTION);
    if (module == null || description == null) {
        return;
    }
    if (environment != null) {
        final List<BindingConfiguration> bindings = processDescriptorEntries(deploymentUnit, environment, description, null, module.getClassLoader(), deploymentReflectionIndex, applicationClasses);
        description.getBindingConfigurations().addAll(bindings);
    }
    for (final ComponentDescription componentDescription : description.getComponentDescriptions()) {
        if (componentDescription.getDeploymentDescriptorEnvironment() != null) {
            final List<BindingConfiguration> bindings = processDescriptorEntries(deploymentUnit, componentDescription.getDeploymentDescriptorEnvironment(), componentDescription, componentDescription, module.getClassLoader(), deploymentReflectionIndex, applicationClasses);
            componentDescription.getBindingConfigurations().addAll(bindings);
        }
    }
    for (final InterceptorEnvironment interceptorEnv : description.getInterceptorEnvironment().values()) {
        final List<BindingConfiguration> bindings = processDescriptorEntries(deploymentUnit, interceptorEnv.getDeploymentDescriptorEnvironment(), interceptorEnv, null, module.getClassLoader(), deploymentReflectionIndex, applicationClasses);
        interceptorEnv.getBindingConfigurations().addAll(bindings);
    }
}
Also used : ComponentDescription(org.jboss.as.ee.component.ComponentDescription) EEModuleDescription(org.jboss.as.ee.component.EEModuleDescription) EEApplicationClasses(org.jboss.as.ee.component.EEApplicationClasses) DeploymentDescriptorEnvironment(org.jboss.as.ee.component.DeploymentDescriptorEnvironment) Module(org.jboss.modules.Module) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit) DeploymentReflectionIndex(org.jboss.as.server.deployment.reflect.DeploymentReflectionIndex) BindingConfiguration(org.jboss.as.ee.component.BindingConfiguration) InterceptorEnvironment(org.jboss.as.ee.component.InterceptorEnvironment)

Example 8 with DeploymentDescriptorEnvironment

use of org.jboss.as.ee.component.DeploymentDescriptorEnvironment in project wildfly by wildfly.

the class InterceptorClassDeploymentDescriptorProcessor method deploy.

@Override
public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    final EjbJarMetaData metaData = deploymentUnit.getAttachment(EjbDeploymentAttachmentKeys.EJB_JAR_METADATA);
    final EEModuleDescription eeModuleDescription = deploymentUnit.getAttachment(Attachments.EE_MODULE_DESCRIPTION);
    if (metaData == null) {
        return;
    }
    if (metaData.getInterceptors() == null) {
        return;
    }
    for (InterceptorMetaData interceptor : metaData.getInterceptors()) {
        String interceptorClassName = interceptor.getInterceptorClass();
        AroundInvokesMetaData aroundInvokes = interceptor.getAroundInvokes();
        if (aroundInvokes != null) {
            for (AroundInvokeMetaData aroundInvoke : aroundInvokes) {
                final InterceptorClassDescription.Builder builder = InterceptorClassDescription.builder();
                String methodName = aroundInvoke.getMethodName();
                MethodIdentifier methodIdentifier = MethodIdentifier.getIdentifier(Object.class, methodName, InvocationContext.class);
                builder.setAroundInvoke(methodIdentifier);
                if (aroundInvoke.getClassName() == null || aroundInvoke.getClassName().isEmpty()) {
                    eeModuleDescription.addInterceptorMethodOverride(interceptorClassName, builder.build());
                } else {
                    eeModuleDescription.addInterceptorMethodOverride(aroundInvoke.getClassName(), builder.build());
                }
            }
        }
        AroundTimeoutsMetaData aroundTimeouts = interceptor.getAroundTimeouts();
        if (aroundTimeouts != null) {
            for (AroundTimeoutMetaData aroundTimeout : aroundTimeouts) {
                final InterceptorClassDescription.Builder builder = InterceptorClassDescription.builder();
                String methodName = aroundTimeout.getMethodName();
                MethodIdentifier methodIdentifier = MethodIdentifier.getIdentifier(Object.class, methodName, InvocationContext.class);
                builder.setAroundTimeout(methodIdentifier);
                if (aroundTimeout.getClassName() == null || aroundTimeout.getClassName().isEmpty()) {
                    eeModuleDescription.addInterceptorMethodOverride(interceptorClassName, builder.build());
                } else {
                    eeModuleDescription.addInterceptorMethodOverride(aroundTimeout.getClassName(), builder.build());
                }
            }
        }
        // post-construct(s) of the interceptor configured (if any) in the deployment descriptor
        LifecycleCallbacksMetaData postConstructs = interceptor.getPostConstructs();
        if (postConstructs != null) {
            for (LifecycleCallbackMetaData postConstruct : postConstructs) {
                final InterceptorClassDescription.Builder builder = InterceptorClassDescription.builder();
                String methodName = postConstruct.getMethodName();
                MethodIdentifier methodIdentifier = MethodIdentifier.getIdentifier(void.class, methodName, InvocationContext.class);
                builder.setPostConstruct(methodIdentifier);
                if (postConstruct.getClassName() == null || postConstruct.getClassName().isEmpty()) {
                    eeModuleDescription.addInterceptorMethodOverride(interceptorClassName, builder.build());
                } else {
                    eeModuleDescription.addInterceptorMethodOverride(postConstruct.getClassName(), builder.build());
                }
            }
        }
        // pre-destroy(s) of the interceptor configured (if any) in the deployment descriptor
        LifecycleCallbacksMetaData preDestroys = interceptor.getPreDestroys();
        if (preDestroys != null) {
            for (LifecycleCallbackMetaData preDestroy : preDestroys) {
                final InterceptorClassDescription.Builder builder = InterceptorClassDescription.builder();
                String methodName = preDestroy.getMethodName();
                MethodIdentifier methodIdentifier = MethodIdentifier.getIdentifier(void.class, methodName, InvocationContext.class);
                builder.setPreDestroy(methodIdentifier);
                if (preDestroy.getClassName() == null || preDestroy.getClassName().isEmpty()) {
                    eeModuleDescription.addInterceptorMethodOverride(interceptorClassName, builder.build());
                } else {
                    eeModuleDescription.addInterceptorMethodOverride(preDestroy.getClassName(), builder.build());
                }
            }
        }
        // pre-passivates(s) of the interceptor configured (if any) in the deployment descriptor
        LifecycleCallbacksMetaData prePassivates = interceptor.getPrePassivates();
        if (prePassivates != null) {
            for (LifecycleCallbackMetaData prePassivate : prePassivates) {
                final InterceptorClassDescription.Builder builder = InterceptorClassDescription.builder();
                String methodName = prePassivate.getMethodName();
                MethodIdentifier methodIdentifier = MethodIdentifier.getIdentifier(void.class, methodName, InvocationContext.class);
                builder.setPrePassivate(methodIdentifier);
                if (prePassivate.getClassName() == null || prePassivate.getClassName().isEmpty()) {
                    eeModuleDescription.addInterceptorMethodOverride(interceptorClassName, builder.build());
                } else {
                    eeModuleDescription.addInterceptorMethodOverride(prePassivate.getClassName(), builder.build());
                }
            }
        }
        // pre-passivates(s) of the interceptor configured (if any) in the deployment descriptor
        LifecycleCallbacksMetaData postActivates = interceptor.getPostActivates();
        if (postActivates != null) {
            for (LifecycleCallbackMetaData postActivate : postActivates) {
                final InterceptorClassDescription.Builder builder = InterceptorClassDescription.builder();
                String methodName = postActivate.getMethodName();
                MethodIdentifier methodIdentifier = MethodIdentifier.getIdentifier(void.class, methodName, InvocationContext.class);
                builder.setPostActivate(methodIdentifier);
                if (postActivate.getClassName() == null || postActivate.getClassName().isEmpty()) {
                    eeModuleDescription.addInterceptorMethodOverride(interceptorClassName, builder.build());
                } else {
                    eeModuleDescription.addInterceptorMethodOverride(postActivate.getClassName(), builder.build());
                }
            }
        }
        if (interceptor.getJndiEnvironmentRefsGroup() != null) {
            final DeploymentDescriptorEnvironment environment = new DeploymentDescriptorEnvironment("java:comp/env", interceptor.getJndiEnvironmentRefsGroup());
            eeModuleDescription.addInterceptorEnvironment(interceptor.getInterceptorClass(), new InterceptorEnvironment(environment));
        }
    }
}
Also used : AroundInvokesMetaData(org.jboss.metadata.ejb.spec.AroundInvokesMetaData) AroundTimeoutsMetaData(org.jboss.metadata.ejb.spec.AroundTimeoutsMetaData) EjbJarMetaData(org.jboss.metadata.ejb.spec.EjbJarMetaData) AroundInvokeMetaData(org.jboss.metadata.ejb.spec.AroundInvokeMetaData) MethodIdentifier(org.jboss.invocation.proxy.MethodIdentifier) InterceptorMetaData(org.jboss.metadata.ejb.spec.InterceptorMetaData) LifecycleCallbacksMetaData(org.jboss.metadata.javaee.spec.LifecycleCallbacksMetaData) EEModuleDescription(org.jboss.as.ee.component.EEModuleDescription) InterceptorClassDescription(org.jboss.as.ee.component.interceptors.InterceptorClassDescription) DeploymentDescriptorEnvironment(org.jboss.as.ee.component.DeploymentDescriptorEnvironment) LifecycleCallbackMetaData(org.jboss.metadata.javaee.spec.LifecycleCallbackMetaData) AroundTimeoutMetaData(org.jboss.metadata.ejb.spec.AroundTimeoutMetaData) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit) InterceptorEnvironment(org.jboss.as.ee.component.InterceptorEnvironment)

Example 9 with DeploymentDescriptorEnvironment

use of org.jboss.as.ee.component.DeploymentDescriptorEnvironment 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 10 with DeploymentDescriptorEnvironment

use of org.jboss.as.ee.component.DeploymentDescriptorEnvironment in project wildfly by wildfly.

the class SessionBeanXmlDescriptorProcessor method processBeanMetaData.

/**
     * Processes the passed {@link org.jboss.metadata.ejb.spec.SessionBeanMetaData} and creates appropriate {@link org.jboss.as.ejb3.component.session.SessionBeanComponentDescription} out of it.
     * The {@link org.jboss.as.ejb3.component.session.SessionBeanComponentDescription} is then added to the {@link org.jboss.as.ee.component.EEModuleDescription module description} available
     * in the deployment unit of the passed {@link DeploymentPhaseContext phaseContext}
     *
     * @param sessionBean  The session bean metadata
     * @param phaseContext
     * @throws DeploymentUnitProcessingException
     *
     */
@Override
protected void processBeanMetaData(final SessionBeanMetaData sessionBean, final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    // get the module description
    final EEModuleDescription moduleDescription = deploymentUnit.getAttachment(org.jboss.as.ee.component.Attachments.EE_MODULE_DESCRIPTION);
    final String beanName = sessionBean.getName();
    ComponentDescription bean = moduleDescription.getComponentByName(beanName);
    if (appclient) {
        if (bean == null) {
            for (final ComponentDescription component : deploymentUnit.getAttachmentList(Attachments.ADDITIONAL_RESOLVABLE_COMPONENTS)) {
                if (component.getComponentName().equals(beanName)) {
                    bean = component;
                    break;
                }
            }
        }
    }
    if (!(bean instanceof SessionBeanComponentDescription)) {
        //if this is a GenericBeanMetadata it may actually represent an MDB
        return;
    }
    SessionBeanComponentDescription sessionBeanDescription = (SessionBeanComponentDescription) bean;
    sessionBeanDescription.setDeploymentDescriptorEnvironment(new DeploymentDescriptorEnvironment("java:comp/env/", sessionBean));
    // mapped-name
    sessionBeanDescription.setMappedName(sessionBean.getMappedName());
    // local business interface views
    final BusinessLocalsMetaData businessLocals = sessionBean.getBusinessLocals();
    if (businessLocals != null && !businessLocals.isEmpty()) {
        sessionBeanDescription.addLocalBusinessInterfaceViews(businessLocals);
    }
    final String local = sessionBean.getLocal();
    if (local != null) {
        sessionBeanDescription.addEjbLocalObjectView(local);
    }
    final String remote = sessionBean.getRemote();
    if (remote != null) {
        sessionBeanDescription.addEjbObjectView(remote);
    }
    // remote business interface views
    final BusinessRemotesMetaData businessRemotes = sessionBean.getBusinessRemotes();
    if (businessRemotes != null && !businessRemotes.isEmpty()) {
        sessionBeanDescription.addRemoteBusinessInterfaceViews(businessRemotes);
    }
    // process EJB3.1 specific session bean description
    if (sessionBean instanceof SessionBean31MetaData) {
        this.processSessionBean31((SessionBean31MetaData) sessionBean, sessionBeanDescription);
    }
}
Also used : ComponentDescription(org.jboss.as.ee.component.ComponentDescription) SessionBeanComponentDescription(org.jboss.as.ejb3.component.session.SessionBeanComponentDescription) EEModuleDescription(org.jboss.as.ee.component.EEModuleDescription) DeploymentDescriptorEnvironment(org.jboss.as.ee.component.DeploymentDescriptorEnvironment) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit) SessionBeanComponentDescription(org.jboss.as.ejb3.component.session.SessionBeanComponentDescription) SessionBean31MetaData(org.jboss.metadata.ejb.spec.SessionBean31MetaData) BusinessLocalsMetaData(org.jboss.metadata.ejb.spec.BusinessLocalsMetaData) BusinessRemotesMetaData(org.jboss.metadata.ejb.spec.BusinessRemotesMetaData)

Aggregations

DeploymentDescriptorEnvironment (org.jboss.as.ee.component.DeploymentDescriptorEnvironment)13 DeploymentUnit (org.jboss.as.server.deployment.DeploymentUnit)8 EEModuleDescription (org.jboss.as.ee.component.EEModuleDescription)7 ArrayList (java.util.ArrayList)3 BindingConfiguration (org.jboss.as.ee.component.BindingConfiguration)3 ResourceRoot (org.jboss.as.server.deployment.module.ResourceRoot)3 HashMap (java.util.HashMap)2 Properties (java.util.Properties)2 Manifest (java.util.jar.Manifest)2 ComponentDescription (org.jboss.as.ee.component.ComponentDescription)2 EEApplicationClasses (org.jboss.as.ee.component.EEApplicationClasses)2 InterceptorEnvironment (org.jboss.as.ee.component.InterceptorEnvironment)2 LookupInjectionSource (org.jboss.as.ee.component.LookupInjectionSource)2 MessageDrivenComponentDescription (org.jboss.as.ejb3.component.messagedriven.MessageDrivenComponentDescription)2 EjbJarDescription (org.jboss.as.ejb3.deployment.EjbJarDescription)2 AbstractDeploymentUnitProcessor.getEjbJarDescription (org.jboss.as.ejb3.deployment.processors.AbstractDeploymentUnitProcessor.getEjbJarDescription)2 EarMetaData (org.jboss.metadata.ear.spec.EarMetaData)2 Module (org.jboss.modules.Module)2 ServiceName (org.jboss.msc.service.ServiceName)2 HashSet (java.util.HashSet)1