Examples of TimerSession


Examples of org.jboss.test.txtimer.interfaces.TimerSession

      List timerHandles = pp.listTimerHandles();
      assertEquals("unexpected handle count", 0, timerHandles.size());

      InitialContext iniCtx = getInitialContext();
      TimerSessionHome home = (TimerSessionHome)iniCtx.lookup(TimerSessionHome.JNDI_NAME);
      TimerSession session = home.create();
      session.resetCallCount();
      try
      {
         // insert a timer into the db
         ObjectName oname = ObjectNameFactory.create("jboss.j2ee:jndiName=test/txtimer/TimerSession,service=EJB");
         TimedObjectId targetId = new TimedObjectId(oname);
         pp.insertTimer("pk1", targetId, new Date(), 0, null);
         sleep(500);

         timerHandles = pp.listTimerHandles();
         assertEquals("unexpected handle count", 1, timerHandles.size());

         // fake restore on server startup
         // we cannot test that the PersistencePolicy is notified after startup
         try
         {
            getServer().invoke(
                  EJBTimerService.OBJECT_NAME,
                  "restoreTimers",
                  new Object[] { oname, null },
                  new String[]{"javax.management.ObjectName", "java.lang.ClassLoader" }
                  );
         }
         catch (Exception e)
         {
            log.warn("Could not restore ejb timers", e);
         }
         sleep(500);
         assertEquals("unexpected call count", 1, session.getGlobalCallCount());

         timerHandles = pp.listTimerHandles();
         assertEquals("unexpected handle count", 0, timerHandles.size());
      }
      finally
      {
         session.remove();
      }
   }
View Full Code Here

Examples of org.jboss.test.txtimer.interfaces.TimerSession

      {
         super.deploy("ejb-txtimer.jar");
        
         InitialContext iniCtx = getInitialContext();
         TimerSessionHome home = (TimerSessionHome)iniCtx.lookup(TimerSessionHome.JNDI_NAME);
         TimerSession session = home.create();
         session.resetCallCount();
  
         // create a timer to expire in 2sec
         session.createTimer(2000, 0, new SimpleInfo("NonScoped"));
           
         // the timer shouldn't have expired yet
         assertEquals("unexpected call count", 0, session.getGlobalCallCount());
        
         // undeploy, the timer must have been persisted
         super.undeploy("ejb-txtimer.jar");
        
         // wait enough time, so the timer expires while "off-line"
         sleep(3000);
        
         // redeploy
         super.deploy("ejb-txtimer.jar");
        
         // just to be safe, give the timer thread a chance to run
         sleep(1000);
        
         // the timer must have expired!
         assertEquals("unexpected call count", 1, session.getGlobalCallCount());
      }
      finally
      {
         // cleanup
         super.undeploy("ejb-txtimer.jar");
View Full Code Here

Examples of org.jboss.test.txtimer.interfaces.TimerSession

      {
         super.deploy("ejb-txtimer-scoped.jar");
        
         InitialContext iniCtx = getInitialContext();
         TimerSessionHome home = (TimerSessionHome)iniCtx.lookup(TimerSessionHome.JNDI_NAME);
         TimerSession session = home.create();
         session.resetCallCount();
  
         // create a timer to expire in 2sec, with a SimpleInfo serializable
         session.createTimer(2000, 0, new SimpleInfo("ScopedTest"));
           
         // the timer shouldn't have expired yet
         assertEquals("unexpected call count", 0, session.getGlobalCallCount());
        
         // undeploy, the timer must have been persisted
         super.undeploy("ejb-txtimer-scoped.jar");
        
         // wait enough time, so the timer expires while "off-line"
         sleep(3000);
        
         // redeploy
         super.deploy("ejb-txtimer-scoped.jar");
        
         // just to be safe, give the timer thread a chance to run
         sleep(1000);
        
         // the timer must have expired!
         assertEquals("unexpected call count", 1, session.getGlobalCallCount());
      }
      finally
      {
         // cleanup
         super.undeploy("ejb-txtimer-scoped.jar");
View Full Code Here

Examples of org.jboss.test.txtimer.interfaces.TimerSession

   public void rollbackAfterCreateSession(long duration)
           throws Exception
   {
      InitialContext iniCtx = new InitialContext();
      TimerSessionHome home = (TimerSessionHome) iniCtx.lookup(TimerSessionHome.JNDI_NAME);
      TimerSession bean = home.create();
      bean.createTimer(duration, 0, null);
      context.setRollbackOnly();
   }
View Full Code Here

Examples of org.jboss.test.txtimer.interfaces.TimerSession

   public void rollbackAfterCancelSession()
           throws Exception
   {
      InitialContext iniCtx = new InitialContext();
      TimerSessionHome home = (TimerSessionHome) iniCtx.lookup(TimerSessionHome.JNDI_NAME);
      TimerSession bean = home.create();
      bean.cancelFirstTimer();
      context.setRollbackOnly();
   }
View Full Code Here

Examples of org.jbpm.pvm.internal.session.TimerSession

  public TimerImpl() {
  }
 
  public void schedule() {
    TimerSession timerSession = Environment.getFromCurrent(TimerSession.class);
    timerSession.schedule(this);
  }
View Full Code Here

Examples of org.jbpm.pvm.internal.session.TimerSession

    return parent;
  }
 
 
  protected void destroyTimers(CompositeElementImpl scope) {
    TimerSession timerSession = Environment.getFromCurrent(TimerSession.class, false);
    if (timerSession!=null) {
      log.debug("destroying timers of "+this);
      List<Timer> timers = timerSession.findTimersByExecution(this);
      for (Timer timer: timers) {
       
        Job job = Environment.getFromCurrent(JobImpl.class, false);
        if (timer!=job) {
          timerSession.cancel(timer);
        }
      }
    }
  }
View Full Code Here

Examples of org.jbpm.pvm.internal.session.TimerSession

    return parent;
  }
 
 
  protected void destroyTimers(CompositeElementImpl scope) {
    TimerSession timerSession = EnvironmentImpl.getFromCurrent(TimerSession.class, false);
    if (timerSession!=null) {
      log.debug("destroying timers of "+this);
      List<Timer> timers = timerSession.findTimersByExecution(this);
      for (Timer timer: timers) {
       
        Job job = EnvironmentImpl.getFromCurrent(JobImpl.class, false);
        if (timer!=job) {
          timerSession.cancel(timer);
        }
      }
    }
  }
View Full Code Here

Examples of org.jbpm.pvm.internal.session.TimerSession

  public TimerImpl() {
  }
 
  public void schedule() {
    this.dbid = DbidGenerator.getDbidGenerator().getNextId();
    TimerSession timerSession = EnvironmentImpl.getFromCurrent(TimerSession.class);
    timerSession.schedule(this);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.