Search in sources :

Example 91 with EjbModule

use of org.apache.openejb.config.EjbModule 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

EjbModule (org.apache.openejb.config.EjbModule)91 EjbJar (org.apache.openejb.jee.EjbJar)81 AppModule (org.apache.openejb.config.AppModule)41 StatelessBean (org.apache.openejb.jee.StatelessBean)37 ConfigurationFactory (org.apache.openejb.config.ConfigurationFactory)30 OpenejbJar (org.apache.openejb.jee.oejb3.OpenejbJar)29 Assembler (org.apache.openejb.assembler.classic.Assembler)27 Properties (java.util.Properties)24 SingletonBean (org.apache.openejb.jee.SingletonBean)21 InitialContext (javax.naming.InitialContext)20 Module (org.apache.openejb.testing.Module)18 EjbDeployment (org.apache.openejb.jee.oejb3.EjbDeployment)15 SecurityServiceInfo (org.apache.openejb.assembler.classic.SecurityServiceInfo)13 TransactionServiceInfo (org.apache.openejb.assembler.classic.TransactionServiceInfo)13 Beans (org.apache.openejb.jee.Beans)12 AppInfo (org.apache.openejb.assembler.classic.AppInfo)11 InitContextFactory (org.apache.openejb.core.ivm.naming.InitContextFactory)10 ContainerSystem (org.apache.openejb.spi.ContainerSystem)10 ArrayList (java.util.ArrayList)9 EnterpriseBean (org.apache.openejb.jee.EnterpriseBean)9