Skip to content
Advertisement

FF4J does not flip when using AOP annotation @Flip in spring project

I’ve injected ff4j following example. Ff4jConfiguration.class:

JavaScript

and application loader was also changed:

JavaScript

my ff4j.xml:

JavaScript

My bean to verify ff4j

JavaScript

In runtime I see ff4j bean injected correctly with correspond properties:

JavaScript

I expect method log2 will be never called, but it is (All used methods were called, none ignored). Can someone help me what I’ve done wrong here please?

Advertisement

Answer

The annotation Flipis meant to be positionned on an Interface and not on bean. The reason is to enforce people to create different implementations for the same method when using AOP. (simpler when cleaning is required later).

I can propose 2 solutions. The first seems obvious but if you don’t have multiple implementations…

JavaScript

The second is to indeed use AOP and you have to :

  1. Add the Autoproxy located in package org.ff4j.aop in your Spring Context. But it’s done already by adding autoconfigure dependency.

  2. Put @Flipannotation on a interface and create different implementations:

Here is a code sample:

JavaScript

Bug has been reproduced and the 2 working solutions are available here : https://github.com/clun/ff4j-samples/tree/master/ff4j-sample-sergii

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement