Search in sources :

Example 6 with StatefulSessionContainerInfo

use of org.apache.openejb.assembler.classic.StatefulSessionContainerInfo in project tomee by apache.

the class Compat3to2Test method test.

public void test() throws Exception {
    System.setProperty(javax.naming.Context.INITIAL_CONTEXT_FACTORY, InitContextFactory.class.getName());
    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));
    // containers
    final StatefulSessionContainerInfo statefulContainerInfo = config.configureService(StatefulSessionContainerInfo.class);
    statefulContainerInfo.properties.setProperty("PoolSize", "0");
    statefulContainerInfo.properties.setProperty("BulkPassivate", "1");
    statefulContainerInfo.properties.setProperty("Frequency", "0");
    assembler.createContainer(statefulContainerInfo);
    final EjbJar ejbJar = new EjbJar();
    final StatefulBean bean = ejbJar.addEnterpriseBean(new StatefulBean(TargetBean.class));
    bean.setHomeAndRemote(TargetHome.class, Target.class);
    assembler.createApplication(config.configureApplication(new EjbModule(getClass().getClassLoader(), getClass().getSimpleName(), "test", ejbJar, null)));
    calls.clear();
    final InitialContext ctx = new InitialContext();
    final TargetHome home = (TargetHome) ctx.lookup("TargetBeanRemoteHome");
    assertNotNull(home);
    final Target target = home.create("Fuzz");
    assertNotNull(target);
    final String name = target.getName();
    assertEquals("Fuzz", name);
    target.remove();
    assertCalls(Call.values());
}
Also used : StatefulSessionContainerInfo(org.apache.openejb.assembler.classic.StatefulSessionContainerInfo) StatefulBean(org.apache.openejb.jee.StatefulBean) EjbModule(org.apache.openejb.config.EjbModule) InitContextFactory(org.apache.openejb.core.ivm.naming.InitContextFactory) InitialContext(javax.naming.InitialContext) ProxyFactoryInfo(org.apache.openejb.assembler.classic.ProxyFactoryInfo) TransactionServiceInfo(org.apache.openejb.assembler.classic.TransactionServiceInfo) 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)

Example 7 with StatefulSessionContainerInfo

use of org.apache.openejb.assembler.classic.StatefulSessionContainerInfo in project tomee by apache.

the class StatefulConcurrentLookupTest method beforeClass.

@BeforeClass
public static synchronized void beforeClass() throws Exception {
    System.setProperty(javax.naming.Context.INITIAL_CONTEXT_FACTORY, LocalInitialContextFactory.class.getName());
    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));
    final StatefulSessionContainerInfo statefulContainerInfo = config.configureService(StatefulSessionContainerInfo.class);
    assembler.createContainer(statefulContainerInfo);
    final EjbJar ejbJar = new EjbJar();
    final StatefulBean bean1 = new StatefulBean(MyLocalBeanImpl.class);
    final Timeout timeout1 = new Timeout();
    timeout1.setTimeout(10);
    timeout1.setUnit(TimeUnit.SECONDS);
    final ConcurrentMethod method1 = new ConcurrentMethod();
    method1.setMethod(new NamedMethod("*"));
    method1.setAccessTimeout(timeout1);
    bean1.getConcurrentMethod().add(method1);
    ejbJar.addEnterpriseBean(bean1);
    assembler.createApplication(config.configureApplication(ejbJar));
}
Also used : StatefulSessionContainerInfo(org.apache.openejb.assembler.classic.StatefulSessionContainerInfo) ProxyFactoryInfo(org.apache.openejb.assembler.classic.ProxyFactoryInfo) TransactionServiceInfo(org.apache.openejb.assembler.classic.TransactionServiceInfo) StatefulBean(org.apache.openejb.jee.StatefulBean) Timeout(org.apache.openejb.jee.Timeout) ConfigurationFactory(org.apache.openejb.config.ConfigurationFactory) Assembler(org.apache.openejb.assembler.classic.Assembler) ConcurrentMethod(org.apache.openejb.jee.ConcurrentMethod) LocalInitialContextFactory(org.apache.openejb.core.LocalInitialContextFactory) NamedMethod(org.apache.openejb.jee.NamedMethod) SecurityServiceInfo(org.apache.openejb.assembler.classic.SecurityServiceInfo) EjbJar(org.apache.openejb.jee.EjbJar) BeforeClass(org.junit.BeforeClass)

Aggregations

Assembler (org.apache.openejb.assembler.classic.Assembler)7 SecurityServiceInfo (org.apache.openejb.assembler.classic.SecurityServiceInfo)7 StatefulSessionContainerInfo (org.apache.openejb.assembler.classic.StatefulSessionContainerInfo)7 TransactionServiceInfo (org.apache.openejb.assembler.classic.TransactionServiceInfo)7 ConfigurationFactory (org.apache.openejb.config.ConfigurationFactory)7 ProxyFactoryInfo (org.apache.openejb.assembler.classic.ProxyFactoryInfo)6 LocalInitialContextFactory (org.apache.openejb.core.LocalInitialContextFactory)6 EjbJar (org.apache.openejb.jee.EjbJar)6 StatefulBean (org.apache.openejb.jee.StatefulBean)6 Timeout (org.apache.openejb.jee.Timeout)3 InitialContext (javax.naming.InitialContext)2 ConcurrentMethod (org.apache.openejb.jee.ConcurrentMethod)2 NamedMethod (org.apache.openejb.jee.NamedMethod)2 EjbModule (org.apache.openejb.config.EjbModule)1 InitContextFactory (org.apache.openejb.core.ivm.naming.InitContextFactory)1 StatelessBean (org.apache.openejb.jee.StatelessBean)1 BeforeClass (org.junit.BeforeClass)1