use of org.apache.openejb.config.sys.Container in project tomee by apache.
the class ConfigureServiceTest method testConfigureServiceAddedPropertyViaURI2.
public void testConfigureServiceAddedPropertyViaURI2() throws Exception {
final ConfigurationFactory factory = new ConfigurationFactory();
final URI uri = new URI("new://Container?type=STATELESS&provider=org.acme%23CheddarContainer&myProperty=Queso");
final Container container = (Container) factory.toConfigDeclaration("MyContainer", uri);
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("Queso", myStatelessContainer.properties.getProperty("myProperty"));
assertNotNull(myStatelessContainer.properties.getProperty("anotherProperty"));
assertEquals("Cheese is good", myStatelessContainer.properties.getProperty("anotherProperty"));
}
use of org.apache.openejb.config.sys.Container in project tomee by apache.
the class ConfigureServiceTest method testConfigureServiceAddedPropertyViaURI_Unencoded.
public void testConfigureServiceAddedPropertyViaURI_Unencoded() throws Exception {
final ConfigurationFactory factory = new ConfigurationFactory();
final Container container = (Container) factory.toConfigDeclaration("MyContainer", "new://Container?type=STATELESS&provider=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.config.sys.Container in project tomee by apache.
the class ConfigureServiceTest method testConfigureService.
public void testConfigureService() throws Exception {
final ConfigurationFactory factory = new ConfigurationFactory();
// We should be able to create a default definition
final StatelessSessionContainerInfo defaultStatelessContainer = factory.configureService(StatelessSessionContainerInfo.class);
assertNotNull(defaultStatelessContainer);
assertNotNull(defaultStatelessContainer.id);
assertNotNull(defaultStatelessContainer.className);
assertNotNull(defaultStatelessContainer.constructorArgs);
assertNotNull(defaultStatelessContainer.properties);
// We should be able to create one of these with a different name
final Container container = new Container("My Stateless Container");
final StatelessSessionContainerInfo myStatelessContainer = factory.configureService(container, StatelessSessionContainerInfo.class);
assertNotNull(myStatelessContainer);
assertEquals("My Stateless Container", myStatelessContainer.id);
assertEquals(defaultStatelessContainer.className, myStatelessContainer.className);
assertNotNull(myStatelessContainer.constructorArgs);
assertNotNull(myStatelessContainer.properties);
}
use of org.apache.openejb.config.sys.Container in project tomee by apache.
the class AutoConfig method processApplicationContainers.
private void processApplicationContainers(final AppModule module, final AppResources appResources) throws OpenEJBException {
if (module.getContainers().isEmpty()) {
return;
}
final String prefix = module.getModuleId() + "/";
for (final Container container : module.getContainers()) {
if (container.getId() == null) {
throw new IllegalStateException("a container can't get a null id: " + container.getType() + " from " + module.getModuleId());
}
if (!container.getId().startsWith(prefix)) {
container.setId(prefix + container.getId());
}
final ContainerInfo containerInfo = configFactory.createContainerInfo(container);
configFactory.install(containerInfo);
appResources.addContainer(containerInfo);
}
}
use of org.apache.openejb.config.sys.Container in project tomee by apache.
the class AppInfoBuilder method buildAppResources.
private void buildAppResources(final AppModule module, final AppInfo info) {
for (final Resource def : module.getResources()) {
// so we skip the undeployement skipping the id
if (!def.getProperties().containsKey("ApplicationWide")) {
info.resourceIds.add(def.getId());
info.resourceAliases.addAll(def.getAliases());
}
}
for (final Container def : module.getContainers()) {
if (!def.getProperties().containsKey("ApplicationWide")) {
info.containerIds.add(def.getId());
}
}
}
Aggregations