Package org.ff4j.aop
Class FeatureAdvisor
java.lang.Object
org.ff4j.aop.FeatureAdvisor
- All Implemented Interfaces:
org.aopalliance.aop.Advice,org.aopalliance.intercept.Interceptor,org.aopalliance.intercept.MethodInterceptor
@Component("ff.advisor")
public class FeatureAdvisor
extends Object
implements org.aopalliance.intercept.MethodInterceptor
At runtime check presence of annotation @{Flip}, then evaluate if the related feature id is enabled.
If the feature is enabled, the implementation is route to the correct implementation.
- Author:
- Cedrick LUNVEN (@clunven)
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanCall if Flipped based on different parameters of the annotationprotected StringgetExecutedBeanName(org.aopalliance.intercept.MethodInvocation mi) Find bean name related to current method invocation.protected Class<?> getExecutedClass(org.aopalliance.intercept.MethodInvocation pMInvoc) Find current class based on theMethodInvocationand passing throug AOP Proxies.getFf4j()Getter accessor for attribute 'ff4j'.protected FlipgetFF4jAnnotation(org.aopalliance.intercept.MethodInvocation mi) Pick annotation from method or class.protected FlippingExecutionContextgetFlippingContext(Flip ff, org.aopalliance.intercept.MethodInvocation mi) RetriveveFlippingExecutionContextfrom FF4J or as parameter.invoke(org.aopalliance.intercept.MethodInvocation mi) protected ObjectinvokeAlterBean(org.aopalliance.intercept.MethodInvocation mi, String alterBeanName) Invoke another Bean for the current Method.protected ObjectinvokeAlterClazz(org.aopalliance.intercept.MethodInvocation mi, Flip ff) Invoke alter class.voidSetter accessor for attribute 'ff4j'.
-
Constructor Details
-
FeatureAdvisor
public FeatureAdvisor()
-
-
Method Details
-
invoke
- Specified by:
invokein interfaceorg.aopalliance.intercept.MethodInterceptor- Throws:
Throwable
-
check
Call if Flipped based on different parameters of the annotation- Parameters:
ff- annotation over current methodcontext-- Returns:
- if flippinf should be considere
-
getFF4jAnnotation
Pick annotation from method or class.- Parameters:
method- current method- Returns:
- the associated annotation
-
getFlippingContext
protected FlippingExecutionContext getFlippingContext(Flip ff, org.aopalliance.intercept.MethodInvocation mi) RetriveveFlippingExecutionContextfrom FF4J or as parameter.- Parameters:
ff- current annotationmi- invocation- Returns:
-
getExecutedClass
Find current class based on theMethodInvocationand passing throug AOP Proxies.- Parameters:
pMInvoc- current method invocation- Returns:
- current class of raise error if static
-
getExecutedBeanName
Find bean name related to current method invocation.- Parameters:
pMInvoc- current method invocation- Returns:
- bean name related to this method
-
invokeAlterBean
protected Object invokeAlterBean(org.aopalliance.intercept.MethodInvocation mi, String alterBeanName) throws Throwable Invoke another Bean for the current Method.- Parameters:
mi- current method invocationalterBean- target bean- Returns:
- return of invocation
- Throws:
Throwable- erros occured
-
invokeAlterClazz
protected Object invokeAlterClazz(org.aopalliance.intercept.MethodInvocation mi, Flip ff) throws Throwable Invoke alter class.- Parameters:
mi- method invocationff- ff4j annotation- Returns:
- object returned by the
- Throws:
Throwable- error during invocation
-
getFf4j
Getter accessor for attribute 'ff4j'.- Returns:
- current value of 'ff4j'
-
setFf4j
Setter accessor for attribute 'ff4j'.- Parameters:
ff4j- new value for 'ff4j '
-