Class AnnotationMethodInterceptor
java.lang.Object
org.apache.shiro.aop.MethodInterceptorSupport
org.apache.shiro.aop.AnnotationMethodInterceptor
- All Implemented Interfaces:
MethodInterceptor
- Direct Known Subclasses:
AuthorizingAnnotationMethodInterceptor
MethodInterceptor that inspects a specific annotation on the method invocation before continuing
its execution.
The annotation is acquired from the
MethodInvocation via a
AnnotationResolver instance that may be configured. Unless
overridden, the default AnnotationResolver is a- Since:
- 0.9
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs anAnnotationMethodInterceptorwith theAnnotationHandlerthat will be used to process annotations of a corresponding type.AnnotationMethodInterceptor(AnnotationHandler handler, AnnotationResolver resolver) Constructs anAnnotationMethodInterceptorwith theAnnotationHandlerthat will be used to process annotations of a corresponding type, using the specifiedAnnotationResolverto acquire annotations at runtime. -
Method Summary
Modifier and TypeMethodDescriptionprotected AnnotationReturns the Annotation that this interceptor will process for the specified method invocation.Returns theAnnotationHandlerused to perform authorization behavior based on an annotation discovered at runtime.Returns theAnnotationResolverto use to acquire annotations from intercepted methods at runtime.voidsetHandler(AnnotationHandler handler) Sets theAnnotationHandlerused to perform authorization behavior based on an annotation discovered at runtime.voidsetResolver(AnnotationResolver resolver) Returns theAnnotationResolverto use to acquire annotations from intercepted methods at runtime.booleanReturnstrueif this interceptor supports, that is, should inspect, the specifiedMethodInvocation,falseotherwise.Methods inherited from class org.apache.shiro.aop.MethodInterceptorSupport
getSubjectMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.shiro.aop.MethodInterceptor
invoke
-
Constructor Details
-
AnnotationMethodInterceptor
Constructs anAnnotationMethodInterceptorwith theAnnotationHandlerthat will be used to process annotations of a corresponding type.- Parameters:
handler- the handler to delegate to for processing the annotation.
-
AnnotationMethodInterceptor
Constructs anAnnotationMethodInterceptorwith theAnnotationHandlerthat will be used to process annotations of a corresponding type, using the specifiedAnnotationResolverto acquire annotations at runtime.- Parameters:
handler- the handler to use to process any discovered annotationresolver- the resolver to use to locate/acquire the annotation- Since:
- 1.1
-
-
Method Details
-
getHandler
Returns theAnnotationHandlerused to perform authorization behavior based on an annotation discovered at runtime.- Returns:
- the
AnnotationHandlerused to perform authorization behavior based on an annotation discovered at runtime.
-
setHandler
Sets theAnnotationHandlerused to perform authorization behavior based on an annotation discovered at runtime.- Parameters:
handler- theAnnotationHandlerused to perform authorization behavior based on an annotation discovered at runtime.
-
getResolver
Returns theAnnotationResolverto use to acquire annotations from intercepted methods at runtime. The annotation is then used by thehandlerto perform authorization logic.- Returns:
- the
AnnotationResolverto use to acquire annotations from intercepted methods at runtime. - Since:
- 1.1
-
setResolver
Returns theAnnotationResolverto use to acquire annotations from intercepted methods at runtime. The annotation is then used by thehandlerto perform authorization logic.- Parameters:
resolver- theAnnotationResolverto use to acquire annotations from intercepted methods at runtime.- Since:
- 1.1
-
supports
Returnstrueif this interceptor supports, that is, should inspect, the specifiedMethodInvocation,falseotherwise. The default implementation simply does the following:returngetAnnotation(mi)!= null- Parameters:
mi- theMethodInvocationfor the method being invoked.- Returns:
trueif this interceptor supports, that is, should inspect, the specifiedMethodInvocation,falseotherwise.
-
getAnnotation
Returns the Annotation that this interceptor will process for the specified method invocation. The default implementation acquires the annotation using an annotationresolverusing the internal annotationhandler'sannotationClass.- Parameters:
mi- the MethodInvocation wrapping the Method from which the Annotation will be acquired.- Returns:
- the Annotation that this interceptor will process for the specified method invocation.
-