public abstract class StorageServiceBase<SOBJ_TYPE extends SObject> extends Object implements IStorageService
The implementation base of IStorageService
IStorageService.f| Modifier and Type | Field and Description |
|---|---|
protected Map<String,String> |
conf |
static String |
CONF_GET_META_ONLY
Get Meta Data only
|
static String |
CONF_GET_NO_GET
For certain case for example, gallery application, it doesn’t need the GET operation because end user can access the object directly from aws’ static web service
|
static String |
CONF_KEY_NAME_PROVIDER
User supplied
KeyNameProvider |
static String |
CONF_STATIC_WEB_ENDPOINT
The static URL to retrieve cloud object
|
static String |
CONF_STORE_SUFFIX
Whether it shall ignore the suffix in the key or not
|
protected String |
contextPath |
protected KeyGenerator |
keygen |
protected static org.osgl.logging.Logger |
logger |
protected Map<String,IStorageService> |
subFolders |
CONF_CONTEXT_PATH, CONF_ID, CONF_KEY_GEN, DEFAULT, VERSION| Constructor and Description |
|---|
StorageServiceBase(Map<String,String> conf,
Class<SOBJ_TYPE> sobjType) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
configure(Map<String,String> conf) |
protected void |
configure(Map<String,String> conf,
String prefix) |
String |
contextPath()
alias of
IStorageService.getContextPath() |
protected IStorageService |
createSubFolder(String path) |
protected abstract InputStream |
doGetInputStream(String fullPath)
Returns the input stream from fullPath specified.
|
protected abstract Map<String,String> |
doGetMeta(String fullPath)
Returns the meta attributes from fullPath specified.
|
protected abstract void |
doPut(String fullPath,
ISObject stuff,
Map<String,String> attrs)
Put the storage object specified by fullPath into the storage service.
|
protected abstract void |
doRemove(String fullPath)
Remove the storage object specified by fullPath.
|
ISObject |
forceGet(String key)
Force retrieving the stuff with content from storage without regarding to the configuration
|
ISObject |
get(String key)
Retrieve the stuff from the storage by key
|
protected String |
getConfValue(Map<String,String> conf,
String key,
String def) |
String |
getContextPath()
Return the context path.
|
ISObject |
getFull(String key)
Force retrieving the stuff with content from storage without regarding to the configuration
|
String |
getKey()
Returns a full path key with a generated unique key name
|
String |
getKey(String keyName)
Returns the full path key from the key name
|
ISObject |
getLazy(String key,
Map<String,String> attrs)
Returns lazy SObject with attributes set.
|
protected Map<String,String> |
getMeta(String key) |
protected Map<String,String> |
getMeta(String key,
boolean force) |
String |
getStaticWebEndpoint()
Return the static web endpoint configured
|
String |
getUrl(String key)
Return the URL to access a stored resource by key
|
String |
id()
Return the ID of the service.
|
boolean |
isManaged(ISObject sobj)
Report if a
storage object is managed by this service |
protected String |
keyWithContextPath(String key) |
ISObject |
loadContent(ISObject sobj)
Load content of an sobject.
|
protected abstract StorageServiceBase |
newService(Map<String,String> conf) |
protected abstract ISObject |
newSObject(String key) |
ISObject |
put(String key,
ISObject stuff)
Update the stuff in the storage.
|
void |
remove(String key)
Remove the file from the storage by key and return it to caller.
|
void |
setKeyGenerator(KeyGenerator keygen)
Allow framework to set the
KeyGenerator directly |
void |
setKeyNameProvider(KeyNameProvider keyNameProvider)
Allow framework to set the
KeyNameProvider directly |
IStorageService |
subFolder(String path)
Returns a storage service whose root is a sub folder of this storage service
|
protected static org.osgl.logging.Logger logger
public static final String CONF_GET_NO_GET
For certain case for example, gallery application, it doesn’t need the GET operation because end user can access the object directly from aws’ static web service
public static final String CONF_GET_META_ONLY
Get Meta Data only
public static final String CONF_STATIC_WEB_ENDPOINT
The static URL to retrieve cloud object
public static final String CONF_STORE_SUFFIX
Whether it shall ignore the suffix in the key or not
public static final String CONF_KEY_NAME_PROVIDER
User supplied KeyNameProvider
protected KeyGenerator keygen
protected String contextPath
protected Map<String,IStorageService> subFolders
public void setKeyNameProvider(KeyNameProvider keyNameProvider)
Allow framework to set the KeyNameProvider directly
keyNameProvider - the key name provider instancepublic void setKeyGenerator(KeyGenerator keygen)
Allow framework to set the KeyGenerator directly
keygen - the key generator instancepublic String id()
IStorageServiceReturn the ID of the service.
id in interface IStorageServicepublic String contextPath()
IStorageServicealias of IStorageService.getContextPath()
contextPath in interface IStorageServicepublic String getKey(String keyName)
Returns the full path key from the key name
getKey in interface IStorageServicekeyName - the key name (which does not contains the hierarchical path)public String getKey()
Returns a full path key with a generated unique key name
getKey in interface IStorageServicepublic ISObject forceGet(String key)
IStorageServiceForce retrieving the stuff with content from storage without regarding to the configuration
forceGet in interface IStorageServiceIStorageService.getFull(String)public ISObject getLazy(String key, Map<String,String> attrs)
IStorageServiceReturns lazy SObject with attributes set. This method is useful when user application choose to store attributes and key of SObject into database, and lazy load SObject content later one by calling IStorageService.loadContent(ISObject)
getLazy in interface IStorageServicepublic String getContextPath()
IStorageServiceReturn the context path. A context path is the path from where all the storage should happen. By default context path is ""
getContextPath in interface IStorageServicepublic String getStaticWebEndpoint()
IStorageServiceReturn the static web endpoint configured
getStaticWebEndpoint in interface IStorageServicepublic IStorageService subFolder(String path)
IStorageServiceReturns a storage service whose root is a sub folder of this storage service
subFolder in interface IStorageServicepath - the path to sub folderpublic final ISObject get(String key)
IStorageServiceRetrieve the stuff from the storage by key
If file cannot be find by key, then null is returned
get in interface IStorageServicepublic final ISObject getFull(String key)
IStorageServiceForce retrieving the stuff with content from storage without regarding to the configuration
getFull in interface IStorageServiceIStorageService.loadContent(ISObject)public ISObject loadContent(ISObject sobj)
IStorageServiceLoad content of an sobject. If the content is already loaded, then the object should be returned directly
loadContent in interface IStorageServicepublic ISObject put(String key, ISObject stuff)
IStorageServiceUpdate the stuff in the storage. If the existing file cannot be find in the storage then it will be added.
put in interface IStorageServicepublic boolean isManaged(ISObject sobj)
IStorageServiceReport if a storage object is managed by this service
isManaged in interface IStorageServicesobj - the sobjecttrue if the sobject is managed by this servicepublic String getUrl(String key)
IStorageServiceReturn the URL to access a stored resource by key
getUrl in interface IStorageServiceprotected final IStorageService createSubFolder(String path)
public final void remove(String key)
IStorageServiceRemove the file from the storage by key and return it to caller.
remove in interface IStorageServiceprotected abstract void doRemove(String fullPath)
Remove the storage object specified by fullPath. The fullPath is composed of * contextPath() * ISObject.getKey()
fullPath - the full path to locate the storage objectprotected abstract Map<String,String> doGetMeta(String fullPath)
Returns the meta attributes from fullPath specified. The fullPath is composed of * contextPath() * ISObject.getKey()
fullPath - the full path to locate the storage objectprotected abstract InputStream doGetInputStream(String fullPath)
Returns the input stream from fullPath specified. The fullPath is composed of * contextPath() * ISObject.getKey()
fullPath - the full path to locate the storage objectprotected abstract void doPut(String fullPath, ISObject stuff, Map<String,String> attrs)
Put the storage object specified by fullPath into the storage service. The fullPath is composed of * contextPath() * ISObject.getKey()
fullPath - the full path to locate the storage objectattrs - the meta attributes of the storage objectprotected abstract StorageServiceBase newService(Map<String,String> conf)
Copyright © 2013–2017 OSGL (Open Source General Library). All rights reserved.