Search in sources :

Example 31 with EjbJar$JAXB

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

the class DependsOnTest method test.

public void test() throws Exception {
    System.setProperty(javax.naming.Context.INITIAL_CONTEXT_FACTORY, InitContextFactory.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));
    // containers
    assembler.createContainer(config.configureService(SingletonSessionContainerInfo.class));
    final StatelessSessionContainerInfo statelessContainer = config.configureService(StatelessSessionContainerInfo.class);
    statelessContainer.properties.setProperty("MinSize", "1");
    statelessContainer.properties.setProperty("MaxSize", "1");
    assembler.createContainer(statelessContainer);
    actualConstruct.clear();
    final EjbJar ejbJar = new EjbJar();
    ejbJar.addEnterpriseBean(new StatelessBean(Two.class));
    ejbJar.addEnterpriseBean(new SingletonBean(One.class));
    ejbJar.addEnterpriseBean(new SingletonBean(Four.class));
    ejbJar.addEnterpriseBean(new StatelessBean(Three.class));
    // startup and trigger @PostConstruct
    assembler.createApplication(config.configureApplication(ejbJar));
    assertEquals(expected(four, three, two, one), actualConstruct);
    actualDestroy.clear();
    // startup and trigger @PreDestroy
    for (final AppInfo appInfo : assembler.getDeployedApplications()) {
        assembler.destroyApplication(appInfo.path);
    }
    assertEquals(expected(one, two, three, four), actualDestroy);
}
Also used : StatelessSessionContainerInfo(org.apache.openejb.assembler.classic.StatelessSessionContainerInfo) InitContextFactory(org.apache.openejb.core.ivm.naming.InitContextFactory) AppInfo(org.apache.openejb.assembler.classic.AppInfo) ProxyFactoryInfo(org.apache.openejb.assembler.classic.ProxyFactoryInfo) SingletonBean(org.apache.openejb.jee.SingletonBean) 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) SingletonSessionContainerInfo(org.apache.openejb.assembler.classic.SingletonSessionContainerInfo) SecurityServiceInfo(org.apache.openejb.assembler.classic.SecurityServiceInfo) EjbJar(org.apache.openejb.jee.EjbJar)

Example 32 with EjbJar$JAXB

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

the class CallbackOverridesTest 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(ChildBean.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 33 with EjbJar$JAXB

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

the class StatefulBeanManagedTest method beforeClass.

@BeforeClass
public static void beforeClass() 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) BeforeClass(org.junit.BeforeClass)

Example 34 with EjbJar$JAXB

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

the class StatefulConcurrencyTest method setUp.

@Override
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));
    final StatefulSessionContainerInfo statefulContainerInfo = config.configureService(StatefulSessionContainerInfo.class);
    assembler.createContainer(statefulContainerInfo);
    final EjbJar ejbJar = new EjbJar();
    final StatefulBean bean1 = new StatefulBean(MyLocalBeanImpl.class);
    final Timeout timeout1 = new Timeout();
    timeout1.setTimeout(1000);
    timeout1.setUnit(TimeUnit.MILLISECONDS);
    final ConcurrentMethod method1 = new ConcurrentMethod();
    method1.setMethod(new NamedMethod("*"));
    method1.setAccessTimeout(timeout1);
    bean1.getConcurrentMethod().add(method1);
    final StatefulBean bean2 = new StatefulBean("BeanNegative", MyLocalBeanImpl.class);
    final Timeout timeout2 = new Timeout();
    timeout2.setTimeout(-1);
    timeout2.setUnit(TimeUnit.MILLISECONDS);
    final ConcurrentMethod method2 = new ConcurrentMethod();
    method2.setMethod(new NamedMethod("*"));
    method2.setAccessTimeout(timeout2);
    bean2.getConcurrentMethod().add(method2);
    ejbJar.addEnterpriseBean(bean1);
    ejbJar.addEnterpriseBean(bean2);
    assembler.createApplication(config.configureApplication(ejbJar));
}
Also used : StatefulSessionContainerInfo(org.apache.openejb.assembler.classic.StatefulSessionContainerInfo) ProxyFactoryInfo(org.apache.openejb.assembler.classic.ProxyFactoryInfo) TransactionServiceInfo(org.apache.openejb.assembler.classic.TransactionServiceInfo) StatefulBean(org.apache.openejb.jee.StatefulBean) Timeout(org.apache.openejb.jee.Timeout) ConfigurationFactory(org.apache.openejb.config.ConfigurationFactory) Assembler(org.apache.openejb.assembler.classic.Assembler) ConcurrentMethod(org.apache.openejb.jee.ConcurrentMethod) LocalInitialContextFactory(org.apache.openejb.core.LocalInitialContextFactory) NamedMethod(org.apache.openejb.jee.NamedMethod) SecurityServiceInfo(org.apache.openejb.assembler.classic.SecurityServiceInfo) EjbJar(org.apache.openejb.jee.EjbJar)

Example 35 with EjbJar$JAXB

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

the class StatefulContainerTest 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 StatefulSessionContainerInfo statefulContainerInfo = config.configureService(StatefulSessionContainerInfo.class);
    statefulContainerInfo.properties.setProperty("PoolSize", "0");
    statefulContainerInfo.properties.setProperty("BulkPassivate", "1");
    statefulContainerInfo.properties.setProperty("Frequency", "0");
    assembler.createContainer(statefulContainerInfo);
    // Setup the descriptor information
    final EjbJar ejbJar = new EjbJar();
    ejbJar.addEnterpriseBean(new StatefulBean(WidgetBean.class));
    assembler.createApplication(config.configureApplication(ejbJar));
    WidgetBean.lifecycle.clear();
    expectedLifecycle = Arrays.asList(Lifecycle.values());
    inTxExpectedLifecycle = new ArrayList<Lifecycle>();
    for (final Lifecycle lifecycle : Lifecycle.values()) {
        if (!lifecycle.name().startsWith("PRE_PASSIVATE") && !lifecycle.name().startsWith("POST_ACTIVATE")) {
            inTxExpectedLifecycle.add(lifecycle);
        }
    }
}
Also used : StatefulSessionContainerInfo(org.apache.openejb.assembler.classic.StatefulSessionContainerInfo) ProxyFactoryInfo(org.apache.openejb.assembler.classic.ProxyFactoryInfo) 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)

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