Search in sources :

Example 36 with EjbJar$JAXB

use of org.apache.openejb.jee.EjbJar$JAXB in project tomee by apache.

the class StatefulTest method setUp.

@Override
protected void setUp() 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 StatefulBean(MyBean.class));
    assembler.createApplication(config.configureApplication(ejbJar));
}
Also used : TransactionServiceInfo(org.apache.openejb.assembler.classic.TransactionServiceInfo) StatefulBean(org.apache.openejb.jee.StatefulBean) ConfigurationFactory(org.apache.openejb.config.ConfigurationFactory) Assembler(org.apache.openejb.assembler.classic.Assembler) LocalInitialContextFactory(org.apache.openejb.core.LocalInitialContextFactory) SecurityServiceInfo(org.apache.openejb.assembler.classic.SecurityServiceInfo) EjbJar(org.apache.openejb.jee.EjbJar)

Example 37 with EjbJar$JAXB

use of org.apache.openejb.jee.EjbJar$JAXB in project tomee by apache.

the class StatefulTransactionAttributesTest method test.

public void test() throws Exception {
    System.setProperty(javax.naming.Context.INITIAL_CONTEXT_FACTORY, LocalInitialContextFactory.class.getName());
    final Assembler assembler = new Assembler();
    final ConfigurationFactory config = new ConfigurationFactory();
    assembler.createProxyFactory(config.configureService(ProxyFactoryInfo.class));
    assembler.createTransactionManager(config.configureService(TransactionServiceInfo.class));
    assembler.createSecurityService(config.configureService(SecurityServiceInfo.class));
    final EjbJar ejbJar = new EjbJar();
    ejbJar.addEnterpriseBean(new StatefulBean(Color.class));
    ejbJar.addEnterpriseBean(new StatefulBean(Red.class));
    ejbJar.addEnterpriseBean(new StatefulBean(Crimson.class));
    ejbJar.addEnterpriseBean(new StatefulBean(Scarlet.class));
    final List<ContainerTransaction> declared = ejbJar.getAssemblyDescriptor().getContainerTransaction();
    declared.add(new ContainerTransaction(TransAttribute.REQUIRED, "*", "Crimson", "*"));
    declared.add(new ContainerTransaction(TransAttribute.REQUIRES_NEW, "*", "Crimson", "create"));
    final ContainerTransaction o = new ContainerTransaction(TransAttribute.SUPPORTS, "*", "Crimson", "create");
    o.getMethod().get(0).setMethodIntf(MethodIntf.HOME);
    declared.add(o);
    declared.add(new ContainerTransaction(TransAttribute.REQUIRES_NEW, "*", "Crimson", "remove"));
    declared.add(new ContainerTransaction(TransAttribute.REQUIRES_NEW, Color.class.getName(), "Scarlet", "*"));
    declared.add(new ContainerTransaction(TransAttribute.NEVER, Red.class.getName(), "Scarlet", "red"));
    declared.add(new ContainerTransaction(TransAttribute.REQUIRED, "Scarlet", Scarlet.class.getMethod("scarlet")));
    final EjbJarInfo ejbJarInfo = config.configureApplication(ejbJar);
    assembler.createApplication(ejbJarInfo);
    final InitialContext context = new InitialContext();
    {
        final ColorLocal color = (ColorLocal) context.lookup("ColorLocal");
        assertEquals("Never", color.color());
        assertEquals("RequiresNew", color.color((Object) null));
        assertEquals("Supports", color.color((String) null));
        assertEquals("Supports", color.color((Boolean) null));
        assertEquals("Supports", color.color((Integer) null));
    }
    {
        final ColorRemote color = (ColorRemote) context.lookup("ColorRemote");
        assertEquals("Never", color.color());
        assertEquals("RequiresNew", color.color((Object) null));
        assertEquals("Supports", color.color((String) null));
        assertEquals("Supports", color.color((Boolean) null));
        assertEquals("Supports", color.color((Integer) null));
    }
    {
        final ColorEjbLocalHome home = (ColorEjbLocalHome) context.lookup("ColorLocalHome");
        final ColorEjbLocalObject color = home.create("Supports");
        assertEquals("Never", color.color());
        assertEquals("RequiresNew", color.color((Object) null));
        assertEquals("Supports", color.color((String) null));
        assertEquals("Supports", color.color((Boolean) null));
        assertEquals("Supports", color.color((Integer) null));
        expected.set("Supports");
        color.remove();
    }
    {
        final ColorEjbHome home = (ColorEjbHome) context.lookup("ColorRemoteHome");
        final ColorEjbObject color = home.create("Supports");
        assertEquals("Never", color.color());
        assertEquals("RequiresNew", color.color((Object) null));
        assertEquals("Supports", color.color((String) null));
        assertEquals("Supports", color.color((Boolean) null));
        assertEquals("Supports", color.color((Integer) null));
        expected.set("Supports");
        color.remove();
    }
    {
        final RedLocal red = (RedLocal) context.lookup("RedLocal");
        assertEquals("Never", red.color());
        assertEquals("Required", red.color((Object) null));
        assertEquals("Supports", red.color((String) null));
        assertEquals("Supports", red.color((Boolean) null));
        assertEquals("Supports", red.color((Integer) null));
        assertEquals("RequiresNew", red.red());
        assertEquals("Required", red.red((Object) null));
        assertEquals("Required", red.red((String) null));
    }
    {
        final RedRemote red = (RedRemote) context.lookup("RedRemote");
        assertEquals("Never", red.color());
        assertEquals("Required", red.color((Object) null));
        assertEquals("Supports", red.color((String) null));
        assertEquals("Supports", red.color((Boolean) null));
        assertEquals("Supports", red.color((Integer) null));
        assertEquals("RequiresNew", red.red());
        assertEquals("Required", red.red((Object) null));
        assertEquals("Required", red.red((String) null));
    }
    {
        final RedEjbLocalHome home = (RedEjbLocalHome) context.lookup("RedLocalHome");
        final RedEjbLocalObject red = home.create("Supports");
        assertEquals("Never", red.color());
        assertEquals("Required", red.color((Object) null));
        assertEquals("Supports", red.color((String) null));
        assertEquals("Supports", red.color((Boolean) null));
        assertEquals("Supports", red.color((Integer) null));
        assertEquals("RequiresNew", red.red());
        assertEquals("Required", red.red((Object) null));
        assertEquals("Required", red.red((String) null));
        expected.set("Supports");
        red.remove();
    }
    {
        final RedEjbHome home = (RedEjbHome) context.lookup("RedRemoteHome");
        final RedEjbObject red = home.create("Supports");
        assertEquals("Never", red.color());
        assertEquals("Required", red.color((Object) null));
        assertEquals("Supports", red.color((String) null));
        assertEquals("Supports", red.color((Boolean) null));
        assertEquals("Supports", red.color((Integer) null));
        assertEquals("RequiresNew", red.red());
        assertEquals("Required", red.red((Object) null));
        assertEquals("Required", red.red((String) null));
        expected.set("Supports");
        red.remove();
    }
    {
        final CrimsonLocal crimson = (CrimsonLocal) context.lookup("CrimsonLocal");
        assertEquals("Required", crimson.color());
        assertEquals("Required", crimson.color((Object) null));
        assertEquals("Required", crimson.color((String) null));
        assertEquals("Required", crimson.color((Boolean) null));
        assertEquals("Required", crimson.color((Integer) null));
        assertEquals("RequiresNew", crimson.red());
        assertEquals("Required", crimson.red((Object) null));
        assertEquals("Required", crimson.red((String) null));
        assertEquals("RequiresNew", crimson.crimson());
        assertEquals("Required", crimson.crimson((String) null));
    }
    {
        final CrimsonRemote crimson = (CrimsonRemote) context.lookup("CrimsonRemote");
        assertEquals("Required", crimson.color());
        assertEquals("Required", crimson.color((Object) null));
        assertEquals("Required", crimson.color((String) null));
        assertEquals("Required", crimson.color((Boolean) null));
        assertEquals("Required", crimson.color((Integer) null));
        assertEquals("RequiresNew", crimson.red());
        assertEquals("Required", crimson.red((Object) null));
        assertEquals("Required", crimson.red((String) null));
        assertEquals("RequiresNew", crimson.crimson());
        assertEquals("Required", crimson.crimson((String) null));
    }
    {
        final CrimsonEjbLocalHome home = (CrimsonEjbLocalHome) context.lookup("CrimsonLocalHome");
        final CrimsonEjbLocalObject crimson = home.create("RequiresNew");
        assertEquals("Required", crimson.color());
        assertEquals("Required", crimson.color((Object) null));
        assertEquals("Required", crimson.color((String) null));
        assertEquals("Required", crimson.color((Boolean) null));
        assertEquals("Required", crimson.color((Integer) null));
        assertEquals("RequiresNew", crimson.red());
        assertEquals("Required", crimson.red((Object) null));
        assertEquals("Required", crimson.red((String) null));
        assertEquals("RequiresNew", crimson.crimson());
        assertEquals("Required", crimson.crimson((String) null));
        expected.set("RequiresNew");
        crimson.remove();
    }
    {
        final CrimsonEjbHome home = (CrimsonEjbHome) context.lookup("CrimsonRemoteHome");
        final CrimsonEjbObject crimson = home.create("Supports");
        assertEquals("Required", crimson.color());
        assertEquals("Required", crimson.color((Object) null));
        assertEquals("Required", crimson.color((String) null));
        assertEquals("Required", crimson.color((Boolean) null));
        assertEquals("Required", crimson.color((Integer) null));
        assertEquals("RequiresNew", crimson.red());
        assertEquals("Required", crimson.red((Object) null));
        assertEquals("Required", crimson.red((String) null));
        assertEquals("RequiresNew", crimson.crimson());
        assertEquals("Required", crimson.crimson((String) null));
        expected.set("RequiresNew");
        crimson.remove();
    }
    {
        final ScarletLocal scarlet = (ScarletLocal) context.lookup("ScarletLocal");
        assertEquals("Never", scarlet.color());
        assertEquals("Required", scarlet.color((Object) null));
        assertEquals("RequiresNew", scarlet.color((String) null));
        assertEquals("RequiresNew", scarlet.color((Boolean) null));
        assertEquals("RequiresNew", scarlet.color((Integer) null));
        assertEquals("RequiresNew", scarlet.red());
        assertEquals("Never", scarlet.red((Object) null));
        assertEquals("Never", scarlet.red((String) null));
        assertEquals("Required", scarlet.scarlet());
        assertEquals("NotSupported", scarlet.scarlet((String) null));
    }
    {
        final ScarletRemote scarlet = (ScarletRemote) context.lookup("ScarletRemote");
        assertEquals("Never", scarlet.color());
        assertEquals("Required", scarlet.color((Object) null));
        assertEquals("RequiresNew", scarlet.color((String) null));
        assertEquals("RequiresNew", scarlet.color((Boolean) null));
        assertEquals("RequiresNew", scarlet.color((Integer) null));
        assertEquals("RequiresNew", scarlet.red());
        assertEquals("Never", scarlet.red((Object) null));
        assertEquals("Never", scarlet.red((String) null));
        assertEquals("Required", scarlet.scarlet());
        assertEquals("NotSupported", scarlet.scarlet((String) null));
    }
    {
        final ScarletEjbLocalHome home = (ScarletEjbLocalHome) context.lookup("ScarletLocalHome");
        final ScarletEjbLocalObject scarlet = home.create("RequiresNew");
        assertEquals("Never", scarlet.color());
        assertEquals("Required", scarlet.color((Object) null));
        assertEquals("RequiresNew", scarlet.color((String) null));
        assertEquals("RequiresNew", scarlet.color((Boolean) null));
        assertEquals("RequiresNew", scarlet.color((Integer) null));
        assertEquals("RequiresNew", scarlet.red());
        assertEquals("Never", scarlet.red((Object) null));
        assertEquals("Never", scarlet.red((String) null));
        assertEquals("Required", scarlet.scarlet());
        assertEquals("NotSupported", scarlet.scarlet((String) null));
    }
    {
        final ScarletEjbHome home = (ScarletEjbHome) context.lookup("ScarletRemoteHome");
        final ScarletEjbObject scarlet = home.create("RequiresNew");
        assertEquals("Never", scarlet.color());
        assertEquals("Required", scarlet.color((Object) null));
        assertEquals("RequiresNew", scarlet.color((String) null));
        assertEquals("RequiresNew", scarlet.color((Boolean) null));
        assertEquals("RequiresNew", scarlet.color((Integer) null));
        assertEquals("RequiresNew", scarlet.red());
        assertEquals("Never", scarlet.red((Object) null));
        assertEquals("Never", scarlet.red((String) null));
        assertEquals("Required", scarlet.scarlet());
        assertEquals("NotSupported", scarlet.scarlet((String) null));
    }
}
Also used : LocalInitialContextFactory(org.apache.openejb.core.LocalInitialContextFactory) ConfigurationFactory(org.apache.openejb.config.ConfigurationFactory) SecurityServiceInfo(org.apache.openejb.assembler.classic.SecurityServiceInfo) EjbJar(org.apache.openejb.jee.EjbJar) StatefulBean(org.apache.openejb.jee.StatefulBean) InitialContext(javax.naming.InitialContext) ProxyFactoryInfo(org.apache.openejb.assembler.classic.ProxyFactoryInfo) TransactionServiceInfo(org.apache.openejb.assembler.classic.TransactionServiceInfo) ContainerTransaction(org.apache.openejb.jee.ContainerTransaction) Assembler(org.apache.openejb.assembler.classic.Assembler) EjbJarInfo(org.apache.openejb.assembler.classic.EjbJarInfo)

