org.springframework.aop.interceptor.AsyncUncaughtExceptionHandler Java Examples

The following examples show how to use org.springframework.aop.interceptor.AsyncUncaughtExceptionHandler. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AsyncAnnotationAdvisor.java    From java-technology-stack with MIT License 6 votes vote down vote up
/**
 * Create a new {@code AsyncAnnotationAdvisor} for the given task executor.
 * @param executor the task executor to use for asynchronous methods
 * (can be {@code null} to trigger default executor resolution)
 * @param exceptionHandler the {@link AsyncUncaughtExceptionHandler} to use to
 * handle unexpected exception thrown by asynchronous method executions
 * @since 5.1
 * @see AnnotationAsyncExecutionInterceptor#getDefaultExecutor(BeanFactory)
 */
@SuppressWarnings("unchecked")
public AsyncAnnotationAdvisor(
		@Nullable Supplier<Executor> executor, @Nullable Supplier<AsyncUncaughtExceptionHandler> exceptionHandler) {

	Set<Class<? extends Annotation>> asyncAnnotationTypes = new LinkedHashSet<>(2);
	asyncAnnotationTypes.add(Async.class);
	try {
		asyncAnnotationTypes.add((Class<? extends Annotation>)
				ClassUtils.forName("javax.ejb.Asynchronous", AsyncAnnotationAdvisor.class.getClassLoader()));
	}
	catch (ClassNotFoundException ex) {
		// If EJB 3.1 API not present, simply ignore.
	}
	this.advice = buildAdvice(executor, exceptionHandler);
	this.pointcut = buildPointcut(asyncAnnotationTypes);
}
 
Example #2
Source File: AsyncAnnotationBeanPostProcessor.java    From spring-analysis-note with MIT License 5 votes vote down vote up
/**
 * Configure this post-processor with the given executor and exception handler suppliers,
 * applying the corresponding default if a supplier is not resolvable.
 * @since 5.1
 */
public void configure(
		@Nullable Supplier<Executor> executor, @Nullable Supplier<AsyncUncaughtExceptionHandler> exceptionHandler) {

	this.executor = executor;
	this.exceptionHandler = exceptionHandler;
}
 
Example #3
Source File: AsyncTaskExecutePool.java    From springboot-learn with MIT License 5 votes vote down vote up
@Override
public AsyncUncaughtExceptionHandler getAsyncUncaughtExceptionHandler() {// 异步任务中异常处理
    return (ex, method, params) -> {
        logger.error("==========================" + ex.getMessage() + "=======================", ex);
        logger.error("exception method:" + method.getName());
        logger.error("params:" + params);
    };
}
 
Example #4
Source File: AsyncTaskExecutePool.java    From eladmin with Apache License 2.0 5 votes vote down vote up
@Override
public AsyncUncaughtExceptionHandler getAsyncUncaughtExceptionHandler() {
    return (throwable, method, objects) -> {
        log.error("===="+throwable.getMessage()+"====", throwable);
        log.error("exception method:"+method.getName());
    };
}
 
Example #5
Source File: AsyncConfig.java    From yue-library with Apache License 2.0 5 votes vote down vote up
/**
 * 自定义异常处理类
 */
@Override
public AsyncUncaughtExceptionHandler getAsyncUncaughtExceptionHandler() {
	return new AsyncUncaughtExceptionHandler() {
		@Override
		public void handleUncaughtException(Throwable arg0, Method arg1, Object... arg2) {
			log.error("=========================={}=======================", arg0.getMessage(), arg0);
			log.error("exception method: {}", arg1.getName());
			for (Object param : arg2) {
	        	log.error("Parameter value - {}", param);
	        }
		}
	};
}
 
