use of org.apache.openejb.config.EjbModule in project tomee by apache.
the class MdbConfigTest method test.
public void test() throws Exception {
final ConfigurationFactory config = new ConfigurationFactory();
final Assembler assembler = new Assembler();
// System services
assembler.createProxyFactory(config.configureService(ProxyFactoryInfo.class));
assembler.createTransactionManager(config.configureService(TransactionServiceInfo.class));
assembler.createSecurityService(config.configureService(SecurityServiceInfo.class));
// JMS persistence datasource
final ResourceInfo dataSourceInfo = config.configureService("Default Unmanaged JDBC Database", ResourceInfo.class);
dataSourceInfo.properties.setProperty("JdbcUrl", "jdbc:hsqldb:mem:MdbConfigTest");
assembler.createResource(dataSourceInfo);
// JMS
assembler.createResource(config.configureService("Default JMS Resource Adapter", ResourceInfo.class));
// JMS Container
final MdbContainerInfo mdbContainerInfo = config.configureService(MdbContainerInfo.class);
assembler.createContainer(mdbContainerInfo);
// FakeRA
final ResourceInfo resourceInfo = new ResourceInfo();
resourceInfo.service = "Resource";
resourceInfo.className = FakeRA.class.getName();
resourceInfo.id = "FakeRA";
resourceInfo.properties = new Properties();
assembler.createResource(resourceInfo);
// FakeRA container
final ContainerInfo containerInfo = config.configureService(MdbContainerInfo.class);
containerInfo.id = "FakeContainer";
containerInfo.displayName = "Fake Container";
containerInfo.properties.setProperty("ResourceAdapter", "FakeRA");
containerInfo.properties.setProperty("MessageListenerInterface", FakeMessageListener.class.getName());
containerInfo.properties.setProperty("ActivationSpecClass", FakeActivationSpec.class.getName());
assembler.createContainer(containerInfo);
// generate ejb jar application
final EjbJar ejbJar = new EjbJar();
ejbJar.addEnterpriseBean(createJaxbMdb("JmsMdb", BasicMdbBean.class.getName(), MessageListener.class.getName()));
ejbJar.addEnterpriseBean(createJaxbMdb("FakeMdb", FakeMdb.class.getName(), FakeMessageListener.class.getName()));
final EjbModule ejbModule = new EjbModule(getClass().getClassLoader(), "FakeEjbJar", "fake.jar", ejbJar, null);
// configure and deploy it
final EjbJarInfo info = config.configureApplication(ejbModule);
assembler.createEjbJar(info);
}
use of org.apache.openejb.config.EjbModule in project tomee by apache.
the class OpenEJBXmlByModuleTest method setUp.
@Before
public void setUp() throws OpenEJBException, NamingException, IOException {
final ConfigurationFactory config = new ConfigurationFactory();
final Assembler assembler = new Assembler();
assembler.createTransactionManager(config.configureService(TransactionServiceInfo.class));
assembler.createSecurityService(config.configureService(SecurityServiceInfo.class));
final AppModule app = new AppModule(OpenEJBXmlByModuleTest.class.getClassLoader(), OpenEJBXmlByModuleTest.class.getSimpleName());
final EjbJar ejbJar = new EjbJar();
ejbJar.addEnterpriseBean(new SingletonBean(UselessBean.class));
app.getEjbModules().add(new EjbModule(ejbJar));
app.getEjbModules().iterator().next().getAltDDs().put("resources.xml", getClass().getClassLoader().getResource("META-INF/resource/appresource.openejb.xml"));
assembler.createApplication(config.configureApplication(app));
final Properties properties = new Properties();
properties.setProperty(javax.naming.Context.INITIAL_CONTEXT_FACTORY, LocalInitialContextFactory.class.getName());
properties.setProperty("openejb.embedded.initialcontext.close", "destroy");
// some hack to be sure to call destroy()
context = new InitialContext(properties);
bean = (UselessBean) context.lookup("UselessBeanLocalBean");
}
use of org.apache.openejb.config.EjbModule in project tomee by apache.
the class AbstractCDIInjectionTest method app.
@Module
public EjbModule app() throws Exception {
final StatelessBean bean = new StatelessBean(AppJpaDAO.class);
bean.setLocalBean(new Empty());
final StatelessBean test = new StatelessBean(AppCDI.class);
bean.setLocalBean(new Empty());
final EjbJar ejbJar = new EjbJar();
ejbJar.addEnterpriseBean(bean);
ejbJar.addEnterpriseBean(test);
final Beans beans = new Beans();
beans.addManagedClass(PlcBaseDAO.class);
beans.addManagedClass(PlcBaseJpaDAO.class);
final EjbModule jar = new EjbModule(ejbJar);
jar.setBeans(beans);
return jar;
}
use of org.apache.openejb.config.EjbModule in project tomee by apache.
the class AbstractInjectionTest method app.
@Module
public EjbModule app() throws Exception {
final StatelessBean bean = new StatelessBean(AppJpaDAO.class);
bean.setLocalBean(new Empty());
final StatelessBean test = new StatelessBean(AppCDI.class);
bean.setLocalBean(new Empty());
final EjbJar ejbJar = new EjbJar();
ejbJar.addEnterpriseBean(bean);
ejbJar.addEnterpriseBean(test);
final Beans beans = new Beans();
beans.addManagedClass(PlcBaseDAO.class);
beans.addManagedClass(PlcBaseJpaDAO.class);
beans.addManagedClass(AppCDI.class);
beans.addManagedClass(AppJpaDAO.class);
final EjbModule jar = new EjbModule(ejbJar);
jar.setBeans(beans);
return jar;
}
use of org.apache.openejb.config.EjbModule in project tomee by apache.
the class SimpleCdiTest method setUp.
@Before
public void setUp() 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 StatelessBean(Echo.class));
final Beans beans = new Beans();
beans.addInterceptor(EchoInterceptor.class);
beans.addDecorator(EchoDecorator.class);
beans.addManagedClass(SimpleModel.class);
beans.addManagedClass(ProducesEjbInjector.class);
final EjbModule module = new EjbModule(ejbJar);
module.setBeans(beans);
assembler.createApplication(config.configureApplication(module));
final Properties properties = new Properties(System.getProperties());
properties.setProperty(Context.INITIAL_CONTEXT_FACTORY, InitContextFactory.class.getName());
ctx = new InitialContext(properties);
}
Aggregations