Search in sources :

Example 11 with DeploymentDescriptorEnvironment

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

the class MessageDrivenComponentDescriptionFactory method processMessageDrivenBeanMetaData.

private void processMessageDrivenBeanMetaData(final DeploymentUnit deploymentUnit, final MessageDrivenBeanMetaData mdb) throws DeploymentUnitProcessingException {
    final EjbJarDescription ejbJarDescription = getEjbJarDescription(deploymentUnit);
    final String beanName = mdb.getName();
    final String beanClassName = mdb.getEjbClass();
    String messageListenerInterface = mdb.getMessagingType();
    if (messageListenerInterface == null || messageListenerInterface.trim().isEmpty()) {
        // TODO: This isn't really correct to default to MessageListener
        messageListenerInterface = MessageListener.class.getName();
    }
    final Properties activationConfigProps = getActivationConfigProperties(mdb.getActivationConfig());
    final String defaultResourceAdapterName = this.getDefaultResourceAdapterName(deploymentUnit.getServiceRegistry());
    final MessageDrivenComponentDescription mdbComponentDescription = new MessageDrivenComponentDescription(beanName, beanClassName, ejbJarDescription, deploymentUnit.getServiceName(), messageListenerInterface, activationConfigProps, defaultResourceAdapterName, mdb);
    mdbComponentDescription.setDeploymentDescriptorEnvironment(new DeploymentDescriptorEnvironment("java:comp/env/", mdb));
    addComponent(deploymentUnit, mdbComponentDescription);
}
Also used : 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) MessageListener(javax.jms.MessageListener) Properties(java.util.Properties)

Example 12 with DeploymentDescriptorEnvironment

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

the class EjbRefProcessor method processDescriptorEntries.

/**
     * Resolves ejb-ref and ejb-local-ref elements
     *
     *
     * @param deploymentUnit
     * @param environment               The environment to resolve the elements for
     * @param componentDescription
     *@param classLoader               The deployment class loader
     * @param deploymentReflectionIndex The reflection index
     * @param applicationClasses    @return The bindings for the environment entries
     */
