Search in sources :

Example 1 with EjbTimerService

use of org.apache.openejb.core.timer.EjbTimerService in project tomee by apache.

the class EntityContainer method cancelTimers.

private void cancelTimers(final ThreadContext threadContext) {
    final BeanContext beanContext = threadContext.getBeanContext();
    final Object primaryKey = threadContext.getPrimaryKey();
    // if we have a real timerservice, stop all timers. Otherwise, ignore...
    if (primaryKey != null) {
        final EjbTimerService timerService = beanContext.getEjbTimerService();
        if (timerService != null && timerService instanceof EjbTimerServiceImpl) {
            for (final Timer timer : beanContext.getEjbTimerService().getTimers(primaryKey)) {
                timer.cancel();
            }
        }
    }
}
Also used : BeanContext(org.apache.openejb.BeanContext) Timer(javax.ejb.Timer) EJBObject(javax.ejb.EJBObject) EJBLocalObject(javax.ejb.EJBLocalObject) EjbTimerServiceImpl(org.apache.openejb.core.timer.EjbTimerServiceImpl) EjbTimerService(org.apache.openejb.core.timer.EjbTimerService)

Example 2 with EjbTimerService

use of org.apache.openejb.core.timer.EjbTimerService in project tomee by apache.

the class SingletonContainer method start.

@Override
public void start(final BeanContext info) throws OpenEJBException {
    instanceManager.start(info);
    final EjbTimerService timerService = info.getEjbTimerService();
    if (timerService != null) {
        timerService.start();
    }
}
Also used : EjbTimerService(org.apache.openejb.core.timer.EjbTimerService)

Example 3 with EjbTimerService

use of org.apache.openejb.core.timer.EjbTimerService in project tomee by apache.

the class EjbTimerImplSerializableTest method timerData.

public static CalendarTimerData timerData() throws Exception {
    final BeanContext context = SystemInstance.get().getComponent(ContainerSystem.class).getBeanContext("EJBWithTimer");
    final EjbTimerService timer = context.getEjbTimerService();
    final MethodContext ctx = context.getMethodContext(EJBWithTimer.class.getMethod("doSthg"));
    final ScheduleData sd = ctx.getSchedules().iterator().next();
    return new CalendarTimerData(1, (EjbTimerServiceImpl) timer, context.getDeploymentID().toString(), null, ctx.getBeanMethod(), sd.getConfig(), sd.getExpression(), false);
}
Also used : ContainerSystem(org.apache.openejb.spi.ContainerSystem) BeanContext(org.apache.openejb.BeanContext) CalendarTimerData(org.apache.openejb.core.timer.CalendarTimerData) ScheduleData(org.apache.openejb.core.timer.ScheduleData) MethodContext(org.apache.openejb.MethodContext) EjbTimerService(org.apache.openejb.core.timer.EjbTimerService)

Example 4 with EjbTimerService

use of org.apache.openejb.core.timer.EjbTimerService in project tomee by apache.

the class StatelessContainer method start.

@Override
public void start(final BeanContext beanContext) throws OpenEJBException {
    this.instanceManager.deploy(beanContext);
    final EjbTimerService timerService = beanContext.getEjbTimerService();
    if (timerService != null) {
        timerService.start();
    }
}
Also used : EjbTimerService(org.apache.openejb.core.timer.EjbTimerService)

Example 5 with EjbTimerService

use of org.apache.openejb.core.timer.EjbTimerService in project tomee by apache.

the class CmpContainer method cancelTimers.

private void cancelTimers(final ThreadContext threadContext) {
    final BeanContext beanContext = threadContext.getBeanContext();
    final Object primaryKey = threadContext.getPrimaryKey();
    // stop timers
    if (primaryKey != null && beanContext.getEjbTimerService() != null) {
        final EjbTimerService timerService = beanContext.getEjbTimerService();
        if (timerService != null && timerService instanceof EjbTimerServiceImpl) {
            for (final Timer timer : beanContext.getEjbTimerService().getTimers(primaryKey)) {
                timer.cancel();
            }
        }
    }
}
Also used : BeanContext(org.apache.openejb.BeanContext) Timer(javax.ejb.Timer) EJBLocalObject(javax.ejb.EJBLocalObject) EJBObject(javax.ejb.EJBObject) EjbTimerServiceImpl(org.apache.openejb.core.timer.EjbTimerServiceImpl) EjbTimerService(org.apache.openejb.core.timer.EjbTimerService)

Aggregations

EjbTimerService (org.apache.openejb.core.timer.EjbTimerService)7 BeanContext (org.apache.openejb.BeanContext)4 Timer (javax.ejb.Timer)3 EjbTimerServiceImpl (org.apache.openejb.core.timer.EjbTimerServiceImpl)3 EJBLocalObject (javax.ejb.EJBLocalObject)2 EJBObject (javax.ejb.EJBObject)2 MethodContext (org.apache.openejb.MethodContext)1 OpenEJBException (org.apache.openejb.OpenEJBException)1 CalendarTimerData (org.apache.openejb.core.timer.CalendarTimerData)1 ScheduleData (org.apache.openejb.core.timer.ScheduleData)1 TimerServiceImpl (org.apache.openejb.core.timer.TimerServiceImpl)1 ContainerSystem (org.apache.openejb.spi.ContainerSystem)1 Test (org.junit.Test)1