com.metamatrix.common.connection
Class ManagedConnection

java.lang.Object
  extended by com.metamatrix.common.connection.ManagedConnection
Direct Known Subclasses:
JDBCMgdResourceConnection, SimpleManagedConnection

public abstract class ManagedConnection
extends java.lang.Object


Nested Class Summary
static class ManagedConnection.ConnectionStatistics
           
 
Field Summary
static java.lang.String DATABASE
          The environment property name for the database name.
static java.lang.String DRIVER
          The environment property name for the class of the driver.
static java.lang.String PASSWORD
          The environment property name for the password that is to be used for connecting to the metadata store.
static java.lang.String PROTOCOL
          The environment property name for the protocol that is to be used.
static java.lang.String USERNAME
          The environment property name for the username that is to be used for connecting to the metadata store.
 
Constructor Summary
protected ManagedConnection(java.util.Properties env)
          Create a new instance of a metadata connection.
 
Method Summary
 void close()
          This method is invoked by the pool to notify the specialized class that the connection is to be terminated.
protected abstract  void closeConnection()
          This method is invoked by the pool to notify the specialized class that the connection is to be terminated.
 void commit()
          Make all changes made since the previous commit/rollback permanent, and release any data source locks currently held by the Connection.
protected  void finalize()
           
 java.util.Properties getEnvironment()
          Obtain the environment properties for this metadata connection.
 ManagedConnection.ConnectionStatistics getStats()
           
 java.lang.String getUserName()
          Returns the name of the user using this managed connection
 void open()
          This method is invoked by the pool to notify the specialized class that the connection is to be established.
protected abstract  void openConnection()
          This method is invoked by the pool to notify the specialized class that the connection is to be established.
protected abstract  void performCommit()
          Make all changes made since the previous commit/rollback permanent, and release any data source locks currently held by the Connection.
protected abstract  void performRollback()
          Make all changes made since the previous commit/rollback permanent, and release any data source locks currently held by the Connection.
protected abstract  void prepareForRead()
          Prepare this connection for read-only transactions.
protected abstract  void prepareForWrite()
          Prepare this connection for write transactions.
 void rollback()
          Make all changes made since the previous commit/rollback permanent, and release any data source locks currently held by the Connection.
 void setForRead()
          Prepare this connection for read-only transactions.
 void setForWrite()
          Prepare this connection for write transactions.
protected  void setUserName(java.lang.String userName)
          This is a new method added as part of the ResourcePooling framework.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DRIVER

public static final java.lang.String DRIVER
The environment property name for the class of the driver. This property is optional.

See Also:
Constant Field Values

PROTOCOL

public static final java.lang.String PROTOCOL
The environment property name for the protocol that is to be used. For JDBC, the connection URL information is created of the form "jdbc:subprotocol:subname", where the value of the PROTOCOL property is used for the "subprotocol:subname" portion. This property is required.

See Also:
Constant Field Values

DATABASE

public static final java.lang.String DATABASE
The environment property name for the database name. This may include the server name and port number, per the driver's requirements. This property is required.

See Also:
Constant Field Values

USERNAME

public static final java.lang.String USERNAME
The environment property name for the username that is to be used for connecting to the metadata store. This property is required.

See Also:
Constant Field Values

PASSWORD

public static final java.lang.String PASSWORD
The environment property name for the password that is to be used for connecting to the metadata store. This property is required.

See Also:
Constant Field Values
Constructor Detail

ManagedConnection

protected ManagedConnection(java.util.Properties env)
Create a new instance of a metadata connection.

Parameters:
context - the metadata context for the connection.
env - the environment properties for the new connection.
Method Detail

finalize

protected void finalize()
Overrides:
finalize in class java.lang.Object

setUserName

protected void setUserName(java.lang.String userName)
This is a new method added as part of the ResourcePooling framework. New extended ManagedConnection classes should set the userName


getUserName

public java.lang.String getUserName()
Returns the name of the user using this managed connection

Returns:
String user name

getEnvironment

public final java.util.Properties getEnvironment()
Obtain the environment properties for this metadata connection. These properties cannot be modified while the metadata connection is in existance.

Returns:
the environment for this metadata connection.

open

public final void open()
                throws ManagedConnectionException
This method is invoked by the pool to notify the specialized class that the connection is to be established.

Throws:
ManagedConnectionException - if there is an error establishing the connection.

close

public final void close()
                 throws ManagedConnectionException
This method is invoked by the pool to notify the specialized class that the connection is to be terminated.

Throws:
ManagedConnectionException - if there is an error terminating the connection.

openConnection

protected abstract void openConnection()
                                throws ManagedConnectionException
This method is invoked by the pool to notify the specialized class that the connection is to be established.

Throws:
ManagedConnectionException - if there is an error establishing the connection.

closeConnection

protected abstract void closeConnection()
                                 throws ManagedConnectionException
This method is invoked by the pool to notify the specialized class that the connection is to be terminated.

Throws:
ManagedConnectionException - if there is an error terminating the connection.

setForRead

public final void setForRead()
                      throws ManagedConnectionException
Prepare this connection for read-only transactions.

Throws:
ManagedConnectionException - if an error occurred within or during communication with this connection.

setForWrite

public final void setForWrite()
                       throws ManagedConnectionException
Prepare this connection for write transactions.

Throws:
ManagedConnectionException - if an error occurred within or during communication with this connection.

prepareForRead

protected abstract void prepareForRead()
                                throws ManagedConnectionException
Prepare this connection for read-only transactions.

Throws:
ManagedConnectionException - if an error occurred within or during communication with this connection.

prepareForWrite

protected abstract void prepareForWrite()
                                 throws ManagedConnectionException
Prepare this connection for write transactions.

Throws:
ManagedConnectionException - if an error occurred within or during communication with this connection.

commit

public final void commit()
                  throws ManagedConnectionException
Make all changes made since the previous commit/rollback permanent, and release any data source locks currently held by the Connection.

Throws:
ManagedConnectionException - if an error occurred within or during communication with this connection.

rollback

public final void rollback()
                    throws ManagedConnectionException
Make all changes made since the previous commit/rollback permanent, and release any data source locks currently held by the Connection.

Throws:
ManagedConnectionException - if an error occurred within or during communication with this connection.

performCommit

protected abstract void performCommit()
                               throws ManagedConnectionException
Make all changes made since the previous commit/rollback permanent, and release any data source locks currently held by the Connection.

Throws:
ManagedConnectionException - if an error occurred within or during communication with this connection.

performRollback

protected abstract void performRollback()
                                 throws ManagedConnectionException
Make all changes made since the previous commit/rollback permanent, and release any data source locks currently held by the Connection.

Throws:
ManagedConnectionException - if an error occurred within or during communication with this connection.

getStats

public final ManagedConnection.ConnectionStatistics getStats()


Copyright © 2009. All Rights Reserved.