Search in sources :

Example 1 with Container

use of org.apache.openejb.config.sys.Container in project tomee by apache.

the class ConfigurationFactory method getContainerIds.

protected List<String> getContainerIds() {
    final List<String> containerIds = new ArrayList<String>();
    final OpenEjbConfiguration runningConfig = getRunningConfig();
    if (runningConfig != null) {
        for (final ContainerInfo containerInfo : runningConfig.containerSystem.containers) {
            containerIds.add(containerInfo.id);
        }
    }
    if (sys != null) {
        for (final ContainerInfo containerInfo : sys.containerSystem.containers) {
            containerIds.add(containerInfo.id);
        }
        // the above sys instance
        if (openejb != null) {
            for (final Container container : openejb.getContainer()) {
                containerIds.add(container.getId());
            }
        }
    }
    return containerIds;
}
Also used : EJBContainer(javax.ejb.embeddable.EJBContainer) Container(org.apache.openejb.config.sys.Container) ArrayList(java.util.ArrayList) ManagedContainerInfo(org.apache.openejb.assembler.classic.ManagedContainerInfo) BmpEntityContainerInfo(org.apache.openejb.assembler.classic.BmpEntityContainerInfo) StatelessSessionContainerInfo(org.apache.openejb.assembler.classic.StatelessSessionContainerInfo) CmpEntityContainerInfo(org.apache.openejb.assembler.classic.CmpEntityContainerInfo) StatefulSessionContainerInfo(org.apache.openejb.assembler.classic.StatefulSessionContainerInfo) SingletonSessionContainerInfo(org.apache.openejb.assembler.classic.SingletonSessionContainerInfo) MdbContainerInfo(org.apache.openejb.assembler.classic.MdbContainerInfo) ContainerInfo(org.apache.openejb.assembler.classic.ContainerInfo) OpenEjbConfiguration(org.apache.openejb.assembler.classic.OpenEjbConfiguration)

Example 2 with Container

use of org.apache.openejb.config.sys.Container in project tomee by apache.

the class AppContainerTest method resources.

@org.apache.openejb.testing.Module
public Resources resources() {
    final Resources resources = new Resources();
    final Container container = new Container();
    container.setId("theMine");
    container.setType("SINGLETON");
    container.setClassName("org.apache.openejb.config.AppContainerTest$MySingletonContainer");
    resources.getContainer().add(container);
    return resources;
}
Also used : SingletonContainer(org.apache.openejb.core.singleton.SingletonContainer) Container(org.apache.openejb.config.sys.Container) Resources(org.apache.openejb.config.sys.Resources)

Example 3 with Container

use of org.apache.openejb.config.sys.Container in project tomee by apache.

the class AppInfoBuilderTest method testShouldCreateContainer.

public void testShouldCreateContainer() throws Exception {
    final EjbJar ejbJar = new EjbJar();
    final OpenejbJar openejbJar = new OpenejbJar();
    final EjbModule ejbModule = new EjbModule(ejbJar, openejbJar);
    final AppModule appModule = new AppModule(ejbModule);
    appModule.getContainers().add(new Container("my-container", "MESSAGE", null));
    final AppInfo appInfo = new AppInfoBuilder(new ConfigurationFactory()).build(appModule);
    assertEquals(1, appInfo.containers.size());
    final ContainerInfo containerInfo = appInfo.containers.get(0);
    assertEquals(appInfo.appId + "/my-container", containerInfo.id);
    assertEquals(1, containerInfo.types.size());
    assertEquals("MESSAGE", containerInfo.types.get(0));
    assertEquals(MdbContainerFactory.class.getName(), containerInfo.className);
    assertEquals("Default JMS Resource Adapter", containerInfo.properties.get("ResourceAdapter"));
    assertEquals(MessageListener.class.getName(), containerInfo.properties.get("MessageListenerInterface"));
    assertEquals(TomEEMessageActivationSpec.class.getName(), containerInfo.properties.get("ActivationSpecClass"));
    assertEquals("10", containerInfo.properties.get("InstanceLimit"));
    assertEquals("true", containerInfo.properties.get("FailOnUnknownActivationSpec"));
}
Also used : TomEEMessageActivationSpec(org.apache.openejb.resource.activemq.TomEEMessageActivationSpec) MdbContainer(org.apache.openejb.core.mdb.MdbContainer) Container(org.apache.openejb.config.sys.Container) OpenejbJar(org.apache.openejb.jee.oejb3.OpenejbJar) MdbContainerFactory(org.apache.openejb.core.mdb.MdbContainerFactory) ContainerInfo(org.apache.openejb.assembler.classic.ContainerInfo) MessageListener(javax.jms.MessageListener) EjbJar(org.apache.openejb.jee.EjbJar) AppInfo(org.apache.openejb.assembler.classic.AppInfo)

