org.jafer.databeans
Class DatabeanManager

java.lang.Object
  extended by org.jafer.interfaces.Databean
      extended by org.jafer.databeans.DatabeanManager
All Implemented Interfaces:
java.io.Serializable, Present, Search

public class DatabeanManager
extends Databean
implements Present, Search

This class manages a collection of databases

See Also:
Serialized Form

Field Summary
private  ActiveBean[] activeBeans
          Stores a reference to an array of active beans forthe current set of databases
private  java.lang.String[] allDatabases
          Stores a reference to this databeanmanagers complete set of configured databases
private  boolean autoPopulateCache
          Stores a reference to whether pre filling of the caching is enabled or not.
private  CacheFactory cacheFactory
          Stores a reference to cache factory that provides the cache for the ActiveBeans data bean to use.
private  java.util.Hashtable databeanFactories
          Stores a reference to factories that can create databeans for specified databases.
private  java.lang.String mode
          Stores a reference to search mode.
private  java.lang.String name
          Stores a reference to the name of this databeanmanager
private  int recordCursor
          Stores a reference to current record cursor position
private  java.lang.String recordSchema
          Stores a reference to record schema that should be applied when retrieving records
private  int totalRecords
          Stores a reference to the total number of records retrieved
 
Constructor Summary
DatabeanManager()
           
 
Method Summary
 boolean autoPopulateCache()
          Returns whether the active beans should prepopulate cache after search
protected  void finalize()
           
 java.lang.String[] getAllDatabases()
          Get the databeanManagers set of all databases it processes
 CacheFactory getCacheFactory()
          Returns the cache factory used by this databeanManager
 java.lang.String getCurrentDatabase()
          Get database of current record
 Field getCurrentRecord()
          Get current record
 java.lang.String[] getDatabases()
          Get databases currently searched
 java.util.Map getDatabeanFactories()
          Returns a map of the supported databean factories
 java.lang.String getElementSpec()
          Currently Not Supported
 java.lang.String getMode()
          get the mode that the DatabeanManager is running in
 java.lang.String getName()
          get the name of the DataBeanManager
 int getNumberOfResults()
          Get number of results for last query
 int getNumberOfResults(java.lang.String databaseName)
          Get number of results from the named database for last query
 java.lang.Object getQuery()
          Currently Not Supported
 int getRecordCursor()
          Get the current record position cursor
 java.lang.String getRecordSchema()
          Get currently set record schema
 java.lang.String getResultSetName()
          Currently Not Supported
 JaferException getSearchException(java.lang.String database)
          If a search fails this method will return the JaferException for the specified database
 JaferException[] getSearchException(java.lang.String[] databases)
          If a search fails this method will return the JaferException for the specified databases
 boolean isCheckRecordFormat()
          Currently Not Supported
 boolean isParseQuery()
          Currently Not Supported
 void saveQuery(java.lang.String file)
          Currently Not Supported
 void setAllDatabases(java.lang.String[] allDatabases)
          Set the databeanManagers set of all databases it processes.
 void setAutoPopulateCache(boolean autoPopulate)
          Sets whether the active beans should prepopulate cache after search
 void setCacheFactory(CacheFactory cacheFactory)
          Sets the cache factory to be used by the DatabeanManager
 void setCheckRecordFormat(boolean checkRecordFormat)
          Currently Not Supported
 void setDatabases(java.lang.String database)
          Set database to search
 void setDatabases(java.lang.String[] databases)
          Set databases to search
 void setDatabeanFactories(java.util.Hashtable databeanFactories)
          Set the databean factories that this databeanmanager supports
 void setElementSpec(java.lang.String elementSpec)
          Currently Not Supported
 void setMode(java.lang.String mode)
          Set the mode that this databeanManager runs in
 void setName(java.lang.String name)
          Set the name of this DataBeanManager
 void setParseQuery(boolean parseQuery)
          Currently Not Supported
 void setRecordCursor(int recordCursor)
          Set the current record cursor
 void setRecordSchema(java.lang.String recordSchema)
          Set current prefered record schema
 void setResultSetName(java.lang.String resultSetName)
          Currently Not Supported
 void stopAutoPopulateCache()
          This method stops any auto caching that may being performed by the databean manager in seperate threads to prempt and speed up retrieval.
 int submitQuery(java.lang.Object query)
          Send query (can be in XML form)
 
