public interface MethodInterceptor
An interceptor will be called instead of the normal method invocation for proxied beans. A typical scenario for an MethodInterceptor is transaction handling:
public Object intercept(Object bean, Method method, Object[] args) throws Exception {
startTransaction();
try {
method.invoke(bean, args);
commitTransaction();
} catch (Exception ex) {
rollbackTransaction();
} finally {
closeTransaction();
}
}
The MethodInterceptor, as any other bean, can enjoy depdendency injection via the @Inject annotation.Intercept| Modifier and Type | Method and Description |
|---|---|
Object |
intercept(Object bean,
Method method,
Object[] args) |
Copyright © 2011-2013 SYSE. All Rights Reserved.