Search in sources :

Example 31 with StatelessBean

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

the class LocalClientNoInjectionTest method setUp.

public void setUp() throws OpenEJBException, NamingException, IOException {
    // avoid linkage error on mac, only used for tests so don't need to add it in Core
    JULLoggerFactory.class.getName();
    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(this.getClass().getClassLoader(), "test-app");
    final Persistence persistence = new Persistence(new org.apache.openejb.jee.jpa.unit.PersistenceUnit("foo-unit"));
    app.addPersistenceModule(new PersistenceModule("root", persistence));
    final EjbJar ejbJar = new EjbJar();
    ejbJar.addEnterpriseBean(new StatelessBean(SuperBean.class));
    app.getEjbModules().add(new EjbModule(ejbJar));
    final ClientModule clientModule = new ClientModule(null, app.getClassLoader(), app.getJarLocation(), null, null);
    clientModule.getLocalClients().add(this.getClass().getName());
    app.getClientModules().add(clientModule);
    assembler.createApplication(config.configureApplication(app));
}
Also used : Persistence(org.apache.openejb.jee.jpa.unit.Persistence) TransactionServiceInfo(org.apache.openejb.assembler.classic.TransactionServiceInfo) StatelessBean(org.apache.openejb.jee.StatelessBean) Assembler(org.apache.openejb.assembler.classic.Assembler) SecurityServiceInfo(org.apache.openejb.assembler.classic.SecurityServiceInfo) EjbJar(org.apache.openejb.jee.EjbJar)

Example 32 with StatelessBean

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

the class MappedNameTest method test.

public void test() throws Exception {
    System.setProperty(javax.naming.Context.INITIAL_CONTEXT_FACTORY, LocalInitialContextFactory.class.getName());
    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(GreenBean.class));
    ejbJar.addEnterpriseBean(new StatelessBean(RedBean.class));
    final EjbModule ejbModule = new EjbModule(ejbJar, new OpenejbJar());
    ejbModule.getOpenejbJar().addEjbDeployment(new EjbDeployment(null, "foo/bar/baz/Green", "GreenBean"));
    ejbModule.getOpenejbJar().addEjbDeployment(new EjbDeployment(null, "foo/bar/baz/Red", "RedBean"));
    final EjbJarInfo info = config.configureApplication(ejbModule);
    assembler.createApplication(info);
    final InitialContext initialContext = new InitialContext();
    final Color green = (Color) initialContext.lookup("foo/bar/baz/GreenLocal");
    final Color red = (Color) initialContext.lookup("foo/bar/baz/RedLocal");
    red.test();
}
Also used : LocalInitialContextFactory(org.apache.openejb.core.LocalInitialContextFactory) InitialContext(javax.naming.InitialContext) OpenejbJar(org.apache.openejb.jee.oejb3.OpenejbJar) TransactionServiceInfo(org.apache.openejb.assembler.classic.TransactionServiceInfo) StatelessBean(org.apache.openejb.jee.StatelessBean) EjbDeployment(org.apache.openejb.jee.oejb3.EjbDeployment) Assembler(org.apache.openejb.assembler.classic.Assembler) SecurityServiceInfo(org.apache.openejb.assembler.classic.SecurityServiceInfo) EjbJarInfo(org.apache.openejb.assembler.classic.EjbJarInfo) EjbJar(org.apache.openejb.jee.EjbJar)

Example 33 with StatelessBean

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

the class OutputGeneratedDescriptorsTest method testOutputDescriptor.

