[jboss-svn-commits] JBL Code SVN: r29255 - in labs/jbosstm/workspace/whitingjr/trunk: MVCCSampleEAR and 2 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Tue Sep 8 13:38:09 EDT 2009
Author: whitingjr
Date: 2009-09-08 13:38:08 -0400 (Tue, 08 Sep 2009)
New Revision: 29255
Modified:
labs/jbosstm/workspace/whitingjr/trunk/MVCCSample-build/build.xml
labs/jbosstm/workspace/whitingjr/trunk/MVCCSample-build/pom.xml
labs/jbosstm/workspace/whitingjr/trunk/MVCCSampleEAR/pom.xml
labs/jbosstm/workspace/whitingjr/trunk/MVCCSampleSTM/pom.xml
labs/jbosstm/workspace/whitingjr/trunk/MVCCSampleSTM/src/main/java/uk/ac/ncl/sdia/a8905943/entitymanager/STMEntityManagerImpl.java
Log:
Changed configuration.
added cargo configuration for jboss5
Modified: labs/jbosstm/workspace/whitingjr/trunk/MVCCSample-build/build.xml
===================================================================
--- labs/jbosstm/workspace/whitingjr/trunk/MVCCSample-build/build.xml 2009-09-08 16:15:51 UTC (rev 29254)
+++ labs/jbosstm/workspace/whitingjr/trunk/MVCCSample-build/build.xml 2009-09-08 17:38:08 UTC (rev 29255)
@@ -18,13 +18,13 @@
<target name="build" depends="check-environment">
<echo>project build target called [${basedir}]</echo>
- <artifact:mvn pom="../MVCCSampleSTM/pom.xml" mavenHome="${user.home}/maven-home">
+ <!--artifact:mvn pom="../MVCCSampleSTM/pom.xml" mavenHome="${user.home}/maven-home">
<arg value="clean" />
</artifact:mvn>
<artifact:mvn pom="../MVCCSampleSTM/pom.xml" mavenHome="${user.home}/maven-home">
<arg value="-Dmaven.test.skip=true" />
<arg value="package" />
- </artifact:mvn>
+ </artifact:mvn-->
<artifact:mvn pom="../MVCCSampleEAR/pom.xml" mavenHome="${user.home}/maven-home">
<arg value="clean" />
</artifact:mvn>
Modified: labs/jbosstm/workspace/whitingjr/trunk/MVCCSample-build/pom.xml
===================================================================
--- labs/jbosstm/workspace/whitingjr/trunk/MVCCSample-build/pom.xml 2009-09-08 16:15:51 UTC (rev 29254)
+++ labs/jbosstm/workspace/whitingjr/trunk/MVCCSample-build/pom.xml 2009-09-08 17:38:08 UTC (rev 29255)
@@ -229,6 +229,12 @@
<version>5.1.0.GA</version>
<scope>provided</scope>
</dependency>
-
+ <!-- purely for example applications -->
+ <dependency>
+ <groupId>org.apache.derby</groupId>
+ <artifactId>derby</artifactId>
+ <version>10.2.1.6</version>
+ <scope>provided</scope>
+ </dependency>
</dependencies>
</project>
\ No newline at end of file
Modified: labs/jbosstm/workspace/whitingjr/trunk/MVCCSampleEAR/pom.xml
===================================================================
--- labs/jbosstm/workspace/whitingjr/trunk/MVCCSampleEAR/pom.xml 2009-09-08 16:15:51 UTC (rev 29254)
+++ labs/jbosstm/workspace/whitingjr/trunk/MVCCSampleEAR/pom.xml 2009-09-08 17:38:08 UTC (rev 29255)
@@ -81,8 +81,23 @@
<version>5</version>
<loader-repository>mvccsample:archive=MVCCSampleEAR.ear</loader-repository>
</jboss>
+
+
</configuration>
</plugin>
+ <plugin>
+ <groupId>org.codehaus.cargo</groupId>
+ <artifactId>cargo-maven2-plugin</artifactId>
+ <configuration>
+ <container>
+ <containerId>jboss5x</containerId>
+ <home>/home/whitingjr/java/jboss/jboss-5.1.0.GA</home>
+ </container>
+ <properties>
+ <cargo.logging>low</cargo.logging>
+ </properties>
+ </configuration>
+ </plugin>
</plugins>
</build>
Modified: labs/jbosstm/workspace/whitingjr/trunk/MVCCSampleSTM/pom.xml
===================================================================
--- labs/jbosstm/workspace/whitingjr/trunk/MVCCSampleSTM/pom.xml 2009-09-08 16:15:51 UTC (rev 29254)
+++ labs/jbosstm/workspace/whitingjr/trunk/MVCCSampleSTM/pom.xml 2009-09-08 17:38:08 UTC (rev 29255)
@@ -24,17 +24,17 @@
<scope>test</scope>
</dependency>
<dependency>
- <groupId>log4j</groupId>
- <artifactId>log4j</artifactId>
- <version>1.2.14</version>
- <scope>compile</scope>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>4.5</version>
- <scope>compile</scope>
- </dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <version>1.2.14</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.5</version>
+ <scope>compile</scope>
+ </dependency>
</dependencies>
<build>
<plugins>
@@ -54,9 +54,9 @@
<includes>
<include>uk/ac/ncl/sdia/a8905943/model/Car.class</include>
<include>uk/ac/ncl/sdia/a8905943/model/Bike.class</include>
- <include>uk/ac/ncl/sdia/a8905943/model/LeccyCar.class</include>
- <include>uk/ac/ncl/sdia/a8905943/aspects/STMWriteAspect.class</include>
- <include>uk/ac/ncl/sdia/a8905943/aspects/STMReadAspect.class</include>
+ <include>uk/ac/ncl/sdia/a8905943/model/LeccyCar.class</include>
+ <include>uk/ac/ncl/sdia/a8905943/aspects/STMWriteAspect.class</include>
+ <include>uk/ac/ncl/sdia/a8905943/aspects/STMReadAspect.class</include>
</includes>
<report>false</report>
</configuration>
@@ -75,14 +75,16 @@
<useSystemClassLoader>false</useSystemClassLoader>
<argLine>-Djboss.aop.path=src/main/resources/META-INF/jboss-aop.xml</argLine>
<excludes>
- <exclude>**/AbstractTest.java</exclude>
+ <exclude>**/AbstractTest.java</exclude>
+ <exclude>**/*TransactionExecutor.java</exclude>
+ <exclude>**/*ConflictingRunnableTransaction.java</exclude>
</excludes>
<testFailureIgnore>true</testFailureIgnore>
-
+
</configuration>
</plugin>
</plugins>
</build>
-
-
+
+
</project>
\ No newline at end of file
Modified: labs/jbosstm/workspace/whitingjr/trunk/MVCCSampleSTM/src/main/java/uk/ac/ncl/sdia/a8905943/entitymanager/STMEntityManagerImpl.java
===================================================================
--- labs/jbosstm/workspace/whitingjr/trunk/MVCCSampleSTM/src/main/java/uk/ac/ncl/sdia/a8905943/entitymanager/STMEntityManagerImpl.java 2009-09-08 16:15:51 UTC (rev 29254)
+++ labs/jbosstm/workspace/whitingjr/trunk/MVCCSampleSTM/src/main/java/uk/ac/ncl/sdia/a8905943/entitymanager/STMEntityManagerImpl.java 2009-09-08 17:38:08 UTC (rev 29255)
@@ -7,6 +7,7 @@
package uk.ac.ncl.sdia.a8905943.entitymanager;
import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.sql.Connection;
import java.sql.SQLException;
@@ -19,376 +20,364 @@
import javax.persistence.spi.PersistenceUnitTransactionType;
import javax.transaction.Synchronization;
+import org.apache.commons.jxpath.JXPathContext;
import org.apache.log4j.Logger;
import org.jboss.resource.adapter.jdbc.WrappedConnection;
import uk.ac.ncl.sdia.a8905943.factory.STMFactory;
+import uk.ac.ncl.sdia.a8905943.handle.FieldUtils;
+import uk.ac.ncl.sdia.a8905943.handle.exception.FieldNotFoundException;
import uk.ac.ncl.sdia.a8905943.persistence.jdbc.STMConnection;
-final class STMEntityManagerImpl implements EntityManager
-{
- private PersistenceUnitTransactionType type;
+final class STMEntityManagerImpl implements EntityManager {
+ private PersistenceUnitTransactionType type;
- // this reference is a wrapped object
- protected Connection connection;
+ // this reference is a wrapped object
+ protected Connection connection;
- private static final Logger logger = Logger.getLogger(STMEntityManagerImpl.class);
-
- private boolean isOpen = false;
+ private static final Logger logger = Logger
+ .getLogger(STMEntityManagerImpl.class);
- @Override
- public void clear()
- {
- STMFactory.getFactoryInstance().deallocate();
- }
+ private boolean isOpen = false;
- @Override
- public void close()
- {
- /* get the currently active transaction on this thread, register a synchronization
- * to close the Connection object. */
- if (logger.isDebugEnabled())
- {
- logger.debug("STMEntityManagerImpl.close called.");
- }
-
- //TransactionManager transactionManager = ServiceLocator.findLocalPersonManager();
- try
- {
- this.connection.close();
- /*
- Transaction transaction = transactionManager.getTransaction();
- if (null != transaction)
- {
- transaction.registerSynchronization(new CloseSTMEM());
- }
- */
- }
- /*catch (SystemException se)
- {
- logger
- .error(
- "Problem occured when registering a synchronization to close the Connection after the Transaction has completed.",
- se);
- throw new RuntimeException(se);
- }
- catch (RollbackException re)
- {
- logger.error("Could not register a Synchronization for STMEntityManager");
- throw new RuntimeException(re);
- }*/
- catch (SQLException sqle)
- {
- logger.error("SQLException occured when closing the connection object when, the EM is closed.");
- throw new RuntimeException(sqle);
- }
- STMFactory.getFactoryInstance().deallocate();
-
- this.isOpen = false;
- }
+ @Override
+ public void clear() {
+ STMFactory.getFactoryInstance().deallocate();
+ }
- @Override
- public boolean contains(Object entity)
- {
- // TODO: jrw check the STM using the open connection to check if this entity exists, use primary key
- return false;
- }
+ @Override
+ public void close() {
+ /*
+ * get the currently active transaction on this thread, register a
+ * synchronization to close the Connection object.
+ */
+ if (logger.isDebugEnabled()) {
+ logger.debug("STMEntityManagerImpl.close called.");
+ }
- @Override
- public Query createNamedQuery(String name)
- {
- if (true)
- {
- throw new UnsupportedOperationException("Unsupported operation createNamedQuery(String)");
- }
- return null;
- }
+ // TransactionManager transactionManager =
+ // ServiceLocator.findLocalPersonManager();
+ try {
+ this.connection.close();
+ /*
+ * Transaction transaction = transactionManager.getTransaction(); if
+ * (null != transaction) { transaction.registerSynchronization(new
+ * CloseSTMEM()); }
+ */
+ }
+ /*
+ * catch (SystemException se) { logger .error(
+ * "Problem occured when registering a synchronization to close the Connection after the Transaction has completed."
+ * , se); throw new RuntimeException(se); } catch (RollbackException re)
+ * {
+ * logger.error("Could not register a Synchronization for STMEntityManager"
+ * ); throw new RuntimeException(re); }
+ */
+ catch (SQLException sqle) {
+ logger
+ .error("SQLException occured when closing the connection object when, the EM is closed.");
+ throw new RuntimeException(sqle);
+ }
+ STMFactory.getFactoryInstance().deallocate();
- @Override
- public Query createNativeQuery(String sqlString)
- {
- if (true)
- {
- throw new UnsupportedOperationException("Unsupported operation createNamedQuery(String)");
- }
+ this.isOpen = false;
+ }
- return null;
- }
+ /**
+ * This method will use the entity class details and the unique identity to
+ * verify if the entity exists in the model store.
+ */
+ @Override
+ public boolean contains(Object entity) {// check the memory store for the
+ // presence of the managed entity
+ boolean returnValue = false;
+ String entityFQCN = null;
+ Long entityUniqueIdentity = null;
- @Override
- public Query createNativeQuery(String sqlString, Class resultClass)
- {
- if (true)
- {
- throw new UnsupportedOperationException("Unsupported operation createNamedQuery(String)");
- }
- return null;
- }
+ if (null != entity) {
+ entityFQCN = entity.getClass().getName();
+ FieldUtils fieldUtils = new FieldUtils();
+ try
+ {
+ Field idField = fieldUtils.findIdField(entity.getClass());
+ entityUniqueIdentity = fieldUtils.getValue(idField, entity);
+ JXPathContext context = JXPathContext.newContext(getSTMConnection().getSTM());
+ context.getVariables().declareVariable("entityType", entityFQCN);
+ context.getVariables().declareVariable("identityField", idField.getName());
+ context.getVariables().declareVariable("identityValue", entityUniqueIdentity);
+ returnValue = (null == context.getValue("model/$entityType[$identityField=$identityValue]") ? Boolean.FALSE.booleanValue(): Boolean.TRUE.booleanValue());
+ }
+ catch (FieldNotFoundException fnfe)
+ {
+ this.logger.error(fnfe.getMessage(), fnfe);
+ }
+ }
+ return returnValue;
+ }
- @Override
- public Query createNativeQuery(String sqlString, String resultSetMapping)
- {
- if (true)
- {
- throw new UnsupportedOperationException("Unsupported operation createNamedQuery(String)");
- }
- return null;
- }
+ @Override
+ public Query createNamedQuery(String name) {
+ if (true) {
+ throw new UnsupportedOperationException(
+ "Unsupported operation createNamedQuery(String)");
+ }
+ return null;
+ }
- @Override
- public Query createQuery(String qlString)
- {
- if (true)
- {
- throw new UnsupportedOperationException("Unsupported operation createNamedQuery(String)");
- }
- return null;
- }
+ @Override
+ public Query createNativeQuery(String sqlString) {
+ if (true) {
+ throw new UnsupportedOperationException(
+ "Unsupported operation createNamedQuery(String)");
+ }
- @Override
- /**
- * To call this method the entity object is expected to follow this contract.
- * Entity has one constructor that is public, contains only one field and is of
- * type {@link java.lang.Long}.
- * The entity class is annotated with the STMEntity annotation.
- * This method does not hit the STM system and only uses reflection to create
- * an instance of the entity.
- */
- public <T> T find(Class<T> entityClass, Object primaryKey)
- {
- if (logger.isDebugEnabled())
- {
- logger.debug("STMEntityManagerImpl.find called.");
- }
- T returnValue = null;
- // check if the class has been annotated using the STM annotations.
- boolean isstmEntity = false;
-
- /** This no longer works, using AOP means the reference given is an instance of
- * some proxy class. */
- /*for (Annotation annotation : entityClass.getAnnotations())
- {
- if (annotation instanceof STMEntity)
- {
- isstmEntity = true;
- }
- }
- */
- //TODO: jrw replace this implementation, should go into STM and check the model store for existence.
- isstmEntity = true;
- if (isstmEntity)
- {// STM entity class, create an instance
- try
- {
- Constructor<T> targetConstructor = entityClass.getConstructor(Long.class);
- returnValue = targetConstructor.newInstance(primaryKey);
- }
- catch (InstantiationException ie)
- {
- logger.error("Problem occured when creating an instance of an entity object.", ie);
- }
- catch (IllegalAccessException iae)
- {
- logger.error("Problem occured when creating an entity, constructor is expected to be public.", iae);
- }
- catch (NoSuchMethodException nsme)
- {
- logger
- .error(
- "Expected constructor does not exist, please create a public constructor taking the primary key field only.",
- nsme);
- if (logger.isDebugEnabled())
- {
- logger.debug(log(entityClass));
- for (Constructor constructor : entityClass.getConstructors())
- {
- logger.debug("Constructor ["+constructor.toGenericString()+"]");
- }
- }
- }
- catch (IllegalArgumentException illae)
- {
- logger.error("Expected primary key type is expected to be Long.", illae);
- }
- catch (InvocationTargetException e)
- {
- logger.error("Something went wrong when getting creating an entity object", e);
- }
- }
- else
- {
- if (logger.isDebugEnabled())
- {
- logger.debug(log(entityClass));
- }
- }
- return returnValue;
- }
+ return null;
+ }
- @Override
- public void flush()
- {
- if (true)
- {
- throw new UnsupportedOperationException("Unsupported operation createNamedQuery(String)");
- }
- }
-
- public String log(Class entityClass)
- {
- String name=entityClass.getName();
- name=name.substring(name.lastIndexOf(".")+1) + ".class";
- return name + " loaded from " + entityClass.getResource(name);
- }
+ @Override
+ public Query createNativeQuery(String sqlString, Class resultClass) {
+ if (true) {
+ throw new UnsupportedOperationException(
+ "Unsupported operation createNamedQuery(String)");
+ }
+ return null;
+ }
- @Override
- public Object getDelegate()
- {
- // FIXME getDelegate
- return null;
- }
+ @Override
+ public Query createNativeQuery(String sqlString, String resultSetMapping) {
+ if (true) {
+ throw new UnsupportedOperationException(
+ "Unsupported operation createNamedQuery(String)");
+ }
+ return null;
+ }
- @Override
- public FlushModeType getFlushMode()
- {
- // FIXME getFlushMode
- return null;
- }
+ @Override
+ public Query createQuery(String qlString) {
+ if (true) {
+ throw new UnsupportedOperationException(
+ "Unsupported operation createNamedQuery(String)");
+ }
+ return null;
+ }
- @Override
- public <T> T getReference(Class<T> entityClass, Object primaryKey)
- {
- // FIXME getReference
- return null;
- }
+ @Override
+ /**
+ * To call this method the entity object is expected to follow this contract.
+ * Entity has one constructor that is public, contains only one field and is of
+ * type {@link java.lang.Long}.
+ * The entity class is annotated with the STMEntity annotation.
+ * This method does not hit the STM system and only uses reflection to create
+ * an instance of the entity.
+ */
+ public <T> T find(Class<T> entityClass, Object primaryKey) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("STMEntityManagerImpl.find called.");
+ }
+ T returnValue = null;
+ // check if the class has been annotated using the STM annotations.
+ boolean isstmEntity = false;
- @Override
- public EntityTransaction getTransaction()
- {
- if (PersistenceUnitTransactionType.JTA == this.type)
- {
- throw new IllegalStateException(
- "An EntityTransaction used bye EXTENDED entity managers is not allowed for the JTA transaction types.");
- }
- return null;
- }
+ /**
+ * This no longer works, using AOP means the reference given is an
+ * instance of some proxy class.
+ */
+ /*
+ * for (Annotation annotation : entityClass.getAnnotations()) { if
+ * (annotation instanceof STMEntity) { isstmEntity = true; } }
+ */
+ // TODO: jrw replace this implementation, should go into STM and check
+ // the model store for existence.
+ isstmEntity = true;
+ if (isstmEntity) {// STM entity class, create an instance
+ try {
+ Constructor<T> targetConstructor = entityClass
+ .getConstructor(Long.class);
+ returnValue = targetConstructor.newInstance(primaryKey);
+ } catch (InstantiationException ie) {
+ logger
+ .error(
+ "Problem occured when creating an instance of an entity object.",
+ ie);
+ } catch (IllegalAccessException iae) {
+ logger
+ .error(
+ "Problem occured when creating an entity, constructor is expected to be public.",
+ iae);
+ } catch (NoSuchMethodException nsme) {
+ logger
+ .error(
+ "Expected constructor does not exist, please create a public constructor taking the primary key field only.",
+ nsme);
+ if (logger.isDebugEnabled()) {
+ logger.debug(log(entityClass));
+ for (Constructor constructor : entityClass
+ .getConstructors()) {
+ logger.debug("Constructor ["
+ + constructor.toGenericString() + "]");
+ }
+ }
+ } catch (IllegalArgumentException illae) {
+ logger.error(
+ "Expected primary key type is expected to be Long.",
+ illae);
+ } catch (InvocationTargetException e) {
+ logger
+ .error(
+ "Something went wrong when getting creating an entity object",
+ e);
+ }
+ } else {
+ if (logger.isDebugEnabled()) {
+ logger.debug(log(entityClass));
+ }
+ }
+ return returnValue;
+ }
- @Override
- public boolean isOpen()
- {
- return this.isOpen;
- }
+ @Override
+ public void flush() {
+ if (true) {
+ throw new UnsupportedOperationException(
+ "Unsupported operation createNamedQuery(String)");
+ }
+ }
- @Override
- public void joinTransaction()
- {
- // FIXME joinTransaction
+ public String log(Class entityClass) {
+ String name = entityClass.getName();
+ name = name.substring(name.lastIndexOf(".") + 1) + ".class";
+ return name + " loaded from " + entityClass.getResource(name);
+ }
- }
+ @Override
+ public Object getDelegate() {
+ // FIXME getDelegate
+ return null;
+ }
- @Override
- public void lock(Object entity, LockModeType lockMode)
- {
- // FIXME lock
+ @Override
+ public FlushModeType getFlushMode() {
+ // FIXME getFlushMode
+ return null;
+ }
- }
+ @Override
+ public <T> T getReference(Class<T> entityClass, Object primaryKey) {
+ // FIXME getReference
+ return null;
+ }
- @Override
- public <T> T merge(T entity)
- {
- // FIXME merge
- return null;
- }
+ @Override
+ public EntityTransaction getTransaction() {
+ if (PersistenceUnitTransactionType.JTA == this.type) {
+ throw new IllegalStateException(
+ "An EntityTransaction used bye EXTENDED entity managers is not allowed for the JTA transaction types.");
+ }
+ return null;
+ }
- @Override
- public void persist(Object entity)
- {
- // FIXME persist
+ @Override
+ public boolean isOpen() {
+ return this.isOpen;
+ }
- }
+ @Override
+ public void joinTransaction() {
+ // FIXME joinTransaction
- @Override
- public void refresh(Object entity)
- {
- // FIXME refresh
+ }
- }
+ @Override
+ public void lock(Object entity, LockModeType lockMode) {
+ // FIXME lock
- @Override
- public void remove(Object entity)
- {
- // FIXME remove
+ }
- }
+ @Override
+ public <T> T merge(T entity) {
+ // FIXME merge
+ return null;
+ }
- @Override
- public void setFlushMode(FlushModeType flushMode)
- {
- // FIXME setFlushMode
+ @Override
+ public void persist(Object entity) {
+ // FIXME persist
- }
+ }
- private STMEntityManagerImpl()
- {
- }
+ @Override
+ public void refresh(Object entity) {
+ // FIXME refresh
- public STMEntityManagerImpl(Connection connection)
- {
- this();
- this.connection = connection;
- STMFactory.getFactoryInstance().allocate(getSTMConnection().getSTM());
- }
+ }
- public STMConnection getSTMConnection()
- {
- STMConnection returnValue = null;
- if (null != this.connection )
- {
- try
- {
- returnValue = (STMConnection)((WrappedConnection)this.connection).getUnderlyingConnection();
- }
- catch (SQLException sqle)
- {
- logger.error(sqle);
- throw new RuntimeException(sqle);
- }
- }
- return returnValue;
- }
+ @Override
+ public void remove(Object entity) {
+ // FIXME remove
- public void setConnection(Connection connection)
- {
- this.connection = connection;
- }
+ }
- private class CloseSTMEM implements Synchronization
- {
- private final Logger logger = Logger.getLogger(CloseSTMEM.class);
+ @Override
+ public void setFlushMode(FlushModeType flushMode) {
+ // FIXME setFlushMode
- @Override
- public void beforeCompletion()
- {
- // do nothing
- }
+ }
- @Override
- public void afterCompletion(int status)
- {
- /* Check to see if the Connection has been release back to the
- * pool.*/
- try
- {
- STMFactory.getFactoryInstance().deallocate();
- if (!connection.isClosed())
- {
- connection.close();// release connection back into container pool
- }
- }
- catch (SQLException e)
- {
- logger.error("Error", e);
- }
- }
- }
+ private STMEntityManagerImpl() {
+ }
+
+ public STMEntityManagerImpl(Connection connection) {
+ this();
+ this.connection = connection;
+ STMFactory.getFactoryInstance().allocate(getSTMConnection().getSTM());
+ }
+
+ public STMConnection getSTMConnection() {
+ STMConnection returnValue = null;
+ if (null != this.connection) {
+ try {
+ returnValue = (STMConnection) ((WrappedConnection) this.connection)
+ .getUnderlyingConnection();
+ } catch (SQLException sqle) {
+ logger.error(sqle);
+ throw new RuntimeException(sqle);
+ } catch (ClassCastException cce) {// check to see if this connection
+ // is a basic STMConnection,
+ // used in unit testing
+ if (this.connection instanceof STMConnection) {
+ returnValue = (STMConnection) this.connection;
+ }
+ }
+ }
+ return returnValue;
+ }
+
+ public void setConnection(Connection connection) {
+ this.connection = connection;
+ }
+
+ private class CloseSTMEM implements Synchronization {
+ private final Logger logger = Logger.getLogger(CloseSTMEM.class);
+
+ @Override
+ public void beforeCompletion() {
+ // do nothing
+ }
+
+ @Override
+ public void afterCompletion(int status) {
+ /*
+ * Check to see if the Connection has been release back to the pool.
+ */
+ try {
+ STMFactory.getFactoryInstance().deallocate();
+ if (!connection.isClosed()) {
+ connection.close();// release connection back into container
+ // pool
+ }
+ } catch (SQLException e) {
+ logger.error("Error", e);
+ }
+ }
+ }
}
More information about the jboss-svn-commits
mailing list