Search in sources :

Example 36 with ContainerSystem

use of org.apache.openejb.spi.ContainerSystem in project tomee by apache.

the class ConcurrentMethodTest method loadAttributes.

private void loadAttributes(final EjbJarInfo ejbJarInfo, final String deploymentId) {
    final ContainerSystem system = SystemInstance.get().getComponent(ContainerSystem.class);
    final BeanContext beanContext = system.getBeanContext(deploymentId);
    final List<MethodConcurrencyInfo> lockInfos = new ArrayList<MethodConcurrencyInfo>();
    final List<MethodConcurrencyInfo> accessTimeoutInfos = new ArrayList<MethodConcurrencyInfo>();
    MethodConcurrencyBuilder.normalize(ejbJarInfo.methodConcurrency, lockInfos, accessTimeoutInfos);
    accessTimeoutAttributes = MethodInfoUtil.resolveAttributes(accessTimeoutInfos, beanContext);
    lockAttributes = MethodInfoUtil.resolveAttributes(lockInfos, beanContext);
}
Also used : ContainerSystem(org.apache.openejb.spi.ContainerSystem) BeanContext(org.apache.openejb.BeanContext) ArrayList(java.util.ArrayList)

Example 37 with ContainerSystem

use of org.apache.openejb.spi.ContainerSystem in project tomee by apache.

the class TransactionAttributesTest method loadAttributes.

private void loadAttributes(final EjbJarInfo ejbJarInfo, final String deploymentId) {
    final ContainerSystem system = SystemInstance.get().getComponent(ContainerSystem.class);
    final BeanContext beanContext = system.getBeanContext(deploymentId);
    final List<MethodTransactionInfo> infos = normalize(ejbJarInfo.methodTransactions);
    attributes = resolveAttributes(infos, beanContext);
    bean = system.getBeanContext(deploymentId).getBusinessLocalBeanHome().create();
}
Also used : ContainerSystem(org.apache.openejb.spi.ContainerSystem) BeanContext(org.apache.openejb.BeanContext)

Example 38 with ContainerSystem

use of org.apache.openejb.spi.ContainerSystem in project tomee by apache.

the class JdbcConfigTest 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));
    // managed JDBC
    assembler.createResource(config.configureService("Default JDBC Database", ResourceInfo.class));
    // unmanaged JDBC
    assembler.createResource(config.configureService("Default Unmanaged JDBC Database", ResourceInfo.class));
    final ContainerSystem containerSystem = SystemInstance.get().getComponent(ContainerSystem.class);
    final DataSource managedDS = (DataSource) containerSystem.getJNDIContext().lookup("openejb/Resource/Default JDBC Database");
    assertNotNull("managedDS is null", managedDS);
    final DataSource unmanagedDS = (DataSource) containerSystem.getJNDIContext().lookup("openejb/Resource/Default Unmanaged JDBC Database");
    assertNotNull("unmanagedDS is null", unmanagedDS);
    // test without a transaction
    // NOTE: without a transaction all connections work as unmanaged
    verifyUnmanagedConnections(managedDS);
    verifyUnmanagedConnections(unmanagedDS);
    // test in the context of a transaction
    final TransactionManager transactionManager = SystemInstance.get().getComponent(TransactionManager.class);
    transactionManager.begin();
    try {
        verifyManagedConnections(managedDS);
        verifyUnmanagedConnections(unmanagedDS);
    } finally {
        // commit the transaction
        transactionManager.commit();
    }
}
Also used : ContainerSystem(org.apache.openejb.spi.ContainerSystem) TransactionManager(javax.transaction.TransactionManager) ConfigurationFactory(org.apache.openejb.config.ConfigurationFactory) DataSource(javax.sql.DataSource)

Example 39 with ContainerSystem

use of org.apache.openejb.spi.ContainerSystem in project tomee by apache.

the class ModulePropertiesTest method testFile.

