Search in sources :

Example 61 with ThreadContext

use of org.apache.openejb.core.ThreadContext in project tomee by apache.

the class Timers method all.

public static Collection<Timer> all() {
    final ThreadContext threadContext = ThreadContext.getThreadContext();
    final BeanContext beanContext = threadContext.getBeanContext();
    final ModuleContext module = beanContext.getModuleContext();
    final Collection<Timer> timers = new HashSet<>();
    for (final BeanContext c : module.getAppContext().getBeanContexts()) {
        if (c.getModuleContext() == module) {
            // filter by module
            if (c.getComponentType() != BeanType.STATEFUL) {
                final TimerService timerService = getTimerService(null, c, true);
                if (timerService == null) {
                    continue;
                }
                final Collection<Timer> beanTimers = timerService.getTimers();
                timers.addAll(beanTimers);
            } else {
                // for all instances
                final TimerService timerService = getTimerService(null, c, true);
                if (timerService == null) {
                    continue;
                }
                final Collection<Timer> beanTimers = timerService.getTimers();
                timers.addAll(beanTimers);
            }
        }
    }
    return timers;
}
Also used : BeanContext(org.apache.openejb.BeanContext) Timer(javax.ejb.Timer) ThreadContext(org.apache.openejb.core.ThreadContext) ModuleContext(org.apache.openejb.ModuleContext) TimerService(javax.ejb.TimerService) HashSet(java.util.HashSet)

Example 62 with ThreadContext

use of org.apache.openejb.core.ThreadContext in project tomee by apache.

the class OpenEJBContext method getThreadContext.

/**
     * Gets current context deployment context.
     *
     * @return context of deployment
     * @throws NamingException for exception
     */
private Context getThreadContext() throws NamingException {
    final ThreadContext threadContext = ThreadContext.getThreadContext();
    if (skipEjbContext(threadContext)) {
        return ContextBindings.getClassLoader();
    }
    final Context context = threadContext.getBeanContext().getJndiEnc();
    return context;
}
Also used : Context(javax.naming.Context) ThreadContext(org.apache.openejb.core.ThreadContext) ThreadContext(org.apache.openejb.core.ThreadContext)

Aggregations

ThreadContext (org.apache.openejb.core.ThreadContext)62 BeanContext (org.apache.openejb.BeanContext)33 Method (java.lang.reflect.Method)19 OpenEJBException (org.apache.openejb.OpenEJBException)18 ApplicationException (org.apache.openejb.ApplicationException)10 InterceptorStack (org.apache.openejb.core.interceptor.InterceptorStack)10 EjbTransactionUtil.handleApplicationException (org.apache.openejb.core.transaction.EjbTransactionUtil.handleApplicationException)10 TransactionPolicy (org.apache.openejb.core.transaction.TransactionPolicy)10 EJBException (javax.ejb.EJBException)9 InterceptorData (org.apache.openejb.core.interceptor.InterceptorData)9 InvocationTargetException (java.lang.reflect.InvocationTargetException)7 RemoteException (java.rmi.RemoteException)7 SystemInstance (org.apache.openejb.loader.SystemInstance)7 BeanTransactionPolicy (org.apache.openejb.core.transaction.BeanTransactionPolicy)6 JtaTransactionPolicy (org.apache.openejb.core.transaction.JtaTransactionPolicy)6 ArrayList (java.util.ArrayList)5 EJBAccessException (javax.ejb.EJBAccessException)5 EJBHome (javax.ejb.EJBHome)5 EJBLocalHome (javax.ejb.EJBLocalHome)5 EJBLocalObject (javax.ejb.EJBLocalObject)5