org.slim3.datasource
Class ConnectionInvocationHandler

java.lang.Object
  extended by org.slim3.datasource.ConnectionInvocationHandler
All Implemented Interfaces:
InvocationHandler

public class ConnectionInvocationHandler
extends Object
implements InvocationHandler

InvocationHandler for connection.

Since:
3.0
Author:
higa

Field Summary
protected  AtomicBoolean closed
          Whether logical connection is closed.
protected static Log log
          The log.
protected  Connection physicalConnection
          The original connection.
protected  XAConnectionImpl pooledConnection
          The pooled connection.
protected  XAResourceImpl xaResource
          The XA resource.
protected  Xid xid
          The transaction identifier.
 
Constructor Summary
ConnectionInvocationHandler(XAConnectionImpl pooledConnection)
          Constructor.
 
Method Summary
protected  void assertOpened()
          Asserts this connection is opened.
protected  void close()
          Closes logical connection.
protected  void closeForError(SQLException error)
          Closes logical connection when error has occurred.
 Object invoke(Object proxy, Method method, Object[] args)
           
protected  boolean isClosed()
          Determines if this connection is closed.
protected  boolean isCloseMethod(Method method)
          Determines if the method is "close" method.
protected  boolean isEqualsMethod(Method method)
          Determines if the method is "getPhysicalConnection" method.
protected  boolean isGetPhysicalConnectionMethod(Method method)
          Determines if the method is "getPhysicalConnection" method.
protected  boolean isIsClosedMethod(Method method)
          Determines if the method is "isClosed" method.
protected  boolean isSameProxy(Object o)
          Determines if an object is same proxy.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected static Log log
The log.


physicalConnection

protected final Connection physicalConnection
The original connection.


pooledConnection

protected final XAConnectionImpl pooledConnection
The pooled connection.


xaResource

protected final XAResourceImpl xaResource
The XA resource.


xid

protected final Xid xid
The transaction identifier.


closed

protected AtomicBoolean closed
Whether logical connection is closed.

Constructor Detail

ConnectionInvocationHandler

public ConnectionInvocationHandler(XAConnectionImpl pooledConnection)
                            throws NullPointerException
Constructor.

Parameters:
pooledConnection - the pooled connection
Throws:
NullPointerException - if the pooledConnection parameter is null
Method Detail

invoke

public Object invoke(Object proxy,
                     Method method,
                     Object[] args)
              throws Throwable
Specified by:
invoke in interface InvocationHandler
Throws:
Throwable

isClosed

protected boolean isClosed()
                    throws RuntimeException
Determines if this connection is closed.

Returns:
whether this connection is closed
Throws:
RuntimeException - if SystemException is encountered

assertOpened

protected void assertOpened()
                     throws SQLException
Asserts this connection is opened.

Throws:
SQLException

isCloseMethod

protected boolean isCloseMethod(Method method)
Determines if the method is "close" method.

Parameters:
method - the method
Returns:
whether the method is "close" method

isIsClosedMethod

protected boolean isIsClosedMethod(Method method)
Determines if the method is "isClosed" method.

Parameters:
method - the method
Returns:
whether the method is "isClosed" method

isGetPhysicalConnectionMethod

protected boolean isGetPhysicalConnectionMethod(Method method)
Determines if the method is "getPhysicalConnection" method.

Parameters:
method - the method
Returns:
whether the method is "getPhysicalConnection" method

isEqualsMethod

protected boolean isEqualsMethod(Method method)
Determines if the method is "getPhysicalConnection" method.

Parameters:
method - the method
Returns:
whether the method is "getPhysicalConnection" method

close

protected void close()
              throws SQLException
Closes logical connection.

Throws:
SQLException - if an exception is encountered

closeForError

protected void closeForError(SQLException error)
Closes logical connection when error has occurred.

Parameters:
error - the error

isSameProxy

protected boolean isSameProxy(Object o)
Determines if an object is same proxy.

Parameters:
o - an object
Returns:
whether an object is same proxy


Copyright © 2008-2009 The Slim3 project. All Rights Reserved.