Search in sources :

Example 41 with StatelessBean

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

Example 42 with StatelessBean

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

the class CheckInvalidSecurityAnnotationsTest method test.

@Keys({ @Key("conflictingSecurityAnnotations"), @Key("permitAllAndRolesAllowedOnClass") })
public EjbJar test() throws Exception {
    final EjbJar ejbJar = new EjbJar();
    ejbJar.addEnterpriseBean(new StatelessBean(FooBean.class));
    return ejbJar;
}
Also used : StatelessBean(org.apache.openejb.jee.StatelessBean) EjbJar(org.apache.openejb.jee.EjbJar)

Example 43 with StatelessBean

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

the class CheckInvalidTransactionAttributeTest method xml.

@Keys(@Key(value = "xml.invalidTransactionAttribute", type = KeyType.WARNING))
public EjbJar xml() throws SecurityException, NoSuchMethodException {
    final EjbJar ejbJar = new EjbJar();
    final StatelessBean bean = ejbJar.addEnterpriseBean(new StatelessBean(CheeseEjb.class));
    bean.setTransactionType(TransactionType.BEAN);
    final ContainerTransaction tx = new ContainerTransaction();
    tx.getMethod().add(new Method(bean.getEjbName(), CheeseEjb.class.getMethod("sayCheesePlease", null)));
    tx.setTransAttribute(TransAttribute.REQUIRED);
    ejbJar.getAssemblyDescriptor().getContainerTransaction().add(tx);
    return ejbJar;
}
Also used : StatelessBean(org.apache.openejb.jee.StatelessBean) ContainerTransaction(org.apache.openejb.jee.ContainerTransaction) Method(org.apache.openejb.jee.Method) EjbJar(org.apache.openejb.jee.EjbJar)

Example 44 with StatelessBean

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

the class BasicInjectionTest method app.

@Module
@Classes(cdi = true, value = { Configuration.class })
public StatelessBean app() throws Exception {
    final StatelessBean bean = new StatelessBean(WidgetBean.class);
    bean.setLocalBean(new Empty());
    return bean;
}
Also used : Empty(org.apache.openejb.jee.Empty) StatelessBean(org.apache.openejb.jee.StatelessBean) Module(org.apache.openejb.testing.Module) Classes(org.apache.openejb.testing.Classes)

Example 45 with StatelessBean

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

the class CdiDecoratorTest method setUp.

@Before
public void setUp() throws Exception {
    final ConfigurationFactory config = new ConfigurationFactory();
    final Assembler assembler = new Assembler();
    assembler.createProxyFactory(config.configureService(ProxyFactoryInfo.class));
    assembler.createTransactionManager(config.configureService(TransactionServiceInfo.class));
    assembler.createSecurityService(config.configureService(SecurityServiceInfo.class));
    assembler.createContainer(config.configureService(StatelessSessionContainerInfo.class));
    final EjbJar ejbJar = new EjbJar();
    ejbJar.addEnterpriseBean(new StatelessBean("HelloOne", RedBean.class));
    ejbJar.addEnterpriseBean(new StatelessBean("HelloTwo", RedBean.class));
    ejbJar.addEnterpriseBean(new StatelessBean(OrangeBean.class));
    final Beans beans = new Beans();
    beans.addInterceptor(OrangeCdiInterceptor.class);
    beans.addDecorator(OrangeOneDecorator.class);
    beans.addDecorator(OrangeTwoDecorator.class);
    beans.addManagedClass(YellowBean.class);
    final EjbModule module = new EjbModule(ejbJar);
    module.setBeans(beans);
    assembler.createApplication(config.configureApplication(module));
    final Properties properties = new Properties(System.getProperties());
    properties.setProperty(Context.INITIAL_CONTEXT_FACTORY, InitContextFactory.class.getName());
    ctx = new InitialContext(properties);
}
Also used : StatelessSessionContainerInfo(org.apache.openejb.assembler.classic.StatelessSessionContainerInfo) EjbModule(org.apache.openejb.config.EjbModule) InitContextFactory(org.apache.openejb.core.ivm.naming.InitContextFactory) Properties(java.util.Properties) InitialContext(javax.naming.InitialContext) ProxyFactoryInfo(org.apache.openejb.assembler.classic.ProxyFactoryInfo) Beans(org.apache.openejb.jee.Beans) TransactionServiceInfo(org.apache.openejb.assembler.classic.TransactionServiceInfo) StatelessBean(org.apache.openejb.jee.StatelessBean) ConfigurationFactory(org.apache.openejb.config.ConfigurationFactory) Assembler(org.apache.openejb.assembler.classic.Assembler) SecurityServiceInfo(org.apache.openejb.assembler.classic.SecurityServiceInfo) EjbJar(org.apache.openejb.jee.EjbJar) Before(org.junit.Before)

Aggregations

StatelessBean (org.apache.openejb.jee.StatelessBean)129 EjbJar (org.apache.openejb.jee.EjbJar)117 Assembler (org.apache.openejb.assembler.classic.Assembler)56 ConfigurationFactory (org.apache.openejb.config.ConfigurationFactory)44 EjbModule (org.apache.openejb.config.EjbModule)37 SecurityServiceInfo (org.apache.openejb.assembler.classic.SecurityServiceInfo)31 TransactionServiceInfo (org.apache.openejb.assembler.classic.TransactionServiceInfo)31 InitialContext (javax.naming.InitialContext)30 Properties (java.util.Properties)28 Module (org.apache.openejb.testing.Module)25 StatelessSessionContainerInfo (org.apache.openejb.assembler.classic.StatelessSessionContainerInfo)18 AppModule (org.apache.openejb.config.AppModule)18 OpenejbJar (org.apache.openejb.jee.oejb3.OpenejbJar)18 ProxyFactoryInfo (org.apache.openejb.assembler.classic.ProxyFactoryInfo)16 ServerFederation (org.apache.openejb.core.ServerFederation)15 Context (javax.naming.Context)14 Empty (org.apache.openejb.jee.Empty)13 ContainerSystem (org.apache.openejb.spi.ContainerSystem)13 LocalInitialContextFactory (org.apache.openejb.core.LocalInitialContextFactory)12 StatefulBean (org.apache.openejb.jee.StatefulBean)12