org.logicalcobwebs.proxool
Class WrappedConnection

java.lang.Object
  extended by org.logicalcobwebs.proxool.WrappedConnection
All Implemented Interfaces:
Callback, MethodInterceptor

public class WrappedConnection
extends java.lang.Object
implements MethodInterceptor

Wraps up a ProxyConnection. It is proxied as a Connection

Since:
Proxool 0.9
Version:
$Revision: 1.5 $, $Date: 2005/10/02 12:32:58 $
Author:
Bill Horsman, $Author: billhorsman $ (current maintainer)

Field Summary
private  java.lang.String alias
           
private static java.lang.String CLOSE_METHOD
           
private static java.lang.String EQUALS_METHOD
           
private static java.lang.String FINALIZE_METHOD
           
private static java.lang.String GET_META_DATA_METHOD
           
private static java.lang.String HASH_CODE_METHOD
           
private  long id
           
private static java.lang.String IS_CLOSED_METHOD
           
private static Log LOG
           
private  boolean manuallyClosed
          This gets set if the close() method is explicitly called.
private  ProxyConnection proxyConnection
          The wrapped object.
private static java.lang.String TO_STRING_METHOD
           
 
Constructor Summary
WrappedConnection(ProxyConnection proxyConnection)
          Construct this wrapper around the proxy connection
 
Method Summary
 boolean equals(java.lang.Object obj)
          If the object passed to this method is actually a proxied version of this class then compare the real class with this one.
 java.lang.String getAlias()
          Get the alias of the connection pool this connection belongs to
 long getId()
          The ID for the encapsulated ProxyConnection.
 ProxyConnection getProxyConnection()
          Get the encapsulated proxy connection
 java.lang.Object intercept(java.lang.Object obj, java.lang.reflect.Method method, java.lang.Object[] args, MethodProxy proxy)
          Delegates to invoke
 java.lang.Object invoke(java.lang.Object proxy, java.lang.reflect.Method method, java.lang.Object[] args)
          Delegates all operations to the encapsulated ProxyConnection except for: close() equals() hashCode() isClosed() getMetaData() finalize() It also spots mutators and remembers that the property has been changed so that it can be reset.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

LOG

private static final Log LOG

CLOSE_METHOD

private static final java.lang.String CLOSE_METHOD
See Also:
Constant Field Values

IS_CLOSED_METHOD

private static final java.lang.String IS_CLOSED_METHOD
See Also:
Constant Field Values

EQUALS_METHOD

private static final java.lang.String EQUALS_METHOD
See Also:
Constant Field Values

GET_META_DATA_METHOD

private static final java.lang.String GET_META_DATA_METHOD
See Also:
Constant Field Values

FINALIZE_METHOD

private static final java.lang.String FINALIZE_METHOD
See Also:
Constant Field Values

HASH_CODE_METHOD

private static final java.lang.String HASH_CODE_METHOD
See Also:
Constant Field Values

TO_STRING_METHOD

private static final java.lang.String TO_STRING_METHOD
See Also:
Constant Field Values

proxyConnection

private ProxyConnection proxyConnection
The wrapped object. We should protect this and not expose it. We have to make sure that if we pass the proxyConnection to another WrappedConnection then this one can no longer manipulate it.


id

private long id

alias

private java.lang.String alias

manuallyClosed

private boolean manuallyClosed
This gets set if the close() method is explicitly called. The proxyConnection could still be really closed without this wrapper knowing about it yet.

Constructor Detail

WrappedConnection

public WrappedConnection(ProxyConnection proxyConnection)
Construct this wrapper around the proxy connection

Parameters:
proxyConnection - to wrap
Method Detail

getProxyConnection

public ProxyConnection getProxyConnection()
Get the encapsulated proxy connection

Returns:
the proxy connection

intercept

public java.lang.Object intercept(java.lang.Object obj,
                                  java.lang.reflect.Method method,
                                  java.lang.Object[] args,
                                  MethodProxy proxy)
                           throws java.lang.Throwable
Delegates to invoke

Specified by:
intercept in interface MethodInterceptor
Parameters:
obj - "this", the enhanced object
method - intercepted Method
args - argument array; primitive types are wrapped
proxy - used to invoke super (non-intercepted method); may be called as many times as needed
Returns:
any value compatible with the signature of the proxied method. Method returning void will ignore this value.
Throws:
java.lang.Throwable - any exception may be thrown; if so, super method will not be invoked
See Also:
MethodInterceptor.intercept(java.lang.Object, java.lang.reflect.Method, java.lang.Object[], org.logicalcobwebs.cglib.proxy.MethodProxy)

invoke

public java.lang.Object invoke(java.lang.Object proxy,
                               java.lang.reflect.Method method,
                               java.lang.Object[] args)
                        throws java.lang.Throwable
Delegates all operations to the encapsulated ProxyConnection except for: It also spots mutators and remembers that the property has been changed so that it can be reset. And any statements that are returned are remembered so that we can track whether all statements have been closed properly when the connection is returned to the pool.

Throws:
java.lang.Throwable
See Also:
InvocationHandler.invoke(java.lang.Object, java.lang.reflect.Method, java.lang.Object[])

getId

public long getId()
The ID for the encapsulated ProxyConnection. This will still return the correct value after the connection is closed.

Returns:
the ID

getAlias

public java.lang.String getAlias()
Get the alias of the connection pool this connection belongs to

Returns:
alias

equals

public boolean equals(java.lang.Object obj)
If the object passed to this method is actually a proxied version of this class then compare the real class with this one.

Overrides:
equals in class java.lang.Object
Parameters:
obj - the object to compare
Returns:
true if the object is a proxy of "this"

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object
See Also:
Object.toString()