Search in sources :

Example 6 with InterceptorBinding

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

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

use of org.apache.openejb.jee.InterceptorBinding 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)

Example 9 with InterceptorBinding

use of org.apache.openejb.jee.InterceptorBinding in project tomee by apache.

the class CheckInvalidInterceptorTest method test.

@Keys({ @Key(value = "interceptor.callback.badReturnType", count = 2), @Key(value = "interceptor.callback.invalidArguments", count = 2), @Key(value = "aroundInvoke.badReturnType", count = 2), @Key(value = "aroundInvoke.invalidArguments", count = 2), @Key("interceptor.callback.missing"), @Key("aroundInvoke.missing"), @Key("interceptorBinding.noSuchEjbName"), @Key("interceptorBinding.ejbNameRequiredWithMethod"), @Key("interceptor.callback.missing.possibleTypo") })
public EjbJar test() throws Exception {
    final EjbJar ejbJar = new EjbJar();
    ejbJar.addEnterpriseBean(new StatelessBean(FooBean.class));
    final Interceptor interceptor = ejbJar.addInterceptor(new org.apache.openejb.jee.Interceptor(CallbackMissingInterceptor.class));
    interceptor.addAroundInvoke("wrongMethod");
    interceptor.addPostConstruct("foo");
    interceptor.addPostConstruct("wrongMethod");
    final List<InterceptorBinding> interceptorBindings = ejbJar.getAssemblyDescriptor().getInterceptorBinding();
    final InterceptorBinding binding = new InterceptorBinding("wrongEjbName");
    // binding.setMethod(new NamedMethod("wrongMethod"));
    interceptorBindings.add(binding);
    final InterceptorBinding binding1 = new InterceptorBinding();
    binding1.setMethod(new NamedMethod("aMethod"));
    interceptorBindings.add(binding1);
    return ejbJar;
}
Also used : InterceptorBinding(org.apache.openejb.jee.InterceptorBinding) StatelessBean(org.apache.openejb.jee.StatelessBean) Interceptor(org.apache.openejb.jee.Interceptor) NamedMethod(org.apache.openejb.jee.NamedMethod) Interceptor(org.apache.openejb.jee.Interceptor) EjbJar(org.apache.openejb.jee.EjbJar)

Example 10 with InterceptorBinding

use of org.apache.openejb.jee.InterceptorBinding in project tomee by apache.

the class CheckInvalidInterceptorTest method test1.

@Keys({ @Key(value = "interceptor.unused", count = 2, type = KeyType.WARNING), @Key("aroundInvoke.invalidArguments") })
public EjbJar test1() {
    final EjbJar ejbJar = new EjbJar();
    ejbJar.addEnterpriseBean(new StatelessBean(BarBean.class));
    final Interceptor unused = ejbJar.addInterceptor(new org.apache.openejb.jee.Interceptor(UnusedInterceptor.class));
    final Interceptor unused1 = ejbJar.addInterceptor(new org.apache.openejb.jee.Interceptor(UnusedInterceptor1.class));
    final Interceptor used = ejbJar.addInterceptor(new org.apache.openejb.jee.Interceptor(UsedInterceptor.class));
    final List<InterceptorBinding> interceptorBindings = ejbJar.getAssemblyDescriptor().getInterceptorBinding();
    final InterceptorBinding binding = new InterceptorBinding("BarBean", used);
    interceptorBindings.add(binding);
    return ejbJar;
}
Also used : InterceptorBinding(org.apache.openejb.jee.InterceptorBinding) StatelessBean(org.apache.openejb.jee.StatelessBean) Interceptor(org.apache.openejb.jee.Interceptor) Interceptor(org.apache.openejb.jee.Interceptor) EjbJar(org.apache.openejb.jee.EjbJar)

Aggregations

InterceptorBinding (org.apache.openejb.jee.InterceptorBinding)17 Interceptor (org.apache.openejb.jee.Interceptor)15 EjbJar (org.apache.openejb.jee.EjbJar)14 AssemblyDescriptor (org.apache.openejb.jee.AssemblyDescriptor)12 StatelessBean (org.apache.openejb.jee.StatelessBean)9 EnterpriseBean (org.apache.openejb.jee.EnterpriseBean)5 NamedMethod (org.apache.openejb.jee.NamedMethod)5 ContainerTransaction (org.apache.openejb.jee.ContainerTransaction)4 ArrayList (java.util.ArrayList)3 ConfigurationFactory (org.apache.openejb.config.ConfigurationFactory)3 Method (org.apache.openejb.jee.Method)3 MethodPermission (org.apache.openejb.jee.MethodPermission)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 EjbModule (org.apache.openejb.config.EjbModule)2