Example #6
Source File: AsyncConfig.java    From Pixiv-Illustration-Collection-Backend with Apache License 2.0 5 votes vote down vote up
@Override
public AsyncUncaughtExceptionHandler getAsyncUncaughtExceptionHandler() {
    return (throwable, method, params) -> {
        try {
            log.error("异步任务异常:方法:{} 参数:{}", method.getName(), objectMapper.writeValueAsString(params));
            log.error(throwable.getMessage(), throwable);
        } catch (JsonProcessingException e) {
            e.printStackTrace();
        }

    };
}
 
Example #7
Source File: AsyncAnnotationAdvisor.java    From spring-analysis-note with MIT License 5 votes vote down vote up
protected Advice buildAdvice(
		@Nullable Supplier<Executor> executor, @Nullable Supplier<AsyncUncaughtExceptionHandler> exceptionHandler) {

	AnnotationAsyncExecutionInterceptor interceptor = new AnnotationAsyncExecutionInterceptor(null);
	interceptor.configure(executor, exceptionHandler);
	return interceptor;
}
 
Example #8
Source File: AsyncTaskExecutePool.java    From sk-admin with Apache License 2.0 5 votes vote down vote up
@Override
public AsyncUncaughtExceptionHandler getAsyncUncaughtExceptionHandler() {
    return (throwable, method, objects) -> {
        log.error("====" + throwable.getMessage() + "====", throwable);
        log.error("exception method:" + method.getName());
    };
}
 
Example #9
Source File: TracedAsyncConfigurer.java    From java-spring-cloud with Apache License 2.0 4 votes vote down vote up
@Override
public AsyncUncaughtExceptionHandler getAsyncUncaughtExceptionHandler() {
  return delegate.getAsyncUncaughtExceptionHandler();
}
 
Example #10
Source File: BladeExecutorConfiguration.java    From blade-tool with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public AsyncUncaughtExceptionHandler getAsyncUncaughtExceptionHandler() {
	return new SimpleAsyncUncaughtExceptionHandler();
}
 
Example #11
Source File: TraderMainConfiguration.java    From java-trader with Apache License 2.0 4 votes vote down vote up
@Override
public AsyncUncaughtExceptionHandler getAsyncUncaughtExceptionHandler() {
    return this;
}
 
Example #12
Source File: AsyncConfiguration.java    From jhipster-microservices-example with Apache License 2.0 4 votes vote down vote up
@Override
public AsyncUncaughtExceptionHandler getAsyncUncaughtExceptionHandler() {
    return new SimpleAsyncUncaughtExceptionHandler();
}
 
Example #13
Source File: AsyncConfiguration.java    From activiti6-boot2 with Apache License 2.0 4 votes vote down vote up
@Override
public AsyncUncaughtExceptionHandler getAsyncUncaughtExceptionHandler() {
    return new SimpleAsyncUncaughtExceptionHandler();
}
 
Example #14
Source File: AsyncTaskExecutorConfiguration.java    From paascloud-master with Apache License 2.0 4 votes vote down vote up
@Override
public AsyncUncaughtExceptionHandler getAsyncUncaughtExceptionHandler() {
	return new SimpleAsyncUncaughtExceptionHandler();
}
 
Example #15
Source File: SkipperServerConfiguration.java    From spring-cloud-skipper with Apache License 2.0 4 votes vote down vote up
@Override
public AsyncUncaughtExceptionHandler getAsyncUncaughtExceptionHandler() {
	return (throwable, method, objects) -> logger.error("Exception thrown in @Async Method " + method.getName(),
			throwable);
}
 
Example #16
Source File: AsyncConfiguration.java    From jhipster-microservices-example with Apache License 2.0 4 votes vote down vote up
@Override
public AsyncUncaughtExceptionHandler getAsyncUncaughtExceptionHandler() {
    return new SimpleAsyncUncaughtExceptionHandler();
}
 
Example #17
Source File: SpringAsyncConfig.java    From TAC with MIT License 4 votes vote down vote up
@Override
public AsyncUncaughtExceptionHandler getAsyncUncaughtExceptionHandler() {
    return new CustomAsyncExceptionHandler();
}
 
