com.cometway.jdbc
Class JDBCObjectManager

java.lang.Object
  extended by com.cometway.jdbc.JDBCObjectManager
All Implemented Interfaces:
IObjectManager

public class JDBCObjectManager
extends java.lang.Object
implements IObjectManager

This is the JDBC implementation of IObjectManager. Object types are stored as tables in a SQL database, their data represented by table schemas which allow for fast and convenient access to data.


Field Summary
protected  java.util.Hashtable typesTable
           
protected  java.sql.PreparedStatement updateUniqueIDStmt
           
 
Fields inherited from interface com.cometway.om.IObjectManager
LIST_SUPPORTED_TYPES, LIST_TYPES
 
Constructor Summary
JDBCObjectManager(java.lang.String jdbcDriver, java.lang.String jdbcURL, java.lang.String user, java.lang.String password)
          Creates a new instance of this object manager and connects to a database using the supplied parameters.
 
Method Summary
 boolean changeObjectID(ObjectID oldID, ObjectID newID)
          Changes the objectID of an object.
 ObjectID createObject(ObjectType type)
          Creates a new object in the object manager of the specified object type.
protected  void debug(java.lang.String methodName, java.lang.String message)
          Called internally to output debugging information to the System.out stream.
protected  void error(java.lang.String methodName, java.lang.String message, java.lang.Exception e)
          Called internally to output error messages to the System.err stream.
protected  void finalize()
          Called by the garbage collector; close prepared statements.
 java.lang.Object getObject(ObjectID id)
          Retrieves the object corresponding to an object ID.
 java.lang.String getStatus()
          Returns a string containing current status information about this object manager.
 java.util.Vector listObjects(java.lang.Object objectQuery)
          Returns a Vector of objects designated by the objectQuery parameter.
 boolean removeObject(ObjectID id)
          Deletes the object corresponding to an object ID from the object manager.
 void setDebug(boolean state)
          Enables debugging messages that are printed to the System.out stream.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

typesTable

protected java.util.Hashtable typesTable

updateUniqueIDStmt

protected java.sql.PreparedStatement updateUniqueIDStmt
Constructor Detail

JDBCObjectManager

public JDBCObjectManager(java.lang.String jdbcDriver,
                         java.lang.String jdbcURL,
                         java.lang.String user,
                         java.lang.String password)
Creates a new instance of this object manager and connects to a database using the supplied parameters. This class uses the pooled JDBC Connection functionality found in com.cometway.jdbc

Parameters:
jdbcDriver - the class name of the JDBC driver to use for this connection (ie: "sun.jdbc.odbc.JdbcOdbcDriver").
jdbcURL - the connection URL for this driver and database (ie: "jdbc:odbc:database").
user - the account username used to access the database.
password - the account password used to access the database.
Method Detail

createObject

public ObjectID createObject(ObjectType type)
Creates a new object in the object manager of the specified object type.

Note: Currently, only the PropsType is supported.

Specified by:
createObject in interface IObjectManager
Parameters:
type - a reference to an ObjectType representing the type of object to create.
Returns:
a reference to a valid ObjectID if successful; null otherwise.

debug

protected void debug(java.lang.String methodName,
                     java.lang.String message)
Called internally to output debugging information to the System.out stream.


error

protected void error(java.lang.String methodName,
                     java.lang.String message,
                     java.lang.Exception e)
Called internally to output error messages to the System.err stream.


finalize

protected void finalize()
                 throws java.lang.Throwable
Called by the garbage collector; close prepared statements.

Overrides:
finalize in class java.lang.Object
Throws:
java.lang.Throwable

getObject

public java.lang.Object getObject(ObjectID id)
Retrieves the object corresponding to an object ID.

Specified by:
getObject in interface IObjectManager
Parameters:
id - a reference to an ObjectID representing a valid object in the object manager.
Returns:
a reference to an Object if one was found; null otherwise.

getStatus

public java.lang.String getStatus()
Returns a string containing current status information about this object manager.


listObjects

public java.util.Vector listObjects(java.lang.Object objectQuery)
Returns a Vector of objects designated by the objectQuery parameter. Valid objects for this parameter are:
IObjectManager.LIST_TYPES Lists object types that already exist.
IObjectManager.LIST_SUPPORTED_TYPES Lists objects which can be passed to createObject.
ObjectType Lists all existing objects of the same ObjectType.
PropsQuery Lists Props based on data from the PropsQuery object.
Note: Some object managers may support additional values for access to non-standard features.

Specified by:
listObjects in interface IObjectManager
Parameters:
objectQuery - any valid object from the list above.
Returns:
a Vector containing Objects based on the query; null if the query wasn't recognized.

removeObject

public boolean removeObject(ObjectID id)
Deletes the object corresponding to an object ID from the object manager.

Specified by:
removeObject in interface IObjectManager
Parameters:
id - a reference to an ObjectID representing a valid object in the object manager.
Returns:
true if the object was successfully deleted; false otherwise.

setDebug

public void setDebug(boolean state)
Enables debugging messages that are printed to the System.out stream. This feature is turned off by default.

Parameters:
state - true enables debugging; false disables it.

changeObjectID

public boolean changeObjectID(ObjectID oldID,
                              ObjectID newID)
Changes the objectID of an object.

Specified by:
changeObjectID in interface IObjectManager