uk.ac.ebi.intact.persistence
Class ObjectBridgeDAOSource

java.lang.Object
  |
  +--uk.ac.ebi.intact.persistence.ObjectBridgeDAOSource
All Implemented Interfaces:
DAOSource, java.io.Serializable

public class ObjectBridgeDAOSource
extends java.lang.Object
implements DAOSource, java.io.Serializable

This class effectively wraps an ObjectBridge broker factory instance and abstracts away the details of the ObjectBridge creation mechanism.

Author:
Chris Lewington
See Also:
Serialized Form

Field Summary
static java.lang.String OJB_LOGGER_NAME
           
 
Constructor Summary
ObjectBridgeDAOSource()
           
 
Method Summary
 java.lang.ClassLoader getClassLoader()
           
 java.lang.String getConfig()
           
 DAO getDAO()
          This method returns a connection to the data source, ie in this case a broker instance which provides database connection.
 DAO getDAO(java.lang.String user, java.lang.String password)
          Returns a connection to the data source, and connects to it using the supplied username and password.
 java.lang.String getDataSourceName()
           
 org.apache.log4j.Logger getLogger()
          Returns the log destination being used for this data source
 java.lang.String getPassword()
           
 java.lang.String getUser()
           
 boolean isAutoSaveSet()
           
 void setAutoSave(boolean val)
          Defines whether or not data are saved automatically
 void setConfig(java.util.Map configFiles)
          This method sets up the configuration of ObjectBridge, based on the content of the configuration file whose name is passed in as a parameter.
 void setLogger(org.apache.log4j.Logger l)
          allows a logging destination to be specified
 void setPassword(java.lang.String password)
          Used to define a password which overrides any default supplied via config data.
 void setUser(java.lang.String user)
          Used to specify a user for connecting to the persistent store.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

OJB_LOGGER_NAME

public static final java.lang.String OJB_LOGGER_NAME
See Also:
Constant Field Values
Constructor Detail

ObjectBridgeDAOSource

public ObjectBridgeDAOSource()
Method Detail

setConfig

public void setConfig(java.util.Map configFiles)
               throws DataSourceException

This method sets up the configuration of ObjectBridge, based on the content of the configuration file whose name is passed in as a parameter.

Specified by:
setConfig in interface DAOSource
Parameters:
configFiles - - a collection of config filenames (this is only one for ObjectBridge)
Throws:
DataSourceException - - thrown if there are problems obtaining configuration data

setUser

public void setUser(java.lang.String user)
Used to specify a user for connecting to the persistent store. If this method is not used, default user details will be obtained from details supplied in the setConfig method (eg from a supplied config file).

Specified by:
setUser in interface DAOSource
Parameters:
user - the username to use for connection (overrides any default)

getUser

public java.lang.String getUser()
Specified by:
getUser in interface DAOSource

setPassword

public void setPassword(java.lang.String password)
Used to define a password which overrides any default supplied via config data. Should typically be used in conjunction with the setUser method for consistency.

Specified by:
setPassword in interface DAOSource
Parameters:
password - the password to be used for persistent store connection.

getPassword

public java.lang.String getPassword()
Specified by:
getPassword in interface DAOSource

getDAO

public DAO getDAO()
           throws DataSourceException
This method returns a connection to the data source, ie in this case a broker instance which provides database connection.

Specified by:
getDAO in interface DAOSource
Returns:
a Data Access Object (connection)
Throws:
DataSourceException - - thrown if a DAO cannot be obtained

getDAO

public DAO getDAO(java.lang.String user,
                  java.lang.String password)
           throws DataSourceException
Returns a connection to the data source, and connects to it using the supplied username and password. If the username is null or the details are invalid then a default connection will be attempted.

Specified by:
getDAO in interface DAOSource
Parameters:
user - - the username to connect with
password - - user's password (null values allowed)
Returns:
a Data Access Object (connection)
Throws:
DataSourceException - - thrown if a DAO cannot be obtained

getDataSourceName

public java.lang.String getDataSourceName()
Specified by:
getDataSourceName in interface DAOSource
Returns:
the name of the data source (as per configuration)

getClassLoader

public java.lang.ClassLoader getClassLoader()
Specified by:
getClassLoader in interface DAOSource
Returns:
The class loader used to load the data source

getConfig

public java.lang.String getConfig()
Specified by:
getConfig in interface DAOSource
Returns:
the configuration information about the data source

setAutoSave

public void setAutoSave(boolean val)
Description copied from interface: DAOSource
Defines whether or not data are saved automatically

Specified by:
setAutoSave in interface DAOSource

isAutoSaveSet

public boolean isAutoSaveSet()
Specified by:
isAutoSaveSet in interface DAOSource
Returns:
true if data are set to be saved automatically, false otherwise

setLogger

public void setLogger(org.apache.log4j.Logger l)
Description copied from interface: DAOSource
allows a logging destination to be specified

Specified by:
setLogger in interface DAOSource
Parameters:
l - A log4j Logger for logging output

getLogger

public org.apache.log4j.Logger getLogger()
Description copied from interface: DAOSource
Returns the log destination being used for this data source

Specified by:
getLogger in interface DAOSource
Returns:
PrintWriter a destination log interface


IntAct Project - EMBL-EBI 2004 - intact-help@ebi.ac.uk