Search in sources :

Example 1 with StatefulSessionContainerInfo

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

the class StatefulTransactionLockingTest method setUp.

@Override
protected void setUp() throws Exception {
    System.setProperty(javax.naming.Context.INITIAL_CONTEXT_FACTORY, LocalInitialContextFactory.class.getName());
    final ConfigurationFactory config = new ConfigurationFactory();
    final Assembler assembler = new Assembler();
    assembler.createTransactionManager(config.configureService(TransactionServiceInfo.class));
    assembler.createSecurityService(config.configureService(SecurityServiceInfo.class));
    final StatefulSessionContainerInfo statefulContainerInfo = config.configureService(StatefulSessionContainerInfo.class);
    statefulContainerInfo.properties.setProperty("AccessTimeout", "0 milliseconds");
    // containers
    assembler.createContainer(statefulContainerInfo);
    // Setup the descriptor information
    final EjbJar ejbJar = new EjbJar();
    ejbJar.addEnterpriseBean(new StatelessBean(BlueStatelessBean.class));
    ejbJar.addEnterpriseBean(new StatefulBean(RedStatefulBean.class));
    ejbJar.addEnterpriseBean(new StatefulBean(LegacyStatefulBean.class));
    assembler.createApplication(config.configureApplication(ejbJar));
}
Also used : StatefulSessionContainerInfo(org.apache.openejb.assembler.classic.StatefulSessionContainerInfo) TransactionServiceInfo(org.apache.openejb.assembler.classic.TransactionServiceInfo) StatelessBean(org.apache.openejb.jee.StatelessBean) StatefulBean(org.apache.openejb.jee.StatefulBean) ConfigurationFactory(org.apache.openejb.config.ConfigurationFactory) Assembler(org.apache.openejb.assembler.classic.Assembler) LocalInitialContextFactory(org.apache.openejb.core.LocalInitialContextFactory) SecurityServiceInfo(org.apache.openejb.assembler.classic.SecurityServiceInfo) EjbJar(org.apache.openejb.jee.EjbJar)

Example 2 with StatefulSessionContainerInfo

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

the class StatefulContainerTest method setUp.

protected void setUp() throws Exception {
    super.setUp();
    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));
    // 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);
    // Setup the descriptor information
    final EjbJar ejbJar = new EjbJar();
    ejbJar.addEnterpriseBean(new StatefulBean(WidgetBean.class));
    assembler.createApplication(config.configureApplication(ejbJar));
    WidgetBean.lifecycle.clear();
    expectedLifecycle = Arrays.asList(Lifecycle.values());
    inTxExpectedLifecycle = new ArrayList<Lifecycle>();
    for (final Lifecycle lifecycle : Lifecycle.values()) {
        if (!lifecycle.name().startsWith("PRE_PASSIVATE") && !lifecycle.name().startsWith("POST_ACTIVATE")) {
            inTxExpectedLifecycle.add(lifecycle);
        }
    }
}
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) ConfigurationFactory(org.apache.openejb.config.ConfigurationFactory) Assembler(org.apache.openejb.assembler.classic.Assembler) LocalInitialContextFactory(org.apache.openejb.core.LocalInitialContextFactory) SecurityServiceInfo(org.apache.openejb.assembler.classic.SecurityServiceInfo) EjbJar(org.apache.openejb.jee.EjbJar)

Example 3 with StatefulSessionContainerInfo

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

the class StatefulConcurrencyTest method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    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(1000);
    timeout1.setUnit(TimeUnit.MILLISECONDS);
    final ConcurrentMethod method1 = new ConcurrentMethod();
    method1.setMethod(new NamedMethod("*"));
    method1.setAccessTimeout(timeout1);
    bean1.getConcurrentMethod().add(method1);
    final StatefulBean bean2 = new StatefulBean("BeanNegative", MyLocalBeanImpl.class);
    final Timeout timeout2 = new Timeout();
    timeout2.setTimeout(-1);
    timeout2.setUnit(TimeUnit.MILLISECONDS);
    final ConcurrentMethod method2 = new ConcurrentMethod();
    method2.setMethod(new NamedMethod("*"));
    method2.setAccessTimeout(timeout2);
    bean2.getConcurrentMethod().add(method2);
    ejbJar.addEnterpriseBean(bean1);
    ejbJar.addEnterpriseBean(bean2);
    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)

Example 4 with StatefulSessionContainerInfo

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

the class StatefulTimeoutTest method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    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);
    statefulContainerInfo.properties.setProperty("BulkPassivate", "1");
    // clear cache every 3 seconds
    statefulContainerInfo.properties.setProperty("Frequency", "3");
    assembler.createContainer(statefulContainerInfo);
    final EjbJar ejbJar = new EjbJar();
    Timeout timeout;
    final StatefulBean bean1 = new StatefulBean("BeanNegative", MyLocalBeanImpl.class);
    timeout = new Timeout();
    timeout.setTimeout(-1);
    timeout.setUnit(TimeUnit.SECONDS);
    bean1.setStatefulTimeout(timeout);
    final StatefulBean bean0 = new StatefulBean("BeanZero", MyLocalBeanImpl.class);
    timeout = new Timeout();
    timeout.setTimeout(0);
    timeout.setUnit(TimeUnit.SECONDS);
    bean0.setStatefulTimeout(timeout);
    final StatefulBean bean5 = new StatefulBean("Bean", MyLocalBeanImpl.class);
    timeout = new Timeout();
    timeout.setTimeout(5);
    timeout.setUnit(TimeUnit.SECONDS);
    bean5.setStatefulTimeout(timeout);
    ejbJar.addEnterpriseBean(bean1);
    ejbJar.addEnterpriseBean(bean0);
    ejbJar.addEnterpriseBean(bean5);
    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) Timeout(org.apache.openejb.jee.Timeout) StatefulBean(org.apache.openejb.jee.StatefulBean) ConfigurationFactory(org.apache.openejb.config.ConfigurationFactory) Assembler(org.apache.openejb.assembler.classic.Assembler) LocalInitialContextFactory(org.apache.openejb.core.LocalInitialContextFactory) SecurityServiceInfo(org.apache.openejb.assembler.classic.SecurityServiceInfo) EjbJar(org.apache.openejb.jee.EjbJar)

Example 5 with StatefulSessionContainerInfo

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

the class StatefulSessionBeanTest method test.

public void test() 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));
    // 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);
    assembler.createApplication(config.configureApplication(buildTestApp()));
    StatefulSessionBeanTest.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) 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) LocalInitialContextFactory(org.apache.openejb.core.LocalInitialContextFactory) SecurityServiceInfo(org.apache.openejb.assembler.classic.SecurityServiceInfo) InitialContext(javax.naming.InitialContext)

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