Examples of TimerEntity


Examples of org.jboss.as.ejb3.timerservice.persistence.TimerEntity

        String timedObjectId = timerHandle.getTimedObjectId();
        if (timerPersistence == null) {
            return null;
        }

        final TimerEntity timerEntity = timerPersistence.getValue().loadTimer(id, timedObjectId);
        if (timerEntity == null) {
            throw EJB3_LOGGER.timerNotFound(id);
        }
        if (timerEntity.isCalendarTimer()) {
            return new CalendarTimer((CalendarTimerEntity) timerEntity, this);
        }
        return new TimerImpl(timerEntity, this);

    }
View Full Code Here

Examples of org.jboss.ejb3.timerservice.mk2.persistence.TimerEntity

      {
         return;
      }

      // get the persistent entity from the timer
      TimerEntity timerEntity = timer.getPersistentState();

      // TODO: Now all that bolierplate for tx management (which
      // needs to go once we have the timer service "managed")
      Transaction previousTx = null;
      boolean newTxStarted = false;
      try
      {
         previousTx = this.transactionManager.getTransaction();
         // we persist with REQUIRED tx semantics
         // if there's no current tx in progress, then create a new one
         if (previousTx == null)
         {
            this.startNewTx();
            newTxStarted = true;
         }

         EntityManager em = this.getCurrentEntityManager();
         // merge the state
         TimerEntity mergedTimerEntity = em.merge(timerEntity);

         // do the actual persistence
         em.persist(mergedTimerEntity);

      }
View Full Code Here

Examples of org.jboss.ejb3.timerservice.mk2.persistence.TimerEntity

      }
      if (timers.size() > 1)
      {
         throw new EJBException("More than one timer found for TimerHandle: " + timerHandle);
      }
      TimerEntity timerEntity = timers.get(0);
      if (timerEntity.isCalendarTimer())
      {
         return new CalendarTimer((CalendarTimerEntity) timerEntity, this);
      }
      return new TimerImpl(timerEntity, this);
View Full Code Here

Examples of org.jboss.ejb3.timerservice.mk2.persistence.TimerEntity

    * Creates and returns a new persistent state of this timer
    * @return
    */
   protected TimerEntity createPersistentState()
   {
      return new TimerEntity(this);
   }
View Full Code Here

Examples of org.jboss.ejb3.timerservice.mk2.persistence.TimerEntity

      {
         return;
      }

      // get the persistent entity from the timer
      TimerEntity timerEntity = timer.getPersistentState();

      // TODO: Now all that bolierplate for tx management (which
      // needs to go once we have the timer service "managed")
      Transaction previousTx = null;
      boolean newTxStarted = false;
      try
      {
         previousTx = this.transactionManager.getTransaction();
         // we persist with REQUIRED tx semantics
         // if there's no current tx in progress, then create a new one
         if (previousTx == null)
         {
            this.startNewTx();
            newTxStarted = true;
         }

         EntityManager em = this.getCurrentEntityManager();
         // merge the state
         TimerEntity mergedTimerEntity = em.merge(timerEntity);

         // do the actual persistence
         em.persist(mergedTimerEntity);

      }
View Full Code Here

Examples of org.jboss.test.timer.interfaces.TimerEntity

    */
   public void testEntityBeanTimer()
      throws Exception
   {
      TimerEntityHome home = (TimerEntityHome) getEJBHome(TimerEntityHome.JNDI_NAME);
      TimerEntity entity = home.create(new Integer(111));
      entity.startTimer(SHORT_PERIOD);
      Thread.sleep(12 * SHORT_PERIOD);
      entity.stopTimer();
      int lCount = entity.getTimeoutCount();
      assertTrue("Timeout was expected to be called at least 10 times but was "
         + "only called: " + lCount + " times",
         lCount >= 10);
      Thread.sleep(5 * SHORT_PERIOD);
      int lCount2 = entity.getTimeoutCount();
      assertTrue("After the timer was stopped no timeout should happen but "
         + "it was called " + (lCount2 - lCount) + " more times",
         lCount == lCount2);
      entity.remove();
   }
View Full Code Here

