Textractor API textractor-720 (20091120123250)

textractor.database
Class DbManager

java.lang.Object
  extended by textractor.database.DbManager
All Implemented Interfaces:
TransactionManager

public final class DbManager
extends Object
implements TransactionManager

Central point for database access in the system. An instantiation of the DbManager allows

  1. base TransactionManager Interface functionality for database _process delimitation methods
  2. Access to related database _process managers


Constructor Summary
DbManager()
          Creates a nwe DbManager in the web application context.
DbManager(String propertyFilename)
          Creates a nwe DbManager in the web application context.
DbManager(String[] args)
          Class Constructor.
 
Method Summary
 void abortTxn()
          Abort a transaction.
 void beginTxn()
          Begin a transaction.
 void bind(Object obj)
          Same as makePersistent
 void bind(Object obj, String name)
          Binds a transient object to a name and make it persistent.
 void checkpointTxn()
          Checkpoints a transaction.
 void commitTxn()
          Commit a transaction.
 boolean delete(Object object)
          Deletes an object from the database.
 boolean deleteAll(Collection c)
           
 void finalize()
          Close the persistence manager upon garbage collection.
 javax.jdo.Extent getExtent(Class extentClass, boolean getSubclasses)
           
 javax.jdo.Extent getExtent(String classname, boolean getSubclasses)
           
 Iterator getExtentIterator(Class extentClass, boolean getSubclasses)
           
 Iterator getExtentIterator(String classname, boolean getSubclasses)
           
 JdoExtension getJdoExtension()
           
 Object getObjectByObjectId(Object objid)
          Returns the object for a certain object id of a firstclass object (JDO persistent object).
 Object getObjectId(Object obj)
          Returns the object id of a firstclass object (JDO persistent object).
 javax.jdo.PersistenceManager getPM()
           
 String getPropertyFilename()
           
 TextractorManager getTextractorManager()
           
protected  void init(String[] args)
           
 Object lookup(String name)
          Returns the reference to the named object, or null if the name cannot be found.
 void makePersistent(Object obj)
          Makes a transient object persistent.
 void makePersistentAll(Collection objects)
          Make element of a collection persistent.
 javax.jdo.Query newQuery()
           
 void retrieve(Object obj)
          Retrieve an instance from the database.
 void retrieveAll(Collection c)
          Retrieve instances from the store.
 void shutdown()
           
 boolean txnInProgress()
          Checks that a valid Transaction is in progress during a database _process,
 void unbind(String name)
          Release the association between the name and a stored object.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DbManager

public DbManager()
          throws TextractorDatabaseException
Creates a nwe DbManager in the web application context.

Throws:
TextractorDatabaseException

DbManager

public DbManager(String propertyFilename)
          throws TextractorDatabaseException
Creates a nwe DbManager in the web application context.

Throws:
TextractorDatabaseException

DbManager

public DbManager(String[] args)
          throws TextractorDatabaseException
Class Constructor. Creates a new DbManager in the command line context.

Throws:
TextractorDatabaseException
Method Detail

getTextractorManager

public TextractorManager getTextractorManager()

init

protected void init(String[] args)
             throws TextractorDatabaseException
Throws:
TextractorDatabaseException

getJdoExtension

public JdoExtension getJdoExtension()

beginTxn

public void beginTxn()
Begin a transaction. To begin a database related _process, the _process must be within a beginTxn()-commitTxn()/abortTxn() block. beginTxn() delimits the beginning of a database related _process.

Specified by:
beginTxn in interface TransactionManager

commitTxn

public void commitTxn()
Commit a transaction. To complete a database related _process such as storing an object, the _process must be within a beginTxn()-commitTxn()/abortTxn() block. commitTxn() delimits the completion of a database related _process.

Specified by:
commitTxn in interface TransactionManager

checkpointTxn

public void checkpointTxn()
Checkpoints a transaction. This is similar to doing a commitTxn() followed by beginTxn() but keep references open.


abortTxn

public void abortTxn()
Abort a transaction. To abort a database related _process such as a failure while attempting to store an object, the _process must be begun with a beginTxn() call followed by an abortTxn() call when the _process fails, or a commitTxn() call when the _process successfully completes. abortTxn() delimits the end of a database _process when the _process fails

Specified by:
abortTxn in interface TransactionManager

txnInProgress

public boolean txnInProgress()
Checks that a valid Transaction is in progress during a database _process,

Specified by:
txnInProgress in interface TransactionManager
Returns:
true if valid Transaction is in progress for this thread, else return false

retrieve

public void retrieve(Object obj)
Retrieve an instance from the database. This is only a hint to the PersistenceManager that the application intends to use the instance, and its field values should be retrieved.


retrieveAll

public void retrieveAll(Collection c)
Retrieve instances from the store. This is only a hint to the PersistenceManager that the application intends to use the instances, and their field values should be retrieved.

Parameters:
c - Collection of objects to be retrived.

makePersistent

public void makePersistent(Object obj)
Makes a transient object persistent.


getObjectId

public Object getObjectId(Object obj)
Returns the object id of a firstclass object (JDO persistent object).

Parameters:
obj - The object you want the oid from.
Returns:
the oid of object obj

getObjectByObjectId

public Object getObjectByObjectId(Object objid)
Returns the object for a certain object id of a firstclass object (JDO persistent object).

Parameters:
objid - an object id.
Returns:
the object

bind

public void bind(Object obj)
Same as makePersistent


bind

public void bind(Object obj,
                 String name)
Binds a transient object to a name and make it persistent.


unbind

public void unbind(String name)
Release the association between the name and a stored object. After this call, lookup(name) will return null.


lookup

public Object lookup(String name)
              throws TextractorDatabaseException
Returns the reference to the named object, or null if the name cannot be found.

Throws:
TextractorDatabaseException

delete

public boolean delete(Object object)
Deletes an object from the database. This call expilcitly removes an object from the database. In general, it is not necessary to call this method to delete an object. Objects are garbage collected when they are no longer referenced. In some special circumstances, though, it is useful to immediately remove the object. This method can then be used.


deleteAll

public boolean deleteAll(Collection c)

finalize

public void finalize()
              throws Throwable
Close the persistence manager upon garbage collection.

Specified by:
finalize in interface TransactionManager
Overrides:
finalize in class Object
Throws:
Throwable - if an error occurs.

shutdown

public void shutdown()

getPM

public javax.jdo.PersistenceManager getPM()

getExtent

public javax.jdo.Extent getExtent(String classname,
                                  boolean getSubclasses)
                           throws TextractorDatabaseException
Throws:
TextractorDatabaseException

getExtent

public javax.jdo.Extent getExtent(Class extentClass,
                                  boolean getSubclasses)

getExtentIterator

public Iterator getExtentIterator(String classname,
                                  boolean getSubclasses)
                           throws TextractorDatabaseException
Throws:
TextractorDatabaseException

getExtentIterator

public Iterator getExtentIterator(Class extentClass,
                                  boolean getSubclasses)

newQuery

public javax.jdo.Query newQuery()

getPropertyFilename

public String getPropertyFilename()

makePersistentAll

public void makePersistentAll(Collection objects)
Make element of a collection persistent.

Parameters:
objects - Elements of the collection will be made persistent.

Textractor API textractor-720 (20091120123250)

Copyright © 2003-2008 Institute for Computational Biomedicine, All Rights Reserved.