com.cometway.jdbc
Class JDBCPropsContainer

java.lang.Object
  extended by com.cometway.props.AbstractPropsContainer
      extended by com.cometway.props.PropsContainer
          extended by com.cometway.jdbc.JDBCPropsContainer
All Implemented Interfaces:
IPropsContainer

public class JDBCPropsContainer
extends PropsContainer


Field Summary
protected  JDBCConnectionDriver connectionMgr
           
protected  java.lang.String name
           
protected  java.lang.String table
           
 
Constructor Summary
JDBCPropsContainer(JDBCConnectionDriver connectionDriver, java.util.Vector objectWriterThreads, java.lang.String table, java.lang.String name)
           
 
Method Summary
 void copy(IPropsContainer ipc)
          Copies the data from this JDBCPropsContainer to the one passed in as an argument.
static boolean createTable(JDBCConnectionDriver connectionMgr, java.lang.String name)
          Creates a table in the database using a connection from the connection pool.
static boolean dropTable(JDBCConnectionDriver connectionMgr, java.lang.String name)
          Drops a table from the database.
 java.util.Enumeration enumerateProps()
          Returns an enumeration of the keys for this container.
 java.lang.Object getProperty(java.lang.String key)
          Returns a reference to a named object in the container.
static java.lang.String getStatus()
          Returns a string containing current status information about JDBCPropsContainer performance.
 boolean removeProperty(java.lang.String key)
          Removes a named object from the container.
static void setDebug(boolean state)
          Enables debugging messages that are printed to the System.out stream.
 void setProperty(java.lang.String key, java.lang.Object value)
          Adds a named object to the container.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

connectionMgr

protected JDBCConnectionDriver connectionMgr

table

protected java.lang.String table

name

protected java.lang.String name
Constructor Detail

JDBCPropsContainer

public JDBCPropsContainer(JDBCConnectionDriver connectionDriver,
                          java.util.Vector objectWriterThreads,
                          java.lang.String table,
                          java.lang.String name)
Parameters:
connectionDriver - The JDBCConnectionDriver to use for DB connections.
objectWriterThreads - The ThreadPool to use when performing lazy writes
table - The name of the table in the database where these props are stored.
name - The name of this props.
Method Detail

copy

public void copy(IPropsContainer ipc)
Copies the data from this JDBCPropsContainer to the one passed in as an argument.

Specified by:
copy in interface IPropsContainer
Overrides:
copy in class PropsContainer
Parameters:
ipc - The props to copy into.

enumerateProps

public java.util.Enumeration enumerateProps()
Description copied from class: PropsContainer
Returns an enumeration of the keys for this container.

Specified by:
enumerateProps in interface IPropsContainer
Overrides:
enumerateProps in class PropsContainer
Returns:
an enumeration of keys as Strings.

getProperty

public java.lang.Object getProperty(java.lang.String key)
Description copied from class: PropsContainer
Returns a reference to a named object in the container.

Specified by:
getProperty in interface IPropsContainer
Overrides:
getProperty in class PropsContainer
Parameters:
key - the name of the object to retrieve.
Returns:
an object reference.

removeProperty

public boolean removeProperty(java.lang.String key)
Description copied from class: PropsContainer
Removes a named object from the container.

Specified by:
removeProperty in interface IPropsContainer
Overrides:
removeProperty in class PropsContainer
Parameters:
key - the name of the object to remove.
Returns:
true if the object existed and was removed; false otherwise.

setProperty

public void setProperty(java.lang.String key,
                        java.lang.Object value)
Description copied from class: PropsContainer
Adds a named object to the container. If the value is null, the property will be removed.

Specified by:
setProperty in interface IPropsContainer
Overrides:
setProperty in class PropsContainer
Parameters:
key - the name of the obejct to add.
value - the object to add.

createTable

public static boolean createTable(JDBCConnectionDriver connectionMgr,
                                  java.lang.String name)
Creates a table in the database using a connection from the connection pool. Tables are created with the following columns: name - the UniqueID of this props object, all properties of this props have the same name ID. keyname - the name of this property in the props object. write_order - a number representing which chunk of data this is (i.e. first chunk, third chunk). value - a chunk (varbinary(maxRowSize)) of the serialized Java object representing this property's value. There can be multiple rows in a table that contain PARTS of a value; these rows will have the same 'name' and 'keyname' values, use the "order by" syntax to sort data by the "write_order" value so data is returned in the order that the object must be de-serialized (top to bottom.)

Parameters:
connectionMgr - The connectionManager to get a pooled connection from.
name - The name of the table to create.

dropTable

public static boolean dropTable(JDBCConnectionDriver connectionMgr,
                                java.lang.String name)
Drops a table from the database.

Parameters:
connectionMgr - The connectionManager to get a pooled DB connection from.
name - The name of the table to drop.

getStatus

public static java.lang.String getStatus()
Returns a string containing current status information about JDBCPropsContainer performance.


setDebug

public static 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.