Search in sources :

Example 51 with EjbDeployment

use of org.apache.openejb.jee.oejb3.EjbDeployment in project tomee by apache.

the class Container method addCallersAsEjbModule.

private static void addCallersAsEjbModule(final ClassLoader loader, final AppModule app, final String... additionalCallers) {
    final Set<String> callers = new HashSet<>(NewLoaderLogic.callers(Filters.classes(Container.class.getName(), "org.apache.openejb.maven.plugins.TomEEEmbeddedMojo")));
    // we don't care of these
    callers.remove("org.apache.tomee.embedded.Container");
    callers.remove("org.apache.tomee.gradle.embedded.TomEEEmbeddedTask");
    final Iterator<String> callerIt = callers.iterator();
    while (callerIt.hasNext()) {
        // TomEEEmbeddedMojo is also used with some anonymous classes (TomEEEmbeddedMojo$x)
        if (callerIt.next().startsWith("org.apache.openejb.maven.plugins.TomEEEmbeddedMojo")) {
            callerIt.remove();
        // no break since we remove anonymous class+the mojo itself
        }
    }
    if (additionalCallers != null && additionalCallers.length > 0) {
        callers.addAll(asList(additionalCallers));
    }
    if (callers.isEmpty()) {
        return;
    }
    final EjbJar ejbJar = new EjbJar();
    final OpenejbJar openejbJar = new OpenejbJar();
    for (final String caller : callers) {
        try {
            if (!AnnotationDeployer.isInstantiable(loader.loadClass(caller))) {
                continue;
            }
        } catch (final ClassNotFoundException e) {
            continue;
        }
        final String name = caller.replace("$", "_");
        final ManagedBean bean = ejbJar.addEnterpriseBean(new ManagedBean(caller.replace("$", "_"), caller, true));
        bean.localBean();
        bean.setTransactionType(TransactionType.BEAN);
        final EjbDeployment ejbDeployment = openejbJar.addEjbDeployment(bean);
        ejbDeployment.setDeploymentId(name);
    }
    final EjbModule ejbModule = new EjbModule(ejbJar, openejbJar);
    ejbModule.setBeans(new Beans());
    app.getEjbModules().add(ejbModule);
}
Also used : Beans(org.apache.openejb.jee.Beans) OpenejbJar(org.apache.openejb.jee.oejb3.OpenejbJar) EjbModule(org.apache.openejb.config.EjbModule) EjbDeployment(org.apache.openejb.jee.oejb3.EjbDeployment) ManagedBean(org.apache.openejb.jee.ManagedBean) HashSet(java.util.HashSet) EjbJar(org.apache.openejb.jee.EjbJar)

Aggregations

EjbDeployment (org.apache.openejb.jee.oejb3.EjbDeployment)47 OpenejbJar (org.apache.openejb.jee.oejb3.OpenejbJar)36 EjbJar (org.apache.openejb.jee.EjbJar)27 EnterpriseBean (org.apache.openejb.jee.EnterpriseBean)16 EjbModule (org.apache.openejb.config.EjbModule)15 Properties (java.util.Properties)14 OpenEJBException (org.apache.openejb.OpenEJBException)10 ResourceLink (org.apache.openejb.jee.oejb3.ResourceLink)9 Assembler (org.apache.openejb.assembler.classic.Assembler)8 StatelessBean (org.apache.openejb.jee.StatelessBean)8 HashMap (java.util.HashMap)7 EjbJarInfo (org.apache.openejb.assembler.classic.EjbJarInfo)7 InitialContext (javax.naming.InitialContext)6 ConfigurationFactory (org.apache.openejb.config.ConfigurationFactory)6 ManagedBean (org.apache.openejb.jee.ManagedBean)6 MessageDrivenBean (org.apache.openejb.jee.MessageDrivenBean)6 SessionBean (org.apache.openejb.jee.SessionBean)6 Map (java.util.Map)5 SingletonBean (org.apache.openejb.jee.SingletonBean)5 ContainerSystem (org.apache.openejb.spi.ContainerSystem)5