Search in sources :

Example 26 with OpenejbJar

use of org.apache.openejb.jee.oejb3.OpenejbJar in project tomee by apache.

the class DeploymentContextPropertiesTest method testModuleContextProperties.

public void testModuleContextProperties() throws Exception {
    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
        final EjbModule ejbModule = new EjbModule(new EjbJar(), new OpenejbJar());
        final EjbJar ejbJar = ejbModule.getEjbJar();
        final OpenejbJar openejbJar = ejbModule.getOpenejbJar();
        openejbJar.getProperties().setProperty("color", "orange");
        ejbJar.addEnterpriseBean(new StatelessBean(WidgetBean.class));
        final EjbJarInfo moduleInfo = config.configureApplication(ejbModule);
        assertProperty(moduleInfo.properties, "color", "orange");
        assembler.createApplication(moduleInfo);
    }
    final ContainerSystem containerSystem = SystemInstance.get().getComponent(ContainerSystem.class);
    final BeanContext beanContext = containerSystem.getBeanContext("WidgetBean");
    final Properties properties = beanContext.getModuleContext().getProperties();
    assertProperty(properties, "color", "orange");
}
Also used : ContainerSystem(org.apache.openejb.spi.ContainerSystem) OpenejbJar(org.apache.openejb.jee.oejb3.OpenejbJar) StatelessBean(org.apache.openejb.jee.StatelessBean) ConfigurationFactory(org.apache.openejb.config.ConfigurationFactory) EjbModule(org.apache.openejb.config.EjbModule) Assembler(org.apache.openejb.assembler.classic.Assembler) Properties(java.util.Properties) EjbJarInfo(org.apache.openejb.assembler.classic.EjbJarInfo) EjbJar(org.apache.openejb.jee.EjbJar)

Example 27 with OpenejbJar

use of org.apache.openejb.jee.oejb3.OpenejbJar in project tomee by apache.

the class DeploymentContextOptionsTest method testModuleContextOptions.

public void testModuleContextOptions() throws Exception {
    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
        final EjbModule ejbModule = new EjbModule(new EjbJar(), new OpenejbJar());
        final EjbJar ejbJar = ejbModule.getEjbJar();
        final OpenejbJar openejbJar = ejbModule.getOpenejbJar();
        openejbJar.getProperties().setProperty("color", "orange");
        ejbJar.addEnterpriseBean(new StatelessBean(WidgetBean.class));
        assembler.createApplication(config.configureApplication(ejbModule));
    }
    final ContainerSystem containerSystem = SystemInstance.get().getComponent(ContainerSystem.class);
    final BeanContext beanContext = containerSystem.getBeanContext("WidgetBean");
    assertOption(beanContext.getOptions(), "color", "orange");
    assertOption(beanContext.getModuleContext().getOptions(), "color", "orange");
    assertNoOption(beanContext.getModuleContext().getAppContext().getOptions(), "color");
}
Also used : ContainerSystem(org.apache.openejb.spi.ContainerSystem) OpenejbJar(org.apache.openejb.jee.oejb3.OpenejbJar) StatelessBean(org.apache.openejb.jee.StatelessBean) ConfigurationFactory(org.apache.openejb.config.ConfigurationFactory) EjbModule(org.apache.openejb.config.EjbModule) Assembler(org.apache.openejb.assembler.classic.Assembler) EjbJar(org.apache.openejb.jee.EjbJar)

Example 28 with OpenejbJar

use of org.apache.openejb.jee.oejb3.OpenejbJar in project tomee by apache.

the class DeploymentContextOptionsTest method testAppContextOptions.

public void testAppContextOptions() throws Exception {
    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
        final EjbModule ejbModule = new EjbModule(new EjbJar(), new OpenejbJar());
        final EjbJar ejbJar = ejbModule.getEjbJar();
        ejbJar.addEnterpriseBean(new StatelessBean(WidgetBean.class));
        final AppModule appModule = new AppModule(ejbModule);
        appModule.getProperties().setProperty("color", "orange");
        assembler.createApplication(config.configureApplication(appModule));
    }
    final ContainerSystem containerSystem = SystemInstance.get().getComponent(ContainerSystem.class);
    final BeanContext beanContext = containerSystem.getBeanContext("WidgetBean");
    assertOption(beanContext.getOptions(), "color", "orange");
    assertOption(beanContext.getModuleContext().getOptions(), "color", "orange");
    assertOption(beanContext.getModuleContext().getAppContext().getOptions(), "color", "orange");
}
Also used : ContainerSystem(org.apache.openejb.spi.ContainerSystem) OpenejbJar(org.apache.openejb.jee.oejb3.OpenejbJar) AppModule(org.apache.openejb.config.AppModule) StatelessBean(org.apache.openejb.jee.StatelessBean) ConfigurationFactory(org.apache.openejb.config.ConfigurationFactory) EjbModule(org.apache.openejb.config.EjbModule) Assembler(org.apache.openejb.assembler.classic.Assembler) EjbJar(org.apache.openejb.jee.EjbJar)

