Search in sources :

Example 46 with ContainerSystem

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

the class ConcurrentLockTypeTest 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);
    attributes = MethodInfoUtil.resolveAttributes(lockInfos, beanContext);
}
Also used : ContainerSystem(org.apache.openejb.spi.ContainerSystem) BeanContext(org.apache.openejb.BeanContext) ArrayList(java.util.ArrayList)

Example 47 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 48 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 49 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 50 with ContainerSystem

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

the class TimerHandleImpl method getTimer.

public Timer getTimer() {
    final ContainerSystem containerSystem = SystemInstance.get().getComponent(ContainerSystem.class);
    if (containerSystem == null) {
        throw new NoSuchObjectLocalException("OpenEJb container system is not running");
    }
    final BeanContext beanContext = containerSystem.getBeanContext(deploymentId);
    if (beanContext == null) {
        throw new NoSuchObjectLocalException("Deployment info not found " + deploymentId);
    }
    final EjbTimerService timerService = beanContext.getEjbTimerService();
    if (timerService == null) {
        throw new NoSuchObjectLocalException("Deployment no longer supports ejbTimout " + deploymentId + ". Has this ejb been redeployed?");
    }
    final Timer timer = timerService.getTimer(id);
    if (timer == null) {
        throw new NoSuchObjectLocalException("Timer not found for ejb " + deploymentId);
    }
    return timer;
}
Also used : ContainerSystem(org.apache.openejb.spi.ContainerSystem) NoSuchObjectLocalException(javax.ejb.NoSuchObjectLocalException) BeanContext(org.apache.openejb.BeanContext) Timer(javax.ejb.Timer)

Aggregations

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