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 if (methodInterceptorsBag == null) {
041 return null;
042 }
043
044 MethodInterceptorsBag newMethodInterceptorsBag =
045 new MethodInterceptorsBag(
046 methodInterceptorsBag.getClassLevelMethodInterceptors(),
047 Collections.<MethodInterceptor>emptyList());
048
049 serviceBeanAopCacheManager.putMethodInterceptorsBag(
050 methodInvocation, newMethodInterceptorsBag);
051
052 ServiceBeanMethodInvocation serviceBeanMethodInvocation =
053 (ServiceBeanMethodInvocation)methodInvocation;
054
055 serviceBeanMethodInvocation.setMethodInterceptors(
056 Collections.<MethodInterceptor>emptyList());
057 }
058
059 return null;
060 }
061
062 @Override
063 public Skip getNullAnnotation() {
064 return _nullSkip;
065 }
066
067 private static Skip _nullSkip = new Skip() {
068
069 @Override
070 public Class<? extends Annotation> annotationType() {
071 return Skip.class;
072 }
073
074 };
075
076 }