Search in sources :

Example 1 with EjbReferenceInfo

use of org.apache.openejb.assembler.classic.EjbReferenceInfo in project tomee by apache.

the class TomcatJndiBuilder method mergeJndi.

public void mergeJndi() throws OpenEJBException {
    final NamingResourcesImpl naming = standardContext.getNamingResources();
    final URI moduleUri = URLs.uri(webAppInfo.moduleId);
    for (final EnvEntryInfo ref : webAppInfo.jndiEnc.envEntries) {
        mergeRef(naming, ref);
    }
    for (final EjbReferenceInfo ref : webAppInfo.jndiEnc.ejbReferences) {
        mergeRef(naming, ref);
    }
    for (final EjbLocalReferenceInfo ref : webAppInfo.jndiEnc.ejbLocalReferences) {
        mergeRef(naming, ref);
    }
    for (final PersistenceContextReferenceInfo ref : webAppInfo.jndiEnc.persistenceContextRefs) {
        mergeRef(naming, ref, moduleUri);
    }
    for (final PersistenceUnitReferenceInfo ref : webAppInfo.jndiEnc.persistenceUnitRefs) {
        mergeRef(naming, ref, moduleUri);
    }
    for (final ResourceReferenceInfo ref : webAppInfo.jndiEnc.resourceRefs) {
        mergeRef(naming, ref);
    }
    for (final ResourceEnvReferenceInfo ref : webAppInfo.jndiEnc.resourceEnvRefs) {
        mergeRef(naming, ref);
    }
    for (final ServiceReferenceInfo ref : webAppInfo.jndiEnc.serviceRefs) {
        mergeRef(naming, ref);
    }
    final ContextTransaction contextTransaction = new ContextTransaction();
    contextTransaction.setProperty(Constants.FACTORY, UserTransactionFactory.class.getName());
    naming.setTransaction(contextTransaction);
}
Also used : ResourceReferenceInfo(org.apache.openejb.assembler.classic.ResourceReferenceInfo) PersistenceContextReferenceInfo(org.apache.openejb.assembler.classic.PersistenceContextReferenceInfo) EjbReferenceInfo(org.apache.openejb.assembler.classic.EjbReferenceInfo) UserTransactionFactory(org.apache.tomee.common.UserTransactionFactory) NamingResourcesImpl(org.apache.catalina.deploy.NamingResourcesImpl) EnvEntryInfo(org.apache.openejb.assembler.classic.EnvEntryInfo) EjbLocalReferenceInfo(org.apache.openejb.assembler.classic.EjbLocalReferenceInfo) ResourceEnvReferenceInfo(org.apache.openejb.assembler.classic.ResourceEnvReferenceInfo) ContextTransaction(org.apache.tomcat.util.descriptor.web.ContextTransaction) URI(java.net.URI) ServiceReferenceInfo(org.apache.openejb.assembler.classic.ServiceReferenceInfo) PersistenceUnitReferenceInfo(org.apache.openejb.assembler.classic.PersistenceUnitReferenceInfo)

Example 2 with EjbReferenceInfo

use of org.apache.openejb.assembler.classic.EjbReferenceInfo in project tomee by apache.

the class JndiEncInfoBuilder method buildEjbRefs.

