/** * Constructor initializing ff4j with an InMemoryStore using an InputStream. Simplify integration with Android through * <code>Asset</code> */ public FF4j(InputStream xmlFileResourceAsStream) { this.fstore = new InMemoryFeatureStore(xmlFileResourceAsStream); }
/** * Constructor initializing ff4j with an InMemoryStore */ public FF4j(String xmlFile) { this.fstore = new InMemoryFeatureStore(xmlFile); this.pStore = new InMemoryPropertyStore(xmlFile); }
/** {@inheritDoc} **/ protected void postProcess(final BeanDefinitionBuilder definitionBuilder, final Element ff4jTag) { super.postProcess(definitionBuilder, ff4jTag); logger.debug("Initialization from <ff4j:ff4j> TAG"); // If filename is present ff4j will be initialized with both features and properties inmemory. if (StringUtils.hasLength(ff4jTag.getAttribute(ATT_FF4J_FILENAME))) { String fileName = ff4jTag.getAttribute(ATT_FF4J_FILENAME); InMemoryFeatureStore imfs = new InMemoryFeatureStore(fileName); InMemoryPropertyStore imps = new InMemoryPropertyStore(fileName); definitionBuilder.getBeanDefinition().getPropertyValues().addPropertyValue("featureStore", imfs); definitionBuilder.getBeanDefinition().getPropertyValues().addPropertyValue("propertiesStore", imps); logger.debug("... Setting in-memory stores : " + imfs.readAll().size() + " feature(s), " + imps.readAllProperties().size() + " propertie(s)"); } if (StringUtils.hasLength(ff4jTag.getAttribute(ATT_FF4J_AUTOCREATE))) { String autocreate = ff4jTag.getAttribute(ATT_FF4J_AUTOCREATE); logger.debug("... Setting autocreate property to '" + autocreate + "'"); } if (StringUtils.hasLength(ff4jTag.getAttribute(ATT_FF4J_AUTH_MANAGER))) { String authManagerBeanId = ff4jTag.getAttribute(ATT_FF4J_AUTH_MANAGER); RuntimeBeanReference refSolution = new RuntimeBeanReference(authManagerBeanId); definitionBuilder.getBeanDefinition().getPropertyValues().addPropertyValue("authorizationsManager", refSolution); logger.debug("... Setting authorizationManager with " + authManagerBeanId); } logger.debug("... Initialization done"); } }
/** {@inheritDoc} */ @Before public void setUp() throws Exception { ff4j = new FF4j(); ff4j.setFeatureStore(new InMemoryFeatureStore("test-ff4j-features.xml")); ff4j.setPropertiesStore(new InMemoryPropertyStore("test-ff4j-features.xml")); ff4j.setEventRepository(initRepository()); repo = ff4j.getEventRepository(); }