org.mmbase.storage.implementation.database
Class DatabaseStorageManagerFactory

java.lang.Object
  extended byorg.mmbase.storage.StorageManagerFactory
      extended byorg.mmbase.storage.implementation.database.DatabaseStorageManagerFactory

public class DatabaseStorageManagerFactory
extends StorageManagerFactory

A storage manager factory for database storages. This factory sets up a datasource for connecting to the database. If you specify the datasource URI in the 'dataource' property in mmbaseroot.xml configuration file, the factory attempts to obtain the datasource from the appplication server. If this fails, or no datasource URI is given, it attempts to use the connectivity offered by the JDBC Module, which is then wrapped in a datasource. Note that if you provide a datasource you should make the JDBC Module inactive to prevent the module from interfering with the storage layer.

Since:
MMBase-1.7
Version:
$Id: DatabaseStorageManagerFactory.java,v 1.13.2.2 2004/07/29 19:44:42 michiel Exp $
Author:
Pierre van Rooden
To Do:
backward compatibility with the old supportclasses should be done by creating a separate Factory (LegacyStorageManagerFactory ?).

Field Summary
protected  java.lang.String catalog
          The catalog used by this storage.
protected  javax.sql.DataSource dataSource
          The datasource in use by this factory.
protected  boolean supportsTransactions
          Whether transactions and rollback are supported by this database
protected  int transactionIsolation
          The transaction isolation level available for this storage.
 
Fields inherited from class org.mmbase.storage.StorageManagerFactory
attributes, changeManager, disallowedFields, getSurrogator, mmbase, queryHandler, queryHandlerClasses, setSurrogator, storageManagerClass, typeMappings
 
Constructor Summary
DatabaseStorageManagerFactory()
           
 
Method Summary
protected  java.lang.String getBinaryFileBasePath()
          Returns the base path for 'binary file'
 java.lang.String getCatalog()
          Returns the name of the catalog used by this storage (null if no catalog is used).
 StorageReader getDocumentReader()
          Locates and opens the storage configuration document.
 double getVersion()
          Returns the version of this factory implementation.
protected  java.lang.Object instantiateBasicHandler(java.lang.Class handlerClass)
          Instantiate a basic handler object using the specified class.
protected  java.lang.Object instantiateChainedHandler(java.lang.Class handlerClass, java.lang.Object handler)
          Instantiate a chained handler object using the specified class.
protected  SearchQueryHandler instantiateQueryHandler(java.lang.Object data)
          Instantiate a SearchQueryHandler object using the specified object.
protected  void load()
          Opens and reads the storage configuration document.
 boolean supportsTransactions()
          Returns whether transactions, and specifically rollback, is supported in the storage layer.
 
Methods inherited from class org.mmbase.storage.StorageManagerFactory
getAttribute, getAttributes, getChangeManager, getDisallowedFields, getGetSurrogator, getMMBase, getScheme, getScheme, getSearchQueryHandler, getSetSurrogator, getStorageIdentifier, getStorageIdentifier, getStorageManager, getTypeMappings, hasOption, init, newInstance, newInstance, setAttribute, setAttributes, setDisallowedFields, setOption, setScheme
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

catalog

protected java.lang.String catalog
The catalog used by this storage.


dataSource

protected javax.sql.DataSource dataSource
The datasource in use by this factory. The datasource is retrieved either from the application server, or by wrapping the JDBC Module in a generic datasource.


transactionIsolation

protected int transactionIsolation
The transaction isolation level available for this storage. Default TRANSACTION_NONE (no transaction support). The actual value is determined from the database metadata.


supportsTransactions

protected boolean supportsTransactions
Whether transactions and rollback are supported by this database

Constructor Detail

DatabaseStorageManagerFactory

public DatabaseStorageManagerFactory()
Method Detail

getVersion

public double getVersion()
Description copied from class: StorageManagerFactory
Returns the version of this factory implementation. The factory uses this number to verify whether it can handle storage configuration files that list version requirements.

Specified by:
getVersion in class StorageManagerFactory
Returns:
the version as an integer

supportsTransactions

public boolean supportsTransactions()
Description copied from class: StorageManagerFactory
Returns whether transactions, and specifically rollback, is supported in the storage layer.

Specified by:
supportsTransactions in class StorageManagerFactory
Returns:
true if trasnactions are supported

getCatalog

public java.lang.String getCatalog()
Description copied from class: StorageManagerFactory
Returns the name of the catalog used by this storage (null if no catalog is used).

Overrides:
getCatalog in class StorageManagerFactory

load

protected void load()
             throws StorageException
Opens and reads the storage configuration document. Obtain a datasource to the storage, and load configuration attributes.

Overrides:
load in class StorageManagerFactory
Throws:
StorageException - if the storage could not be accessed or necessary configuration data is missing or invalid

getDocumentReader

public StorageReader getDocumentReader()
                                throws StorageException
Locates and opens the storage configuration document. The configuration document to open is dependent on the storage type and version. You can explicitly set this type in mmbaseroot (using the storage property), or let MMBase determine it using information gained from the datasource, and the lookup.xml file in the database configuration directory

Overrides:
getDocumentReader in class StorageManagerFactory
Returns:
a StorageReader instance
Throws:
StorageException - if the storage could not be accessed while determining the database type
To Do:
configuration path should be retrieved from the MMBase instance, rather than directly from the (static) MMBaseContext class. Storage configuration files should become resource files, and configurable using a storageresource property. The type of reader to return should be a StorageReader.

getBinaryFileBasePath

protected java.lang.String getBinaryFileBasePath()
Returns the base path for 'binary file'


instantiateBasicHandler

protected java.lang.Object instantiateBasicHandler(java.lang.Class handlerClass)
Description copied from class: StorageManagerFactory
Instantiate a basic handler object using the specified class. A basic handler can be any type of class and is dependent on the factory implementation. For instance, the database factory expects an org.mmbase.storage.search.implentation.database.SQLHandler class.

Specified by:
instantiateBasicHandler in class StorageManagerFactory
Parameters:
handlerClass - the class to instantuate teh object with
Returns:
the new handler class

instantiateChainedHandler

protected java.lang.Object instantiateChainedHandler(java.lang.Class handlerClass,
                                                     java.lang.Object handler)
Description copied from class: StorageManagerFactory
Instantiate a chained handler object using the specified class. A chained handler can be any type of class and is dependent on the factory implementation. For instance, the database factory expects an org.mmbase.storage.search.implentation.database.ChainedSQLHandler class.

Specified by:
instantiateChainedHandler in class StorageManagerFactory
Parameters:
handlerClass - the class to instantuate teh object with
handler - 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.
Returns:
the new handler class

instantiateQueryHandler

protected SearchQueryHandler instantiateQueryHandler(java.lang.Object data)
Description copied from class: StorageManagerFactory
Instantiate a SearchQueryHandler object using the specified object. The specified parameter may be an actual SearchQueryHandler object, or it may be a utility class. For instance, the database factory expects an org.mmbase.storage.search.implentation.database.SQLHandler object, which is used as a parameter in the construction of the actual SearchQueryHandler class.

Specified by:
instantiateQueryHandler in class StorageManagerFactory


MMBase build 1.7.4.20050922