return binaryStorage.getLong(FieldName.MINIMUM_STRING_SIZE, getMinimumBinarySizeInBytes());
}
public BinaryStore getBinaryStore() throws Exception {
String type = getType();
BinaryStore store = null;
if (type.equalsIgnoreCase("transient")) {
store = TransientBinaryStore.get();
} else if (type.equalsIgnoreCase("file")) {
String directory = binaryStorage.getString(FieldName.DIRECTORY);
assert directory != null;
File dir = new File(directory);
store = FileSystemBinaryStore.create(dir);
} else if (type.equalsIgnoreCase("database")) {
String driverClass = binaryStorage.getString(FieldName.JDBC_DRIVER_CLASS);
String connectionURL = binaryStorage.getString(FieldName.CONNECTION_URL);
String username = binaryStorage.getString(FieldName.USER_NAME);
String password = binaryStorage.getString(FieldName.USER_PASSWORD);
String dataSourceJndi = binaryStorage.getString(FieldName.DATA_SOURCE_JNDI_NAME);
if (StringUtil.isBlank(dataSourceJndi)) {
// Use the connection properties ...
store = new DatabaseBinaryStore(driverClass, connectionURL, username, password);
} else {
// Use the DataSource in JNDI ...
store = new DatabaseBinaryStore(dataSourceJndi);
}
} else if (type.equalsIgnoreCase("cache")) {
String metadataCacheName = binaryStorage.getString(FieldName.METADATA_CACHE_NAME, getName());
String blobCacheName = binaryStorage.getString(FieldName.DATA_CACHE_NAME, getName());
String cacheConfiguration = binaryStorage.getString(FieldName.CACHE_CONFIGURATION); // may be null
int chunkSize = binaryStorage.getInteger(FieldName.CHUNK_SIZE, InfinispanBinaryStore.DEFAULT_CHUNK_SIZE);
boolean dedicatedCacheContainer = false;
if (cacheConfiguration == null) {
cacheConfiguration = getCacheConfiguration();
} else {
dedicatedCacheContainer = true;
}
CacheContainer cacheContainer = getCacheContainer(cacheConfiguration);
// String cacheTransactionManagerLookupClass = binaryStorage.getString(FieldName.CACHE_TRANSACTION_MANAGER_LOOKUP,
// Default.CACHE_TRANSACTION_MANAGER_LOOKUP);
store = new InfinispanBinaryStore(cacheContainer, dedicatedCacheContainer, metadataCacheName, blobCacheName,
chunkSize);
} else if (type.equalsIgnoreCase("composite")) {
Map<String, BinaryStore> binaryStores = new LinkedHashMap<String, BinaryStore>();
Document binaryStoresConfiguration = binaryStorage.getDocument(FieldName.COMPOSITE_STORE_NAMED_BINARY_STORES);
for (String sourceName : binaryStoresConfiguration.keySet()) {
Document binaryStoreConfig = binaryStoresConfiguration.getDocument(sourceName);
binaryStores.put(sourceName, new BinaryStorage(binaryStoreConfig).getBinaryStore());
}
// must have at least one named store
if (binaryStores.isEmpty()) {
throw new BinaryStoreException(JcrI18n.missingVariableValue.text("namedStores"));
}
store = new CompositeBinaryStore(binaryStores);
} else if (type.equalsIgnoreCase("custom")) {
classname = binaryStorage.getString(FieldName.CLASSNAME);
classPath = binaryStorage.getString(FieldName.CLASSLOADER);
// class name is mandatory
if (StringUtil.isBlank(classname)) {
throw new BinaryStoreException(JcrI18n.missingVariableValue.text("classname"));
}
store = createInstance();
setTypeFields(store, binaryStorage);
}
if (store == null) store = TransientBinaryStore.get();
store.setMinimumBinarySizeInBytes(getMinimumBinarySizeInBytes());
return store;
}