当前位置: 首页>>代码示例>>Java>>正文


Java ErrorHandler类代码示例

本文整理汇总了Java中org.springframework.util.ErrorHandler的典型用法代码示例。如果您正苦于以下问题:Java ErrorHandler类的具体用法?Java ErrorHandler怎么用?Java ErrorHandler使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ErrorHandler类属于org.springframework.util包,在下文中一共展示了ErrorHandler类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: invokeListener

import org.springframework.util.ErrorHandler; //导入依赖的package包/类
/**
 * Invoke the given listener with the given event.
 * @param listener the ApplicationListener to invoke
 * @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);
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:22,代码来源:SimpleApplicationEventMulticaster.java

示例2: invokeListener

import org.springframework.util.ErrorHandler; //导入依赖的package包/类
/**
 * Invoke the given listener with the given event.
 * @param listener the ApplicationListener to invoke
 * @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 {
		try {
			listener.onApplicationEvent(event);
		}
		catch (ClassCastException ex) {
			// Possibly a lambda-defined listener which we could not resolve the generic event type for
			LogFactory.getLog(getClass()).debug("Non-matching event type for listener: " + listener, ex);
		}
	}
}
 
开发者ID:txazo,项目名称:spring,代码行数:28,代码来源:SimpleApplicationEventMulticaster.java

示例3: init

import org.springframework.util.ErrorHandler; //导入依赖的package包/类
@PostConstruct
public void init() {
  this.actionMonitor = new ActionMonitor();
  this.detectionTasks = new HashMap<>();
  this.taskScheduler = new ThreadPoolTaskScheduler();
  this.taskScheduler.setPoolSize(10);
  this.taskScheduler.setWaitForTasksToCompleteOnShutdown(true);
  this.taskScheduler.setRemoveOnCancelPolicy(true);
  this.taskScheduler.setErrorHandler(
      new ErrorHandler() {
        protected Logger log = LoggerFactory.getLogger(this.getClass());

        @Override
        public void handleError(Throwable t) {
          log.error(t.getMessage(), t);
        }
      });
  this.taskScheduler.initialize();
}
 
开发者ID:openbaton,项目名称:autoscaling-engine,代码行数:20,代码来源:DetectionManagement.java

示例4: init

import org.springframework.util.ErrorHandler; //导入依赖的package包/类
@PostConstruct
public void init() {
  this.actionMonitor = new ActionMonitor();
  this.executionEngine.setActionMonitor(actionMonitor);
  this.taskScheduler = new ThreadPoolTaskScheduler();
  this.taskScheduler.setPoolSize(10);
  this.taskScheduler.setWaitForTasksToCompleteOnShutdown(true);
  this.taskScheduler.setRemoveOnCancelPolicy(true);
  this.taskScheduler.setErrorHandler(
      new ErrorHandler() {
        protected Logger log = LoggerFactory.getLogger(this.getClass());

        @Override
        public void handleError(Throwable t) {
          log.error(t.getMessage(), t);
        }
      });
  this.taskScheduler.initialize();
}
 
开发者ID:openbaton,项目名称:autoscaling-engine,代码行数:20,代码来源:ExecutionManagement.java

示例5: init

import org.springframework.util.ErrorHandler; //导入依赖的package包/类
@PostConstruct
public void init() {
  this.actionMonitor = new ActionMonitor();
  this.taskScheduler = new ThreadPoolTaskScheduler();
  this.taskScheduler.setPoolSize(10);
  this.taskScheduler.setWaitForTasksToCompleteOnShutdown(true);
  this.taskScheduler.setRemoveOnCancelPolicy(true);
  this.taskScheduler.setErrorHandler(
      new ErrorHandler() {
        protected Logger log = LoggerFactory.getLogger(this.getClass());

        @Override
        public void handleError(Throwable t) {
          log.error(t.getMessage(), t);
        }
      });
  this.taskScheduler.initialize();
}
 
开发者ID:openbaton,项目名称:autoscaling-engine,代码行数:19,代码来源:DecisionManagement.java

示例6: DelegatingErrorHandlingRunnable

import org.springframework.util.ErrorHandler; //导入依赖的package包/类
/**
 * Create a new DelegatingErrorHandlingRunnable.
 * @param delegate the Runnable implementation to delegate to
 * @param errorHandler the ErrorHandler for handling any exceptions
 */
