Search in sources :

Example 6 with EjbJar$JAXB

use of org.apache.openejb.jee.EjbJar$JAXB 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 7 with EjbJar$JAXB

use of org.apache.openejb.jee.EjbJar$JAXB 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 8 with EjbJar$JAXB

use of org.apache.openejb.jee.EjbJar$JAXB in project tomee by apache.

the class DebuggableVmHackery method deploy.

public AppModule deploy(final AppModule appModule) throws OpenEJBException {
    for (final EjbModule ejbModule : appModule.getEjbModules()) {
        final EjbJar ejbJar = ejbModule.getEjbJar();
        final OpenejbJar openejbJar = ejbModule.getOpenejbJar();
        final Map<String, EjbDeployment> deployments = openejbJar.getDeploymentsByEjbName();
        ejbJar.setRelationships(null);
        final List<String> removed = new ArrayList<String>();
        for (final EnterpriseBean bean : ejbJar.getEnterpriseBeans()) {
            final String ejbName = bean.getEjbName();
            final EjbDeployment ejbDeployment = deployments.get(ejbName);
            pruneRefs(bean, ejbDeployment);
            //                }
            if (!(bean instanceof MessageDrivenBean) && !(bean instanceof EntityBean)) {
                continue;
            }
            ejbJar.removeEnterpriseBean(ejbName);
            openejbJar.removeEjbDeployment(ejbDeployment);
            removed.add(ejbName);
            final AssemblyDescriptor assemblyDescriptor = ejbJar.getAssemblyDescriptor();
            if (assemblyDescriptor != null) {
                for (final MethodPermission permission : copy(assemblyDescriptor.getMethodPermission())) {
                    for (final Method method : copy(permission.getMethod())) {
                        if (method.getEjbName().equals(ejbName)) {
                            permission.getMethod().remove(method);
                        }
                    }
                    if (permission.getMethod().size() == 0) {
                        assemblyDescriptor.getMethodPermission().remove(permission);
                    }
                }
                for (final ContainerTransaction transaction : copy(assemblyDescriptor.getContainerTransaction())) {
                    for (final Method method : copy(transaction.getMethod())) {
                        if (method.getEjbName().equals(ejbName)) {
                            transaction.getMethod().remove(method);
                        }
                    }
                    if (transaction.getMethod().size() == 0) {
                        assemblyDescriptor.getContainerTransaction().remove(transaction);
                    }
                }
                for (final InterceptorBinding binding : copy(assemblyDescriptor.getInterceptorBinding())) {
                    if (binding.getEjbName().equals(ejbName)) {
                        assemblyDescriptor.getInterceptorBinding().remove(binding);
                    }
                }
            }
        }
        // Drop any ejb ref to with an ejb-link to a removed ejb
        for (final EnterpriseBean bean : ejbJar.getEnterpriseBeans()) {
            bean.getEjbLocalRefMap().keySet().removeAll(removed);
            bean.getEjbRefMap().keySet().removeAll(removed);
        }
        for (final Interceptor interceptor : ejbJar.getInterceptors()) {
            pruneRefs(interceptor, new EjbDeployment());
        }
    }
    return appModule;
}
Also used : EnterpriseBean(org.apache.openejb.jee.EnterpriseBean) ArrayList(java.util.ArrayList) Method(org.apache.openejb.jee.Method) MethodPermission(org.apache.openejb.jee.MethodPermission) InterceptorBinding(org.apache.openejb.jee.InterceptorBinding) OpenejbJar(org.apache.openejb.jee.oejb3.OpenejbJar) MessageDrivenBean(org.apache.openejb.jee.MessageDrivenBean) ContainerTransaction(org.apache.openejb.jee.ContainerTransaction) EntityBean(org.apache.openejb.jee.EntityBean) EjbDeployment(org.apache.openejb.jee.oejb3.EjbDeployment) AssemblyDescriptor(org.apache.openejb.jee.AssemblyDescriptor) Interceptor(org.apache.openejb.jee.Interceptor) EjbJar(org.apache.openejb.jee.EjbJar)

Example 9 with EjbJar$JAXB

use of org.apache.openejb.jee.EjbJar$JAXB in project tomee by apache.

the class DeploymentLoader method fillEjbJar.

/**
     * If the web.xml is metadata-complete and there is no ejb-jar.xml
     * then per specification we use the web.xml metadata-complete setting
     * to imply the same for EJBs.
     *
     * @param webModule WebModule
     * @param ejbModule EjbModule
     */
