Search in sources :

Example 6 with Container

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"));
}
Also used : StatelessSessionContainerInfo(org.apache.openejb.assembler.classic.StatelessSessionContainerInfo) Container(org.apache.openejb.config.sys.Container) URI(java.net.URI)

Example 7 with Container

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"));
}
Also used : StatelessSessionContainerInfo(org.apache.openejb.assembler.classic.StatelessSessionContainerInfo) Container(org.apache.openejb.config.sys.Container)

Example 8 with Container

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);
}
Also used : StatelessSessionContainerInfo(org.apache.openejb.assembler.classic.StatelessSessionContainerInfo) Container(org.apache.openejb.config.sys.Container)

Example 9 with Container

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);
    }
}
Also used : Container(org.apache.openejb.config.sys.Container) ContainerInfo(org.apache.openejb.assembler.classic.ContainerInfo)

Example 10 with Container

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());
        }
    }
}
Also used : Container(org.apache.openejb.config.sys.Container) Resource(org.apache.openejb.config.sys.Resource)

Aggregations

Container (org.apache.openejb.config.sys.Container)16 StatelessSessionContainerInfo (org.apache.openejb.assembler.classic.StatelessSessionContainerInfo)10 ContainerInfo (org.apache.openejb.assembler.classic.ContainerInfo)4 MdbContainerInfo (org.apache.openejb.assembler.classic.MdbContainerInfo)4 Resource (org.apache.openejb.config.sys.Resource)4 File (java.io.File)2 URI (java.net.URI)2 ArrayList (java.util.ArrayList)2 Properties (java.util.Properties)2 EJBContainer (javax.ejb.embeddable.EJBContainer)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 SingletonSessionContainerInfo (org.apache.openejb.assembler.classic.SingletonSessionContainerInfo)2 StatefulSessionContainerInfo (org.apache.openejb.assembler.classic.StatefulSessionContainerInfo)2 IOException (java.io.IOException)1 URL (java.net.URL)1 MessageListener (javax.jms.MessageListener)1