public DelegatingErrorHandlingRunnable(Runnable delegate, ErrorHandler errorHandler) {
	Assert.notNull(delegate, "Delegate must not be null");
	Assert.notNull(errorHandler, "ErrorHandler must not be null");
	this.delegate = delegate;
	this.errorHandler = errorHandler;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:12,代码来源:DelegatingErrorHandlingRunnable.java

示例7: decorateTaskWithErrorHandler

import org.springframework.util.ErrorHandler; //导入依赖的package包/类
/**
 * Decorate the task for error handling. If the provided {@link ErrorHandler}
 * is not {@code null}, it will be used. Otherwise, repeating tasks will have
 * errors suppressed by default whereas one-shot tasks will have errors
 * propagated by default since those errors may be expected through the
 * returned {@link Future}. In both cases, the errors will be logged.
 */
public static DelegatingErrorHandlingRunnable decorateTaskWithErrorHandler(
		Runnable task, ErrorHandler errorHandler, boolean isRepeatingTask) {

	if (task instanceof DelegatingErrorHandlingRunnable) {
		return (DelegatingErrorHandlingRunnable) task;
	}
	ErrorHandler eh = (errorHandler != null ? errorHandler : getDefaultErrorHandler(isRepeatingTask));
	return new DelegatingErrorHandlingRunnable(task, eh);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:17,代码来源:TaskUtils.java

示例8: schedule

import org.springframework.util.ErrorHandler; //导入依赖的package包/类
@Override
public ScheduledFuture<?> schedule(Runnable task, Trigger trigger) {
	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);
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:16,代码来源:ConcurrentTaskScheduler.java

示例9: schedule

import org.springframework.util.ErrorHandler; //导入依赖的package包/类
@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);
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:13,代码来源:ThreadPoolTaskScheduler.java

示例10: invokeErrorHandler

import org.springframework.util.ErrorHandler; //导入依赖的package包/类
/**
 * 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 {
		logger.warn("Execution of JMS message listener failed, and no ErrorHandler has been set.", ex);
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:15,代码来源:AbstractMessageListenerContainer.java

示例11: testErrorHandlers

import org.springframework.util.ErrorHandler; //导入依赖的package包/类
@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);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:11,代码来源:JmsNamespaceHandlerTests.java

示例12: errorHandler

import org.springframework.util.ErrorHandler; //导入依赖的package包/类
/**
 * Register the bean for the custom error handler.
 *
 * @return custom error handler
 */
@Bean
@ConditionalOnMissingBean(ErrorHandler.class)
public ErrorHandler errorHandler() {
    return new ConditionalRejectingErrorHandler(
            new DelayedRequeueExceptionStrategy(amqpProperties.getRequeueDelay()));
}
 
开发者ID:eclipse,项目名称:hawkbit,代码行数:12,代码来源:AmqpConfiguration.java

示例13: listenerContainerFactory

import org.springframework.util.ErrorHandler; //导入依赖的package包/类
@Bean
@ConditionalOnMissingBean(name = "listenerContainerFactory")
public RabbitListenerContainerFactory<SimpleMessageListenerContainer> listenerContainerFactory(
        final SimpleRabbitListenerContainerFactoryConfigurer configurer, final ErrorHandler errorHandler) {
    final ConfigurableRabbitListenerContainerFactory factory = new ConfigurableRabbitListenerContainerFactory(
            amqpProperties.isMissingQueuesFatal(), amqpProperties.getDeclarationRetries(), errorHandler);
    configurer.configure(factory, rabbitConnectionFactory);
    return factory;
}
 
开发者ID:eclipse,项目名称:hawkbit,代码行数:10,代码来源:AmqpConfiguration.java

示例14: taskScheduler

import org.springframework.util.ErrorHandler; //导入依赖的package包/类
@Bean(destroyMethod = "shutdown")
public TaskScheduler taskScheduler() {
	ThreadPoolTaskScheduler scheduler = new ThreadPoolTaskScheduler();
	scheduler.setErrorHandler(new ErrorHandler() {
		@Override
		public void handleError(Throwable t) {
			LogManager.getLogger().error("error while handling job", t);
		}
	});
	scheduler.initialize();
	return scheduler;
}
 
开发者ID:digitalfondue,项目名称:lavagna,代码行数:13,代码来源:PersistenceAndServiceConfig.java

示例15: decorateTaskWithErrorHandler

import org.springframework.util.ErrorHandler; //导入依赖的package包/类
/**
 * Decorates the task for error handling. If the provided
 * {@link ErrorHandler} is not null, it will be used. Otherwise,
 * repeating tasks will have errors suppressed by default whereas
 * one-shot tasks will have errors propagated by default since those
 * errors may be expected through the returned {@link Future}. In both
 * cases, the errors will be logged.
 */
public static DelegatingErrorHandlingRunnable decorateTaskWithErrorHandler(
		Runnable task, ErrorHandler errorHandler, boolean isRepeatingTask) {

	if (task instanceof DelegatingErrorHandlingRunnable) {
		return (DelegatingErrorHandlingRunnable) task;
	}
	ErrorHandler eh = errorHandler != null ? errorHandler : getDefaultErrorHandler(isRepeatingTask);
	return new DelegatingErrorHandlingRunnable(task, eh);
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:18,代码来源:TaskUtils.java


注:本文中的org.springframework.util.ErrorHandler类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。