Example 38 with EjbJar$JAXB

use of org.apache.openejb.jee.EjbJar$JAXB in project tomee by apache.

the class StatefulTransactionLockingTest method setUp.

@Override
protected void setUp() 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 StatefulSessionContainerInfo statefulContainerInfo = config.configureService(StatefulSessionContainerInfo.class);
    statefulContainerInfo.properties.setProperty("AccessTimeout", "0 milliseconds");
    // containers
    assembler.createContainer(statefulContainerInfo);
    // Setup the descriptor information
    final EjbJar ejbJar = new EjbJar();
    ejbJar.addEnterpriseBean(new StatelessBean(BlueStatelessBean.class));
    ejbJar.addEnterpriseBean(new StatefulBean(RedStatefulBean.class));
    ejbJar.addEnterpriseBean(new StatefulBean(LegacyStatefulBean.class));
    assembler.createApplication(config.configureApplication(ejbJar));
}
Also used : StatefulSessionContainerInfo(org.apache.openejb.assembler.classic.StatefulSessionContainerInfo) TransactionServiceInfo(org.apache.openejb.assembler.classic.TransactionServiceInfo) StatelessBean(org.apache.openejb.jee.StatelessBean) StatefulBean(org.apache.openejb.jee.StatefulBean) ConfigurationFactory(org.apache.openejb.config.ConfigurationFactory) Assembler(org.apache.openejb.assembler.classic.Assembler) LocalInitialContextFactory(org.apache.openejb.core.LocalInitialContextFactory) SecurityServiceInfo(org.apache.openejb.assembler.classic.SecurityServiceInfo) EjbJar(org.apache.openejb.jee.EjbJar)

