Search in sources :

Example 41 with SingletonBean

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

the class RsInterceptorInjectionTest method service.

@Module
public static SingletonBean service() throws Exception {
    final SingletonBean bean = new SingletonBean(RsInjection.class);
    bean.setLocalBean(new Empty());
    return bean;
}
Also used : SingletonBean(org.apache.openejb.jee.SingletonBean) Empty(org.apache.openejb.jee.Empty) Module(org.apache.openejb.testing.Module)

Example 42 with SingletonBean

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

the class AppExceptionTest method jar.

@Module
public EjbJar jar() {
    final EjbJar ejbJar = new EjbJar();
    ejbJar.addEnterpriseBean(new SingletonBean(Ejb.class).localBean());
    return ejbJar;
}
Also used : SingletonBean(org.apache.openejb.jee.SingletonBean) EjbJar(org.apache.openejb.jee.EjbJar) Module(org.apache.openejb.testing.Module)

Example 43 with SingletonBean

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

the class AccessTimeoutTest method test.

public void test() throws Exception {
    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));
    // TODO alternative to hack in CidBuilder to initialize if missing
    // SystemInstance.get().setComponent(ThreadSingletonService.class, new ThreadSingletonServiceImpl(getClass().getClassLoader()));
    final EjbJar ejbJar = new EjbJar();
    ejbJar.addEnterpriseBean(new SingletonBean(Color.class));
    ejbJar.addEnterpriseBean(new SingletonBean(Red.class));
    ejbJar.addEnterpriseBean(new SingletonBean(Crimson.class));
    ejbJar.addEnterpriseBean(new SingletonBean(Scarlet.class));
    final EjbJarInfo ejbJarInfo = config.configureApplication(ejbJar);
    assembler.createApplication(ejbJarInfo);
    loadAttributes(ejbJarInfo, "Color");
    assertAttribute(2, TimeUnit.SECONDS, Color.class.getMethod("color"));
    assertAttribute(3, TimeUnit.SECONDS, Color.class.getMethod("color", Object.class));
    assertAttribute(1, TimeUnit.SECONDS, Color.class.getMethod("color", String.class));
    assertAttribute(1, TimeUnit.SECONDS, Color.class.getMethod("color", Boolean.class));
    assertAttribute(1, TimeUnit.SECONDS, Color.class.getMethod("color", Integer.class));
    loadAttributes(ejbJarInfo, "Red");
    assertAttribute(2, TimeUnit.SECONDS, Red.class.getMethod("color"));
    assertNullAttribute(Red.class.getMethod("color", Object.class));
    assertAttribute(1, TimeUnit.SECONDS, Red.class.getMethod("color", String.class));
    assertAttribute(1, TimeUnit.SECONDS, Red.class.getMethod("color", Boolean.class));
    assertAttribute(1, TimeUnit.SECONDS, Red.class.getMethod("color", Integer.class));
    assertAttribute(1, TimeUnit.MINUTES, Red.class.getMethod("red"));
    assertNullAttribute(Red.class.getMethod("red", Object.class));
    assertNullAttribute(Red.class.getMethod("red", String.class));
    loadAttributes(ejbJarInfo, "Crimson");
    assertAttribute(1, TimeUnit.HOURS, Crimson.class.getMethod("color"));
    assertNullAttribute(Crimson.class.getMethod("color", Object.class));
    assertAttribute(1, TimeUnit.HOURS, Crimson.class.getMethod("color", String.class));
    assertAttribute(1, TimeUnit.SECONDS, Crimson.class.getMethod("color", Boolean.class));
    assertAttribute(1, TimeUnit.SECONDS, Crimson.class.getMethod("color", Integer.class));
    assertAttribute(1, TimeUnit.MINUTES, Crimson.class.getMethod("red"));
    assertNullAttribute(Crimson.class.getMethod("red", Object.class));
    assertNullAttribute(Crimson.class.getMethod("red", String.class));
    assertAttribute(2, TimeUnit.HOURS, Crimson.class.getMethod("crimson"));
    assertAttribute(1, TimeUnit.HOURS, Crimson.class.getMethod("crimson", String.class));
    loadAttributes(ejbJarInfo, "Scarlet");
    assertAttribute(2, TimeUnit.SECONDS, Scarlet.class.getMethod("color"));
    assertNullAttribute(Scarlet.class.getMethod("color", Object.class));
    assertAttribute(1, TimeUnit.SECONDS, Scarlet.class.getMethod("color", String.class));
    assertAttribute(1, TimeUnit.SECONDS, Scarlet.class.getMethod("color", Boolean.class));
    assertAttribute(1, TimeUnit.SECONDS, Scarlet.class.getMethod("color", Integer.class));
    assertAttribute(1, TimeUnit.MINUTES, Scarlet.class.getMethod("red"));
    assertNullAttribute(Scarlet.class.getMethod("red", Object.class));
    assertNullAttribute(Scarlet.class.getMethod("red", String.class));
    assertAttribute(2, TimeUnit.DAYS, Scarlet.class.getMethod("scarlet"));
    assertAttribute(1, TimeUnit.DAYS, Scarlet.class.getMethod("scarlet", String.class));
}
Also used : SingletonBean(org.apache.openejb.jee.SingletonBean) ConfigurationFactory(org.apache.openejb.config.ConfigurationFactory) EjbJar(org.apache.openejb.jee.EjbJar)

Example 44 with SingletonBean

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

the class ConcurrentLockTypeTest method test.

