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;
}
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());
}
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;
}
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"));
}
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;
}
Aggregations