Example 39 with EjbJar$JAXB

use of org.apache.openejb.jee.EjbJar$JAXB in project tomee by apache.

the class CrossClassLoaderProxyTest method setUp.

protected void setUp() throws Exception {
    super.setUp();
    System.setProperty(javax.naming.Context.INITIAL_CONTEXT_FACTORY, LocalInitialContextFactory.class.getName());
    final ConfigurationFactory config = new ConfigurationFactory();
    final Assembler assembler = new Assembler();
    assembler.createProxyFactory(config.configureService(ProxyFactoryInfo.class));
    assembler.createTransactionManager(config.configureService(TransactionServiceInfo.class));
    assembler.createSecurityService(config.configureService(SecurityServiceInfo.class));
    // containers
    final StatelessSessionContainerInfo statelessContainerInfo = config.configureService(StatelessSessionContainerInfo.class);
    statelessContainerInfo.properties.setProperty("TimeOut", "10");
    statelessContainerInfo.properties.setProperty("MaxSize", "0");
    statelessContainerInfo.properties.setProperty("StrictPooling", "false");
    assembler.createContainer(statelessContainerInfo);
    // Setup the descriptor information
    final StatelessBean bean = new StatelessBean(WidgetBean.class);
    bean.addBusinessLocal(Widget.class.getName());
    bean.addBusinessRemote(RemoteWidget.class.getName());
    bean.setHomeAndRemote(WidgetHome.class, WidgetRemote.class);
    bean.addPostConstruct("init");
    bean.addPreDestroy("destroy");
    final EjbJar ejbJar = new EjbJar();
    ejbJar.addEnterpriseBean(bean);
    assembler.createApplication(config.configureApplication(ejbJar));
    WidgetBean.lifecycle.clear();
}
Also used : StatelessSessionContainerInfo(org.apache.openejb.assembler.classic.StatelessSessionContainerInfo) ProxyFactoryInfo(org.apache.openejb.assembler.classic.ProxyFactoryInfo) TransactionServiceInfo(org.apache.openejb.assembler.classic.TransactionServiceInfo) StatelessBean(org.apache.openejb.jee.StatelessBean) ConfigurationFactory(org.apache.openejb.config.ConfigurationFactory) Assembler(org.apache.openejb.assembler.classic.Assembler) LocalInitialContextFactory(org.apache.openejb.core.LocalInitialContextFactory) SecurityServiceInfo(org.apache.openejb.assembler.classic.SecurityServiceInfo) EjbJar(org.apache.openejb.jee.EjbJar)

