spring-framework / org.springframework.aop.interceptor

Package org.springframework.aop.interceptor

Types

AbstractTraceInterceptor

abstract class AbstractTraceInterceptor : MethodInterceptor, Serializable

Base MethodInterceptor implementation for tracing.

By default, log messages are written to the log for the interceptor class, not the class which is being intercepted. Setting the useDynamicLogger bean property to true causes all log messages to be written to the Log for the target class being intercepted.

Subclasses must implement the invokeUnderTrace method, which is invoked by this class ONLY when a particular invocation SHOULD be traced. Subclasses should write to the Log instance provided.

AsyncExecutionAspectSupport

abstract class AsyncExecutionAspectSupport : BeanFactoryAware

Base class for asynchronous method execution aspects, such as org.springframework.scheduling.annotation.AnnotationAsyncExecutionInterceptor or org.springframework.scheduling.aspectj.AnnotationAsyncExecutionAspect.

Provides support for executor qualification on a method-by-method basis. AsyncExecutionAspectSupport objects must be constructed with a default Executor, but each individual method may further qualify a specific Executor bean to be used when executing it, e.g. through an annotation attribute.

AsyncExecutionInterceptor

open class AsyncExecutionInterceptor : AsyncExecutionAspectSupport, MethodInterceptor, Ordered

AOP Alliance MethodInterceptor that processes method invocations asynchronously, using a given org.springframework.core.task.AsyncTaskExecutor. Typically used with the org.springframework.scheduling.annotation.Async annotation.

In terms of target method signatures, any parameter types are supported. However, the return type is constrained to either void or java.util.concurrent.Future. In the latter case, the Future handle returned from the proxy will be an actual asynchronous Future that can be used to track the result of the asynchronous method execution. However, since the target method needs to implement the same signature, it will have to return a temporary Future handle that just passes the return value through (like Spring's org.springframework.scheduling.annotation.AsyncResult or EJB 3.1's javax.ejb.AsyncResult).

When the return type is java.util.concurrent.Future, any exception thrown during the execution can be accessed and managed by the caller. With void return type however, such exceptions cannot be transmitted back. In that case an AsyncUncaughtExceptionHandler can be registered to process such exceptions.

As of Spring 3.1.2 the AnnotationAsyncExecutionInterceptor subclass is preferred for use due to its support for executor qualification in conjunction with Spring's @Async annotation.

ConcurrencyThrottleInterceptor

open class ConcurrencyThrottleInterceptor : ConcurrencyThrottleSupport, MethodInterceptor, Serializable

Interceptor that throttles concurrent access, blocking invocations if a specified concurrency limit is reached.

Can be applied to methods of local services that involve heavy use of system resources, in a scenario where it is more efficient to throttle concurrency for a specific service rather than restricting the entire thread pool (e.g. the web container's thread pool).

The default concurrency limit of this interceptor is 1. Specify the "concurrencyLimit" bean property to change this value.

CustomizableTraceInterceptor

open class CustomizableTraceInterceptor : AbstractTraceInterceptor

MethodInterceptor implementation that allows for highly customizable method-level tracing, using placeholders.

Trace messages are written on method entry, and if the method invocation succeeds on method exit. If an invocation results in an exception, then an exception message is written. The contents of these trace messages is fully customizable and special placeholders are available to allow you to include runtime information in your log messages. The placeholders available are:

  • $[methodName] - replaced with the name of the method being invoked
  • $[targetClassName] - replaced with the name of the class that is the target of the invocation
  • $[targetClassShortName] - replaced with the short name of the class that is the target of the invocation
  • $[returnValue] - replaced with the value returned by the invocation
  • $[argumentTypes] - replaced with a comma-separated list of the short class names of the method arguments
  • $[arguments] - replaced with a comma-separated list of the String representation of the method arguments
  • $[exception] - replaced with the String representation of any Throwable raised during the invocation
  • $[invocationTime] - replaced with the time, in milliseconds, taken by the method invocation

There are restrictions on which placeholders can be used in which messages: see the individual message properties for details on the valid placeholders.

DebugInterceptor

open class DebugInterceptor : SimpleTraceInterceptor

AOP Alliance MethodInterceptor that can be introduced in a chain to display verbose information about intercepted invocations to the logger.

Logs full invocation details on method entry and method exit, including invocation arguments and invocation count. This is only intended for debugging purposes; use SimpleTraceInterceptor or CustomizableTraceInterceptor for pure tracing purposes.

ExposeBeanNameAdvisors

abstract class ExposeBeanNameAdvisors

Convenient methods for creating advisors that may be used when autoproxying beans created with the Spring IoC container, binding the bean name to the current invocation. May support a bean() pointcut designator with AspectJ.

Typically used in Spring auto-proxying, where the bean name is known at proxy creation time.

ExposeInvocationInterceptor

open class ExposeInvocationInterceptor : MethodInterceptor, PriorityOrdered, Serializable

Interceptor that exposes the current org.aopalliance.intercept.MethodInvocation as a thread-local object. We occasionally need to do this; for example, when a pointcut (e.g. an AspectJ expression pointcut) needs to know the full invocation context.

Don't use this interceptor unless this is really necessary. Target objects should not normally know about Spring AOP, as this creates a dependency on Spring API. Target objects should be plain POJOs as far as possible.

If used, this interceptor will normally be the first in the interceptor chain.

JamonPerformanceMonitorInterceptor

open class JamonPerformanceMonitorInterceptor : AbstractMonitoringInterceptor

Performance monitor interceptor that uses JAMon library to perform the performance measurement on the intercepted method and output the stats. In addition, it tracks/counts exceptions thrown by the intercepted method. The stack traces can be viewed in the JAMon web application.

This code is inspired by Thierry Templier's blog.

PerformanceMonitorInterceptor

open class PerformanceMonitorInterceptor : AbstractMonitoringInterceptor

Simple AOP Alliance MethodInterceptor for performance monitoring. This interceptor has no effect on the intercepted method call.

Uses a StopWatch for the actual performance measuring.

SimpleAsyncUncaughtExceptionHandler

open class SimpleAsyncUncaughtExceptionHandler : AsyncUncaughtExceptionHandler

A default AsyncUncaughtExceptionHandler that simply logs the exception.