Example 29 with OpenejbJar

use of org.apache.openejb.jee.oejb3.OpenejbJar in project tomee by apache.

the class DeploymentContextOptionsTest method testBeanContextOptions.

public void testBeanContextOptions() throws Exception {
    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
        final EjbModule ejbModule = new EjbModule(new EjbJar(), new OpenejbJar());
        final EjbJar ejbJar = ejbModule.getEjbJar();
        final OpenejbJar openejbJar = ejbModule.getOpenejbJar();
        final StatelessBean statelessBean = ejbJar.addEnterpriseBean(new StatelessBean(WidgetBean.class));
        {
            // Set at BeanContext level
            final EjbDeployment deployment = openejbJar.addEjbDeployment(statelessBean);
            deployment.getProperties().put("color", "orange");
        }
        assembler.createApplication(config.configureApplication(ejbModule));
    }
    final ContainerSystem containerSystem = SystemInstance.get().getComponent(ContainerSystem.class);
    final BeanContext beanContext = containerSystem.getBeanContext("WidgetBean");
    assertOption(beanContext.getOptions(), "color", "orange");
    assertNoOption(beanContext.getModuleContext().getOptions(), "color");
    assertNoOption(beanContext.getModuleContext().getAppContext().getOptions(), "color");
}
Also used : ContainerSystem(org.apache.openejb.spi.ContainerSystem) OpenejbJar(org.apache.openejb.jee.oejb3.OpenejbJar) StatelessBean(org.apache.openejb.jee.StatelessBean) ConfigurationFactory(org.apache.openejb.config.ConfigurationFactory) EjbModule(org.apache.openejb.config.EjbModule) EjbDeployment(org.apache.openejb.jee.oejb3.EjbDeployment) Assembler(org.apache.openejb.assembler.classic.Assembler) EjbJar(org.apache.openejb.jee.EjbJar)

Example 30 with OpenejbJar

use of org.apache.openejb.jee.oejb3.OpenejbJar in project tomee by apache.

the class AdvancedProviderConfigTest method service.

@Module
public static EjbModule service() throws Exception {
    final EjbModule module = new EjbModule(new EjbJar(), new OpenejbJar());
    final EnterpriseBean bean = new SingletonBean(AdvancedBean.class).localBean();
    module.getEjbJar().addEnterpriseBean(bean);
    final Resources resources = new Resources();
    final Service feature = new Service("xml", null);
    feature.setClassName(JAXBElementProvider.class.getName());
    feature.getProperties().put("eventHandler", "$handler");
    resources.getService().add(feature);
    final Service handler = new Service("handler", null);
    handler.setClassName(MyValidator.class.getName());
    resources.getService().add(handler);
    module.initResources(resources);
    final PojoDeployment e = new PojoDeployment();
    e.setClassName("jaxrs-application");
    e.getProperties().setProperty("cxf.jaxrs.providers", "xml");
    module.getOpenejbJar().getPojoDeployment().add(e);
    return module;
}
Also used : JAXBElementProvider(org.apache.cxf.jaxrs.provider.JAXBElementProvider) SingletonBean(org.apache.openejb.jee.SingletonBean) OpenejbJar(org.apache.openejb.jee.oejb3.OpenejbJar) EnterpriseBean(org.apache.openejb.jee.EnterpriseBean) EjbModule(org.apache.openejb.config.EjbModule) Service(org.apache.openejb.config.sys.Service) PojoDeployment(org.apache.openejb.jee.oejb3.PojoDeployment) Resources(org.apache.openejb.config.sys.Resources) EjbJar(org.apache.openejb.jee.EjbJar) EjbModule(org.apache.openejb.config.EjbModule) Module(org.apache.openejb.testing.Module)

Aggregations

OpenejbJar (org.apache.openejb.jee.oejb3.OpenejbJar)65 EjbJar (org.apache.openejb.jee.EjbJar)52 EjbDeployment (org.apache.openejb.jee.oejb3.EjbDeployment)37 EjbModule (org.apache.openejb.config.EjbModule)30 Properties (java.util.Properties)20 StatelessBean (org.apache.openejb.jee.StatelessBean)19 Assembler (org.apache.openejb.assembler.classic.Assembler)18 EnterpriseBean (org.apache.openejb.jee.EnterpriseBean)16 ConfigurationFactory (org.apache.openejb.config.ConfigurationFactory)12 ContainerSystem (org.apache.openejb.spi.ContainerSystem)12 SingletonBean (org.apache.openejb.jee.SingletonBean)11 Module (org.apache.openejb.testing.Module)11 AppModule (org.apache.openejb.config.AppModule)8 PojoDeployment (org.apache.openejb.jee.oejb3.PojoDeployment)8 InitialContext (javax.naming.InitialContext)7 OpenEJBException (org.apache.openejb.OpenEJBException)7 Resources (org.apache.openejb.config.sys.Resources)7 Service (org.apache.openejb.config.sys.Service)7 MessageDrivenBean (org.apache.openejb.jee.MessageDrivenBean)7 File (java.io.File)6