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
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected boolean
    check(Flip ff, org.aopalliance.intercept.MethodInvocation mi)
    Call if Flipped based on different parameters of the annotation
    protected String
    getExecutedBeanName(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 the MethodInvocation and passing throug AOP Proxies.
    org.ff4j.FF4j
    Getter accessor for attribute 'ff4j'.
    protected Flip
    getFF4jAnnotation(org.aopalliance.intercept.MethodInvocation mi)
    Pick annotation from method or class.
    protected org.ff4j.core.FlippingExecutionContext
    getFlippingContext(Flip ff, org.aopalliance.intercept.MethodInvocation mi)
    Retriveve FlippingExecutionContext from FF4J or as parameter.
    invoke(org.aopalliance.intercept.MethodInvocation mi)
    protected Object
    invokeAlterBean(org.aopalliance.intercept.MethodInvocation mi, String alterBeanName)
    Invoke another Bean for the current Method.
    protected Object
    invokeAlterClazz(org.aopalliance.intercept.MethodInvocation mi, Flip ff)
    Invoke alter class.
    void
    setFf4j(org.ff4j.FF4j ff4j)
    Setter accessor for attribute 'ff4j'.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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 org.ff4j.core.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 org.ff4j.FF4j getFf4j()
      Getter accessor for attribute 'ff4j'.
      Returns:
      current value of 'ff4j'
    • setFf4j

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