Search in sources :

Example 16 with AssemblyDescriptor$JAXB.readAssemblyDescriptor

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

the class SecondStatelessInterceptedTest method module.

@Module
public EjbJar module() {
    final EjbJar ejbJar = new EjbJar();
    final StatelessBean bean = ejbJar.addEnterpriseBean(new StatelessBean(SecondStatelessInterceptedBean.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 17 with AssemblyDescriptor$JAXB.readAssemblyDescriptor

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

the class CheckAssemblyBindings method checkUnusedInterceptors.

private void checkUnusedInterceptors(final EjbModule ejbModule) {
    final AssemblyDescriptor assembly = ejbModule.getEjbJar().getAssemblyDescriptor();
    final Interceptor[] interceptorsArray = ejbModule.getEjbJar().getInterceptors();
    final List<Interceptor> interceptors = Arrays.asList(interceptorsArray);
    final Set<String> interceptorClassNames = new HashSet<String>(interceptors.size());
    for (final Interceptor interceptor : interceptors) {
        interceptorClassNames.add(interceptor.getInterceptorClass());
    }
    final Set<String> interceptorClassNamesUsedInBindings = new HashSet<String>();
    for (final InterceptorBinding binding : assembly.getInterceptorBinding()) {
        final List<String> interceptorClass = binding.getInterceptorClass();
        interceptorClassNamesUsedInBindings.addAll(interceptorClass);
    }
    final Set<String> unusedInterceptors = new HashSet<String>();
    for (final String clazz : interceptorClassNames) {
        if (!interceptorClassNamesUsedInBindings.contains(clazz)) {
            unusedInterceptors.add(clazz);
        }
    }
    for (final String clazz : unusedInterceptors) {
        warn("Interceptors", "interceptor.unused", clazz);
    }
}
Also used : InterceptorBinding(org.apache.openejb.jee.InterceptorBinding) AssemblyDescriptor(org.apache.openejb.jee.AssemblyDescriptor) Interceptor(org.apache.openejb.jee.Interceptor) HashSet(java.util.HashSet)

Aggregations

AssemblyDescriptor (org.apache.openejb.jee.AssemblyDescriptor)15 InterceptorBinding (org.apache.openejb.jee.InterceptorBinding)12 EjbJar (org.apache.openejb.jee.EjbJar)11 Interceptor (org.apache.openejb.jee.Interceptor)11 StatelessBean (org.apache.openejb.jee.StatelessBean)7 EnterpriseBean (org.apache.openejb.jee.EnterpriseBean)6 NamedMethod (org.apache.openejb.jee.NamedMethod)4 ArrayList (java.util.ArrayList)3 Assembler (org.apache.openejb.assembler.classic.Assembler)3 SecurityServiceInfo (org.apache.openejb.assembler.classic.SecurityServiceInfo)3 TransactionServiceInfo (org.apache.openejb.assembler.classic.TransactionServiceInfo)3 ConfigurationFactory (org.apache.openejb.config.ConfigurationFactory)3 EjbModule (org.apache.openejb.config.EjbModule)3 ContainerTransaction (org.apache.openejb.jee.ContainerTransaction)3 Method (org.apache.openejb.jee.Method)3 MethodPermission (org.apache.openejb.jee.MethodPermission)3 StatefulBean (org.apache.openejb.jee.StatefulBean)3 EjbDeployment (org.apache.openejb.jee.oejb3.EjbDeployment)3 OpenejbJar (org.apache.openejb.jee.oejb3.OpenejbJar)3 Module (org.apache.openejb.testing.Module)3