Search in sources :

Example 51 with ContainerSystem

use of org.apache.openejb.spi.ContainerSystem in project tomee by apache.

the class ApplicationPropertiesTest method testConflictingFiles.

/**
 * A child module META-INF/application.properties sets color to white
 * <p/>
 * In the root ear META-INF/application.properties color is set to orange
 * <p/>
 * The root ear META-INF/application.properties wins
 *
 * @throws Exception
 */
public void testConflictingFiles() 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> moduleFiles = new HashMap<String, String>();
        moduleFiles.put("META-INF/ejb-jar.xml", "<ejb-jar id=\"fooModule\"/>");
        moduleFiles.put("META-INF/application.properties", "color=white");
        final File module = Archives.jarArchive(moduleFiles, "fooModule", WidgetBean.class);
        final Map<String, String> appFiles = new HashMap<String, String>();
        appFiles.put("META-INF/application.xml", "" + "<application id=\"fooApp\">\n" + "  <module>\n" + "    <ejb>" + module.getName() + "</ejb>\n" + "  </module>\n" + "</application>");
        appFiles.put("META-INF/application.properties", "color=orange");
        final File app = Archives.fileArchive(appFiles);
        assertTrue(module.renameTo(new File(app, module.getName())));
        final AppInfo appInfo = config.configureApplication(app);
        assembler.createApplication(appInfo);
    }
    final ContainerSystem containerSystem = SystemInstance.get().getComponent(ContainerSystem.class);
    assertContexts(containerSystem);
}
Also used : ContainerSystem(org.apache.openejb.spi.ContainerSystem) Assembler(org.apache.openejb.assembler.classic.Assembler) HashMap(java.util.HashMap) Map(java.util.Map) File(java.io.File) AppInfo(org.apache.openejb.assembler.classic.AppInfo)

Example 52 with ContainerSystem

use of org.apache.openejb.spi.ContainerSystem in project tomee by apache.

the class ApplicationPropertiesTest method testOverrideReplace.

public void testOverrideReplace() 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("fooApp.color", "orange");
        final Map<String, String> map = new HashMap<String, String>();
        map.put("META-INF/ejb-jar.xml", "<ejb-jar id=\"fooModule\"/>");
        map.put("META-INF/application.properties", "color=white");
        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);
}
Also used : ContainerSystem(org.apache.openejb.spi.ContainerSystem) Assembler(org.apache.openejb.assembler.classic.Assembler) HashMap(java.util.HashMap) Map(java.util.Map) File(java.io.File) AppInfo(org.apache.openejb.assembler.classic.AppInfo)

Example 53 with ContainerSystem

use of org.apache.openejb.spi.ContainerSystem in project tomee by apache.

the class ApplicationPropertiesTest method testOverrideUnprefixedVsPrefixedTomEE.

public void testOverrideUnprefixedVsPrefixedTomEE() 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("tomee.fooApp.color", "orange");
        SystemInstance.get().getProperties().put("fooApp.color", "green");
        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);
}
Also used : ContainerSystem(org.apache.openejb.spi.ContainerSystem) Assembler(org.apache.openejb.assembler.classic.Assembler) HashMap(java.util.HashMap) Map(java.util.Map) File(java.io.File) AppInfo(org.apache.openejb.assembler.classic.AppInfo)

Example 54 with ContainerSystem

use of org.apache.openejb.spi.ContainerSystem in project tomee by apache.

the class ApplicationWideTest method testShouldCreateAResourceAndRemoveOnUndeploy.

public void testShouldCreateAResourceAndRemoveOnUndeploy() 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", "false");
    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");
        assertNull(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 55 with ContainerSystem

use of org.apache.openejb.spi.ContainerSystem in project tomee by apache.

the class CommandHelper method listEJBs.

public static Lines listEJBs(final String cr) throws Exception {
    final ContainerSystem cs = SystemInstance.get().getComponent(ContainerSystem.class);
    final Lines lines = new Lines(cr);
    lines.add(new Line("Name", "Class", "Interface Type", "Bean Type"));
    for (final BeanContext bc : cs.deployments()) {
        if (bc.isHidden()) {
            continue;
        }
        lines.add(new Line(bc.getEjbName(), bc.getBeanClass().getName(), getType(bc), componentType(bc.getComponentType())));
    }
    return lines;
}
Also used : ContainerSystem(org.apache.openejb.spi.ContainerSystem) Line(org.apache.openejb.table.Line) BeanContext(org.apache.openejb.BeanContext) Lines(org.apache.openejb.table.Lines)

Aggregations

ContainerSystem (org.apache.openejb.spi.ContainerSystem)67 Assembler (org.apache.openejb.assembler.classic.Assembler)33 BeanContext (org.apache.openejb.BeanContext)22 HashMap (java.util.HashMap)21 Map (java.util.Map)19 File (java.io.File)17 ConfigurationFactory (org.apache.openejb.config.ConfigurationFactory)13 EjbJar (org.apache.openejb.jee.EjbJar)13 StatelessBean (org.apache.openejb.jee.StatelessBean)13 Context (javax.naming.Context)12 AppInfo (org.apache.openejb.assembler.classic.AppInfo)12 OpenejbJar (org.apache.openejb.jee.oejb3.OpenejbJar)11 AppContext (org.apache.openejb.AppContext)10 ArrayList (java.util.ArrayList)9 Properties (java.util.Properties)9 EjbModule (org.apache.openejb.config.EjbModule)9 NamingException (javax.naming.NamingException)8 WebContext (org.apache.openejb.core.WebContext)8 InitialContext (javax.naming.InitialContext)7 NameNotFoundException (javax.naming.NameNotFoundException)6