use of org.apache.openejb.assembler.classic.StatelessSessionContainerInfo in project tomee by apache.
the class ConfigureServiceTest method testConfigureServiceAddedProperty.
public void testConfigureServiceAddedProperty() throws Exception {
final ConfigurationFactory factory = new ConfigurationFactory();
final Container container = new Container("MyContainer", "STATELESS", "org.acme#CheddarContainer");
container.getProperties().setProperty("anotherProperty", "Cheese is good");
final StatelessSessionContainerInfo myStatelessContainer = factory.configureService(container, StatelessSessionContainerInfo.class);
assertNotNull(myStatelessContainer);
assertEquals("MyContainer", myStatelessContainer.id);
assertEquals("org.acme.SuperContainer", myStatelessContainer.className);
assertNotNull(myStatelessContainer.constructorArgs);
assertNotNull(myStatelessContainer.properties);
assertNotNull(myStatelessContainer.properties.getProperty("myProperty"));
assertEquals("Yummy Cheese", myStatelessContainer.properties.getProperty("myProperty"));
assertNotNull(myStatelessContainer.properties.getProperty("anotherProperty"));
assertEquals("Cheese is good", myStatelessContainer.properties.getProperty("anotherProperty"));
}
use of org.apache.openejb.assembler.classic.StatelessSessionContainerInfo in project tomee by apache.
the class ConfigureServiceTest method testConfigureServiceOverriddenProperty.
public void testConfigureServiceOverriddenProperty() throws Exception {
final ConfigurationFactory factory = new ConfigurationFactory();
final Container container = new Container("MyContainer", "STATELESS", "org.acme#CheddarContainer");
container.getProperties().setProperty("myProperty", "Cheese is good");
final StatelessSessionContainerInfo myStatelessContainer = factory.configureService(container, StatelessSessionContainerInfo.class);
assertNotNull(myStatelessContainer);
assertEquals("MyContainer", myStatelessContainer.id);
assertEquals("org.acme.SuperContainer", myStatelessContainer.className);
assertNotNull(myStatelessContainer.constructorArgs);
assertNotNull(myStatelessContainer.properties);
assertNotNull(myStatelessContainer.properties.getProperty("myProperty"));
assertEquals("Cheese is good", myStatelessContainer.properties.getProperty("myProperty"));
}
use of org.apache.openejb.assembler.classic.StatelessSessionContainerInfo in project tomee by apache.
the class FullPoolFailoverTest method setup.
protected void setup(final int statelessPoolSize, final int connectionPoolSize) throws Exception {
Properties initProps = new Properties();
initProps.setProperty("openejb.deployments.classpath.include", "");
initProps.setProperty("openejb.deployments.classpath.filter.descriptors", "true");
OpenEJB.init(initProps, new ServerFederation());
System.setProperty(org.apache.openejb.client.SocketConnectionFactory.PROPERTY_POOL_SIZE, "" + connectionPoolSize);
EjbServer ejbServer = new EjbServer();
ejbServer.init(new Properties());
daemons.add(createServiceDaemon(connectionPoolSize, ejbServer, red));
daemons.add(createServiceDaemon(connectionPoolSize, ejbServer, blue));
final ConfigurationFactory config = new ConfigurationFactory();
final Assembler assembler = SystemInstance.get().getComponent(Assembler.class);
// containers
StatelessSessionContainerInfo statelessContainerInfo = config.configureService(StatelessSessionContainerInfo.class);
statelessContainerInfo.properties.setProperty("TimeOut", "100");
statelessContainerInfo.properties.setProperty("PoolSize", "" + statelessPoolSize);
statelessContainerInfo.properties.setProperty("MinSize", "2");
statelessContainerInfo.properties.setProperty("StrictPooling", "true");
assembler.createContainer(statelessContainerInfo);
// Setup the descriptor information
StatelessBean bean = new StatelessBean(CounterBean.class);
bean.addBusinessLocal(Counter.class.getName());
bean.addBusinessRemote(RemoteCounter.class.getName());
bean.addPostConstruct("init");
bean.addPreDestroy("destroy");
EjbJar ejbJar = new EjbJar();
ejbJar.addEnterpriseBean(bean);
CounterBean.instances.set(0);
assembler.createApplication(config.configureApplication(ejbJar));
String failoverURI = "failover:sticky:";
failoverURI += "ejbd://127.0.0.1:" + daemons.get(0).getPort() + "?red,";
failoverURI += "ejbd://127.0.0.1:" + daemons.get(1).getPort() + "?blue";
Properties props = new Properties();
props.put("java.naming.factory.initial", "org.apache.openejb.client.RemoteInitialContextFactory");
props.put("java.naming.provider.url", failoverURI);
Context context = new InitialContext(props);
counter = (Counter) context.lookup("CounterBeanRemote");
hold.clear();
hits.clear();
}
Aggregations