Search in sources :

Example 1 with EnterpriseBean

use of org.apache.openejb.jee.EnterpriseBean in project tomee by apache.

the class AnnotationDeployerTest method interceptingGenericBusinessMethodCalls.

/**
     * For https://issues.apache.org/jira/browse/OPENEJB-1128
     */
@Test
public void interceptingGenericBusinessMethodCalls() throws Exception {
    EjbModule ejbModule = testModule();
    final EjbJar ejbJar = ejbModule.getEjbJar();
    final AnnotationDeployer.DiscoverAnnotatedBeans discvrAnnBeans = new AnnotationDeployer.DiscoverAnnotatedBeans();
    ejbModule = discvrAnnBeans.deploy(ejbModule);
    final EnterpriseBean bean = ejbJar.getEnterpriseBean("InterceptedSLSBean");
    assert bean != null;
}
Also used : EnterpriseBean(org.apache.openejb.jee.EnterpriseBean) EjbJar(org.apache.openejb.jee.EjbJar) Test(org.junit.Test)

Example 2 with EnterpriseBean

use of org.apache.openejb.jee.EnterpriseBean in project tomee by apache.

the class AnnotationDeployerTest method testLocalBean.

/**
     * For https://issues.apache.org/jira/browse/OPENEJB-1188
     *
     * @throws Exception
     */
@Test
public void testLocalBean() throws Exception {
    final EjbModule ejbModule = testModule();
    final EjbJar ejbJar = ejbModule.getEjbJar();
    AppModule appModule = new AppModule(Thread.currentThread().getContextClassLoader(), "myapp");
    appModule.getEjbModules().add(ejbModule);
    final AnnotationDeployer annotationDeployer = new AnnotationDeployer();
    appModule = annotationDeployer.deploy(appModule);
    EnterpriseBean bean = ejbJar.getEnterpriseBean("TestLocalBean");
    assert bean != null;
    assert (((SessionBean) bean).getLocalBean() != null);
    bean = ejbJar.getEnterpriseBean("InterceptedSLSBean");
    assert bean != null;
    assert (((SessionBean) bean).getLocalBean() == null);
}
Also used : EnterpriseBean(org.apache.openejb.jee.EnterpriseBean) SessionBean(org.apache.openejb.jee.SessionBean) EjbJar(org.apache.openejb.jee.EjbJar) Test(org.junit.Test)

Example 3 with EnterpriseBean

use of org.apache.openejb.jee.EnterpriseBean in project tomee by apache.

the class EnvEntriesPropertiesDeployer method deploy.

public AppModule deploy(final AppModule appModule) throws OpenEJBException {
    // ApplicationClient META-INF/env-entries.properties
    for (final ClientModule module : appModule.getClientModules()) {
        if (module.getApplicationClient() == null) {
            continue;
        }
        for (final Map.Entry<String, String> entry : getEnvEntries(module).entrySet()) {
            final EnvEntry envEntry = new EnvEntry(entry.getKey(), "java.lang.String", entry.getValue());
            apply(module.getApplicationClient(), envEntry, "AppClient");
        }
    }
    // WebModule META-INF/env-entries.properties
    for (final WebModule webModule : appModule.getWebModules()) {
        deploy(webModule);
    }
    // EjbJar META-INF/env-entries.properties
    for (final EjbModule module : appModule.getEjbModules()) {
        for (final Map.Entry<String, String> entry : getEnvEntries(module).entrySet()) {
            final EnvEntry envEntry = new EnvEntry(entry.getKey(), "java.lang.String", entry.getValue());
            // <ejb-name>.name = value
            if (envEntry.getName().contains(".")) {
                String name = envEntry.getName();
                final String ejbName = name.substring(0, name.indexOf('.'));
                name = name.substring(name.indexOf('.') + 1);
                final EnterpriseBean bean = module.getEjbJar().getEnterpriseBean(ejbName);
                if (bean != null) {
                    // Set the new property name without the <ejb-name>. prefix
                    envEntry.setName(name);
                    apply(bean, envEntry, bean.getEjbName());
                    continue;
                }
            }
            for (final EnterpriseBean bean : module.getEjbJar().getEnterpriseBeans()) {
                apply(bean, envEntry, bean.getEjbName());
            }
        }
    }
    return appModule;
}
Also used : EnterpriseBean(org.apache.openejb.jee.EnterpriseBean) HashMap(java.util.HashMap) Map(java.util.Map) EnvEntry(org.apache.openejb.jee.EnvEntry)

Example 4 with EnterpriseBean

use of org.apache.openejb.jee.EnterpriseBean in project tomee by apache.

the class GeronimoMappedName method mapReferences.

