org.lateralnz.simpletrans
Class TransDataSource

java.lang.Object
  extended by org.lateralnz.simpletrans.TransDataSource
All Implemented Interfaces:
javax.naming.Referenceable, javax.sql.DataSource, Constants

public class TransDataSource
extends java.lang.Object
implements Constants, javax.sql.DataSource, javax.naming.Referenceable

a transaction aware data source, wrapping a 'real' datasource (ensuring that all connections returned are wrapped by a TransConnection)


Field Summary
 
Fields inherited from interface org.lateralnz.common.util.Constants
AMPERSAND, AND, APPLICATION_X_WWW_FORM_URLENCODED, ASTERISK, AT, BACK_SLASH, CHAR_LEFT_CHEV, CHAR_RIGHT_CHEV, COLON, COMMA, CRLF, DASH, DELETE, DOLLAR, DOT, DOT_CLASS, DOT_JAVA, EIGHT, EMPTY, EQUALS, FALSE, FILE_SEPARATOR, FIVE, FORWARD_SLASH, FOUR, FULLSTOP, HASH, HAT, INSERT, LEFT_BRACE, LEFT_BRACKET, LEFT_CHEV, MAX_LEN_APPCODE, MAX_LEN_APPGROUP, MAX_LEN_MSGCODE, MAX_LEN_MSGTEXT, MINUS_ONE, N, NEWLINE, NINE, NO, NULL_STRING, OFF, ON, ONE, ONE_DAY, ONE_HOUR, ONE_MINUTE, ONE_WEEK, PATH_SEPARATOR, PERCENT, PIPE, PLUS, QUESTION_MARK, QUOTE, REQUIRED, REQUIRES_NEW, RETURN, RIGHT_BRACE, RIGHT_BRACKET, RIGHT_CHEV, SELECT, SEMICOLON, SEVEN, SINGLE_QUOTE, SIX, SPACE, SQ_LEFT_BRACKET, SQ_RIGHT_BRACKET, SUPPORTS, TEXT_HTML, TEXT_PLAIN, TEXT_XML, THREE, TRUE, TWO, UNDERSCORE, UPDATE, UTF_8, Y, YES, ZERO
 
Constructor Summary
TransDataSource(java.lang.String name, javax.sql.DataSource source)
           
 
Method Summary
 java.sql.Connection getConnection()
          get a connection (see the next getConnection method for more detail)
 java.sql.Connection getConnection(java.lang.String str, java.lang.String str1)
          get a jdbc connection -- if the calling thread is in a transaction, then this connection will be wrapped by a TransConnection object, otherwise the base connection is returned NOTE: RequiresNew is -NOT- handled properly at the moment
 int getLoginTimeout()
           
 java.io.PrintWriter getLogWriter()
           
 javax.naming.Reference getReference()
          reference method required so this object can be loaded into a registry
protected static TransDataSource getTransDataSource(java.lang.String name)
          helper method for the object factory associated with this class
 void setLoginTimeout(int timeout)
           
 void setLogWriter(java.io.PrintWriter pw)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TransDataSource

public TransDataSource(java.lang.String name,
                       javax.sql.DataSource source)
                throws java.lang.Exception
Throws:
java.lang.Exception
Method Detail

getTransDataSource

protected static final TransDataSource getTransDataSource(java.lang.String name)
helper method for the object factory associated with this class


getConnection

public java.sql.Connection getConnection()
                                  throws java.sql.SQLException
get a connection (see the next getConnection method for more detail)

Specified by:
getConnection in interface javax.sql.DataSource
Throws:
java.sql.SQLException

getConnection

public java.sql.Connection getConnection(java.lang.String str,
                                         java.lang.String str1)
                                  throws java.sql.SQLException
get a jdbc connection -- if the calling thread is in a transaction, then this connection will be wrapped by a TransConnection object, otherwise the base connection is returned NOTE: RequiresNew is -NOT- handled properly at the moment

Specified by:
getConnection in interface javax.sql.DataSource
Throws:
java.sql.SQLException

setLogWriter

public void setLogWriter(java.io.PrintWriter pw)
                  throws java.sql.SQLException
Specified by:
setLogWriter in interface javax.sql.DataSource
Throws:
java.sql.SQLException
See Also:
DataSource.setLogWriter(java.io.PrintWriter)

getLogWriter

public java.io.PrintWriter getLogWriter()
                                 throws java.sql.SQLException
Specified by:
getLogWriter in interface javax.sql.DataSource
Throws:
java.sql.SQLException
See Also:
DataSource.getLogWriter()

setLoginTimeout

public void setLoginTimeout(int timeout)
                     throws java.sql.SQLException
Specified by:
setLoginTimeout in interface javax.sql.DataSource
Throws:
java.sql.SQLException
See Also:
DataSource.setLoginTimeout(int)

getLoginTimeout

public int getLoginTimeout()
                    throws java.sql.SQLException
Specified by:
getLoginTimeout in interface javax.sql.DataSource
Throws:
java.sql.SQLException
See Also:
DataSource.getLoginTimeout()

getReference

public javax.naming.Reference getReference()
reference method required so this object can be loaded into a registry

Specified by:
getReference in interface javax.naming.Referenceable