Examples of org.jboss.test.timer.interfaces.TimerEntity

    */
   public void testEntityBeanSingleTimer()
      throws Exception
   {
      TimerEntityHome home = (TimerEntityHome) getEJBHome(TimerEntityHome.JNDI_NAME);
      TimerEntity entity = home.create(new Integer(222));
      entity.startSingleTimer(SHORT_PERIOD);
      Thread.sleep(5 * SHORT_PERIOD);
      int lCount = entity.getTimeoutCount();
      assertTrue("Timeout was expected to be called only once but was called: "
         + lCount + " times",
         lCount == 1);
      try
      {
         entity.stopTimer();
         fail("A single timer should expire after the first event and therefore this "
            + "has to throw an NoSuchObjectLocalException");
      }
      catch (RemoteException re)
      {
         Throwable lCause = re.detail;
         if (lCause instanceof ServerException)
         {
            lCause = ((ServerException) lCause).detail;
            if (lCause instanceof NoSuchObjectLocalException)
            {
               // This exception is expected -> ignore
            }
            else
            {
               throw re;
            }
         }
      }
      entity.remove();
   }
View Full Code Here

Examples of org.jboss.test.timer.interfaces.TimerEntity

   public void testSecuredEntityBeanTimer()
      throws Exception
   {
      login();
      TimerEntityHome home = (TimerEntityHome) getEJBHome(TimerEntityHome.SECURED_JNDI_NAME);
      TimerEntity entity = home.create(new Integer(111));
      entity.startTimer(SHORT_PERIOD);
      Thread.sleep(12 * SHORT_PERIOD);
      entity.stopTimer();
      int count = entity.getTimeoutCount();
      assertTrue("Timeout was expected to be called at least 10 times but was "
         + "only called: " + count + " times",
         count >= 10);
      Thread.sleep(5 * SHORT_PERIOD);
      int count2 = entity.getTimeoutCount();
      assertTrue("After the timer was stopped no timeout should happen but "
         + "it was called " + (count2 - count) + " more times",
         count == count2);
      entity.remove();
      logout();
   }
View Full Code Here

Examples of org.jboss.test.timer.interfaces.TimerEntity

   public void testSecuredEntityBeanSingleTimer()
      throws Exception
   {
      login();
      TimerEntityHome home = (TimerEntityHome) getEJBHome(TimerEntityHome.SECURED_JNDI_NAME);
      TimerEntity entity = home.create(new Integer(222));
      entity.startSingleTimer(SHORT_PERIOD);
      Thread.sleep(5 * SHORT_PERIOD);
      int count = entity.getTimeoutCount();
      assertTrue("Timeout was expected to be called only once but was called: "
         + count + " times",
         count == 1);
      try
      {
         entity.stopTimer();
         fail("A single timer should expire after the first event and therefore this "
            + "has to throw an NoSuchObjectLocalException");
      }
      catch (RemoteException re)
      {
         Throwable lCause = re.detail;
         if (lCause instanceof ServerException)
         {
            lCause = ((ServerException) lCause).detail;
            if (lCause instanceof NoSuchObjectLocalException)
            {
               // This exception is expected -> ignore
            }
            else
            {
               throw re;
            }
         }
      }
      entity.remove();
      logout();
   }
View Full Code Here

Examples of org.jboss.test.timer.interfaces.TimerEntity

    */
   public void testEntityBeanTimer()
      throws Exception
   {
      TimerEntityHome home = (TimerEntityHome) getEJBHome(TimerEntityHome.JNDI_NAME);
      TimerEntity entity = home.create(new Integer(111));
      entity.startTimer(SHORT_PERIOD);
      Thread.sleep(12 * SHORT_PERIOD);
      entity.stopTimer();
      int lCount = entity.getTimeoutCount();
      assertTrue("Timeout was expected to be called at least 10 times but was "
         + "only called: " + lCount + " times",
         lCount >= 10);
      Thread.sleep(5 * SHORT_PERIOD);
      int lCount2 = entity.getTimeoutCount();
      assertTrue("After the timer was stopped no timeout should happen but "
         + "it was called " + (lCount2 - lCount) + " more times",
         lCount == lCount2);
      entity.remove();
   }
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.