/** {@inheritDoc} */ @Override public Property<?> readProperty(String name) { assertPropertyExist(name); return properties.get(name); }
/** * Constructor with inputstream fileName. * * @param fileName * fileName present in classPath or on fileSystem. */ public InMemoryPropertyStore(InputStream xmlIN) { loadConf(xmlIN); }
/** * Setter accessor for attribute 'locations'. * * @param locations * new value for 'locations ' */ public void setLocation(String locations) { loadConfFile(locations); }
/** * 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} */ @Override public <T> void createProperty(Property<T> value) { // Check Params assertPropertyNotNull(value); assertPropertyNotExist(value.getName()); // Create properties.put(value.getName(), value); }
/** {@inheritDoc} */ @Override public Configuration subset(String prefix) { Map < String, Property<?>> myProps = ff4jStore().readAllProperties(); PropertyStore ps = new InMemoryPropertyStore(); for (Map.Entry< String, Property<?>> prop : myProps.entrySet()) { if (prop.getKey().startsWith(prefix)) { ps.createProperty(prop.getValue()); } } return new FF4jConfiguration(ps); }
/** {@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(); }
/** * Load configuration through FF4J.vml file. * * @param conf * xml filename */ private void loadConfFile(String conf) { this.fileName = conf; loadConf(getClass().getClassLoader().getResourceAsStream(conf)); }
/** {@inheritDoc} */ @Override public void deleteProperty(String name) { assertPropertyExist(name); // Delete properties.remove(name); }
/** * Constructor with configuration fileName. * * @param fileName * fileName present in classPath or on fileSystem. */ public InMemoryPropertyStore(String fileName) { if (fileName == null || fileName.isEmpty()) { throw new IllegalArgumentException( "fileName is required, cannot be null nor empty : the file must exist in classpath"); } loadConfFile(fileName); }