Examples of TimerImpl


Examples of org.jboss.as.ejb3.timerservice.TimerImpl

        super.registerOperations(resourceRegistration);
        resourceRegistration.registerOperationHandler(SUSPEND, new AbstractTimerHandler() {

            @Override
            void executeRuntime(OperationContext context, ModelNode operation) throws OperationFailedException {
                final TimerImpl timer = getTimer(context, operation);
                timer.suspend();
                context.completeStep(new OperationContext.RollbackHandler() {

                    @Override
                    public void handleRollback(OperationContext context, ModelNode operation) {
                        timer.scheduleTimeout(true);
                    }
                });
            }
        });

        resourceRegistration.registerOperationHandler(ACTIVATE, new AbstractTimerHandler() {

            @Override
            void executeRuntime(OperationContext context, ModelNode operation) throws OperationFailedException {
                final TimerImpl timer = getTimer(context, operation);
                if (!timer.isActive()) {
                    timer.scheduleTimeout(true);
                    context.completeStep(new OperationContext.RollbackHandler() {

                        @Override
                        public void handleRollback(OperationContext context, ModelNode operation) {
                            timer.suspend();
                        }
                    });
                } else {
                    throw EjbLogger.ROOT_LOGGER.timerIsActive(timer);
                }
            }
        });

        resourceRegistration.registerOperationHandler(CANCEL, new AbstractTimerHandler() {

            @Override
            void executeRuntime(OperationContext context, ModelNode operation) throws OperationFailedException {
                final TimerImpl timer = getTimer(context, operation);
                // this is TX aware
                timer.cancel();
                context.completeStep(OperationContext.RollbackHandler.NOOP_ROLLBACK_HANDLER);
            }
        });

        resourceRegistration.registerOperationHandler(TRIGGER, new AbstractTimerHandler() {

            @Override
            void executeRuntime(OperationContext context, ModelNode operation) throws OperationFailedException {
                // This will invoke timer in 'management-handler-thread'
                final TimerImpl timer = getTimer(context, operation);
                timer.invoke();
                context.completeStep(OperationContext.RollbackHandler.NOOP_ROLLBACK_HANDLER);
            }
        });
    }
View Full Code Here

Examples of org.jboss.as.ejb3.timerservice.TimerImpl

            final String opName = operation.require(ModelDescriptionConstants.OP).asString();
            if (!opName.equals(ModelDescriptionConstants.READ_ATTRIBUTE_OPERATION)) {
                throw EjbLogger.ROOT_LOGGER.unknownOperations(opName);
            }

            final TimerImpl timer = getTimer(context, operation);

            if(timer != null) {
                //the timer can expire at any point, so protect against an NPE
                readAttribute(timer, context.getResult());
            }
View Full Code Here

