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 Details

    • FeatureAdvisor

      public FeatureAdvisor()
  • Method Details

    • invoke

      public Object invoke(org.aopalliance.intercept.MethodInvocation mi) throws Throwable
      Specified by:
      invoke in interface org.aopalliance.intercept.MethodInterceptor
      Throws:
      Throwable
    • check

      protected boolean check(Flip ff, org.aopalliance.intercept.MethodInvocation mi)
      Call if Flipped based on different parameters of the annotation
      Parameters:
      ff - annotation over current method
      context -
      Returns:
      if flippinf should be considere
    • getFF4jAnnotation

      protected Flip getFF4jAnnotation(org.aopalliance.intercept.MethodInvocation mi)
      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)
      Retriveve FlippingExecutionContext from FF4J or as parameter.
      Parameters:
      ff - current annotation
      mi - invocation
      Returns:
    • getExecutedClass

      protected Class<?> getExecutedClass(org.aopalliance.intercept.MethodInvocation pMInvoc)
      Find current class based on the MethodInvocation and passing throug AOP Proxies.
      Parameters:
      pMInvoc - current method invocation
      Returns:
      current class of raise error if static
    • getExecutedBeanName

      protected String getExecutedBeanName(org.aopalliance.intercept.MethodInvocation mi)
      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 invocation
      alterBean - 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 invocation
      ff - ff4j annotation
      Returns:
      object returned by the
      Throws:
      Throwable - error during invocation
    • getFf4j

      public FF4j getFf4j()
      Getter accessor for attribute 'ff4j'.
      Returns:
      current value of 'ff4j'
    • setFf4j

      public void setFf4j(FF4j ff4j)
      Setter accessor for attribute 'ff4j'.
      Parameters:
      ff4j - new value for 'ff4j '