private static void fillEjbJar(final WebModule webModule, final EjbModule ejbModule) {
    final Object o = webModule.getAltDDs().get("ejb-jar.xml");
    if (o != null) {
        return;
    }
    if (ejbModule.getEjbJar() != null) {
        return;
    }
    final EjbJar ejbJar = new EjbJar();
    final WebApp webApp = webModule.getWebApp();
    ejbJar.setMetadataComplete(webApp.isMetadataComplete());
    ejbModule.setEjbJar(ejbJar);
}
Also used : EjbJar(org.apache.openejb.jee.EjbJar) WebApp(org.apache.openejb.jee.WebApp)

Example 10 with EjbJar$JAXB

use of org.apache.openejb.jee.EjbJar$JAXB in project tomee by apache.

the class DeploymentLoader method addBeansXmls.

private void addBeansXmls(final AppModule appModule) {
    final List<URL> urls = appModule.getAdditionalLibraries();
    final URLClassLoader loader = new URLClassLoader(urls.toArray(new URL[urls.size()]));
    final ArrayList<URL> xmls;
    try {
        xmls = Collections.list(loader.getResources("META-INF/beans.xml"));
    } catch (final IOException e) {
        return;
    }
    final CompositeBeans complete = new CompositeBeans();
    for (final URL url : xmls) {
        if (url == null) {
            continue;
        }
        mergeBeansXml(complete, url);
    }
    if (complete.getDiscoveryByUrl().isEmpty()) {
        return;
    }
    complete.removeDuplicates();
    ensureContainerUrls();
    appModule.getScannableContainerUrls().addAll(containerUrls);
    IAnnotationFinder finder;
    try {
        finder = FinderFactory.createFinder(appModule);
    } catch (final Exception e) {
        finder = new FinderFactory.ModuleLimitedFinder(new FinderFactory.OpenEJBAnnotationFinder(new WebappAggregatedArchive(appModule.getClassLoader(), appModule.getAltDDs(), xmls)));
    }
    appModule.setEarLibFinder(finder);
    final EjbModule ejbModule = new EjbModule(appModule.getClassLoader(), EAR_SCOPED_CDI_BEANS + appModule.getModuleId(), new EjbJar(), new OpenejbJar());
    ejbModule.setBeans(complete);
    ejbModule.setFinder(finder);
    ejbModule.setEjbJar(new EmptyEjbJar());
    appModule.getEjbModules().add(ejbModule);
}
Also used : CompositeBeans(org.apache.openejb.cdi.CompositeBeans) IAnnotationFinder(org.apache.xbean.finder.IAnnotationFinder) IOException(java.io.IOException) URL(java.net.URL) OpenEJBException(org.apache.openejb.OpenEJBException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException) OpenejbJar(org.apache.openejb.jee.oejb3.OpenejbJar) URLClassLoader(java.net.URLClassLoader) EjbJar(org.apache.openejb.jee.EjbJar)

Aggregations

EjbJar (org.apache.openejb.jee.EjbJar)233 StatelessBean (org.apache.openejb.jee.StatelessBean)113 Assembler (org.apache.openejb.assembler.classic.Assembler)90 EjbModule (org.apache.openejb.config.EjbModule)78 ConfigurationFactory (org.apache.openejb.config.ConfigurationFactory)75 SecurityServiceInfo (org.apache.openejb.assembler.classic.SecurityServiceInfo)64 TransactionServiceInfo (org.apache.openejb.assembler.classic.TransactionServiceInfo)64 Properties (java.util.Properties)48 OpenejbJar (org.apache.openejb.jee.oejb3.OpenejbJar)47 InitialContext (javax.naming.InitialContext)42 SingletonBean (org.apache.openejb.jee.SingletonBean)42 AppModule (org.apache.openejb.config.AppModule)39 StatefulBean (org.apache.openejb.jee.StatefulBean)33 ProxyFactoryInfo (org.apache.openejb.assembler.classic.ProxyFactoryInfo)31 EjbDeployment (org.apache.openejb.jee.oejb3.EjbDeployment)27 EjbJarInfo (org.apache.openejb.assembler.classic.EjbJarInfo)26 Module (org.apache.openejb.testing.Module)26 LocalInitialContextFactory (org.apache.openejb.core.LocalInitialContextFactory)25 InitContextFactory (org.apache.openejb.core.ivm.naming.InitContextFactory)23 EnterpriseBean (org.apache.openejb.jee.EnterpriseBean)19