Search in sources :

Example 81 with EjbModule

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);
}
Also used : EjbModule(org.apache.openejb.config.EjbModule) Properties(java.util.Properties) ConfigurationFactory(org.apache.openejb.config.ConfigurationFactory) EjbJar(org.apache.openejb.jee.EjbJar)

Example 82 with EjbModule

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");
}
Also used : AppModule(org.apache.openejb.config.AppModule) EjbModule(org.apache.openejb.config.EjbModule) Properties(java.util.Properties) LocalInitialContextFactory(org.apache.openejb.core.LocalInitialContextFactory) InitialContext(javax.naming.InitialContext) SingletonBean(org.apache.openejb.jee.SingletonBean) ConfigurationFactory(org.apache.openejb.config.ConfigurationFactory) EjbJar(org.apache.openejb.jee.EjbJar) Before(org.junit.Before)

Example 83 with EjbModule

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;
}
Also used : Empty(org.apache.openejb.jee.Empty) Beans(org.apache.openejb.jee.Beans) StatelessBean(org.apache.openejb.jee.StatelessBean) EjbModule(org.apache.openejb.config.EjbModule) EjbJar(org.apache.openejb.jee.EjbJar) EjbModule(org.apache.openejb.config.EjbModule) Module(org.apache.openejb.testing.Module)

Example 84 with EjbModule

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;
}
Also used : Empty(org.apache.openejb.jee.Empty) Beans(org.apache.openejb.jee.Beans) StatelessBean(org.apache.openejb.jee.StatelessBean) EjbModule(org.apache.openejb.config.EjbModule) EjbJar(org.apache.openejb.jee.EjbJar) EjbModule(org.apache.openejb.config.EjbModule) Module(org.apache.openejb.testing.Module)

Example 85 with EjbModule

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);
}
Also used : Beans(org.apache.openejb.jee.Beans) TransactionServiceInfo(org.apache.openejb.assembler.classic.TransactionServiceInfo) StatelessBean(org.apache.openejb.jee.StatelessBean) ConfigurationFactory(org.apache.openejb.config.ConfigurationFactory) EjbModule(org.apache.openejb.config.EjbModule) InitContextFactory(org.apache.openejb.core.ivm.naming.InitContextFactory) Assembler(org.apache.openejb.assembler.classic.Assembler) Properties(java.util.Properties) SecurityServiceInfo(org.apache.openejb.assembler.classic.SecurityServiceInfo) InitialContext(javax.naming.InitialContext) EjbJar(org.apache.openejb.jee.EjbJar) Before(org.junit.Before)

Aggregations

EjbModule (org.apache.openejb.config.EjbModule)91 EjbJar (org.apache.openejb.jee.EjbJar)81 AppModule (org.apache.openejb.config.AppModule)41 StatelessBean (org.apache.openejb.jee.StatelessBean)37 ConfigurationFactory (org.apache.openejb.config.ConfigurationFactory)30 OpenejbJar (org.apache.openejb.jee.oejb3.OpenejbJar)29 Assembler (org.apache.openejb.assembler.classic.Assembler)27 Properties (java.util.Properties)24 SingletonBean (org.apache.openejb.jee.SingletonBean)21 InitialContext (javax.naming.InitialContext)20 Module (org.apache.openejb.testing.Module)18 EjbDeployment (org.apache.openejb.jee.oejb3.EjbDeployment)15 SecurityServiceInfo (org.apache.openejb.assembler.classic.SecurityServiceInfo)13 TransactionServiceInfo (org.apache.openejb.assembler.classic.TransactionServiceInfo)13 Beans (org.apache.openejb.jee.Beans)12 AppInfo (org.apache.openejb.assembler.classic.AppInfo)11 InitContextFactory (org.apache.openejb.core.ivm.naming.InitContextFactory)10 ContainerSystem (org.apache.openejb.spi.ContainerSystem)10 ArrayList (java.util.ArrayList)9 EnterpriseBean (org.apache.openejb.jee.EnterpriseBean)9