Search in sources :

Example 1 with Interceptor$JAXB.readInterceptor

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

the class EjbJarInfoBuilder method initInterceptors.

private void initInterceptors(final EjbModule jar, final EjbJarInfo ejbJar) throws OpenEJBException {
    if (jar.getEjbJar().getInterceptors().length == 0) {
        return;
    }
    if (jar.getEjbJar().getAssemblyDescriptor() == null) {
        return;
    }
    if (jar.getEjbJar().getAssemblyDescriptor().getInterceptorBinding() == null) {
        return;
    }
    for (final Interceptor s : jar.getEjbJar().getInterceptors()) {
        final InterceptorInfo info = new InterceptorInfo();
        info.clazz = s.getInterceptorClass();
        copyCallbacks(s.getAroundInvoke(), info.aroundInvoke);
        copyCallbacks(s.getPostConstruct(), info.postConstruct);
        copyCallbacks(s.getPreDestroy(), info.preDestroy);
        copyCallbacks(s.getPostActivate(), info.postActivate);
        copyCallbacks(s.getPrePassivate(), info.prePassivate);
        copyCallbacks(s.getAfterBegin(), info.afterBegin);
        copyCallbacks(s.getBeforeCompletion(), info.beforeCompletion);
        copyCallbacks(s.getAfterCompletion(), info.afterCompletion);
        copyCallbacks(s.getAroundTimeout(), info.aroundTimeout);
        ejbJar.interceptors.add(info);
    }
    for (final InterceptorBinding binding : jar.getEjbJar().getAssemblyDescriptor().getInterceptorBinding()) {
        final InterceptorBindingInfo info = new InterceptorBindingInfo();
        info.ejbName = binding.getEjbName();
        info.excludeClassInterceptors = binding.getExcludeClassInterceptors();
        info.excludeDefaultInterceptors = binding.getExcludeDefaultInterceptors();
        info.interceptors.addAll(binding.getInterceptorClass());
        if (binding.getInterceptorOrder() != null) {
            info.interceptorOrder.addAll(binding.getInterceptorOrder().getInterceptorClass());
        }
        info.method = toInfo(binding.getMethod());
        info.className = binding.getClassName();
        ejbJar.interceptorBindings.add(info);
    }
}
Also used : InterceptorBinding(org.apache.openejb.jee.InterceptorBinding) InterceptorBindingInfo(org.apache.openejb.assembler.classic.InterceptorBindingInfo) InterceptorInfo(org.apache.openejb.assembler.classic.InterceptorInfo) Interceptor(org.apache.openejb.jee.Interceptor)

Example 2 with Interceptor$JAXB.readInterceptor

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

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

the class FullyInterceptedTest method module.

@Module
public EjbJar module() {
    final EjbJar ejbJar = new EjbJar();
    final StatelessBean bean = ejbJar.addEnterpriseBean(new StatelessBean(FullyInterceptedBean.class));
    final AssemblyDescriptor assembly = ejbJar.getAssemblyDescriptor();
    assembly.addInterceptorBinding(new InterceptorBinding("*", new Interceptor(DefaultInterceptorOne.class)));
    assembly.addInterceptorBinding(new InterceptorBinding("*", new Interceptor(DefaultInterceptorTwo.class)));
    final InterceptorBinding b = assembly.addInterceptorBinding(new InterceptorBinding(bean));
    b.setExcludeDefaultInterceptors(true);
    b.setMethod(new NamedMethod("methodWithDefaultInterceptorsExcluded"));
    return ejbJar;
}
Also used : InterceptorBinding(org.apache.openejb.jee.InterceptorBinding) StatelessBean(org.apache.openejb.jee.StatelessBean) AssemblyDescriptor(org.apache.openejb.jee.AssemblyDescriptor) NamedMethod(org.apache.openejb.jee.NamedMethod) Interceptor(org.apache.openejb.jee.Interceptor) EjbJar(org.apache.openejb.jee.EjbJar) Module(org.apache.openejb.testing.Module)