Methods inherited from class org.jafer.interfaces.Databean
getCacheSupport, getPresentSupport, getScanSupport, getSearchSupport
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

databeanFactories

private java.util.Hashtable databeanFactories
Stores a reference to factories that can create databeans for specified databases. A map entry consists of key = database name and value = factory that creates a databean supporting Search and Present for the specified database


cacheFactory

private CacheFactory cacheFactory
Stores a reference to cache factory that provides the cache for the ActiveBeans data bean to use. If this is set to null then the cache will not be set on the databean and the databeans internal one will be used


autoPopulateCache

private boolean autoPopulateCache
Stores a reference to whether pre filling of the caching is enabled or not. Enabled (true) as default.


activeBeans

private ActiveBean[] activeBeans
Stores a reference to an array of active beans forthe current set of databases


recordCursor

private int recordCursor
Stores a reference to current record cursor position


recordSchema

private java.lang.String recordSchema
Stores a reference to record schema that should be applied when retrieving records


mode

private java.lang.String mode
Stores a reference to search mode.


totalRecords

private int totalRecords
Stores a reference to the total number of records retrieved


name

private java.lang.String name
Stores a reference to the name of this databeanmanager


allDatabases

private java.lang.String[] allDatabases
Stores a reference to this databeanmanagers complete set of configured databases

Constructor Detail

DatabeanManager

public DatabeanManager()
Method Detail

setDatabeanFactories

public void setDatabeanFactories(java.util.Hashtable databeanFactories)
Set the databean factories that this databeanmanager supports

Parameters:
databeanFactories - A map where key = database name and value = factory that creates a databean supporting Search and Present for the specified database

getDatabeanFactories

public java.util.Map getDatabeanFactories()
Returns a map of the supported databean factories

Returns:
the supported databean factories map

setRecordCursor

public void setRecordCursor(int recordCursor)
                     throws JaferException
Description copied from interface: Present
Set the current record cursor

Specified by:
setRecordCursor in interface Present
Parameters:
recordCursor - Record position (starting at 1)
Throws:
JaferException

getRecordCursor

public int getRecordCursor()
Description copied from interface: Present
Get the current record position cursor

Specified by:
getRecordCursor in interface Present
Returns:
get record position

setRecordSchema

public void setRecordSchema(java.lang.String recordSchema)
Description copied from interface: Present
Set current prefered record schema

Specified by:
setRecordSchema in interface Present
Parameters:
recordSchema - record schema

getRecordSchema

public java.lang.String getRecordSchema()
Description copied from interface: Present
Get currently set record schema

Specified by:
getRecordSchema in interface Present
Returns:
record schema

autoPopulateCache

public boolean autoPopulateCache()
Returns whether the active beans should prepopulate cache after search

Returns:
Returns true is auto population of cache should take place

setAutoPopulateCache

public void setAutoPopulateCache(boolean autoPopulate)
Sets whether the active beans should prepopulate cache after search

Parameters:
autoPopulate - true if the cache should be auto populated

setDatabases

public void setDatabases(java.lang.String database)
Description copied from interface: Search
Set database to search

Specified by:
setDatabases in interface Search
Parameters:
database - database

setDatabases

public void setDatabases(java.lang.String[] databases)
Description copied from interface: Search
Set databases to search

Specified by:
setDatabases in interface Search
Parameters:
databases - databases

getDatabases

public java.lang.String[] getDatabases()
Description copied from interface: Search
Get databases currently searched

Specified by:
getDatabases in interface Search
Returns:
databases

submitQuery

public int submitQuery(java.lang.Object query)
                throws JaferException
Description copied from interface: Search
Send query (can be in XML form)

Specified by:
submitQuery in interface Search
Returns:
number of records found
Throws:
JaferException

getNumberOfResults

public int getNumberOfResults()
Description copied from interface: Search
Get number of results for last query

Specified by:
getNumberOfResults in interface Search
Returns:
number of results

getNumberOfResults

public int getNumberOfResults(java.lang.String databaseName)
Description copied from interface: Search
Get number of results from the named database for last query

Specified by:
getNumberOfResults in interface Search
Returns:
number of results

getCurrentRecord

public Field getCurrentRecord()
                       throws JaferException
Description copied from interface: Present
Get current record

Specified by:
getCurrentRecord in interface Present
Returns:
record
Throws:
JaferException

getCurrentDatabase

public java.lang.String getCurrentDatabase()
                                    throws JaferException