public void testFile() throws Exception {
    final ConfigurationFactory config = new ConfigurationFactory();
    final Assembler assembler = new Assembler();
    {
        // setup the system
        assembler.createTransactionManager(config.configureService(TransactionServiceInfo.class));
        assembler.createSecurityService(config.configureService(SecurityServiceInfo.class));
    }
    {
        final Map<String, String> map = new HashMap<String, String>();
        map.put("META-INF/module.properties", "color=orange");
        final File app = Archives.fileArchive(map, WidgetBean.class);
        assembler.createApplication(config.configureApplication(app));
    }
    final ContainerSystem containerSystem = SystemInstance.get().getComponent(ContainerSystem.class);
    assertContexts(containerSystem);
}
Also used : ContainerSystem(org.apache.openejb.spi.ContainerSystem) Assembler(org.apache.openejb.assembler.classic.Assembler) HashMap(java.util.HashMap) Map(java.util.Map) File(java.io.File)

Example 40 with ContainerSystem

use of org.apache.openejb.spi.ContainerSystem in project tomee by apache.

the class UberInterfaceTest 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();
    final StatelessBean bean = ejbJar.addEnterpriseBean(new StatelessBean(SuperBean.class));
    final EjbJarInfo ejbJarInfo = config.configureApplication(ejbJar);
    final EnterpriseBeanInfo beanInfo = ejbJarInfo.enterpriseBeans.get(0);
    assertEquals(asList(Everything.class.getName()), beanInfo.businessLocal);
    assertEquals(asList(Everything.class.getName()), beanInfo.businessRemote);
    assertEquals(Everything.class.getName(), beanInfo.serviceEndpoint);
    assembler.createApplication(ejbJarInfo);
    final ContainerSystem containerSystem = SystemInstance.get().getComponent(ContainerSystem.class);
    final BeanContext deployment = containerSystem.getBeanContext(beanInfo.ejbDeploymentId);
    assertEquals(asList(Everything.class), deployment.getBusinessLocalInterfaces());
    assertEquals(asList(Everything.class), deployment.getBusinessRemoteInterfaces());
    assertEquals(Everything.class, deployment.getServiceEndpointInterface());
    final InitialContext context = new InitialContext();
    final Everything local = (Everything) context.lookup("SuperBeanLocal");
    final Everything remote = (Everything) context.lookup("SuperBeanRemote");
    final Reference reference = new Reference("test");
    assertEquals(reference, local.echo(reference));
    // pass by reference
    assertSame(reference, local.echo(reference));
    assertEquals(reference, remote.echo(reference));
    // pass by value
    assertNotSame(reference, remote.echo(reference));
}
Also used : ContainerSystem(org.apache.openejb.spi.ContainerSystem) LocalInitialContextFactory(org.apache.openejb.core.LocalInitialContextFactory) InitialContext(javax.naming.InitialContext) EnterpriseBeanInfo(org.apache.openejb.assembler.classic.EnterpriseBeanInfo) BeanContext(org.apache.openejb.BeanContext) 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) EjbJarInfo(org.apache.openejb.assembler.classic.EjbJarInfo) EjbJar(org.apache.openejb.jee.EjbJar)

Aggregations

ContainerSystem (org.apache.openejb.spi.ContainerSystem)64 Assembler (org.apache.openejb.assembler.classic.Assembler)31 BeanContext (org.apache.openejb.BeanContext)22 HashMap (java.util.HashMap)20 Map (java.util.Map)19 File (java.io.File)17 ConfigurationFactory (org.apache.openejb.config.ConfigurationFactory)13 Context (javax.naming.Context)12 EjbJar (org.apache.openejb.jee.EjbJar)11 StatelessBean (org.apache.openejb.jee.StatelessBean)11 AppContext (org.apache.openejb.AppContext)10 AppInfo (org.apache.openejb.assembler.classic.AppInfo)10 Properties (java.util.Properties)9 EjbModule (org.apache.openejb.config.EjbModule)9 OpenejbJar (org.apache.openejb.jee.oejb3.OpenejbJar)9 ArrayList (java.util.ArrayList)8 NamingException (javax.naming.NamingException)8 WebContext (org.apache.openejb.core.WebContext)8 InitialContext (javax.naming.InitialContext)7 NameNotFoundException (javax.naming.NameNotFoundException)6