public void test() throws Exception {
    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 SingletonBean(Color.class));
    ejbJar.addEnterpriseBean(new SingletonBean(Red.class));
    ejbJar.addEnterpriseBean(new SingletonBean(Crimson.class));
    ejbJar.addEnterpriseBean(new SingletonBean(Scarlet.class));
    final List<ContainerConcurrency> declared = ejbJar.getAssemblyDescriptor().getContainerConcurrency();
    declared.add(new ContainerConcurrency(ConcurrentLockType.WRITE, "*", "*", "*"));
    declared.add(new ContainerConcurrency(ConcurrentLockType.READ, "*", "Crimson", "*"));
    declared.add(new ContainerConcurrency(ConcurrentLockType.READ, Color.class.getName(), "Scarlet", "*"));
    declared.add(new ContainerConcurrency(ConcurrentLockType.READ, Red.class.getName(), "Scarlet", "red"));
    declared.add(new ContainerConcurrency(ConcurrentLockType.WRITE, "Scarlet", Scarlet.class.getMethod("scarlet")));
    final EjbJarInfo ejbJarInfo = config.configureApplication(ejbJar);
    assembler.createApplication(ejbJarInfo);
    loadAttributes(ejbJarInfo, "Color");
    assertAttribute("Read", Color.class.getMethod("color"));
    assertAttribute("Write", Color.class.getMethod("color", Object.class));
    assertAttribute("Write", Color.class.getMethod("color", String.class));
    assertAttribute("Write", Color.class.getMethod("color", Boolean.class));
    assertAttribute("Write", Color.class.getMethod("color", Integer.class));
    loadAttributes(ejbJarInfo, "Red");
    assertAttribute("Read", Red.class.getMethod("color"));
    assertAttribute("Write", Red.class.getMethod("color", Object.class));
    assertAttribute("Write", Red.class.getMethod("color", String.class));
    assertAttribute("Write", Red.class.getMethod("color", Boolean.class));
    assertAttribute("Write", Red.class.getMethod("color", Integer.class));
    assertAttribute("Write", Red.class.getMethod("red"));
    assertAttribute("Write", Red.class.getMethod("red", Object.class));
    assertAttribute("Write", Red.class.getMethod("red", String.class));
    loadAttributes(ejbJarInfo, "Crimson");
    assertAttribute("Read", Crimson.class.getMethod("color"));
    assertAttribute("Read", Crimson.class.getMethod("color", Object.class));
    assertAttribute("Read", Crimson.class.getMethod("color", String.class));
    assertAttribute("Read", Crimson.class.getMethod("color", Boolean.class));
    assertAttribute("Read", Crimson.class.getMethod("color", Integer.class));
    assertAttribute("Write", Crimson.class.getMethod("red"));
    assertAttribute("Read", Crimson.class.getMethod("red", Object.class));
    assertAttribute("Read", Crimson.class.getMethod("red", String.class));
    assertAttribute("Write", Crimson.class.getMethod("crimson"));
    assertAttribute("Read", Crimson.class.getMethod("crimson", String.class));
    loadAttributes(ejbJarInfo, "Scarlet");
    assertAttribute("Read", Scarlet.class.getMethod("color"));
    assertAttribute("Write", Scarlet.class.getMethod("color", Object.class));
    assertAttribute("Read", Scarlet.class.getMethod("color", String.class));
    assertAttribute("Read", Scarlet.class.getMethod("color", Boolean.class));
    assertAttribute("Read", Scarlet.class.getMethod("color", Integer.class));
    assertAttribute("Write", Scarlet.class.getMethod("red"));
    assertAttribute("Read", Scarlet.class.getMethod("red", Object.class));
    assertAttribute("Read", Scarlet.class.getMethod("red", String.class));
    assertAttribute("Write", Scarlet.class.getMethod("scarlet"));
    assertAttribute("Read", Scarlet.class.getMethod("scarlet", String.class));
}
Also used : SingletonBean(org.apache.openejb.jee.SingletonBean) ContainerConcurrency(org.apache.openejb.jee.ContainerConcurrency) ConfigurationFactory(org.apache.openejb.config.ConfigurationFactory) EjbJar(org.apache.openejb.jee.EjbJar)

Example 45 with SingletonBean

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

the class ImportSqlScriptTest method app.

@Module
public SingletonBean app() throws Exception {
    final SingletonBean bean = new SingletonBean(Persister.class);
    bean.setLocalBean(new Empty());
    return bean;
}
Also used : SingletonBean(org.apache.openejb.jee.SingletonBean) Empty(org.apache.openejb.jee.Empty) Module(org.apache.openejb.testing.Module)

Aggregations

SingletonBean (org.apache.openejb.jee.SingletonBean)49 EjbJar (org.apache.openejb.jee.EjbJar)42 EjbModule (org.apache.openejb.config.EjbModule)21 ConfigurationFactory (org.apache.openejb.config.ConfigurationFactory)17 Module (org.apache.openejb.testing.Module)16 Assembler (org.apache.openejb.assembler.classic.Assembler)14 SecurityServiceInfo (org.apache.openejb.assembler.classic.SecurityServiceInfo)12 TransactionServiceInfo (org.apache.openejb.assembler.classic.TransactionServiceInfo)12 AppModule (org.apache.openejb.config.AppModule)11 Properties (java.util.Properties)10 OpenejbJar (org.apache.openejb.jee.oejb3.OpenejbJar)10 InitialContext (javax.naming.InitialContext)8 StatelessBean (org.apache.openejb.jee.StatelessBean)8 SingletonSessionContainerInfo (org.apache.openejb.assembler.classic.SingletonSessionContainerInfo)7 InitContextFactory (org.apache.openejb.core.ivm.naming.InitContextFactory)7 AppInfo (org.apache.openejb.assembler.classic.AppInfo)6 ProxyFactoryInfo (org.apache.openejb.assembler.classic.ProxyFactoryInfo)6 Empty (org.apache.openejb.jee.Empty)6 EjbDeployment (org.apache.openejb.jee.oejb3.EjbDeployment)5 Test (org.junit.Test)5