@Test
public void testOutputDescriptor() throws Exception {
    final OutputGeneratedDescriptors dynamicDeployer = new OutputGeneratedDescriptors();
    final EjbJar ejbJar = new EjbJar();
    final StatelessBean redBean = new StatelessBean();
    redBean.setEjbClass("com.foo.Red");
    redBean.setEjbName("Red");
    redBean.setRemote("com.foo.Color");
    final ManagedBean orangeBean = new ManagedBean("Orange", "com.foo.Orange");
    final StatefulBean yellowBean = new StatefulBean();
    yellowBean.setEjbClass("com.foo.Yellow");
    yellowBean.setEjbName("Yellow");
    yellowBean.setRemote("com.foo.Color");
    final SingletonBean greenBean = new SingletonBean();
    greenBean.setEjbClass("com.foo.Green");
    greenBean.setEjbName("Green");
    greenBean.setRemote("com.foo.Color");
    ejbJar.addEnterpriseBean(redBean);
    ejbJar.addEnterpriseBean(orangeBean);
    ejbJar.addEnterpriseBean(yellowBean);
    ejbJar.addEnterpriseBean(greenBean);
    final OpenejbJar openejbJar = new OpenejbJar();
    final EjbModule ejbModule = new EjbModule(ejbJar, openejbJar);
    final AppModule appModule = new AppModule(ejbModule);
    File tempFolder = File.createTempFile("tmp", "ogd");
    tempFolder.delete();
    Assert.assertTrue("unable to create temp folder", tempFolder.mkdirs());
    try {
        Properties properties = ejbModule.getOpenejbJar().getProperties();
        properties.setProperty(OutputGeneratedDescriptors.OUTPUT_DESCRIPTORS, "true");
        properties.setProperty(OutputGeneratedDescriptors.OUTPUT_DESCRIPTORS_FOLDER, tempFolder.getAbsolutePath());
        SystemInstance.get().setProperty(OutputGeneratedDescriptors.OUTPUT_DESCRIPTORS_FOLDER, tempFolder.getAbsolutePath());
        dynamicDeployer.deploy(appModule);
        boolean seenEjbJarXml = false;
        boolean seenOpenejbJarXml = false;
        File[] listFiles = tempFolder.listFiles();
        for (File file : listFiles) {
            if (file.getName().startsWith("ejb-jar-")) {
                seenEjbJarXml = true;
                assertEjbFileCorrect(file);
            }
            if (file.getName().startsWith("openejb-jar-")) {
                seenOpenejbJarXml = true;
            }
        }
        Assert.assertTrue("No ejb-jar.xml file produced", seenEjbJarXml);
        Assert.assertTrue("No openejb-jar.xml file produced", seenOpenejbJarXml);
    } finally {
        // clean up temporary folder
        Files.delete(tempFolder);
    }
}
Also used : StatefulBean(org.apache.openejb.jee.StatefulBean) Properties(java.util.Properties) SingletonBean(org.apache.openejb.jee.SingletonBean) OpenejbJar(org.apache.openejb.jee.oejb3.OpenejbJar) StatelessBean(org.apache.openejb.jee.StatelessBean) ManagedBean(org.apache.openejb.jee.ManagedBean) File(java.io.File) EjbJar(org.apache.openejb.jee.EjbJar) Test(org.junit.Test)

Example 34 with StatelessBean

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

the class XmlDataSourceTest method app.

@Module
public EjbJar app() {
    final EjbJar ejbJar = new EjbJar();
    final StatelessBean statelessBean = ejbJar.addEnterpriseBean(new StatelessBean(Bean.class));
    final org.apache.openejb.jee.DataSource ds = new org.apache.openejb.jee.DataSource();
    ds.setName("java:comp/env/foo");
    ds.setUrl("jdbc:hsqldb:mem:override");
    ds.setClassName("org.hsqldb.jdbcDriver");
    statelessBean.getDataSourceMap().put("foo", ds);
    return ejbJar;
}
Also used : StatelessBean(org.apache.openejb.jee.StatelessBean) EjbJar(org.apache.openejb.jee.EjbJar) StatelessBean(org.apache.openejb.jee.StatelessBean) DataSource(javax.sql.DataSource) Module(org.apache.openejb.testing.Module)

Example 35 with StatelessBean

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

the class CheckAnnotationTest method shouldWarnForLocalAnnotationOnBeanWithNoInterface.

@Keys({ @Key(value = "ann.local.forLocalBean", type = KeyType.WARNING) })
public EjbModule shouldWarnForLocalAnnotationOnBeanWithNoInterface() {
    final EjbJar ejbJar = new EjbJar();
    ejbJar.addEnterpriseBean(new StatelessBean(EjbWithoutInterface.class));
    final EjbModule ejbModule = new EjbModule(ejbJar);
    ejbModule.setFinder(new AnnotationFinder(new ClassesArchive(EjbWithoutInterface.class)).link());
    return ejbModule;
}
Also used : StatelessBean(org.apache.openejb.jee.StatelessBean) EjbModule(org.apache.openejb.config.EjbModule) ClassesArchive(org.apache.xbean.finder.archive.ClassesArchive) AnnotationFinder(org.apache.xbean.finder.AnnotationFinder) EjbJar(org.apache.openejb.jee.EjbJar)

Aggregations

StatelessBean (org.apache.openejb.jee.StatelessBean)129 EjbJar (org.apache.openejb.jee.EjbJar)117 Assembler (org.apache.openejb.assembler.classic.Assembler)56 ConfigurationFactory (org.apache.openejb.config.ConfigurationFactory)44 EjbModule (org.apache.openejb.config.EjbModule)37 SecurityServiceInfo (org.apache.openejb.assembler.classic.SecurityServiceInfo)31 TransactionServiceInfo (org.apache.openejb.assembler.classic.TransactionServiceInfo)31 InitialContext (javax.naming.InitialContext)30 Properties (java.util.Properties)28 Module (org.apache.openejb.testing.Module)25 StatelessSessionContainerInfo (org.apache.openejb.assembler.classic.StatelessSessionContainerInfo)18 AppModule (org.apache.openejb.config.AppModule)18 OpenejbJar (org.apache.openejb.jee.oejb3.OpenejbJar)18 ProxyFactoryInfo (org.apache.openejb.assembler.classic.ProxyFactoryInfo)16 ServerFederation (org.apache.openejb.core.ServerFederation)15 Context (javax.naming.Context)14 Empty (org.apache.openejb.jee.Empty)13 ContainerSystem (org.apache.openejb.spi.ContainerSystem)13 LocalInitialContextFactory (org.apache.openejb.core.LocalInitialContextFactory)12 StatefulBean (org.apache.openejb.jee.StatefulBean)12