public abstract class StorageManagerFactory<SM extends StorageManager> extends Object
newInstance() or newInstance(MMBase)
methods to obtain a factory class.| Modifier and Type | Field and Description |
|---|---|
protected Map<String,Object> |
attributes
The map with configuration data
|
protected ChangeManager |
changeManager
The ChangeManager object, used to register/broadcast changes to a node or set of nodes.
|
protected Map<String,String> |
collationMappings |
protected SortedMap<String,String> |
disallowedFields
The map with disallowed fieldnames and (if given) alternates
|
protected CharTransformer |
getSurrogator |
protected MMBase |
mmbase
A reference to the MMBase module
|
protected SearchQueryHandler |
queryHandler
The query handler to use with this factory.
|
protected List<Class<?>> |
queryHandlerClasses
The query handler classes.
|
protected CharTransformer |
setSurrogator |
protected Class<SM> |
storageManagerClass
The class used to instantiate storage managers.
|
protected List<String> |
storeBinaryAsFileObjects
The list with objects of which binary data should not be stored in database
|
protected List<TypeMapping> |
typeMappings
The list with type mappings
|
| Constructor and Description |
|---|
StorageManagerFactory() |
| Modifier and Type | Method and Description |
|---|---|
void |
beginTransaction()
Puts the current thread in a database transaction
|
void |
commit()
Commits the current thread's database transaction
|
protected SM |
createStorageManager() |
Object |
getAttribute(String key)
Obtain an attribute from this factory.
|
Map<String,Object> |
getAttributes()
Retrieve a map of attributes for this factory.
|
String |
getCatalog()
Returns the name of the catalog used by this storage (
null if no catalog is used). |
ChangeManager |
getChangeManager()
Returns the ChangeManager utility instance, used to register and broadcast changes to nodes
in the storage layer.
|
Map<String,String> |
getDisallowedFields()
Returns a map of disallowed field names and their possible alternate values.
|
StorageReader<SM> |
getDocumentReader()
Locates and opens the storage configuration document, if available.
|
CharTransformer |
getGetSurrogator()
Returns a filter which can be used to filter strings taken from storage or
null if none defined. |
String |
getMappedCollation(Collator s)
Given a
Collator return a String such as the storage
implemetnation may use to identify a collation. |
MMBase |
getMMBase()
Return the MMBase module for which the factory was instantiated
|
Scheme |
getScheme(String key)
Obtain a scheme from this factory.
|
Scheme |
getScheme(String key,
String defaultPattern)
Obtain a scheme from this factory.
|
SearchQueryHandler |
getSearchQueryHandler()
Obtains a SearchQueryHandler from the factory.
|
CharTransformer |
getSetSurrogator()
Returns a filter which can be used to filter strings which are to be set into storage or
null if none defined. |
Object |
getStorageIdentifier()
Obtains the identifier for the basic storage element.
|
Object |
getStorageIdentifier(Object mmobject)
Obtains a identifier for an MMBase object.
|
SM |
getStorageManager()
Obtains a StorageManager from the factory.
|
List<String> |
getStoreBinaryAsFileObjects()
Returns a list of objects of which binary data should be stored in a file.
|
int |
getTimeZoneOffset(long time)
Returns the offset which must be used in the database.
|
List<TypeMapping> |
getTypeMappings()
Returns a sorted list of type mappings for this storage.
|
abstract double |
getVersion()
Returns the version of this factory implementation.
|
boolean |
hasOption(String key)
Check whether an option was set.
|
protected void |
init(MMBase mmbase)
Initialize the StorageManagerFactory.
|
protected abstract Object |
instantiateBasicHandler(Class handlerClass)
Instantiate a basic handler object using the specified class.
|
protected abstract Object |
instantiateChainedHandler(Class handlerClass,
Object previousHandler)
Instantiate a chained handler object using the specified class.
|
protected abstract SearchQueryHandler |
instantiateQueryHandler(Object data)
Instantiate a SearchQueryHandler object using the specified object.
|
protected void |
load()
Opens and reads the storage configuration document.
|
static StorageManagerFactory |
newInstance()
Obtain the storage manager factory belonging to the default MMBase module.
|
static StorageManagerFactory |
newInstance(MMBase mmbase)
Obtain the StorageManagerFactory belonging to the indicated MMBase module.
|
boolean |
rollback()
Rolls back the current thread's database transaction
|
void |
setAttribute(String key,
Object value)
Set an attribute of this factory.
|
void |
setAttributes(Map<String,Object> attributes)
Add a map of attributes for this factory.
|
protected void |
setDisallowedFields(Map disallowedFields)
Sets the map of disallowed Fields.
|
void |
setOption(String key,
boolean value)
Set an option to true or false.
|
void |
setScheme(String key,
String pattern)
Set a scheme of this factory, using a string pattern to base the Scheme on.
|
abstract boolean |
supportsTransactions()
Returns whether transactions, and specifically rollback, is supported in the storage layer.
|
protected MMBase mmbase
protected Class<SM extends StorageManager> storageManagerClass
protected List<TypeMapping> typeMappings
protected List<String> storeBinaryAsFileObjects
protected ChangeManager changeManager
protected final SortedMap<String,String> disallowedFields
protected SearchQueryHandler queryHandler
protected List<Class<?>> queryHandlerClasses
protected CharTransformer setSurrogator
getSetSurrogator()protected CharTransformer getSurrogator
getGetSurrogator()public static StorageManagerFactory newInstance(MMBase mmbase) throws StorageException
mmbase - The MMBase module for which to retrieve the storagefactoryStorageException - if the StorageManagerFactory class cannot be located, accessed, or instantiated,
or when something went wrong during configuration of the factorypublic static StorageManagerFactory newInstance() throws StorageException
StorageException - if the StorageManagerFactory class cannot be located, accessed, or instantiated,
or when something went wrong during configuration of the factoryprotected final void init(MMBase mmbase) throws StorageError
newInstance() and newInstance(MMBase).mmbase - the MMBase instance to which this factory belongsStorageError - when something went wrong during configuration of the factory, or when the storage cannot be accessedpublic MMBase getMMBase()
protected abstract Object instantiateBasicHandler(Class handlerClass)
handlerClass - the class to instantuate teh object withprotected abstract Object instantiateChainedHandler(Class handlerClass, Object previousHandler)
handlerClass - the class to instantuate teh object withpreviousHandler - a handler thatw a sinstantiated previously.
this handler should be passed to the new handler class during or
after constrcution, so the ne whandler can 'chain' any events it cannot
handle to this class.protected abstract SearchQueryHandler instantiateQueryHandler(Object data)
data - the object to instantuate a SearchQueryHandler object withprotected void load()
throws StorageException
StorageException - if the storage could not be accessed or necessary configuration data is missing or invalidprotected SM createStorageManager() throws StorageException
StorageExceptionpublic SM getStorageManager() throws StorageException
StorageException - when the storagemanager cannot be createdpublic SearchQueryHandler getSearchQueryHandler() throws StorageException
StorageException - when the handler cannot be createdpublic StorageReader<SM> getDocumentReader() throws StorageException
StorageException - if something went wrong while obtaining the document readerpublic Map<String,Object> getAttributes()
public void setAttributes(Map<String,Object> attributes)
attributes - the map of attributes to addpublic Object getAttribute(String key)
key - the key of the attributepublic void setAttribute(String key, Object value)
null value.key - the key of the attributevalue - the value of the attributepublic Scheme getScheme(String key)
key - the key of the attributepublic Scheme getScheme(String key, String defaultPattern)
key - the key of the attributedefaultPattern - the pattern to use for the default scheme, null if there is no defaultnull if there is no schemepublic void setScheme(String key, String pattern)
key - the key of the schemepattern - the pattern to use for the schemepublic boolean hasOption(String key)
key - the key of the optiontrue if the option was setpublic void setOption(String key, boolean value)
key - the key of the optionvalue - the value of the option (true or false)public List<TypeMapping> getTypeMappings()
public String getMappedCollation(Collator s)
Collator return a String such as the storage
implemetnation may use to identify a collation. E.g. MySql would like something like
'utf8_danish_ci'. Internally, MMBase uses strings as defined by LocaleCollator to identify collators.public List<String> getStoreBinaryAsFileObjects()
public Map<String,String> getDisallowedFields()
protected void setDisallowedFields(Map disallowedFields)
public Object getStorageIdentifier() throws StorageException
StorageException - if the object cannot be given a valid identifierpublic Object getStorageIdentifier(Object mmobject) throws StorageException
mmobject - the MMBase objectyStorageException - if the object cannot be given a valid identifierStorablepublic ChangeManager getChangeManager()
public String getCatalog()
null if no catalog is used).public abstract double getVersion()
public abstract boolean supportsTransactions()
true if trasnactions are supportedpublic CharTransformer getGetSurrogator()
null if none defined.public CharTransformer getSetSurrogator()
null if none defined.public int getTimeZoneOffset(long time)
time - The time at which it is evaluated (summer time issues)public void beginTransaction()
throws StorageException
IllegalStateException - if the current thread already in transactionStorageExceptionpublic void commit()
throws StorageException
IllegalStateException - if the current thread not in a transactionStorageExceptionpublic boolean rollback()
throws StorageException
IllegalStateException - if the current thread not in a transactionStorageExceptionMMBase 1.9-SNAPSHOT - ${javadoctimestamp}