|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.xenonsoft.bridgetown.aop.helper.SimpleJDBCTransactionInterceptor
A simple JDBC Transaction interceptor that advises a target bean. This interceptor acquires a JDBC connection from an external bean source. In the auto commit of the connection is saved and then switched to false. It then proceed to inject the connection in the target bean using a property (setter injection). The interceptor executes the target method.
If the inteception method returns normally then the connection is committed.
If the inteception method returns abnormally by raising an exception, then the connection is rolled back.
Regardlessly of normal or abnormal execution, the connection is alway released after used. If the close on release flag is set, the connection will be closed.
| Field Summary | |
protected boolean |
closeOnRelease
Close when we release the connection boolean flag |
protected java.lang.Object |
connectionBean
The bean that has the JDBC connection |
protected java.lang.String |
connectionProperty
The property name of the connection bean that will return a JDBC connection |
protected java.lang.String |
targetProperty
The property name of the Advised bean that expects the JDBC connection |
| Constructor Summary | |
SimpleJDBCTransactionInterceptor()
Default constructor |
|
| Method Summary | |
java.sql.Connection |
acquireConnection()
Acquire the JDBC connection |
java.lang.Object |
getConnectionBean()
Gets the JDBC connection bean |
java.lang.String |
getConnectionProperty()
Gets the JDBC connection property of the bean |
java.lang.String |
getTargetProperty()
Gets the property of the target bean being advised |
void |
injectConnectionDependency(java.lang.Object targetBean,
java.sql.Connection conn)
Inject the connection into the target bean being advised |
java.lang.Object |
invocation(IInterceptionContext context)
Implements / overrides method invocation |
boolean |
isCloseOnRelease()
Gets the close on release connection flag |
void |
releaseConnection(java.sql.Connection conn)
Release the previously acquired JDBC connection |
void |
setCloseOnRelease(boolean closeOnRelease)
Sets the close on release connection flag |
void |
setConnectionBean(java.lang.Object connectionBean)
Sets the JDBC connection bean |
void |
setConnectionProperty(java.lang.String connectionProperty)
Sets the JDBC connection property of the bean |
void |
setTargetProperty(java.lang.String targetProperty)
Sets the property of the target bean being advised |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
protected java.lang.Object connectionBean
protected java.lang.String connectionProperty
protected java.lang.String targetProperty
protected boolean closeOnRelease
| Constructor Detail |
public SimpleJDBCTransactionInterceptor()
| Method Detail |
public boolean isCloseOnRelease()
public void setCloseOnRelease(boolean closeOnRelease)
closeOnRelease - the new value for closeOnReleasepublic java.lang.Object getConnectionBean()
public void setConnectionBean(java.lang.Object connectionBean)
connectionBean - the new value for connectionBeanpublic java.lang.String getConnectionProperty()
public void setConnectionProperty(java.lang.String connectionProperty)
connectionProperty - the new value for connectionPropertypublic java.lang.String getTargetProperty()
public void setTargetProperty(java.lang.String targetProperty)
targetProperty - the new value for targetProperty
public java.lang.Object invocation(IInterceptionContext context)
throws java.lang.Throwable
invocation in interface IMethodInterceptorcontext - contextual informal about the intercepted method
java.lang.ThrowableIMethodInterceptor.invocation(com.xenonsoft.bridgetown.aop.IInterceptionContext)public java.sql.Connection acquireConnection()
java.lang.RuntimeExceptionpublic void releaseConnection(java.sql.Connection conn)
conn - the JDBC connection
public void injectConnectionDependency(java.lang.Object targetBean,
java.sql.Connection conn)
targetBean - the target beanconn - the JDBC connection
InterceptionWeaveException - failure to inject dependency
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||