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));
}
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);
}
}
}
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));
}
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));
}
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());
}
Aggregations