Search in sources :

Example 11 with SingletonBean

use of org.apache.openejb.jee.SingletonBean in project tomee by apache.

the class CheckDependsOnTest method dependsOn.

@Keys({ @Key(value = "dependsOn.circuit", count = 2), @Key(value = "dependsOn.noSuchEjb", count = 2) })
public EjbJar dependsOn() throws OpenEJBException {
    final EjbJar ejbJar = new EjbJar();
    final SingletonBean one = new SingletonBean(One.class);
    final SingletonBean two = new SingletonBean(Two.class);
    final SingletonBean three = new SingletonBean(Three.class);
    final SingletonBean four = new SingletonBean(Four.class);
    final SingletonBean five = new SingletonBean(Five.class);
    final SingletonBean six = new SingletonBean(Six.class);
    ejbJar.addEnterpriseBean(one);
    ejbJar.addEnterpriseBean(two);
    ejbJar.addEnterpriseBean(three);
    ejbJar.addEnterpriseBean(four);
    ejbJar.addEnterpriseBean(five);
    ejbJar.addEnterpriseBean(six);
    return ejbJar;
}
Also used : SingletonBean(org.apache.openejb.jee.SingletonBean) EjbJar(org.apache.openejb.jee.EjbJar)

Example 12 with SingletonBean

use of org.apache.openejb.jee.SingletonBean in project tomee by apache.

the class NoServiceJarTest method test.

public void test() throws Exception {
    final ConfigurationFactory factory = new ConfigurationFactory();
    final Assembler assembler = new Assembler();
    final Resource orange = new Resource("Orange");
    orange.setClassName(Color.class.getName());
    orange.getProperties().setProperty("red", "255");
    orange.getProperties().setProperty("green", "200");
    orange.getProperties().setProperty("blue", "0");
    final ResourceInfo resourceInfo = factory.configureService(orange, ResourceInfo.class);
    assembler.createResource(resourceInfo);
    assembler.createSecurityService(factory.configureService(SecurityServiceInfo.class));
    assembler.createTransactionManager(factory.configureService(TransactionServiceInfo.class));
    final EjbJar ejbJar = new EjbJar();
    ejbJar.addEnterpriseBean(new SingletonBean(MyBean.class));
    final AppContext application = assembler.createApplication(factory.configureApplication(new EjbModule(ejbJar)));
    final MyBean myBean = (MyBean) application.getBeanContexts().get(0).getBusinessLocalBeanHome().create();
    final Color color = myBean.getColor();
    assertNotNull(color);
    assertEquals(255, color.getRed());
    assertEquals(200, color.getGreen());
    assertEquals(0, color.getBlue());
}
Also used : ResourceInfo(org.apache.openejb.assembler.classic.ResourceInfo) SingletonBean(org.apache.openejb.jee.SingletonBean) TransactionServiceInfo(org.apache.openejb.assembler.classic.TransactionServiceInfo) AppContext(org.apache.openejb.AppContext) ConfigurationFactory(org.apache.openejb.config.ConfigurationFactory) EjbModule(org.apache.openejb.config.EjbModule) Assembler(org.apache.openejb.assembler.classic.Assembler) SecurityServiceInfo(org.apache.openejb.assembler.classic.SecurityServiceInfo) EjbJar(org.apache.openejb.jee.EjbJar)

Example 13 with SingletonBean

use of org.apache.openejb.jee.SingletonBean in project tomee by apache.

the class ParseAppCtxXmlTest method module.

@Module
public AppModule module() {
    final AppModule app = new AppModule(ParseAppCtxXmlTest.class.getClassLoader(), "");
    app.getAltDDs().put("app-ctx.xml", ParseAppCtxXmlTest.class.getClassLoader().getResource("complete-app-ctx.xml"));
    app.getEjbModules().add(ejbModule("1"));
    app.getEjbModules().iterator().next().getEjbJar().addEnterpriseBean(new SingletonBean("CalculatorBean", CalculatorConfigured.class.getName()));
    app.getEjbModules().add(ejbModule("2"));
    app.getEjbModules().get(1).getEjbJar().addEnterpriseBean(new SingletonBean("BeanInAModule", CalculatorConfigured2.class.getName()));
    return app;
}
Also used : SingletonBean(org.apache.openejb.jee.SingletonBean) AppModule(org.apache.openejb.config.AppModule) EjbModule(org.apache.openejb.config.EjbModule) AppModule(org.apache.openejb.config.AppModule) Module(org.apache.openejb.testing.Module)

Example 14 with SingletonBean

use of org.apache.openejb.jee.SingletonBean in project tomee by apache.