protected List<BindingConfiguration> processDescriptorEntries(DeploymentUnit deploymentUnit, DeploymentDescriptorEnvironment environment, ResourceInjectionTarget resourceInjectionTarget, final ComponentDescription componentDescription, ClassLoader classLoader, DeploymentReflectionIndex deploymentReflectionIndex, final EEApplicationClasses applicationClasses) throws DeploymentUnitProcessingException {
    final RemoteEnvironment remoteEnvironment = environment.getEnvironment();
    List<BindingConfiguration> bindingDescriptions = new ArrayList<BindingConfiguration>();
    EJBReferencesMetaData ejbRefs = remoteEnvironment.getEjbReferences();
    if (ejbRefs != null) {
        for (EJBReferenceMetaData ejbRef : ejbRefs) {
            String name = ejbRef.getEjbRefName();
            String ejbName = ejbRef.getLink();
            String lookup = ejbRef.getLookupName() != null ? ejbRef.getLookupName() : ejbRef.getMappedName();
            String remoteInterface = ejbRef.getRemote();
            String home = ejbRef.getHome();
            Class<?> remoteInterfaceType = null;
            //if a home is specified this is the type that is bound
            if (!isEmpty(home)) {
                try {
                    remoteInterfaceType = ClassLoadingUtils.loadClass(home, deploymentUnit);
                } catch (ClassNotFoundException e) {
                    throw EjbLogger.ROOT_LOGGER.failedToLoadViewClass(e, home);
                }
            } else if (!isEmpty(remoteInterface)) {
                try {
                    remoteInterfaceType = ClassLoadingUtils.loadClass(remoteInterface, deploymentUnit);
                } catch (ClassNotFoundException e) {
                    throw EjbLogger.ROOT_LOGGER.failedToLoadViewClass(e, remoteInterface);
                }
            }
            if (!name.startsWith("java:")) {
                name = environment.getDefaultContext() + name;
            }
            // our injection (source) comes from the local (ENC) lookup, no matter what.
            LookupInjectionSource injectionSource = new LookupInjectionSource(name);
            //add any injection targets
            remoteInterfaceType = processInjectionTargets(resourceInjectionTarget, injectionSource, classLoader, deploymentReflectionIndex, ejbRef, remoteInterfaceType);
            final BindingConfiguration bindingConfiguration;
            EjbInjectionSource ejbInjectionSource = null;
            if (!isEmpty(lookup)) {
                if (!lookup.startsWith("java:")) {
                    bindingConfiguration = new BindingConfiguration(name, new EjbLookupInjectionSource(lookup, remoteInterfaceType));
                } else {
                    bindingConfiguration = new BindingConfiguration(name, new LookupInjectionSource(lookup));
                }
            } else {
                if (remoteInterfaceType == null) {
                    throw EjbLogger.ROOT_LOGGER.couldNotDetermineEjbRefForInjectionTarget(name, resourceInjectionTarget);
                }
                if (!isEmpty(ejbName)) {
                    bindingConfiguration = new BindingConfiguration(name, ejbInjectionSource = new EjbInjectionSource(ejbName, remoteInterfaceType.getName(), name, deploymentUnit, appclient));
                } else {
                    bindingConfiguration = new BindingConfiguration(name, ejbInjectionSource = new EjbInjectionSource(remoteInterfaceType.getName(), name, deploymentUnit, appclient));
                }
            }
            if (ejbInjectionSource != null) {
                deploymentUnit.addToAttachmentList(EjbDeploymentAttachmentKeys.EJB_INJECTIONS, ejbInjectionSource);
            }
            bindingDescriptions.add(bindingConfiguration);
        }
    }
    if (remoteEnvironment instanceof Environment && !appclient) {
        EJBLocalReferencesMetaData ejbLocalRefs = ((Environment) remoteEnvironment).getEjbLocalReferences();
        if (ejbLocalRefs != null) {
            for (EJBLocalReferenceMetaData ejbRef : ejbLocalRefs) {
                String name = ejbRef.getEjbRefName();
                String ejbName = ejbRef.getLink();
                String lookup = ejbRef.getLookupName() != null ? ejbRef.getLookupName() : ejbRef.getMappedName();
                String localInterface = ejbRef.getLocal();
                String localHome = ejbRef.getLocalHome();
                Class<?> localInterfaceType = null;
                //if a home is specified this is the type that is bound
                if (!isEmpty(localHome)) {
                    try {
                        localInterfaceType = ClassLoadingUtils.loadClass(localHome, deploymentUnit);
                    } catch (ClassNotFoundException e) {
                        throw EjbLogger.ROOT_LOGGER.failedToLoadViewClass(e, localHome);
                    }
                } else if (!isEmpty(localInterface)) {
                    try {
                        localInterfaceType = ClassLoadingUtils.loadClass(localInterface, deploymentUnit);
                    } catch (ClassNotFoundException e) {
                        throw EjbLogger.ROOT_LOGGER.failedToLoadViewClass(e, localInterface);
                    }
                }
                if (!name.startsWith("java:")) {
                    name = environment.getDefaultContext() + name;
                }
                // our injection (source) comes from the local (ENC) lookup, no matter what.
                LookupInjectionSource injectionSource = new LookupInjectionSource(name);
                //add any injection targets
                localInterfaceType = processInjectionTargets(resourceInjectionTarget, injectionSource, classLoader, deploymentReflectionIndex, ejbRef, localInterfaceType);
                if (localInterfaceType == null) {
                    throw EjbLogger.ROOT_LOGGER.couldNotDetermineEjbLocalRefForInjectionTarget(name, resourceInjectionTarget);
                }
                final BindingConfiguration bindingConfiguration;
                EjbInjectionSource ejbInjectionSource = null;
                if (!isEmpty(lookup)) {
                    if (!lookup.startsWith("java:")) {
                        bindingConfiguration = new BindingConfiguration(name, new EjbLookupInjectionSource(lookup, localInterfaceType));
                    } else {
                        bindingConfiguration = new BindingConfiguration(name, new LookupInjectionSource(lookup));
                    }
                } else if (!isEmpty(ejbName)) {
                    bindingConfiguration = new BindingConfiguration(name, ejbInjectionSource = new EjbInjectionSource(ejbName, localInterfaceType.getName(), name, deploymentUnit, appclient));
                } else {
                    bindingConfiguration = new BindingConfiguration(name, ejbInjectionSource = new EjbInjectionSource(localInterfaceType.getName(), name, deploymentUnit, appclient));
                }
                if (ejbInjectionSource != null) {
                    deploymentUnit.addToAttachmentList(EjbDeploymentAttachmentKeys.EJB_INJECTIONS, ejbInjectionSource);
                }
                bindingDescriptions.add(bindingConfiguration);
            }
        }
    }
    return bindingDescriptions;
}
Also used : RemoteEnvironment(org.jboss.metadata.javaee.spec.RemoteEnvironment) EJBLocalReferenceMetaData(org.jboss.metadata.javaee.spec.EJBLocalReferenceMetaData) ArrayList(java.util.ArrayList) EJBReferenceMetaData(org.jboss.metadata.javaee.spec.EJBReferenceMetaData) Environment(org.jboss.metadata.javaee.spec.Environment) RemoteEnvironment(org.jboss.metadata.javaee.spec.RemoteEnvironment) DeploymentDescriptorEnvironment(org.jboss.as.ee.component.DeploymentDescriptorEnvironment) BindingConfiguration(org.jboss.as.ee.component.BindingConfiguration) EJBReferencesMetaData(org.jboss.metadata.javaee.spec.EJBReferencesMetaData) LookupInjectionSource(org.jboss.as.ee.component.LookupInjectionSource) EJBLocalReferencesMetaData(org.jboss.metadata.javaee.spec.EJBLocalReferencesMetaData)