Example 4 with Interceptor$JAXB.readInterceptor

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

the class MethodLevelInterceptorOnlyTest method module.

@Module
public EjbJar module() {
    final EjbJar ejbJar = new EjbJar();
    final StatelessBean bean = ejbJar.addEnterpriseBean(new StatelessBean(MethodLevelInterceptorOnlySLSBean.class));
    final AssemblyDescriptor assembly = ejbJar.getAssemblyDescriptor();
    assembly.addInterceptorBinding(new InterceptorBinding("*", new Interceptor(DefaultInterceptorOne.class)));
    assembly.addInterceptorBinding(new InterceptorBinding("*", new Interceptor(DefaultInterceptorTwo.class)));
    assembly.addInterceptorBinding(new InterceptorBinding(bean)).setExcludeDefaultInterceptors(true);
    return ejbJar;
}
Also used : InterceptorBinding(org.apache.openejb.jee.InterceptorBinding) StatelessBean(org.apache.openejb.jee.StatelessBean) AssemblyDescriptor(org.apache.openejb.jee.AssemblyDescriptor) Interceptor(org.apache.openejb.jee.Interceptor) EjbJar(org.apache.openejb.jee.EjbJar) Module(org.apache.openejb.testing.Module)

Example 5 with Interceptor$JAXB.readInterceptor

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

the class ThirdSLSBeanTest method module.

@Module
public EjbJar module() {
    final EjbJar ejbJar = new EjbJar();
    final StatelessBean bean = ejbJar.addEnterpriseBean(new StatelessBean(ThirdSLSBean.class));
    final AssemblyDescriptor assembly = ejbJar.getAssemblyDescriptor();
    assembly.addInterceptorBinding(new InterceptorBinding("*", new Interceptor(DefaultInterceptorOne.class)));
    assembly.addInterceptorBinding(new InterceptorBinding("*", new Interceptor(DefaultInterceptorTwo.class)));
    return ejbJar;
}
Also used : InterceptorBinding(org.apache.openejb.jee.InterceptorBinding) StatelessBean(org.apache.openejb.jee.StatelessBean) AssemblyDescriptor(org.apache.openejb.jee.AssemblyDescriptor) Interceptor(org.apache.openejb.jee.Interceptor) EjbJar(org.apache.openejb.jee.EjbJar) Module(org.apache.openejb.testing.Module)

Aggregations

Interceptor (org.apache.openejb.jee.Interceptor)20 EjbJar (org.apache.openejb.jee.EjbJar)16 InterceptorBinding (org.apache.openejb.jee.InterceptorBinding)15 AssemblyDescriptor (org.apache.openejb.jee.AssemblyDescriptor)11 StatelessBean (org.apache.openejb.jee.StatelessBean)10 EnterpriseBean (org.apache.openejb.jee.EnterpriseBean)6 NamedMethod (org.apache.openejb.jee.NamedMethod)5 ArrayList (java.util.ArrayList)3 Module (org.apache.openejb.testing.Module)3 InitialContext (javax.naming.InitialContext)2 Assembler (org.apache.openejb.assembler.classic.Assembler)2 EjbJarInfo (org.apache.openejb.assembler.classic.EjbJarInfo)2 ProxyFactoryInfo (org.apache.openejb.assembler.classic.ProxyFactoryInfo)2 SecurityServiceInfo (org.apache.openejb.assembler.classic.SecurityServiceInfo)2 TransactionServiceInfo (org.apache.openejb.assembler.classic.TransactionServiceInfo)2 ConfigurationFactory (org.apache.openejb.config.ConfigurationFactory)2 EjbModule (org.apache.openejb.config.EjbModule)2 LocalInitialContextFactory (org.apache.openejb.core.LocalInitialContextFactory)2 ContainerTransaction (org.apache.openejb.jee.ContainerTransaction)2 Interceptor$JAXB.readInterceptor (org.apache.openejb.jee.Interceptor$JAXB.readInterceptor)2