Example 40 with EjbJar$JAXB

use of org.apache.openejb.jee.EjbJar$JAXB in project tomee by apache.

the class JaxRpcInvocationTest method buildTestApp.

public EjbModule buildTestApp() {
    final EjbJar ejbJar = new EjbJar();
    final StatelessBean bean = ejbJar.addEnterpriseBean(new StatelessBean(EchoBean.class));
    bean.setServiceEndpoint(EchoServiceEndpoint.class.getName());
    return new EjbModule(this.getClass().getClassLoader(), this.getClass().getSimpleName(), "test", ejbJar, null);
}
Also used : StatelessBean(org.apache.openejb.jee.StatelessBean) EjbModule(org.apache.openejb.config.EjbModule) EjbJar(org.apache.openejb.jee.EjbJar)

Aggregations

EjbJar (org.apache.openejb.jee.EjbJar)242 StatelessBean (org.apache.openejb.jee.StatelessBean)117 Assembler (org.apache.openejb.assembler.classic.Assembler)88 EjbModule (org.apache.openejb.config.EjbModule)81 ConfigurationFactory (org.apache.openejb.config.ConfigurationFactory)76 SecurityServiceInfo (org.apache.openejb.assembler.classic.SecurityServiceInfo)60 TransactionServiceInfo (org.apache.openejb.assembler.classic.TransactionServiceInfo)60 OpenejbJar (org.apache.openejb.jee.oejb3.OpenejbJar)50 Properties (java.util.Properties)49 InitialContext (javax.naming.InitialContext)43 SingletonBean (org.apache.openejb.jee.SingletonBean)42 AppModule (org.apache.openejb.config.AppModule)40 StatefulBean (org.apache.openejb.jee.StatefulBean)33 ProxyFactoryInfo (org.apache.openejb.assembler.classic.ProxyFactoryInfo)31 Module (org.apache.openejb.testing.Module)30 EjbDeployment (org.apache.openejb.jee.oejb3.EjbDeployment)27 Test (org.junit.Test)26 LocalInitialContextFactory (org.apache.openejb.core.LocalInitialContextFactory)25 InitContextFactory (org.apache.openejb.core.ivm.naming.InitContextFactory)24 EjbJarInfo (org.apache.openejb.assembler.classic.EjbJarInfo)21