我正在尝试查找是否可以在非 Web 应用程序中使用 togglz - 就像我们有普通的 java 项目或 java 批处理程序一样。
我尝试在独立应用程序中添加 togglz 库并尝试运行它。
这是我的代码片段 -
import com.feature.MyFeature;
public class Test {
public static void main(String[] args) {
Test t = new Test();
boolean valid=t.validate("CREATE_TEAM");
System.out.println(valid);
}
public boolean validate(String feature){
if (MyFeature.valueOf(feature).isActive()) {
return true;
}
return false;
}
}
它说 -
Exception in thread "main" java.lang.IllegalStateException: Could not find the FeatureManager. For web applications please verify that the TogglzFilter starts up correctly. In other deployment scenarios you will typically have to implement a FeatureManagerProvider as described in the 'Advanced Configuration' chapter of the documentation.
at com.amdocs.switchlite.core.context.FeatureContext.getFeatureManager(FeatureContext.java:53)
at com.feature.MyFeature.isActive(MyFeature.java:20)
at Test.validate(Test.java:22)
at Test.main(Test.java:12)