Example #18
Source File: Application.java    From Hands-On-Reactive-Programming-in-Spring-5 with MIT License 4 votes vote down vote up
@Override
public AsyncUncaughtExceptionHandler getAsyncUncaughtExceptionHandler() {
   return new SimpleAsyncUncaughtExceptionHandler();
}
 
Example #19
Source File: AsyncConfiguration.java    From TeamDojo with Apache License 2.0 4 votes vote down vote up
@Override
public AsyncUncaughtExceptionHandler getAsyncUncaughtExceptionHandler() {
    return new SimpleAsyncUncaughtExceptionHandler();
}
 
Example #20
Source File: AsyncConfiguration.java    From okta-jhipster-microservices-oauth-example with Apache License 2.0 4 votes vote down vote up
@Override
public AsyncUncaughtExceptionHandler getAsyncUncaughtExceptionHandler() {
    return new SimpleAsyncUncaughtExceptionHandler();
}
 
Example #21
Source File: AsyncConfiguration.java    From okta-jhipster-microservices-oauth-example with Apache License 2.0 4 votes vote down vote up
@Override
public AsyncUncaughtExceptionHandler getAsyncUncaughtExceptionHandler() {
    return new SimpleAsyncUncaughtExceptionHandler();
}
 
Example #22
Source File: AsyncConfiguration.java    From okta-jhipster-microservices-oauth-example with Apache License 2.0 4 votes vote down vote up
@Override
public AsyncUncaughtExceptionHandler getAsyncUncaughtExceptionHandler() {
    return new SimpleAsyncUncaughtExceptionHandler();
}
 
Example #23
Source File: AsyncConfiguration.java    From cola-cloud with MIT License 4 votes vote down vote up
@Override
public AsyncUncaughtExceptionHandler getAsyncUncaughtExceptionHandler() {
    return new SimpleAsyncUncaughtExceptionHandler();
}
 
Example #24
Source File: ThreadPoolConfig.java    From spring-boot-start-current with Apache License 2.0 4 votes vote down vote up
@Override
public AsyncUncaughtExceptionHandler getAsyncUncaughtExceptionHandler () {
    return new SimpleAsyncUncaughtExceptionHandler();
}
 
Example #25
Source File: EnableAsyncTests.java    From java-technology-stack with MIT License 4 votes vote down vote up
@Override
public AsyncUncaughtExceptionHandler getAsyncUncaughtExceptionHandler() {
	return null;
}
 
Example #26
Source File: EnableAsyncTests.java    From java-technology-stack with MIT License 4 votes vote down vote up
@Bean
public AsyncUncaughtExceptionHandler exceptionHandler() {
	return new TestableAsyncUncaughtExceptionHandler();
}
 
Example #27
Source File: ThreadPoolConfig.java    From spring-boot-start-current with Apache License 2.0 4 votes vote down vote up
@Override
public AsyncUncaughtExceptionHandler getAsyncUncaughtExceptionHandler () {
	return new SimpleAsyncUncaughtExceptionHandler();
}
 
Example #28
Source File: EnableAsyncTests.java    From java-technology-stack with MIT License 4 votes vote down vote up
@Bean
public AsyncUncaughtExceptionHandler exceptionHandler() {
	return new TestableAsyncUncaughtExceptionHandler();
}
 
Example #29
Source File: AsyncAnnotationBeanPostProcessorTests.java    From java-technology-stack with MIT License 4 votes vote down vote up
@Override
public AsyncUncaughtExceptionHandler getAsyncUncaughtExceptionHandler() {
	return exceptionHandler();
}
 
Example #30
Source File: AsyncConfiguration.java    From spring-boot-completablefuture with MIT License 4 votes vote down vote up
@Override
public AsyncUncaughtExceptionHandler getAsyncUncaughtExceptionHandler() {
    return new SimpleAsyncUncaughtExceptionHandler();
}