private static void configure(Object o, Map<String, ?> config) { PropertiesUtil.populate(o, config, false); }
private static void configure(Object o, Map<String, ?> config) { PropertiesUtil.populate(o, config, false); }
private static void configure(Object o) { PropertiesUtil.populate(o, getConfig(), false); }
private static void configure(Object o) { PropertiesUtil.populate(o, getConfig(), false); }
@Activate protected void activate(ComponentContext context, Map<String, Object> config) { String homeDir = lookup(context, PROP_HOME); if (homeDir != null) { log.info("Initializing the FileBlobStore with homeDir [{}]", homeDir); } BlobStore blobStore = new FileBlobStore(FilenameUtils.concat(homeDir,"datastore")); PropertiesUtil.populate(blobStore, config, false); Dictionary<String, Object> props = new Hashtable<String, Object>(); if (context.getProperties().get(PROP_SPLIT_BLOBSTORE) != null) { props.put(PROP_SPLIT_BLOBSTORE, context.getProperties().get(PROP_SPLIT_BLOBSTORE)); } reg = context.getBundleContext().registerService(new String[]{ BlobStore.class.getName(), GarbageCollectableBlobStore.class.getName() }, blobStore, props); }
@Activate protected void activate(ComponentContext context, Map<String, Object> config) { String homeDir = lookup(context, PROP_HOME); if (homeDir != null) { log.info("Initializing the FileBlobStore with homeDir [{}]", homeDir); } BlobStore blobStore = new FileBlobStore(FilenameUtils.concat(homeDir,"datastore")); PropertiesUtil.populate(blobStore, config, false); Dictionary<String, Object> props = new Hashtable<String, Object>(); if (context.getProperties().get(PROP_SPLIT_BLOBSTORE) != null) { props.put(PROP_SPLIT_BLOBSTORE, context.getProperties().get(PROP_SPLIT_BLOBSTORE)); } reg = context.getBundleContext().registerService(new String[]{ BlobStore.class.getName(), GarbageCollectableBlobStore.class.getName() }, blobStore, props); }
@Activate protected void activate(ComponentContext context, Map<String, Object> config) { String homeDir = lookup(context, PROP_HOME); if (homeDir != null) { log.info("Initializing the FileBlobStore with homeDir [{}]", homeDir); } BlobStore blobStore = new FileBlobStore(FilenameUtils.concat(homeDir,"datastore")); PropertiesUtil.populate(blobStore, config, false); Dictionary<String, Object> props = new Hashtable<String, Object>(); if (context.getProperties().get(PROP_SPLIT_BLOBSTORE) != null) { props.put(PROP_SPLIT_BLOBSTORE, context.getProperties().get(PROP_SPLIT_BLOBSTORE)); } reg = context.getBundleContext().registerService(new String[]{ BlobStore.class.getName(), GarbageCollectableBlobStore.class.getName() }, blobStore, props); }
static S3DataStore createDS(String directory, Properties props) { Properties strippedProperties = new Properties(); Map<String, String> map = Maps.newHashMap(); for (Object key : new HashSet<>(props.keySet())) { String strippedValue = stripValue(props.getProperty((String) key)); strippedProperties.put(key, strippedValue); map.put((String) key, strippedValue); } S3DataStore ds = new S3DataStore(); ds.setProperties(strippedProperties); ds.setPath(directory); PropertiesUtil.populate(ds, map, false); return ds; }
static S3DataStore createDS(String directory, Properties props) { Properties strippedProperties = new Properties(); Map<String, String> map = Maps.newHashMap(); for (Object key : new HashSet<>(props.keySet())) { String strippedValue = stripValue(props.getProperty((String) key)); strippedProperties.put(key, strippedValue); map.put((String) key, strippedValue); } S3DataStore ds = new S3DataStore(); ds.setProperties(strippedProperties); ds.setPath(directory); PropertiesUtil.populate(ds, map, false); return ds; }
log.info("Initializing the DataStore with homeDir [{}]", homeDir); PropertiesUtil.populate(ds, config, false); ds.init(homeDir); this.dataStore = new DataStoreBlobStore(ds, encodeLengthInId, cacheSizeInMB); this.dataStore.setBlobStatsCollector(stats); PropertiesUtil.populate(dataStore, config, false);
@Test(expected = IllegalArgumentException.class) public void testPopulateAndValidate() { Map<String, Object> props = new HashMap<String, Object>(); props.put("something", "foo"); TestBeanA bean = new TestBeanA(); PropertiesUtil.populate(bean, props, true); }
public static DataStore getS3DataStore(String className, Properties props, String homeDir) throws Exception { DataStore ds = Class.forName(className).asSubclass(DataStore.class).newInstance(); PropertiesUtil.populate(ds, Utils.asMap(props), false); // Set the props object if (S3.getName().equals(className)) { ((S3DataStore) ds).setProperties(props); } ds.init(homeDir); return ds; }
public static DataStoreBlobStore getBlobStore(String homeDir) throws Exception { String className = System.getProperty(DS_CLASS_NAME, OakFileDataStore.class.getName()); DataStore ds = Class.forName(className).asSubclass(DataStore.class).newInstance(); PropertiesUtil.populate(ds, getConfig(), false); ds.init(homeDir); return new DataStoreBlobStore(ds); }
private DataStore getAssertCachingFileDataStore(String nasPath, String cachePath) throws RepositoryException { long cacheSize = 100L; Map<String, Object> config = new HashMap<String, Object>(); config.put("repository.home", folder.getRoot().getAbsolutePath()); config.put(FileDataStoreService.CACHE_SIZE, cacheSize); config.put(FileDataStoreService.PATH, nasPath); config.put(FileDataStoreService.CACHE_PATH, cachePath); FileDataStoreService fdsSvc = new FileDataStoreService(); DataStore ds = fdsSvc.createDataStore(context.componentContext(), config); PropertiesUtil.populate(ds, config, false); ds.init(folder.getRoot().getAbsolutePath()); assertTrue("not instance of CachingFDS", ds instanceof CachingFileDataStore); return ds; }
public static CachingFileDataStore createCachingFDS(String path, String cachePath) throws DataStoreException { Properties props = new Properties(); props.setProperty("fsBackendPath", path); CachingFileDataStore ds = new CachingFileDataStore(); ds.setMinRecordLength(10); Map<String, ?> config = DataStoreUtils.getConfig(); props.putAll(config); PropertiesUtil.populate(ds, Maps.fromProperties(props), false); ds.setProperties(props); ds.init(cachePath); return ds; }
protected DataStore createDataStore() throws RepositoryException { CachingFileDataStore ds = null; try { ds = new CachingFileDataStore(); Map<String, ?> config = DataStoreUtils.getConfig(); props.putAll(config); PropertiesUtil.populate(ds, Maps.fromProperties(props), false); ds.setProperties(props); ds.init(dataStoreDir); } catch (Exception e) { e.printStackTrace(); } return ds; }
@Test public void testPopulate() { Map<String, Object> props = new HashMap<String, Object>(); props.put("string", "foo"); props.put("bool", "true"); props.put("integer", "7"); props.put("aLong", "11"); TestBeanA bean = new TestBeanA(); PropertiesUtil.populate(bean, props, false); assertEquals("foo", bean.getString()); assertTrue(bean.getBool()); assertEquals(7, bean.getInteger()); assertEquals(11, bean.getaLong()); }
public static DataStore getAzureDataStore(Properties props, String homeDir) throws Exception { AzureDataStore ds = new AzureDataStore(); PropertiesUtil.populate(ds, Maps.fromProperties(props), false); ds.setProperties(props); ds.init(homeDir); return ds; }
@Before public void setup() throws Exception { if (type == CACHING_FDS) { CachingFileDataStore ds = new CachingFileDataStore(); Properties props = new Properties(); props.setProperty("fsBackendPath", folder.newFolder().getAbsolutePath()); PropertiesUtil.populate(ds, Maps.fromProperties(props), false); ds.setProperties(props); ds.init(folder.newFolder().getAbsolutePath()); dataStore = ds; } else { OakFileDataStore ds = new OakFileDataStore(); ds.init(folder.newFolder().getAbsolutePath()); dataStore = ds; } }
/** * * Test to verify @FileDataStore is returned if cacheSize is not configured. */ @Test public void configFileDataStore() throws Exception { String nasPath = folder.getRoot().getAbsolutePath() + "/NASPath"; String cachePath = folder.getRoot().getAbsolutePath() + "/cachePath"; Map<String, Object> config = new HashMap<String, Object>(); config.put("repository.home", folder.getRoot().getAbsolutePath()); config.put(FileDataStoreService.PATH, nasPath); config.put(FileDataStoreService.CACHE_PATH, cachePath); FileDataStoreService fdsSvc = new FileDataStoreService(); DataStore ds = fdsSvc.createDataStore(context.componentContext(), config); PropertiesUtil.populate(ds, config, false); ds.init(folder.getRoot().getAbsolutePath()); assertTrue("not instance of FileDataStore", ds instanceof FileDataStore); FileDataStore fds = (FileDataStore) ds; assertEquals("path not equal", nasPath, fds.getPath()); }