Package org.springframework.util

Examples of org.springframework.util.ErrorHandler


            this.listenerContainer.shutdown();
            this.listenerContainer.destroy();
        }

        public final ErrorHandler getErrorHandler() {
            return new ErrorHandler() {
                @Override
                public void handleError(Throwable t) {
                    if(t instanceof AmqpConnectException) {
                        LOG.error("AMQP Connection error, marking this connection as failed");
                        onClose(null);
View Full Code Here


            this.listenerContainer.shutdown();
            this.listenerContainer.destroy();
        }

        public final ErrorHandler getErrorHandler() {
            return new ErrorHandler() {
                @Override
                public void handleError(Throwable t) {
                    if(t instanceof AmqpConnectException) {
                        LOG.error("AMQP Connection error, marking this connection as failed");
                        onClose(null);
View Full Code Here

            this.listenerContainer.shutdown();
            this.listenerContainer.destroy();
        }

        public final ErrorHandler getErrorHandler() {
            return new ErrorHandler() {
                @Override
                public void handleError(Throwable t) {
                    if(t instanceof AmqpConnectException) {
                        LOG.error("AMQP Connection error, marking this connection as failed");
                        onClose(null);
View Full Code Here

    try {
      if (this.enterpriseConcurrentScheduler) {
        return new EnterpriseConcurrentTriggerScheduler().schedule(decorateTask(task, true), trigger);
      }
      else {
        ErrorHandler errorHandler = (this.errorHandler != null ? this.errorHandler : TaskUtils.getDefaultErrorHandler(true));
        return new ReschedulingRunnable(task, trigger, this.scheduledExecutor, errorHandler).schedule();
      }
    }
    catch (RejectedExecutionException ex) {
      throw new TaskRejectedException("Executor [" + this.scheduledExecutor + "] did not accept task: " + task, ex);
View Full Code Here

   * @param event the current event to propagate
   * @since 4.1
   */
  @SuppressWarnings({"unchecked", "rawtypes"})
  protected void invokeListener(ApplicationListener listener, ApplicationEvent event) {
    ErrorHandler errorHandler = getErrorHandler();
    if (errorHandler != null) {
      try {
        listener.onApplicationEvent(event);
      }
      catch (Throwable err) {
        errorHandler.handleError(err);
      }
    }
    else {
      listener.onApplicationEvent(event);
    }
View Full Code Here

  @Override
  public ScheduledFuture<?> schedule(Runnable task, Trigger trigger) {
    ScheduledExecutorService executor = getScheduledExecutor();
    try {
      ErrorHandler errorHandler =
          (this.errorHandler != null ? this.errorHandler : TaskUtils.getDefaultErrorHandler(true));
      return new ReschedulingRunnable(task, trigger, executor, errorHandler).schedule();
    }
    catch (RejectedExecutionException ex) {
      throw new TaskRejectedException("Executor [" + executor + "] did not accept task: " + task, ex);
View Full Code Here

   * Invoke the registered ErrorHandler, if any. Log at warn level otherwise.
   * @param ex the uncaught error that arose during JMS processing.
   * @see #setErrorHandler
   */
  protected void invokeErrorHandler(Throwable ex) {
    ErrorHandler errorHandler = getErrorHandler();
    if (errorHandler != null) {
      errorHandler.handleError(ex);
    }
    else if (logger.isWarnEnabled()) {
      logger.warn("Execution of JMS message listener failed, and no ErrorHandler has been set.", ex);
    }
  }
View Full Code Here

      public void onMessage(Message message, Session session) throws JMSException {
        throw theException;
      }
    });

    ErrorHandler errorHandler = mock(ErrorHandler.class);
    this.container.setErrorHandler(errorHandler);
    this.container.afterPropertiesSet();
    this.container.start();

    // manually trigger an Exception with the above bad MessageListener...
View Full Code Here

        listener4.getActivationSpecConfig().getMaxConcurrency());
  }

  @Test
  public void testErrorHandlers() {
    ErrorHandler expected = this.context.getBean("testErrorHandler", ErrorHandler.class);
    ErrorHandler errorHandler1 = getErrorHandler("listener1");
    ErrorHandler errorHandler2 = getErrorHandler("listener2");
    ErrorHandler defaultErrorHandler = getErrorHandler(DefaultMessageListenerContainer.class.getName() + "#0");
    assertSame(expected, errorHandler1);
    assertSame(expected, errorHandler2);
    assertNull(defaultErrorHandler);
  }
View Full Code Here

  }


  public ScheduledFuture schedule(Runnable task, Trigger trigger) {
    try {
      ErrorHandler errorHandler = this.errorHandler != null ?
          this.errorHandler : TaskUtils.getDefaultErrorHandler(true);
      return new ReschedulingRunnable(task, trigger, this.scheduledExecutor, errorHandler).schedule();
    }
    catch (RejectedExecutionException ex) {
      throw new TaskRejectedException("Executor [" + this.scheduledExecutor + "] did not accept task: " + task, ex);
View Full Code Here

TOP

Related Classes of org.springframework.util.ErrorHandler

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.