use of org.apache.openejb.spi.ContainerSystem in project tomee by apache.
the class ClassLoaderCommand method execute.
@Override
public void execute(final String cmd) {
final String appName = extractAppName(cmd);
final ContainerSystem cs = SystemInstance.get().getComponent(ContainerSystem.class);
for (AppContext ctx : cs.getAppContexts()) {
if (appName.equalsIgnoreCase(ctx.getId())) {
dumpClassLoader(ctx.getClassLoader());
return;
}
}
streamManager.writeErr("can't find app " + appName);
streamManager.writeErr("available apps are:");
for (AppContext ctx : cs.getAppContexts()) {
streamManager.writeErr("- " + ctx.getId());
}
}
use of org.apache.openejb.spi.ContainerSystem in project tomee by apache.
the class TestObserver method beanContext.
private BeanContext beanContext() {
final TestClass tc = testClass.get();
if (tc == null) {
return null;
}
final String className = tc.getName();
final ContainerSystem containerSystem = SystemInstance.get().getComponent(ContainerSystem.class);
for (final AppContext app : containerSystem.getAppContexts()) {
final BeanContext context = containerSystem.getBeanContext(app.getId() + "_" + className);
if (context != null) {
return context;
}
}
return null;
}
use of org.apache.openejb.spi.ContainerSystem in project tomee by apache.
the class ModulePropertiesTest method testOverrideAdd.
public void testOverrideAdd() throws Exception {
final ConfigurationFactory config = new ConfigurationFactory();
final Assembler assembler = new Assembler();
{
// setup the system
assembler.createTransactionManager(config.configureService(TransactionServiceInfo.class));
assembler.createSecurityService(config.configureService(SecurityServiceInfo.class));
}
{
SystemInstance.get().getProperties().put("fooModule.color", "orange");
final Map<String, String> map = new HashMap<String, String>();
map.put("META-INF/ejb-jar.xml", "<ejb-jar id=\"fooModule\"/>");
final File module = Archives.fileArchive(map, WidgetBean.class);
final AppModule appModule = config.loadApplication(this.getClass().getClassLoader(), "fooApp", Arrays.asList(module));
final AppInfo appInfo = config.configureApplication(appModule);
assembler.createApplication(appInfo);
}
final ContainerSystem containerSystem = SystemInstance.get().getComponent(ContainerSystem.class);
assertContexts(containerSystem);
}
use of org.apache.openejb.spi.ContainerSystem in project tomee by apache.
the class ModulePropertiesTest method testFile.
public void testFile() throws Exception {
final ConfigurationFactory config = new ConfigurationFactory();
final Assembler assembler = new Assembler();
{
// setup the system
assembler.createTransactionManager(config.configureService(TransactionServiceInfo.class));
assembler.createSecurityService(config.configureService(SecurityServiceInfo.class));
}
{
final Map<String, String> map = new HashMap<String, String>();
map.put("META-INF/module.properties", "color=orange");
final File app = Archives.fileArchive(map, WidgetBean.class);
assembler.createApplication(config.configureApplication(app));
}
final ContainerSystem containerSystem = SystemInstance.get().getComponent(ContainerSystem.class);
assertContexts(containerSystem);
}
use of org.apache.openejb.spi.ContainerSystem in project tomee by apache.
the class UberInterfaceTest 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.createTransactionManager(config.configureService(TransactionServiceInfo.class));
assembler.createSecurityService(config.configureService(SecurityServiceInfo.class));
final EjbJar ejbJar = new EjbJar();
final StatelessBean bean = ejbJar.addEnterpriseBean(new StatelessBean(SuperBean.class));
final EjbJarInfo ejbJarInfo = config.configureApplication(ejbJar);
final EnterpriseBeanInfo beanInfo = ejbJarInfo.enterpriseBeans.get(0);
assertEquals(asList(Everything.class.getName()), beanInfo.businessLocal);
assertEquals(asList(Everything.class.getName()), beanInfo.businessRemote);
assertEquals(Everything.class.getName(), beanInfo.serviceEndpoint);
assembler.createApplication(ejbJarInfo);
final ContainerSystem containerSystem = SystemInstance.get().getComponent(ContainerSystem.class);
final BeanContext deployment = containerSystem.getBeanContext(beanInfo.ejbDeploymentId);
assertEquals(asList(Everything.class), deployment.getBusinessLocalInterfaces());
assertEquals(asList(Everything.class), deployment.getBusinessRemoteInterfaces());
assertEquals(Everything.class, deployment.getServiceEndpointInterface());
final InitialContext context = new InitialContext();
final Everything local = (Everything) context.lookup("SuperBeanLocal");
final Everything remote = (Everything) context.lookup("SuperBeanRemote");
final Reference reference = new Reference("test");
assertEquals(reference, local.echo(reference));
// pass by reference
assertSame(reference, local.echo(reference));
assertEquals(reference, remote.echo(reference));
// pass by value
assertNotSame(reference, remote.echo(reference));
}
Aggregations