private void buildEjbRefs(final JndiConsumer jndiConsumer, final URI moduleUri, final String moduleId, final String ejbName, final JndiEncInfo moduleJndiEnc, final JndiEncInfo compJndiEnc) throws OpenEJBException {
    final Collection<EjbRef> ejbRefs = jndiConsumer.getEjbRef();
    final Collection<EjbLocalRef> ejbLocalRefs = jndiConsumer.getEjbLocalRef();
    final List<EjbReference> references = new ArrayList<EjbReference>(ejbRefs.size() + ejbLocalRefs.size());
    references.addAll(ejbRefs);
    references.addAll(ejbLocalRefs);
    for (final EjbReference ref : references) {
        final EjbReferenceInfo info = new EjbReferenceInfo();
        info.homeClassName = ref.getHome();
        info.interfaceClassName = ref.getInterface();
        info.referenceName = ref.getName();
        info.link = ref.getEjbLink();
        info.location = buildLocationInfo(ref);
        info.targets.addAll(buildInjectionInfos(ref));
        info.localbean = isIntefaceLocalBean(info.interfaceClassName);
        if (info.location != null) {
            if (ref.getRefType() == EjbReference.Type.LOCAL) {
                insert(toLocal(info), appInfo.globalJndiEnc.ejbLocalReferences, appInfo.appJndiEnc.ejbLocalReferences, moduleJndiEnc.ejbLocalReferences, compJndiEnc.ejbLocalReferences);
            } else {
                insert(info, appInfo.globalJndiEnc.ejbReferences, appInfo.appJndiEnc.ejbReferences, moduleJndiEnc.ejbReferences, compJndiEnc.ejbReferences);
            }
            continue;
        }
        final EjbResolver ejbResolver = getEjbResolver(moduleId);
        final String deploymentId = ejbResolver.resolve(new Ref(ref), moduleUri);
        info.ejbDeploymentId = deploymentId;
        if (info.ejbDeploymentId == null) {
            if (info.link != null) {
                logger.warning("config.noBeanFoundEjbLink", ref.getName(), ejbName, ref.getEjbLink());
            } else {
                logger.warning("config.noBeanFound", ref.getName(), ejbName, ref.getEjbLink());
            }
        } else {
            final EjbResolver.Scope scope = ejbResolver.getScope(deploymentId);
            info.externalReference = scope != EAR && scope != EJBJAR;
            if (ref.getRefType() == EjbReference.Type.UNKNOWN) {
                final EnterpriseBeanInfo otherBean = ejbResolver.getEnterpriseBeanInfo(deploymentId);
                if (otherBean != null) {
                    if (otherBean.businessLocal.contains(ref.getInterface()) || otherBean.ejbClass.equals(ref.getInterface())) {
                        ref.setRefType(EjbReference.Type.LOCAL);
                        ejbRefs.remove(ref);
                        ejbLocalRefs.add(new EjbLocalRef(ref));
                    } else {
                        ref.setRefType(EjbReference.Type.REMOTE);
                    }
                }
            }
        }
        if (ref.getRefType() == EjbReference.Type.LOCAL) {
            insert(toLocal(info), appInfo.globalJndiEnc.ejbLocalReferences, appInfo.appJndiEnc.ejbLocalReferences, moduleJndiEnc.ejbLocalReferences, compJndiEnc.ejbLocalReferences);
        } else {
            insert(info, appInfo.globalJndiEnc.ejbReferences, appInfo.appJndiEnc.ejbReferences, moduleJndiEnc.ejbReferences, compJndiEnc.ejbReferences);
        }
    }
}
Also used : EjbLocalRef(org.apache.openejb.jee.EjbLocalRef) EjbResolver(org.apache.openejb.assembler.classic.EjbResolver) EjbReferenceInfo(org.apache.openejb.assembler.classic.EjbReferenceInfo) ArrayList(java.util.ArrayList) EjbReference(org.apache.openejb.jee.EjbReference) EnterpriseBeanInfo(org.apache.openejb.assembler.classic.EnterpriseBeanInfo) ServiceRef(org.apache.openejb.jee.ServiceRef) ResourceEnvRef(org.apache.openejb.jee.ResourceEnvRef) MessageDestinationRef(org.apache.openejb.jee.MessageDestinationRef) PersistenceUnitRef(org.apache.openejb.jee.PersistenceUnitRef) EjbRef(org.apache.openejb.jee.EjbRef) PersistenceContextRef(org.apache.openejb.jee.PersistenceContextRef) ResourceRef(org.apache.openejb.jee.ResourceRef) EjbLocalRef(org.apache.openejb.jee.EjbLocalRef) PortComponentRef(org.apache.openejb.jee.PortComponentRef) EjbRef(org.apache.openejb.jee.EjbRef)

Aggregations

EjbReferenceInfo (org.apache.openejb.assembler.classic.EjbReferenceInfo)2 URI (java.net.URI)1 ArrayList (java.util.ArrayList)1 NamingResourcesImpl (org.apache.catalina.deploy.NamingResourcesImpl)1 EjbLocalReferenceInfo (org.apache.openejb.assembler.classic.EjbLocalReferenceInfo)1 EjbResolver (org.apache.openejb.assembler.classic.EjbResolver)1 EnterpriseBeanInfo (org.apache.openejb.assembler.classic.EnterpriseBeanInfo)1 EnvEntryInfo (org.apache.openejb.assembler.classic.EnvEntryInfo)1 PersistenceContextReferenceInfo (org.apache.openejb.assembler.classic.PersistenceContextReferenceInfo)1 PersistenceUnitReferenceInfo (org.apache.openejb.assembler.classic.PersistenceUnitReferenceInfo)1 ResourceEnvReferenceInfo (org.apache.openejb.assembler.classic.ResourceEnvReferenceInfo)1 ResourceReferenceInfo (org.apache.openejb.assembler.classic.ResourceReferenceInfo)1 ServiceReferenceInfo (org.apache.openejb.assembler.classic.ServiceReferenceInfo)1 EjbLocalRef (org.apache.openejb.jee.EjbLocalRef)1 EjbRef (org.apache.openejb.jee.EjbRef)1 EjbReference (org.apache.openejb.jee.EjbReference)1 MessageDestinationRef (org.apache.openejb.jee.MessageDestinationRef)1 PersistenceContextRef (org.apache.openejb.jee.PersistenceContextRef)1 PersistenceUnitRef (org.apache.openejb.jee.PersistenceUnitRef)1 PortComponentRef (org.apache.openejb.jee.PortComponentRef)1