Package javax.ejb

Examples of javax.ejb.TimerHandle


    */
   void addTimer(TimerImpl txtimer)
   {
      synchronized (timers)
      {
         TimerHandle handle = new TimerHandleImpl(txtimer);
         timers.put(handle, txtimer);
      }
   }
View Full Code Here


    @Transactional
    public void cancel() {
        Payment payment = getInstance();
       
        TimerHandle handle = payment.getTimerHandle();
        payment.setTimerHandle(null);
        payment.setActive(false);
       
        if (handle != null) {
            try {
                handle.getTimer().cancel();
            } catch (NoSuchObjectLocalException e) {
                FacesMessages.instance().add("Payment already processed");
            }
        }
    }
View Full Code Here

    @Test
    public void testCancelSimpleWhileTimeoutActive() throws NamingException, InterruptedException {
        InitialContext ctx = new InitialContext();
        SimpleTimerServiceBean bean = (SimpleTimerServiceBean)ctx.lookup("java:module/" + SimpleTimerServiceBean.class.getSimpleName());
        TimerHandle handle = bean.createTimer();
        Assert.assertTrue(bean.getTimerEntry().await(TIMER_CALL_WAITING_S, TimeUnit.SECONDS));
        //now the timeout is in progress cancel the timer
        handle.getTimer().cancel();
        bean.getTimerExit().countDown();
        Assert.assertFalse(SimpleTimerServiceBean.quickAwaitTimerCall());
        Assert.assertEquals(0, bean.getTimerCount());

    }
View Full Code Here

    @Test
    public void testCancelCalendarWhileTimeoutActive() throws NamingException, InterruptedException {
        InitialContext ctx = new InitialContext();
        CalendarTimerServiceBean bean = (CalendarTimerServiceBean)ctx.lookup("java:module/" + CalendarTimerServiceBean.class.getSimpleName());
        TimerHandle handle = bean.createTimer();
        Assert.assertTrue(bean.getTimerEntry().await(TIMER_CALL_WAITING_S, TimeUnit.SECONDS));
        //now the timeout is in progress cancel the timer
        handle.getTimer().cancel();
        bean.getTimerExit().countDown();
        Assert.assertFalse(CalendarTimerServiceBean.quickAwaitTimerCall());
        Assert.assertEquals(0, bean.getTimerCount());

    }
View Full Code Here

    @Test
    public void createAndCancelTimerService() throws NamingException {
        InitialContext ctx = new InitialContext();
        CancelledTimerServiceBean bean = (CancelledTimerServiceBean)ctx.lookup("java:module/" + CancelledTimerServiceBean.class.getSimpleName());
        TimerHandle handle = bean.createTimer();
        Assert.assertTrue(CancelledTimerServiceBean.awaitTimerCall());
        Assert.assertEquals("info", handle.getTimer().getInfo());
        handle.getTimer().cancel();
    }
View Full Code Here

     * Cancels any scheduled {@link java.util.concurrent.Future} corresponding to the passed <code>timer</code>
     *
     * @param timer
     */
    protected void cancelTimeout(TimerImpl timer) {
        TimerHandle handle = timer.getTimerHandle();
        java.util.TimerTask timerTask = this.scheduledTimerFutures.get(handle);
        if (timerTask != null) {
            timerTask.cancel();
        }

View Full Code Here

   public void testTimerHandleSerialization() throws Exception
   {
      TimedMockObject to = new TimedMockObject();
      TimerService service = createTimerService(to);
      Timer timer1 = service.createTimer(500, null);
      TimerHandle handle1 = timer1.getHandle();

      ByteArrayOutputStream baos = new ByteArrayOutputStream();
      ObjectOutputStream oos = new ObjectOutputStream(baos);
      oos.writeObject(handle1);
      ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
      ObjectInputStream ois = new ObjectInputStream(bais);
      TimerHandle handle2 = (TimerHandle)ois.readObject();

      Timer timer2 = handle2.getTimer();
      assertEquals("Timers are not equal", timer1, timer2);

      sleep(1000);
      assertTrue("TimedObject not called", 1 == to.getCallCount());
      assertEquals("Expected no txtimer", 0, service.getTimers().size());
View Full Code Here

      try
      {

         try
         {
            TimerHandle handle = (TimerHandle) entity.createTimerReturnHandle(500);
            fail("TimerHandle should not pass through the remote interface: " + handle);
         }
         catch (Exception e)
         {
            assertTrue("Timer list should be empty", entity.getTimers().size() == 0);
            sleep(1000);
            assertEquals("unexpected call count", 0, entity.getCallCount());
         }

         try
         {
            TimerHandle handle = TimerHandleImpl.parse("[[id=jboss.j2ee:jndiName=test/txtimer/TimerEntity,service=EJB,pk=1],created=10-Apr-2004 20:16:11.000,first=10-Apr-2004 20:16:11.000,periode=0]");
            String retStr = entity.passTimerHandle(handle);
            fail("TimerHandle should not pass through the remote interface: " + retStr);
         }
         catch (Exception e)
         {
View Full Code Here

   {
      try
      {
         ByteArrayInputStream bais = new ByteArrayInputStream(handle);
         ObjectInputStream ois = new ObjectInputStream(bais);
         TimerHandle th = null;
         th = (TimerHandle) ois.readObject();
         ois.close();
         Timer timer = th.getTimer();
         return timer;
      }
      catch(NoSuchObjectLocalException e)
      {
         throw e;
View Full Code Here

            final TimerServiceImpl timerService = (TimerServiceImpl) ejbcomponent.getTimerService();

            final PathAddress address = PathAddress.pathAddress(operation.require(ModelDescriptionConstants.OP_ADDR));
            final String timerId = address.getLastElement().getValue();
            final String timedInvokerObjectId = timerService.getTimedObjectInvoker().getValue().getTimedObjectId();
            final TimerHandle handle = new TimerHandleImpl(timerId, timedInvokerObjectId, timerService);
            try {
                return timerService.getTimer(handle);
            } catch (Exception e) {
                throw new OperationFailedException(e, null);
            }
View Full Code Here

TOP

Related Classes of javax.ejb.TimerHandle

Copyright © 2018 www.massapicom. 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.