private void mapReferences(final EjbJar ejbJar) {
    if (ejbJar == null) {
        return;
    }
    for (final EnterpriseBean enterpriseBean : ejbJar.getEnterpriseBeans()) {
        for (final EjbRef ref : enterpriseBean.getEjbRef()) {
            // remap only corba references
            final String mappedName = ref.getMappedName();
            if (mappedName != null && (mappedName.startsWith("jndi:corbaloc") || mappedName.startsWith("jndi:corbaname"))) {
                final String refName = ref.getEjbRefName();
                ref.setMappedName(MAPPED_NAME_PREFIX + refName);
            }
            if (null == mappedName && ref.getEjbRefName().equals("ejb/MEJB")) {
                ref.setMappedName("mejb/ejb/mgmt/MEJB");
            }
        }
        for (final MessageDestinationRef ref : enterpriseBean.getMessageDestinationRef()) {
            final String refName = ref.getMessageDestinationRefName();
            ref.setMappedName(MAPPED_NAME_PREFIX + refName);
        }
        for (final PersistenceContextRef ref : enterpriseBean.getPersistenceContextRef()) {
            final String refName = ref.getPersistenceContextRefName();
            ref.setMappedName(MAPPED_NAME_PREFIX + refName);
        }
        for (final PersistenceUnitRef ref : enterpriseBean.getPersistenceUnitRef()) {
            final String refName = ref.getPersistenceUnitRefName();
            ref.setMappedName(MAPPED_NAME_PREFIX + refName);
        }
        for (final ResourceRef ref : enterpriseBean.getResourceRef()) {
            final String refName = ref.getResRefName();
            ref.setMappedName(MAPPED_NAME_PREFIX + refName);
        }
        for (final ResourceEnvRef ref : enterpriseBean.getResourceEnvRef()) {
            final String refName = ref.getResourceEnvRefName();
            ref.setMappedName(MAPPED_NAME_PREFIX + refName);
        }
        for (final ServiceRef ref : enterpriseBean.getServiceRef()) {
            final String refName = ref.getServiceRefName();
            ref.setMappedName(MAPPED_NAME_PREFIX + refName);
        }
    }
}
Also used : MessageDestinationRef(org.apache.openejb.jee.MessageDestinationRef) EnterpriseBean(org.apache.openejb.jee.EnterpriseBean) EjbRef(org.apache.openejb.jee.EjbRef) PersistenceContextRef(org.apache.openejb.jee.PersistenceContextRef) ResourceRef(org.apache.openejb.jee.ResourceRef) ServiceRef(org.apache.openejb.jee.ServiceRef) PersistenceUnitRef(org.apache.openejb.jee.PersistenceUnitRef) ResourceEnvRef(org.apache.openejb.jee.ResourceEnvRef)

Example 5 with EnterpriseBean

use of org.apache.openejb.jee.EnterpriseBean in project tomee by apache.

the class InitEjbDeployments method deploy.

public synchronized AppModule deploy(final AppModule appModule) throws OpenEJBException {
    final Set<String> abstractSchemaNames = new HashSet<String>();
    for (final EjbModule ejbModule : appModule.getEjbModules()) {
        for (final EnterpriseBean bean : ejbModule.getEjbJar().getEnterpriseBeans()) {
            if (isCmpEntity(bean)) {
                final EntityBean entity = (EntityBean) bean;
                final String name = entity.getAbstractSchemaName();
                if (name != null) {
                    abstractSchemaNames.add(name);
                }
            }
        }
    }
    final Map<String, String> contextData = new HashMap<String, String>();
    contextData.put("appId", appModule.getModuleId());
    for (final EjbModule ejbModule : appModule.getEjbModules()) {
        contextData.put("host", ejbModule.isWebapp() ? findHost(ejbModule.getModuleId(), appModule.getWebModules()) : appModule.uniqueHostIfExists());
        contextData.put("hash", Integer.toString(ejbModule.hashCode()));
        contextData.put("ejbJarId", ejbModule.getModuleId());
        deploy(ejbModule, contextData, abstractSchemaNames);
    }
    contextData.clear();
    return appModule;
}
Also used : EnterpriseBean(org.apache.openejb.jee.EnterpriseBean) HashMap(java.util.HashMap) EntityBean(org.apache.openejb.jee.EntityBean) HashSet(java.util.HashSet)

Aggregations

EnterpriseBean (org.apache.openejb.jee.EnterpriseBean)46 EjbJar (org.apache.openejb.jee.EjbJar)19 EjbDeployment (org.apache.openejb.jee.oejb3.EjbDeployment)16 OpenejbJar (org.apache.openejb.jee.oejb3.OpenejbJar)14 SessionBean (org.apache.openejb.jee.SessionBean)12 ArrayList (java.util.ArrayList)9 EjbModule (org.apache.openejb.config.EjbModule)9 HashMap (java.util.HashMap)8 OpenEJBException (org.apache.openejb.OpenEJBException)7 MessageDrivenBean (org.apache.openejb.jee.MessageDrivenBean)7 Map (java.util.Map)6 AssemblyDescriptor (org.apache.openejb.jee.AssemblyDescriptor)6 Interceptor (org.apache.openejb.jee.Interceptor)6 List (java.util.List)5 Properties (java.util.Properties)5 EntityBean (org.apache.openejb.jee.EntityBean)5 InterceptorBinding (org.apache.openejb.jee.InterceptorBinding)5 ResourceLink (org.apache.openejb.jee.oejb3.ResourceLink)5 Resources (org.apache.openejb.config.sys.Resources)4 JndiConsumer (org.apache.openejb.jee.JndiConsumer)4