use of org.apache.openejb.assembler.classic.AppInfo in project tomee by apache.
the class EarModuleNamesTest method testDefaultIdWebapp.
@Test
public void testDefaultIdWebapp() throws Exception {
final File appsDir = Files.tmpdir();
final Assembler assembler = new Assembler();
final ConfigurationFactory factory = new ConfigurationFactory();
final File ear = new File(appsDir, "testDefaultIdWebapp.ear");
final Map<String, Object> contents = new HashMap<String, Object>();
contents.put("testDefaultIdWebapp.war", Archives.jarArchive(Orange.class));
Archives.jarArchive(ear, contents);
final AppInfo appInfo = factory.configureApplication(ear);
assertEquals(appInfo.ejbJars.size(), 1);
assertEquals("testDefaultIdWebapp", appInfo.webApps.get(0).moduleId);
}
use of org.apache.openejb.assembler.classic.AppInfo in project tomee by apache.
the class OpenEjbContainer method doClose.
private synchronized void doClose() {
if (instance == null) {
return;
}
if (serviceManager != null) {
serviceManager.stop();
}
try {
globalJndiContext.close();
} catch (final NamingException e) {
throw new IllegalStateException(e);
}
final Assembler assembler = SystemInstance.get().getComponent(Assembler.class);
if (assembler != null) {
for (final AppInfo info : assembler.getDeployedApplications()) {
try {
assembler.destroyApplication(info);
} catch (final UndeployException e) {
logger().error(e.getMessage(), e);
}
}
}
if (webBeanContext != null) {
try {
stopContexts(webBeanContext.getContextsService(), servletContext, session);
} catch (final Exception e) {
logger().warning("can't stop all CDI contexts", e);
}
}
logger().info("Destroying OpenEJB container");
OpenEJB.destroy();
instance = null;
}
use of org.apache.openejb.assembler.classic.AppInfo in project tomee by apache.
the class QuartzMdbContainerTest method test.
public void test() throws Exception {
System.setProperty(javax.naming.Context.INITIAL_CONTEXT_FACTORY, InitContextFactory.class.getName());
final ConfigurationFactory config = new ConfigurationFactory();
final Assembler assembler = new Assembler();
assembler.createTransactionManager(config.configureService(TransactionServiceInfo.class));
assembler.createSecurityService(config.configureService(SecurityServiceInfo.class));
// Setup the descriptor information
CronBean.lifecycle.clear();
final AppModule app = new AppModule(this.getClass().getClassLoader(), "testapp");
final Connector connector = new Connector("email-ra");
final ResourceAdapter adapter = new ResourceAdapter(QuartzResourceAdapter.class);
connector.setResourceAdapter(adapter);
final InboundResourceadapter inbound = adapter.setInboundResourceAdapter(new InboundResourceadapter());
final MessageAdapter messageAdapter = inbound.setMessageAdapter(new MessageAdapter());
final MessageListener listener = messageAdapter.addMessageListener(new MessageListener(Job.class, JobSpec.class));
listener.getActivationSpec().addRequiredConfigProperty("cronExpression");
app.getConnectorModules().add(new ConnectorModule(connector));
final EjbJar ejbJar = new EjbJar();
ejbJar.addEnterpriseBean(new MessageDrivenBean(CronBean.class));
app.getEjbModules().add(new EjbModule(ejbJar));
final AppInfo appInfo = config.configureApplication(app);
assembler.createApplication(appInfo);
assertTrue(CronBean.latch.await(5, TimeUnit.SECONDS));
final Stack<Lifecycle> lifecycle = CronBean.lifecycle;
final List expected = Arrays.asList(Lifecycle.values());
Assert.assertEquals(expected.get(0), lifecycle.get(0));
Assert.assertEquals(expected.get(1), lifecycle.get(1));
}
use of org.apache.openejb.assembler.classic.AppInfo in project tomee by apache.
the class DependsOnTest method testNoStartUp.
public void testNoStartUp() throws Exception {
System.setProperty(javax.naming.Context.INITIAL_CONTEXT_FACTORY, InitContextFactory.class.getName());
final Assembler assembler = new Assembler();
final ConfigurationFactory config = new ConfigurationFactory();
assembler.createProxyFactory(config.configureService(ProxyFactoryInfo.class));
assembler.createTransactionManager(config.configureService(TransactionServiceInfo.class));
assembler.createSecurityService(config.configureService(SecurityServiceInfo.class));
// containers
assembler.createContainer(config.configureService(SingletonSessionContainerInfo.class));
actualConstruct.clear();
final EjbJar ejbJar = new EjbJar();
ejbJar.addEnterpriseBean(new SingletonBean(Two.class)).setInitOnStartup(false);
ejbJar.addEnterpriseBean(new SingletonBean(One.class));
ejbJar.addEnterpriseBean(new SingletonBean(Four.class)).setInitOnStartup(false);
ejbJar.addEnterpriseBean(new SingletonBean(Three.class)).setInitOnStartup(false);
// startup and trigger @PostConstruct
assembler.createApplication(config.configureApplication(ejbJar));
assertEquals(expected(four, three, two, one), actualConstruct);
actualDestroy.clear();
// startup and trigger @PreDestroy
for (final AppInfo appInfo : assembler.getDeployedApplications()) {
assembler.destroyApplication(appInfo.path);
}
assertEquals(expected(one, two, three, four), actualDestroy);
}
use of org.apache.openejb.assembler.classic.AppInfo in project tomee by apache.
the class DependsOnTest method test.
public void test() throws Exception {
System.setProperty(javax.naming.Context.INITIAL_CONTEXT_FACTORY, InitContextFactory.class.getName());
final Assembler assembler = new Assembler();
final ConfigurationFactory config = new ConfigurationFactory();
assembler.createProxyFactory(config.configureService(ProxyFactoryInfo.class));
assembler.createTransactionManager(config.configureService(TransactionServiceInfo.class));
assembler.createSecurityService(config.configureService(SecurityServiceInfo.class));
// containers
assembler.createContainer(config.configureService(SingletonSessionContainerInfo.class));
final StatelessSessionContainerInfo statelessContainer = config.configureService(StatelessSessionContainerInfo.class);
statelessContainer.properties.setProperty("MinSize", "1");
statelessContainer.properties.setProperty("MaxSize", "1");
assembler.createContainer(statelessContainer);
actualConstruct.clear();
final EjbJar ejbJar = new EjbJar();
ejbJar.addEnterpriseBean(new StatelessBean(Two.class));
ejbJar.addEnterpriseBean(new SingletonBean(One.class));
ejbJar.addEnterpriseBean(new SingletonBean(Four.class));
ejbJar.addEnterpriseBean(new StatelessBean(Three.class));
// startup and trigger @PostConstruct
assembler.createApplication(config.configureApplication(ejbJar));
assertEquals(expected(four, three, two, one), actualConstruct);
actualDestroy.clear();
// startup and trigger @PreDestroy
for (final AppInfo appInfo : assembler.getDeployedApplications()) {
assembler.destroyApplication(appInfo.path);
}
assertEquals(expected(one, two, three, four), actualDestroy);
}
Aggregations