org.apache.beehive.controls.system.jdbc
Class JdbcControlImpl

Object
  extended by JdbcControlImpl
All Implemented Interfaces:
Serializable, Extensible, JdbcControl

public class JdbcControlImpl
extends Object
implements JdbcControl, Extensible, Serializable

The implementation class for the database controller.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface JdbcControl
JdbcControl.ComplexSqlFragment, JdbcControl.ConnectionDataSource, JdbcControl.ConnectionDriver, JdbcControl.ConnectionOptions, JdbcControl.FetchDirection, JdbcControl.HoldabilityType, JdbcControl.JndiContextFactory, JdbcControl.ScrollType, JdbcControl.SQL, JdbcControl.SQLParameter, JdbcControl.TypeMapper, JdbcControl.UndefinedIteratorType, JdbcControl.UndefinedResultSetMapper
 
Field Summary
protected  Connection _connection
           
protected  JdbcControl.ConnectionDataSource _connectionDataSource
           
protected  JdbcControl.ConnectionDriver _connectionDriver
           
protected  ControlBeanContext _context
           
protected  DataSource _dataSource
           
protected  ResourceContext _resourceContext
           
protected static HashMap<Class,ResultSetMapper> _resultMappers
           
protected static Class<?> _xmlObjectClass
           
 
Fields inherited from interface JdbcControl
DEFAULT_FETCH_SIZE, MAXROWS_ALL
 
Constructor Summary
JdbcControlImpl()
          Constructor
 
Method Summary
protected  Object execPreparedStatement(Method method, Object[] args)
          Create and exec a PreparedStatement
 Connection getConnection()
          Returns a database connection to the server associated with the control.
 Calendar getDataSourceCalendar()
          Returns the Calendar used when working with time/date types.
 Object invoke(Method method, Object[] args)
          Called by the Controls runtime to handle calls to methods of an extensible control.
 void onAquire()
          Invoked by the controls runtime when a new instance of this class is aquired by the runtime
 void onRelease()
          Invoked by the controls runtime when an instance of this class is released by the runtime
 void setDataSourceCalendar(Calendar cal)
          Sets the Calendar used when working with time/date types
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_context

protected ControlBeanContext _context

_resourceContext

protected ResourceContext _resourceContext

_connection

protected transient Connection _connection

_connectionDataSource

protected transient JdbcControl.ConnectionDataSource _connectionDataSource

_dataSource

protected transient DataSource _dataSource

_connectionDriver

protected transient JdbcControl.ConnectionDriver _connectionDriver

_resultMappers

protected static final HashMap<Class,ResultSetMapper> _resultMappers

_xmlObjectClass

protected static Class<?> _xmlObjectClass
Constructor Detail

JdbcControlImpl

public JdbcControlImpl()
Constructor

Method Detail

onAquire

public void onAquire()
Invoked by the controls runtime when a new instance of this class is aquired by the runtime


onRelease

public void onRelease()
Invoked by the controls runtime when an instance of this class is released by the runtime


getConnection

public Connection getConnection()
                         throws SQLException
Returns a database connection to the server associated with the control. The connection type is specified by a ConnectionDataSource or ConnectionDriver annotation on the control class which extends this control.

It is typically not necessary to call this method when using the control.

Specified by:
getConnection in interface JdbcControl
Returns:
A Connection a database.
Throws:
SQLException

invoke

public Object invoke(Method method,
                     Object[] args)
              throws Throwable
Called by the Controls runtime to handle calls to methods of an extensible control.

Specified by:
invoke in interface Extensible
Parameters:
method - The extended operation that was called.
args - Parameters of the operation.
Returns:
The value that should be returned by the operation.
Throws:
Throwable - any exception declared on the extended operation may be thrown. If a checked exception is thrown from the implementation that is not declared on the original interface, it will be wrapped in a ControlException.

setDataSourceCalendar

public void setDataSourceCalendar(Calendar cal)
Sets the Calendar used when working with time/date types

Specified by:
setDataSourceCalendar in interface JdbcControl
See Also:
java.sql.ResultSet#getDate(int, Calendar), java.sql.ResultSet#getTime(int, Calendar), java.sql.ResultSet#getTimestamp(int, Calendar), java.sql.PreparedStatement#setDate(int, Date, Calendar), java.sql.PreparedStatement#setTime(int, Time, Calendar), java.sql.PreparedStatement#setTimestamp(int, Timestamp, Calendar)

getDataSourceCalendar

public Calendar getDataSourceCalendar()
Returns the Calendar used when working with time/date types.

Specified by:
getDataSourceCalendar in interface JdbcControl
Returns:
the Calendar to use with this DataSource

execPreparedStatement

protected Object execPreparedStatement(Method method,
                                       Object[] args)
                                throws Throwable
Create and exec a PreparedStatement

Parameters:
method - the method to invoke
args - the method's arguments
Returns:
the return value from the PreparedStatement
Throws:
Throwable - any exception that occurs; the caller should handle these appropriately