the class DefaultDataSourceTest method test.

/**
     * Default DataSource should be a JtaManaged DataSource
     *
     * @throws Exception
     */
public void test() throws Exception {
    final ConfigurationFactory config = new ConfigurationFactory();
    final Assembler assembler = new Assembler();
    assembler.createTransactionManager(config.configureService(TransactionServiceInfo.class));
    assembler.createSecurityService(config.configureService(SecurityServiceInfo.class));
    final EjbJar ejbJar = new EjbJar();
    ejbJar.addEnterpriseBean(new SingletonBean(MyBean.class));
    assembler.createApplication(config.configureApplication(new EjbModule(ejbJar)));
    final OpenEjbConfiguration configuration = SystemInstance.get().getComponent(OpenEjbConfiguration.class);
    final ResourceInfo resourceInfo = configuration.facilities.resources.get(0);
    assertEquals("Default JDBC Database", resourceInfo.id);
    assertEquals("true", resourceInfo.properties.getProperty("JtaManaged"));
}
Also used : ResourceInfo(org.apache.openejb.assembler.classic.ResourceInfo) SingletonBean(org.apache.openejb.jee.SingletonBean) TransactionServiceInfo(org.apache.openejb.assembler.classic.TransactionServiceInfo) Assembler(org.apache.openejb.assembler.classic.Assembler) SecurityServiceInfo(org.apache.openejb.assembler.classic.SecurityServiceInfo) EjbJar(org.apache.openejb.jee.EjbJar) OpenEjbConfiguration(org.apache.openejb.assembler.classic.OpenEjbConfiguration)

Example 15 with SingletonBean

use of org.apache.openejb.jee.SingletonBean in project tomee by apache.

the class TomEEConfigurableJohnzonTest method service.

@Module
public static EjbModule service() throws Exception {
    final EjbModule module = new EjbModule(new EjbJar(), new OpenejbJar());
    final EnterpriseBean bean = new SingletonBean(Endpoint.class).localBean();
    module.getEjbJar().addEnterpriseBean(bean);
    final Resources resources = new Resources();
    final Service sorter = new Service("testSorter", null);
    sorter.setClassName(Sorter.class.getName());
    resources.getService().add(sorter);
    final Service converter = new Service("customerConverter", null);
    converter.setClassName(MyConverter.class.getName());
    resources.getService().add(converter);
    final Service johnzon = new Service("johnzon", null);
    johnzon.setClassName(TomEEConfigurableJohnzon.class.getName());
    johnzon.getProperties().put("datePattern", "yyyy");
    // johnzon.getProperties().put("converter", "$customerConverter"); // or the collection syntax
    johnzon.getProperties().put("converters", "collection:$customerConverter,$customerConverter");
    johnzon.getProperties().put("attributeOrder", "$testSorter");
    resources.getService().add(johnzon);
    module.initResources(resources);
    final PojoDeployment e = new PojoDeployment();
    e.setClassName("jaxrs-application");
    e.getProperties().setProperty("cxf.jaxrs.providers", "johnzon");
    module.getOpenejbJar().getPojoDeployment().add(e);
    return module;
}
Also used : 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

SingletonBean (org.apache.openejb.jee.SingletonBean)49 EjbJar (org.apache.openejb.jee.EjbJar)42 EjbModule (org.apache.openejb.config.EjbModule)21 ConfigurationFactory (org.apache.openejb.config.ConfigurationFactory)17 Module (org.apache.openejb.testing.Module)16 Assembler (org.apache.openejb.assembler.classic.Assembler)14 SecurityServiceInfo (org.apache.openejb.assembler.classic.SecurityServiceInfo)12 TransactionServiceInfo (org.apache.openejb.assembler.classic.TransactionServiceInfo)12 AppModule (org.apache.openejb.config.AppModule)11 Properties (java.util.Properties)10 OpenejbJar (org.apache.openejb.jee.oejb3.OpenejbJar)10 InitialContext (javax.naming.InitialContext)8 StatelessBean (org.apache.openejb.jee.StatelessBean)8 SingletonSessionContainerInfo (org.apache.openejb.assembler.classic.SingletonSessionContainerInfo)7 InitContextFactory (org.apache.openejb.core.ivm.naming.InitContextFactory)7 AppInfo (org.apache.openejb.assembler.classic.AppInfo)6 ProxyFactoryInfo (org.apache.openejb.assembler.classic.ProxyFactoryInfo)6 Empty (org.apache.openejb.jee.Empty)6 EjbDeployment (org.apache.openejb.jee.oejb3.EjbDeployment)5 Test (org.junit.Test)5