Description copied from interface: Present
Get database of current record

Specified by:
getCurrentDatabase in interface Present
Returns:
database
Throws:
JaferException

setCheckRecordFormat

public void setCheckRecordFormat(boolean checkRecordFormat)
Currently Not Supported

Specified by:
setCheckRecordFormat in interface Present
Parameters:
checkRecordFormat - setting of record schema checking
See Also:
Present.setCheckRecordFormat(boolean)

isCheckRecordFormat

public boolean isCheckRecordFormat()
Currently Not Supported

Specified by:
isCheckRecordFormat in interface Present
Returns:
record checking setting
See Also:
Present.isCheckRecordFormat()

setElementSpec

public void setElementSpec(java.lang.String elementSpec)
Currently Not Supported

Specified by:
setElementSpec in interface Present
Parameters:
elementSpec - element specification
See Also:
Present.setElementSpec(java.lang.String)

getElementSpec

public java.lang.String getElementSpec()
Currently Not Supported

Specified by:
getElementSpec in interface Present
Returns:
element specification
See Also:
Present.getElementSpec()

setResultSetName

public void setResultSetName(java.lang.String resultSetName)
Currently Not Supported

Specified by:
setResultSetName in interface Search
See Also:
Search.setResultSetName(java.lang.String)

getResultSetName

public java.lang.String getResultSetName()
Currently Not Supported

Specified by:
getResultSetName in interface Search
See Also:
Search.getResultSetName()

setParseQuery

public void setParseQuery(boolean parseQuery)
Currently Not Supported

Specified by:
setParseQuery in interface Search
See Also:
Search.setParseQuery(boolean)

isParseQuery

public boolean isParseQuery()
Currently Not Supported

Specified by:
isParseQuery in interface Search
See Also:
Search.isParseQuery()

saveQuery

public void saveQuery(java.lang.String file)
               throws JaferException
Currently Not Supported

Specified by:
saveQuery in interface Search
Throws:
JaferException
See Also:
Search.saveQuery(java.lang.String)

getQuery

public java.lang.Object getQuery()
Currently Not Supported

Specified by:
getQuery in interface Search
Returns:
query
See Also:
Search.getQuery()

setMode

public void setMode(java.lang.String mode)
Set the mode that this databeanManager runs in

Parameters:
mode - The mode to set use statics in DatabeanManagerFactory

getMode

public java.lang.String getMode()
get the mode that the DatabeanManager is running in

Returns:
The current mode Serial or Parallel

setName

public void setName(java.lang.String name)
Set the name of this DataBeanManager

Parameters:
name - The name of the databean manager

getName

public java.lang.String getName()
get the name of the DataBeanManager

Returns:
the name of the databean manager

setAllDatabases

public void setAllDatabases(java.lang.String[] allDatabases)
Set the databeanManagers set of all databases it processes. All the databases must be configured in the databeanfactories for the databeanManager

Parameters:
allDatabases - the array of database names

getAllDatabases

public java.lang.String[] getAllDatabases()
Get the databeanManagers set of all databases it processes

Returns:
An array of all the database names

setCacheFactory

public void setCacheFactory(CacheFactory cacheFactory)
Sets the cache factory to be used by the DatabeanManager

Parameters:
cacheFactory - the cache factory to use

getCacheFactory

public CacheFactory getCacheFactory()
Returns the cache factory used by this databeanManager

Returns:
The cache factory used

getSearchException

public JaferException getSearchException(java.lang.String database)
Description copied from interface: Search
If a search fails this method will return the JaferException for the specified database

Specified by:
getSearchException in interface Search
Parameters:
database - The name of the database to check
Returns:
null if no errors were found

getSearchException

public JaferException[] getSearchException(java.lang.String[] databases)
Description copied from interface: Search
If a search fails this method will return the JaferException for the specified databases

Specified by:
getSearchException in interface Search
Parameters:
databases - The databases to search
Returns:
An empty array if no errors were found

finalize

protected void finalize()
                 throws java.lang.Throwable
Overrides:
finalize in class java.lang.Object
Throws:
java.lang.Throwable

stopAutoPopulateCache

public void stopAutoPopulateCache()
This method stops any auto caching that may being performed by the databean manager in seperate threads to prempt and speed up retrieval.

This is important as the databean manager will continue to cache records if the setting is enabled until this method is called, a new query is submitted or the databean manager is garbage collected