Examples of org.jboss.as.ejb3.timerservice.TimerImpl

     * before calling the timeout method for the current timeout.
     * </p>
     */
    @Override
    public void run() {
        final TimerImpl timer = timerService.getTimer(timerId);
        try {
            if (cancelled) {
                ROOT_LOGGER.debug("Timer task was cancelled for " + timer);
                return;
            }

            Date now = new Date();
            if (ROOT_LOGGER.isDebugEnabled()) {
                ROOT_LOGGER.debug("Timer task invoked at: " + now + " for timer " + timer);
            }

            // If a retry thread is in progress, we don't want to allow another
            // interval to execute until the retry is complete. See JIRA-1926.
            if (timer.isInRetry()) {
                ROOT_LOGGER.skipInvokeTimeoutDuringRetry(timer, now);
                // compute the next timeout, See JIRA AS7-2995.
                timer.setNextTimeout(calculateNextTimeout(timer));
                timerService.persistTimer(timer, false);
                scheduleTimeoutIfRequired(timer);
                return;
            }

            // Check whether the timer is running local
            // If the recurring timer running longer than the interval is, we don't want to allow another
            // execution until it is complete. See JIRA AS7-3119
            if (timer.getState() == TimerState.IN_TIMEOUT || timer.getState() == TimerState.RETRY_TIMEOUT) {
                ROOT_LOGGER.skipOverlappingInvokeTimeout(timer, now);
                timer.setNextTimeout(this.calculateNextTimeout(timer));
                timerService.persistTimer(timer, false);
                scheduleTimeoutIfRequired(timer);
                return;
            }

            // Check whether we want to run the timer
            if(!timerService.shouldRun(timer)) {
                ROOT_LOGGER.debugf("Skipping execution of timer for %s as it is being run on another node or the execution is suppressed by configuration", timer.getTimedObjectId());
                timer.setNextTimeout(calculateNextTimeout(timer));
                scheduleTimeoutIfRequired(timer);
                return;
            }

            //we lock the timer for this check, because if a cancel is in progress then
            //we do not want to do the isActive check, but wait for the cancelling transaction to finish
            //one way or another
            timer.lock();
            try {
                if (!timer.isActive()) {
                    ROOT_LOGGER.debug("Timer is not active, skipping this scheduled execution at: " + now + "for " + timer);
                    return;
                }
                // set the current date as the "previous run" of the timer.
                timer.setPreviousRun(new Date());
                Date nextTimeout = this.calculateNextTimeout(timer);
                timer.setNextTimeout(nextTimeout);
                // change the state to mark it as in timeout method
                timer.setTimerState(TimerState.IN_TIMEOUT);

                // persist changes
                timerService.persistTimer(timer, false);

            } finally {
                timer.unlock();
            }
            try {
                // invoke timeout
                this.callTimeout(timer);
            } catch (BeanRemovedException e) {
                ROOT_LOGGER.debugf("Removing timer %s as EJB has been removed ", timer);
                timer.cancel();
            } catch (Exception e) {
                ROOT_LOGGER.errorInvokeTimeout(timer, e);
                try {
                    ROOT_LOGGER.timerRetried(timer);
                    retryTimeout(timer);
View Full Code Here

Examples of org.jboss.as.ejb3.timerservice.TimerImpl

     */
    public void removeAllTimers() {
        //cancel all timers for this entity
        for (final Timer timer : getComponent().getTimerService().getTimers()) {
            if (timer instanceof TimerImpl) {
                TimerImpl timerImpl = (TimerImpl) timer;
                if (timerImpl.getPrimaryKey() != null && timerImpl.getPrimaryKey().equals(getPrimaryKey())) {
                    timer.cancel();
                }
            }
        }
    }
View Full Code Here

Examples of org.jboss.as.ejb3.timerservice.TimerImpl

     */
    public void removeAllTimers() {
        //cancel all timers for this entity
        for (final Timer timer : getComponent().getTimerService().getTimers()) {
            if (timer instanceof TimerImpl) {
                TimerImpl timerImpl = (TimerImpl) timer;
                if (timerImpl.getPrimaryKey() != null && timerImpl.getPrimaryKey().equals(getPrimaryKey())) {
                    timer.cancel();
                }
            }
        }
    }
View Full Code Here

Examples of org.jboss.as.ejb3.timerservice.TimerImpl

     */
    public void removeAllTimers() {
        //cancel all timers for this entity
        for (final Timer timer : getComponent().getTimerService().getTimers()) {
            if (timer instanceof TimerImpl) {
                TimerImpl timerImpl = (TimerImpl) timer;
                if (timerImpl.getPrimaryKey() != null && timerImpl.getPrimaryKey().equals(getPrimaryKey())) {
                    timer.cancel();
                }
            }
        }
    }
View Full Code Here

Examples of org.jboss.as.ejb3.timerservice.TimerImpl

     */
    public void removeAllTimers() {
        //cancel all timers for this entity
        for (final Timer timer : getComponent().getTimerService().getTimers()) {
            if (timer instanceof TimerImpl) {
                TimerImpl timerImpl = (TimerImpl) timer;
                if (timerImpl.getPrimaryKey() != null && timerImpl.getPrimaryKey().equals(getPrimaryKey())) {
                    timer.cancel();
                }
            }
        }
    }
View Full Code Here

Examples of org.jboss.as.ejb3.timerservice.TimerImpl

     */
    public void removeAllTimers() {
        //cancel all timers for this entity
        for (final Timer timer : getComponent().getTimerService().getTimers()) {
            if (timer instanceof TimerImpl) {
                TimerImpl timerImpl = (TimerImpl) timer;
                if (timerImpl.getPrimaryKey() != null && timerImpl.getPrimaryKey().equals(getPrimaryKey())) {
                    timer.cancel();
                }
            }
        }
    }
View Full Code Here

Examples of org.jboss.ejb.txtimer.TimerImpl

         {
            transactionManager.begin();
            tx = transactionManager.getTransaction();
         }

         TimerImpl txtimer = (TimerImpl) timer;
         tx.registerSynchronization(txtimer);
      }
      catch (Exception e)
      {
         throw new EJBException("Cannot register timer with Tx", e);
View Full Code Here

Examples of org.jbpm.pvm.internal.job.TimerImpl

  }

  // timers ///////////////////////////////////////////////////////////////////

  protected TimerImpl newTimer() {
    return new TimerImpl();
  }
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.