Example 4 with Container

use of org.apache.openejb.config.sys.Container in project tomee by apache.

the class ApplicationWideTest method testShouldCreateAResourceAndNotRemoveOnUndeploy.

public void testShouldCreateAResourceAndNotRemoveOnUndeploy() throws Exception {
    final EjbModule ejbModule = new EjbModule(new EjbJar(), new OpenejbJar());
    final EjbJar ejbJar = ejbModule.getEjbJar();
    ejbJar.addEnterpriseBean(new StatelessBean(EchoBean.class));
    final AppModule appModule = new AppModule(ejbModule);
    final Container container = new Container();
    container.setId("My Container");
    container.setCtype("STATELESS");
    container.getProperties().setProperty("ApplicationWide", "true");
    appModule.getContainers().add(container);
    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 AppInfo appInfo = config.configureApplication(appModule);
    assembler.createApplication(appInfo);
    {
        final ContainerSystem containerSystem = assembler.getContainerSystem();
        final org.apache.openejb.Container appContainer = containerSystem.getContainer(ejbModule.getModuleId() + "/My Container");
        assertNotNull(appContainer);
    }
    assembler.destroyApplication(appInfo);
    {
        final ContainerSystem containerSystem = assembler.getContainerSystem();
        final org.apache.openejb.Container appContainer = containerSystem.getContainer(ejbModule.getModuleId() + "/My Container");
        assertNotNull(appContainer);
    }
}
Also used : ContainerSystem(org.apache.openejb.spi.ContainerSystem) Container(org.apache.openejb.config.sys.Container) OpenejbJar(org.apache.openejb.jee.oejb3.OpenejbJar) StatelessBean(org.apache.openejb.jee.StatelessBean) Assembler(org.apache.openejb.assembler.classic.Assembler) EjbJar(org.apache.openejb.jee.EjbJar) AppInfo(org.apache.openejb.assembler.classic.AppInfo)

Example 5 with Container

use of org.apache.openejb.config.sys.Container in project tomee by apache.

the class AutoConfigMdbContainerTest method _testConfiguredContainerSelection.

public void _testConfiguredContainerSelection() throws Exception {
    // Create a JMS MDB Container
    final MdbContainerInfo info = config.configureService(MdbContainerInfo.class);
    assertEquals(MessageListener.class.getName(), info.properties.get("MessageListenerInterface"));
    assembler.createContainer(info);
    // Create an Email MDB Container
    final Container container = new Container("EmailContainer", "MESSAGE", null);
    final Properties properties = container.getProperties();
    properties.setProperty("ResourceAdapter", EmailResourceAdapter.class.getSimpleName());
    properties.setProperty("MessageListenerInterface", EmailConsumer.class.getName());
    properties.setProperty("ActivationSpecClass", EmailAccountInfo.class.getName());
    assembler.createContainer(config.configureService(container, MdbContainerInfo.class));
}
Also used : Container(org.apache.openejb.config.sys.Container) MdbContainerInfo(org.apache.openejb.assembler.classic.MdbContainerInfo) MessageListener(javax.jms.MessageListener) Properties(java.util.Properties)

Aggregations

Container (org.apache.openejb.config.sys.Container)22 StatelessSessionContainerInfo (org.apache.openejb.assembler.classic.StatelessSessionContainerInfo)10 ContainerInfo (org.apache.openejb.assembler.classic.ContainerInfo)7 AppInfo (org.apache.openejb.assembler.classic.AppInfo)4 MdbContainerInfo (org.apache.openejb.assembler.classic.MdbContainerInfo)4 Resource (org.apache.openejb.config.sys.Resource)4 EjbJar (org.apache.openejb.jee.EjbJar)4 Test (org.junit.Test)4 ArrayList (java.util.ArrayList)3 File (java.io.File)2 URI (java.net.URI)2 Properties (java.util.Properties)2 EJBContainer (javax.ejb.embeddable.EJBContainer)2 MessageListener (javax.jms.MessageListener)2 Assembler (org.apache.openejb.assembler.classic.Assembler)2 BmpEntityContainerInfo (org.apache.openejb.assembler.classic.BmpEntityContainerInfo)2 CmpEntityContainerInfo (org.apache.openejb.assembler.classic.CmpEntityContainerInfo)2 ManagedContainerInfo (org.apache.openejb.assembler.classic.ManagedContainerInfo)2 OpenEjbConfiguration (org.apache.openejb.assembler.classic.OpenEjbConfiguration)2 ResourceInfo (org.apache.openejb.assembler.classic.ResourceInfo)2