001
014
015 package com.liferay.portal.spring.aop;
016
017 import com.liferay.portal.kernel.spring.aop.Skip;
018
019 import java.lang.annotation.Annotation;
020
021 import java.util.Collections;
022
023 import org.aopalliance.intercept.MethodInterceptor;
024 import org.aopalliance.intercept.MethodInvocation;
025
026
029 public class SkipAdvice extends AnnotationChainableMethodAdvice<Skip> {
030
031 @Override
032 public Object before(MethodInvocation methodInvocation) throws Throwable {
033 Skip skip = findAnnotation(methodInvocation);
034
035 if (skip != _nullSkip) {
036 MethodInterceptorsBag methodInterceptorsBag =
037 serviceBeanAopCacheManager.getMethodInterceptorsBag(
038 methodInvocation);
039
040 MethodInterceptorsBag newMethodInterceptorsBag =
041 new MethodInterceptorsBag(
042 methodInterceptorsBag.getClassLevelMethodInterceptors(),
043 Collections.<MethodInterceptor>emptyList());
044
045 serviceBeanAopCacheManager.putMethodInterceptorsBag(
046 methodInvocation, newMethodInterceptorsBag);
047
048 ServiceBeanMethodInvocation serviceBeanMethodInvocation =
049 (ServiceBeanMethodInvocation)methodInvocation;
050
051 serviceBeanMethodInvocation.setMethodInterceptors(
052 Collections.<MethodInterceptor>emptyList());
053 }
054
055 return null;
056 }
057
058 @Override
059 public Skip getNullAnnotation() {
060 return _nullSkip;
061 }
062
063 private static Skip _nullSkip = new Skip() {
064
065 @Override
066 public Class<? extends Annotation> annotationType() {
067 return Skip.class;
068 }
069
070 };
071
072 }