You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ode.apache.org by se...@apache.org on 2009/06/08 04:41:17 UTC
svn commit: r782509 - in /ode/trunk: ./ axis2-war/ bpel-test/
dao-hibernate/src/main/java/org/apache/ode/daohib/
dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/ dao-jpa-db/
Author: seanahn
Date: Mon Jun 8 02:41:17 2009
New Revision: 782509
URL: http://svn.apache.org/viewvc?rev=782509&view=rev
Log:
Upgraded to Hibernate 3.3.1.GA
Added:
ode/trunk/dao-hibernate/src/main/java/org/apache/ode/daohib/JotmTransaction.java
ode/trunk/dao-hibernate/src/main/java/org/apache/ode/daohib/JotmTransactionFactory.java
Modified:
ode/trunk/Buildfile
ode/trunk/axis2-war/ (props changed)
ode/trunk/bpel-test/ (props changed)
ode/trunk/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/BpelDAOConnectionFactoryImpl.java
ode/trunk/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/BpelDAOConnectionImpl.java
ode/trunk/dao-jpa-db/ (props changed)
Modified: ode/trunk/Buildfile
URL: http://svn.apache.org/viewvc/ode/trunk/Buildfile?rev=782509&r1=782508&r2=782509&view=diff
==============================================================================
--- ode/trunk/Buildfile (original)
+++ ode/trunk/Buildfile Mon Jun 8 02:41:17 2009
@@ -134,8 +134,8 @@
:transaction =>"org.apache.geronimo.components:geronimo-transaction:jar:2.0.1",
:connector =>"org.apache.geronimo.components:geronimo-connector:jar:2.0.1"
)
-HIBERNATE = [ "org.hibernate:hibernate:jar:3.2.5.ga", "asm:asm:jar:1.5.3",
- "antlr:antlr:jar:2.7.6", "cglib:cglib:jar:2.1_3", "net.sf.ehcache:ehcache:jar:1.2.3" ]
+HIBERNATE = [ "org.hibernate:hibernate-core:jar:3.3.1.GA", "javassist:javassist:jar:3.4.GA",
+ "antlr:antlr:jar:2.7.6" ]
HSQLDB = "hsqldb:hsqldb:jar:1.8.0.7"
JAVAX = struct(
:activation => findArtifacts(AXIS2_DEPS, "org.apache.geronimo.specs:geronimo-activation_1.1_spec"), #"javax.activation:activation:jar:1.1", # TODO: do we use Sun's or Geronimo's?
@@ -160,6 +160,7 @@
SAXON = group("saxon", "saxon-xpath", "saxon-dom", "saxon-xqj", :under=>"net.sf.saxon", :version=>"9.x")
SERVICEMIX = group("servicemix-core", "servicemix-shared", "servicemix-services",
:under=>"org.apache.servicemix", :version=>"3.1-incubating")
+SLF4J = group(%w{ slf4j-api slf4j-log4j12 jcl104-over-slf4j }, :under=>"org.slf4j", :version=>"1.4.3")
SPRING = group("spring-beans", "spring-context", "spring-core", "spring-jmx",
:under=>"org.springframework", :version=>"2.0.1")
TRANQL = [ "tranql:tranql-connector:jar:1.1", "axion:axion:jar:1.0-M3-dev", COMMONS.primitives ]
@@ -184,6 +185,7 @@
repositories.remote << "http://people.apache.org/repo/m2-snapshot-repository"
repositories.remote << "http://download.java.net/maven/2"
repositories.remote << "http://ws.zones.apache.org/repository2"
+repositories.remote << "http://repository.jboss.org/maven2"
repositories.release_to[:url] ||= "sftp://guest@localhost/home/guest"
desc "Apache ODE"
@@ -381,7 +383,7 @@
resources hibernate_doclet(:package=>"org.apache.ode.store.hib", :excludedtags=>"@version,@author,@todo")
test.with COMMONS.collections, COMMONS.lang, JAVAX.connector, JAVAX.transaction, DOM4J, LOG4J,
- XERCES, XALAN, JAXEN, SAXON, OPENJPA
+ XERCES, XALAN, JAXEN, SAXON, OPENJPA, SLF4J
package :jar
end
@@ -417,7 +419,7 @@
test.exclude "org.apache.ode.daohib.bpel.BaseTestDAO"
test.with project("il-common"), BACKPORT, COMMONS.collections, COMMONS.lang, HSQLDB,
- GERONIMO.transaction, GERONIMO.kernel, GERONIMO.connector, JAVAX.connector, JAVAX.ejb, SPRING
+ GERONIMO.transaction, GERONIMO.kernel, GERONIMO.connector, JAVAX.connector, JAVAX.ejb, SPRING, SLF4J, LOG4J
package :jar
end
Propchange: ode/trunk/axis2-war/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Mon Jun 8 02:41:17 2009
@@ -5,3 +5,5 @@
*~
reports
*.log
+log
+bin
Propchange: ode/trunk/bpel-test/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Mon Jun 8 02:41:17 2009
@@ -3,7 +3,7 @@
.project
~*
*~
-
.project.swp
reports
*.log
+test-output
Added: ode/trunk/dao-hibernate/src/main/java/org/apache/ode/daohib/JotmTransaction.java
URL: http://svn.apache.org/viewvc/ode/trunk/dao-hibernate/src/main/java/org/apache/ode/daohib/JotmTransaction.java?rev=782509&view=auto
==============================================================================
--- ode/trunk/dao-hibernate/src/main/java/org/apache/ode/daohib/JotmTransaction.java (added)
+++ ode/trunk/dao-hibernate/src/main/java/org/apache/ode/daohib/JotmTransaction.java Mon Jun 8 02:41:17 2009
@@ -0,0 +1,360 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.apache.ode.daohib;
+
+import javax.transaction.Status;
+import javax.transaction.Synchronization;
+import javax.transaction.SystemException;
+import javax.transaction.TransactionManager;
+import javax.transaction.UserTransaction;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.hibernate.HibernateException;
+import org.hibernate.Transaction;
+import org.hibernate.TransactionException;
+import org.hibernate.jdbc.JDBCContext;
+import org.hibernate.transaction.TransactionFactory;
+import org.hibernate.util.JTAHelper;
+
+/**
+ * {@link Transaction} implementation based on transaction management through
+ * a JTA {@link UserTransaction}. Similar to {@link CMTTransaction}, except
+ * here we are actually managing the transactions through the Hibernate
+ * transaction mechanism.
+ *
+ * @author Gavin King
+ * @author Steve Ebersole
+ * @author Les Hazlewood
+ *
+ * Scraped from org.hibernate
+ */
+public class JotmTransaction implements Transaction {
+ private static final Log log = LogFactory.getLog( JotmTransaction.class );
+
+ private final JDBCContext jdbcContext;
+ private final TransactionFactory.Context transactionContext;
+
+ private UserTransaction userTransaction;
+ private boolean newTransaction;
+ private boolean begun;
+ private boolean commitFailed;
+ private boolean commitSucceeded;
+ private boolean callback;
+
+ public JotmTransaction(
+ UserTransaction userTransaction,
+ JDBCContext jdbcContext,
+ TransactionFactory.Context transactionContext) {
+ this.jdbcContext = jdbcContext;
+ this.transactionContext = transactionContext;
+ this.userTransaction = userTransaction;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void begin() throws HibernateException {
+ if ( begun ) {
+ return;
+ }
+ if ( commitFailed ) {
+ throw new TransactionException( "cannot re-start transaction after failed commit" );
+ }
+
+ log.debug( "begin" );
+
+ try {
+ newTransaction = userTransaction.getStatus() == Status.STATUS_NO_TRANSACTION;
+ if ( newTransaction ) {
+ userTransaction.begin();
+ log.debug( "Began a new JTA transaction" );
+ }
+ }
+ catch ( Exception e ) {
+ log.error( "JTA transaction begin failed", e );
+ throw new TransactionException( "JTA transaction begin failed", e );
+ }
+
+ /*if (newTransaction) {
+ // don't need a synchronization since we are committing
+ // or rolling back the transaction ourselves - assuming
+ // that we do no work in beforeTransactionCompletion()
+ synchronization = false;
+ }*/
+
+ boolean synchronization = jdbcContext.registerSynchronizationIfPossible();
+
+ if ( !newTransaction && !synchronization ) {
+ log.warn( "You should set hibernate.transaction.manager_lookup_class if cache is enabled" );
+ }
+
+ if ( !synchronization ) {
+ //if we could not register a synchronization,
+ //do the before/after completion callbacks
+ //ourself (but we need to let jdbcContext
+ //know that this is what we are going to
+ //do, so it doesn't keep trying to register
+ //synchronizations)
+ callback = jdbcContext.registerCallbackIfNecessary();
+ }
+
+ begun = true;
+ commitSucceeded = false;
+
+ jdbcContext.afterTransactionBegin( this );
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void commit() throws HibernateException {
+ if ( !begun ) {
+ throw new TransactionException( "Transaction not successfully started" );
+ }
+
+ log.debug( "commit" );
+
+ boolean flush = !transactionContext.isFlushModeNever()
+ && ( callback || !transactionContext.isFlushBeforeCompletionEnabled() );
+
+ if ( flush ) {
+ transactionContext.managedFlush(); //if an exception occurs during flush, user must call rollback()
+ }
+
+ if ( callback && newTransaction ) {
+ jdbcContext.beforeTransactionCompletion( this );
+ }
+
+ closeIfRequired();
+
+ if ( newTransaction ) {
+ try {
+ userTransaction.commit();
+ commitSucceeded = true;
+ log.debug( "Committed JTA UserTransaction" );
+ }
+ catch ( Exception e ) {
+ commitFailed = true; // so the transaction is already rolled back, by JTA spec
+ log.error( "JTA commit failed", e );
+ throw new TransactionException( "JTA commit failed: ", e );
+ }
+ finally {
+ afterCommitRollback();
+ }
+ }
+ else {
+ // this one only really needed for badly-behaved applications!
+ // (if the TransactionManager has a Sychronization registered,
+ // its a noop)
+ // (actually we do need it for downgrading locks)
+ afterCommitRollback();
+ }
+
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void rollback() throws HibernateException {
+ if ( !begun && !commitFailed ) {
+ throw new TransactionException( "Transaction not successfully started" );
+ }
+
+ log.debug( "rollback" );
+
+ try {
+ closeIfRequired();
+ }
+ catch ( Exception e ) {
+ // swallow it, and continue to roll back JTA transaction
+ log.error( "could not close session during rollback", e );
+ }
+
+ try {
+ if ( newTransaction ) {
+ if ( !commitFailed ) {
+ userTransaction.rollback();
+ log.debug( "Rolled back JTA UserTransaction" );
+ }
+ }
+ else {
+ userTransaction.setRollbackOnly();
+ log.debug( "set JTA UserTransaction to rollback only" );
+ }
+ }
+ catch ( Exception e ) {
+ log.error( "JTA rollback failed", e );
+ throw new TransactionException( "JTA rollback failed", e );
+ }
+ finally {
+ afterCommitRollback();
+ }
+ }
+
+ private static final int NULL = Integer.MIN_VALUE;
+
+ private void afterCommitRollback() throws TransactionException {
+
+ begun = false;
+ // this method is a noop if there is a Synchronization!
+ if ( callback ) {
+ if ( !newTransaction ) {
+ log.warn( "You should set hibernate.transaction.manager_lookup_class if cache is enabled" );
+ }
+ int status = NULL;
+ try {
+ status = userTransaction.getStatus();
+ }
+ catch ( Exception e ) {
+ log.error( "Could not determine transaction status after commit", e );
+ throw new TransactionException( "Could not determine transaction status after commit", e );
+ }
+ finally {
+ jdbcContext.afterTransactionCompletion( status == Status.STATUS_COMMITTED, this );
+ }
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean wasRolledBack() throws TransactionException {
+ final int status;
+ try {
+ status = userTransaction.getStatus();
+ }
+ catch ( SystemException se ) {
+ log.error( "Could not determine transaction status", se );
+ throw new TransactionException( "Could not determine transaction status", se );
+ }
+ if ( status == Status.STATUS_UNKNOWN ) {
+ throw new TransactionException( "Could not determine transaction status" );
+ }
+ else {
+ return JTAHelper.isRollback( status );
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean wasCommitted() throws TransactionException {
+ final int status;
+ try {
+ status = userTransaction.getStatus();
+ }
+ catch ( SystemException se ) {
+ log.error( "Could not determine transaction status", se );
+ throw new TransactionException( "Could not determine transaction status: ", se );
+ }
+ if ( status == Status.STATUS_UNKNOWN ) {
+ throw new TransactionException( "Could not determine transaction status" );
+ }
+ else {
+ return status == Status.STATUS_COMMITTED;
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isActive() throws TransactionException {
+ if ( !begun || commitFailed || commitSucceeded ) {
+ return false;
+ }
+
+ final int status;
+ try {
+ status = userTransaction.getStatus();
+ }
+ catch ( SystemException se ) {
+ log.error( "Could not determine transaction status", se );
+ throw new TransactionException( "Could not determine transaction status: ", se );
+ }
+ if ( status == Status.STATUS_UNKNOWN ) {
+ throw new TransactionException( "Could not determine transaction status" );
+ }
+ else {
+ return status == Status.STATUS_ACTIVE;
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void registerSynchronization(Synchronization sync) throws HibernateException {
+ if ( getTransactionManager() == null ) {
+ throw new IllegalStateException( "JTA TransactionManager not available" );
+ }
+ else {
+ try {
+ getTransactionManager().getTransaction().registerSynchronization( sync );
+ }
+ catch ( Exception e ) {
+ throw new TransactionException( "could not register synchronization", e );
+ }
+ }
+ }
+
+ /**
+ * Getter for property 'transactionManager'.
+ *
+ * @return Value for property 'transactionManager'.
+ */
+ private TransactionManager getTransactionManager() {
+ return transactionContext.getFactory().getTransactionManager();
+ }
+
+ private void closeIfRequired() throws HibernateException {
+ boolean close = callback &&
+ transactionContext.shouldAutoClose() &&
+ !transactionContext.isClosed();
+ if ( close ) {
+ transactionContext.managedClose();
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void setTimeout(int seconds) {
+ try {
+ userTransaction.setTransactionTimeout( seconds );
+ }
+ catch ( SystemException se ) {
+ throw new TransactionException( "could not set transaction timeout", se );
+ }
+ }
+
+ /**
+ * Getter for property 'userTransaction'.
+ *
+ * @return Value for property 'userTransaction'.
+ */
+ protected UserTransaction getUserTransaction() {
+ return userTransaction;
+ }
+}
Added: ode/trunk/dao-hibernate/src/main/java/org/apache/ode/daohib/JotmTransactionFactory.java
URL: http://svn.apache.org/viewvc/ode/trunk/dao-hibernate/src/main/java/org/apache/ode/daohib/JotmTransactionFactory.java?rev=782509&view=auto
==============================================================================
--- ode/trunk/dao-hibernate/src/main/java/org/apache/ode/daohib/JotmTransactionFactory.java (added)
+++ ode/trunk/dao-hibernate/src/main/java/org/apache/ode/daohib/JotmTransactionFactory.java Mon Jun 8 02:41:17 2009
@@ -0,0 +1,309 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors. All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301 USA
+ *
+ */
+package org.apache.ode.daohib;
+
+import java.util.Properties;
+
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import javax.transaction.HeuristicMixedException;
+import javax.transaction.HeuristicRollbackException;
+import javax.transaction.NotSupportedException;
+import javax.transaction.RollbackException;
+import javax.transaction.SystemException;
+import javax.transaction.TransactionManager;
+import javax.transaction.UserTransaction;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.hibernate.ConnectionReleaseMode;
+import org.hibernate.HibernateException;
+import org.hibernate.Transaction;
+import org.hibernate.TransactionException;
+import org.hibernate.jdbc.JDBCContext;
+import org.hibernate.cfg.Environment;
+import org.hibernate.transaction.TransactionFactory;
+import org.hibernate.transaction.TransactionManagerLookup;
+import org.hibernate.transaction.TransactionManagerLookupFactory;
+import org.hibernate.util.NamingHelper;
+import org.hibernate.util.JTAHelper;
+
+/**
+ * Factory for {@link JotmTransaction} instances.
+ * <p/>
+ * To be completely accurate to the JTA spec, JTA implementations should
+ * publish their contextual {@link UserTransaction} reference into JNDI.
+ * However, in practice there are quite a few <tt>stand-alone</tt>
+ * implementations intended for use outside of J2EE/JEE containers and
+ * which therefore do not publish their {@link UserTransaction} references
+ * into JNDI but which otherwise follow the aspects of the JTA specification.
+ * This {@link TransactionFactory} implementation can support both models.
+ * <p/>
+ * For complete JTA implementations (including dependence on JNDI), the
+ * {@link UserTransaction} reference is obtained by a call to
+ * {@link #resolveInitialContext}. Hibernate will then attempt to locate the
+ * {@link UserTransaction} within this resolved
+ * {@link InitialContext} based on the namespace returned by
+ * {@link #resolveUserTransactionName}.
+ * <p/>
+ * For the so-called <tt>stand-alone</tt> implementations, we do not care at
+ * all about the JNDI aspects just described. Here, the implementation would
+ * have a specific manner to obtain a reference to its contextual
+ * {@link UserTransaction}; usually this would be a static code reference, but
+ * again it varies. Anyway, for each implementation the integration would need
+ * to override the {@link #getUserTransaction} method and return the appropriate
+ * thing.
+ *
+ * @author Gavin King
+ * @author Steve Ebersole
+ * @author Les Hazlewood
+ *
+ * Scraped from org.hibernate
+ */
+public class JotmTransactionFactory implements TransactionFactory {
+ public static final String DEFAULT_USER_TRANSACTION_NAME = "java:comp/UserTransaction";
+ private static final Log log = LogFactory.getLog( JotmTransactionFactory.class );
+
+ protected InitialContext initialContext;
+ protected String userTransactionName;
+
+ private TransactionManager txManager;
+
+ /**
+ * Configure this transaction factory. Specifically here we are attempting to
+ * resolve both an {@link #getInitialContext InitialContext} as well as the
+ * {@link #getUserTransactionName() JNDI namespace} for the {@link UserTransaction}.
+ *
+ * @param props The configuration properties
+ *
+ * @exception HibernateException
+ */
+ public void configure(Properties props) throws HibernateException {
+ this.initialContext = resolveInitialContext( props );
+ this.userTransactionName = resolveUserTransactionName( props );
+ log.debug( "Configured JTATransactionFactory to use [" + userTransactionName + "] for UserTransaction JDNI namespace" );
+ txManager = new HibernateTransactionManagerLookup().getTransactionManager(props);
+ }
+
+ /**
+ * Given the lot of Hibernate configuration properties, resolve appropriate
+ * reference to JNDI {@link InitialContext}.
+ * <p/>
+ * In general, the properties in which we are interested here all begin with
+ * <tt>hibernate.jndi</tt>. Especially important depending on your
+ * environment are {@link Environment#JNDI_URL hibernate.jndi.url} and
+ * {@link Environment#JNDI_CLASS hibernate.jndi.class}
+ *
+ * @param properties The Hibernate config properties.
+ * @return The resolved InitialContext.
+ */
+ protected final InitialContext resolveInitialContext(Properties properties) {
+ try {
+ return NamingHelper.getInitialContext( properties );
+ }
+ catch ( NamingException ne ) {
+ throw new HibernateException( "Could not obtain initial context", ne );
+ }
+ }
+
+ /**
+ * Given the lot of Hibernate configuration properties, resolve appropriate
+ * JNDI namespace to use for {@link UserTransaction} resolution.
+ * <p/>
+ * We determine the namespace to use by<ol>
+ * <li>Any specified {@link Environment#USER_TRANSACTION jta.UserTransaction} config property</li>
+ * <li>If a {@link TransactionManagerLookup} was indicated, use its
+ * {@link TransactionManagerLookup#getUserTransactionName}</li>
+ * <li>finally, as a last resort, we use {@link #DEFAULT_USER_TRANSACTION_NAME}</li>
+ * </ol>
+ *
+ * @param properties The Hibernate config properties.
+ * @return The resolved {@link UserTransaction} namespace
+ */
+ protected final String resolveUserTransactionName(Properties properties) {
+ String utName = properties.getProperty( Environment.USER_TRANSACTION );
+ if ( utName == null ) {
+ TransactionManagerLookup lookup = TransactionManagerLookupFactory.getTransactionManagerLookup( properties );
+ if ( lookup != null ) {
+ utName = lookup.getUserTransactionName();
+ }
+ }
+ return utName == null ? DEFAULT_USER_TRANSACTION_NAME : utName;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Transaction createTransaction(JDBCContext jdbcContext, Context transactionContext)
+ throws HibernateException {
+ /*
+ * JTA TransactionManager returns a JTA transaction. We need a user transaction to use
+ * hibernate's JTATransactionFactory.
+ */
+ // UserTransaction ut = getUserTransaction();
+ UserTransaction ut;
+ try {
+ ut = new UserTransaction() {
+ javax.transaction.Transaction transaction = txManager.getTransaction();
+ public void begin() throws NotSupportedException, SystemException {
+ // TODO Auto-generated method stub
+ }
+
+ public void commit() throws HeuristicMixedException,
+ HeuristicRollbackException, IllegalStateException,
+ RollbackException, SecurityException, SystemException {
+ transaction.commit();
+ }
+
+ public int getStatus() throws SystemException {
+ // TODO Auto-generated method stub
+ return transaction.getStatus();
+ }
+
+ public void rollback() throws IllegalStateException,
+ SecurityException, SystemException {
+ // TODO Auto-generated method stub
+ transaction.rollback();
+ }
+
+ public void setRollbackOnly() throws IllegalStateException,
+ SystemException {
+ // TODO Auto-generated method stub
+ transaction.setRollbackOnly();
+ }
+
+ public void setTransactionTimeout(int i) throws SystemException {
+ // TODO Auto-generated method stub
+ }
+ };
+ } catch (SystemException e) {
+ throw new HibernateException(e);
+ }
+
+ return new JotmTransaction( ut, jdbcContext, transactionContext );
+ }
+
+ /**
+ * Get the {@link UserTransaction} reference.
+ *
+ * @return The appropriate {@link UserTransaction} reference.
+ */
+ protected UserTransaction getUserTransaction() {
+ final String utName = getUserTransactionName();
+ log.debug( "Attempting to locate UserTransaction via JNDI [" + utName + "]");
+
+ try {
+ UserTransaction ut = ( UserTransaction ) getInitialContext().lookup( utName );
+ if ( ut == null ) {
+ throw new TransactionException( "Naming service lookup for UserTransaction returned null [" + utName +"]" );
+ }
+
+ log.trace( "Obtained UserTransaction" );
+
+ return ut;
+ }
+ catch ( NamingException ne ) {
+ throw new TransactionException( "Could not find UserTransaction in JNDI [" + utName + "]", ne );
+ }
+ }
+
+ /**
+ * Getter for property 'initialContext'.
+ *
+ * @return Value for property 'initialContext'.
+ */
+ protected InitialContext getInitialContext() {
+ return initialContext;
+ }
+
+ /**
+ * Getter for property 'userTransactionName'.
+ * The algorithm here is
+ *
+ * @return Value for property 'userTransactionName'.
+ */
+ protected String getUserTransactionName() {
+ return userTransactionName;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public ConnectionReleaseMode getDefaultReleaseMode() {
+ return ConnectionReleaseMode.AFTER_STATEMENT;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isTransactionManagerRequired() {
+ return false;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean areCallbacksLocalToHibernateTransactions() {
+ return false;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isTransactionInProgress(
+ JDBCContext jdbcContext,
+ Context transactionContext,
+ Transaction transaction) {
+ try {
+ // Essentially:
+ // 1) If we have a local (Hibernate) transaction in progress
+ // and it already has the UserTransaction cached, use that
+ // UserTransaction to determine the status.
+ // 2) If a transaction manager has been located, use
+ // that transaction manager to determine the status.
+ // 3) Finally, as the last resort, try to lookup the
+ // UserTransaction via JNDI and use that to determine the
+ // status.
+ if ( transaction != null ) {
+ UserTransaction ut = ( ( JotmTransaction ) transaction ).getUserTransaction();
+ if ( ut != null ) {
+ return JTAHelper.isInProgress( ut.getStatus() );
+ }
+ }
+
+ if ( jdbcContext.getFactory().getTransactionManager() != null ) {
+ return JTAHelper.isInProgress( jdbcContext.getFactory().getTransactionManager().getStatus() );
+ }
+ else {
+ UserTransaction ut = getUserTransaction();
+ return ut != null && JTAHelper.isInProgress( ut.getStatus() );
+ }
+ }
+ catch ( SystemException se ) {
+ throw new TransactionException( "Unable to check transaction status", se );
+ }
+ }
+
+}
Modified: ode/trunk/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/BpelDAOConnectionFactoryImpl.java
URL: http://svn.apache.org/viewvc/ode/trunk/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/BpelDAOConnectionFactoryImpl.java?rev=782509&r1=782508&r2=782509&view=diff
==============================================================================
--- ode/trunk/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/BpelDAOConnectionFactoryImpl.java (original)
+++ ode/trunk/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/BpelDAOConnectionFactoryImpl.java Mon Jun 8 02:41:17 2009
@@ -69,6 +69,7 @@
/**
* @see org.apache.ode.bpel.dao.BpelDAOConnectionFactory#init(java.util.Properties)
*/
+ @SuppressWarnings("unchecked")
public void init(Properties initialProps) {
if (_ds == null) {
String errmsg = "setDataSource() not called!";
@@ -100,7 +101,13 @@
properties.put(Environment.CONNECTION_PROVIDER, DataSourceConnectionProvider.class.getName());
properties.put(Environment.TRANSACTION_MANAGER_STRATEGY, HibernateTransactionManagerLookup.class.getName());
- properties.put(Environment.TRANSACTION_STRATEGY, "org.hibernate.transaction.JTATransactionFactory");
+ /*
+ * Since Hibernate 3.2.6, Hibernate JTATransaction requires User Transaction bound on JNDI. Let's work around
+ * by implementing Hibernate JTATransactionFactory that hooks up to the JTATransactionManager(ODE uses geronimo
+ * by default).
+ */
+ // properties.put(Environment.TRANSACTION_STRATEGY, "org.hibernate.transaction.JTATransactionFactory");
+ properties.put(Environment.TRANSACTION_STRATEGY, "org.apache.ode.daohib.JotmTransactionFactory");
properties.put(Environment.CURRENT_SESSION_CONTEXT_CLASS, "jta");
// Guess Hibernate dialect if not specified in hibernate.properties
Modified: ode/trunk/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/BpelDAOConnectionImpl.java
URL: http://svn.apache.org/viewvc/ode/trunk/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/BpelDAOConnectionImpl.java?rev=782509&r1=782508&r2=782509&view=diff
==============================================================================
--- ode/trunk/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/BpelDAOConnectionImpl.java (original)
+++ ode/trunk/dao-hibernate/src/main/java/org/apache/ode/daohib/bpel/BpelDAOConnectionImpl.java Mon Jun 8 02:41:17 2009
@@ -111,6 +111,7 @@
.setString("url", url).setString("method", method).executeUpdate();
}
+ @SuppressWarnings("unchecked")
public List<ResourceRouteDAO> getAllResourceRoutes() {
List<HResourceRoute> hrr = getSession().createCriteria(HResourceRoute.class).list();
ArrayList<ResourceRouteDAO> rr = new ArrayList<ResourceRouteDAO>(hrr.size());
Propchange: ode/trunk/dao-jpa-db/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Mon Jun 8 02:41:17 2009
@@ -1 +1 @@
-reports
+.project:.classpath