Example 13 with DeploymentDescriptorEnvironment

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

the class EarMetaDataParsingProcessor method deploy.

public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    if (!DeploymentTypeMarker.isType(DeploymentType.EAR, deploymentUnit)) {
        return;
    }
    final ResourceRoot deploymentRoot = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.DEPLOYMENT_ROOT);
    final VirtualFile deploymentFile = deploymentRoot.getRoot();
    EarMetaData earMetaData = handleSpecMetadata(deploymentFile, SpecDescriptorPropertyReplacement.propertyReplacer(deploymentUnit));
    JBossAppMetaData jbossMetaData = handleJbossMetadata(deploymentFile, JBossDescriptorPropertyReplacement.propertyReplacer(deploymentUnit), deploymentUnit);
    if (earMetaData == null && jbossMetaData == null) {
        return;
    }
    // the jboss-app.xml has a distinct-name configured then attach it to the deployment unit
    if (jbossMetaData != null && jbossMetaData.getDistinctName() != null) {
        deploymentUnit.putAttachment(Attachments.DISTINCT_NAME, jbossMetaData.getDistinctName());
    }
    JBossAppMetaData merged;
    if (earMetaData != null) {
        merged = new JBossAppMetaData(earMetaData.getEarVersion());
    } else {
        merged = new JBossAppMetaData();
    }
    JBossAppMetaDataMerger.merge(merged, jbossMetaData, earMetaData);
    deploymentUnit.putAttachment(Attachments.EAR_METADATA, merged);
    if (merged.getEarEnvironmentRefsGroup() != null) {
        final DeploymentDescriptorEnvironment bindings = new DeploymentDescriptorEnvironment("java:app/env/", merged.getEarEnvironmentRefsGroup());
        deploymentUnit.putAttachment(org.jboss.as.ee.component.Attachments.MODULE_DEPLOYMENT_DESCRIPTOR_ENVIRONMENT, bindings);
    }
}
Also used : VirtualFile(org.jboss.vfs.VirtualFile) ResourceRoot(org.jboss.as.server.deployment.module.ResourceRoot) JBossAppMetaData(org.jboss.metadata.ear.jboss.JBossAppMetaData) DeploymentDescriptorEnvironment(org.jboss.as.ee.component.DeploymentDescriptorEnvironment) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit) EarMetaData(org.jboss.metadata.ear.spec.EarMetaData)

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