FileDocCategorySizeDatePackage
TransactionHelper.javaAPI DocGlassfish v2 API10988Fri May 04 22:35:04 BST 2007com.sun.jdo.spi.persistence.support.sqlstore.ejb

TransactionHelper

public interface TransactionHelper
Provide a Forte for Java implementation with information about the distributed transaction environment. This is an interface that a helper class implements that is specific to a managed environment.

This interface is specific to Forte for Java, version 3.0, and is subject to change without notice. In particular, as additional experience is gained with specific application servers, this interface may have methods added and removed, even with patch releases. Therefore, this interface should be considered very volatile, and any class that implements it might have to be reimplemented whenever an upgrade to either the application server or Forte for Java occurs.

The class that implements this interface must register itself by a static method at class initialization time. For example,
import com.sun.jdo.spi.persistence.support.sqlstore.ejb.*;
class blackHerringTransactionHelper implements TransactionHelper {
static EJBHelper.register(new blackHerringTransactionHelper());
...
}

Fields Summary
Constructors Summary
Methods Summary
public java.sql.ConnectiongetConnection(java.lang.Object resource, java.lang.String username, java.lang.String password)
Called in a managed environment to get a Connection from the application server specific resource. In a non-managed environment throws an Exception as it should not be called.

param
resource the application server specific resource.
param
username the resource username. If null, Connection is requested without username and password validation.
param
password the password for the resource username.
return
a Connection.
throw
java.sql.SQLException.

public java.lang.StringgetDDLNamePrefix(java.lang.Object info)
Returns name prefix for DDL files extracted from the info instance by the application server specific code.

param
info the instance to use for the name generation.
return
name prefix as String.

public javax.transaction.TransactionManagergetLocalTransactionManager()
Called in a managed environment to access a TransactionManager for managing local transaction boundaries and registering synchronization for call backs during completion of a local transaction.

return
javax.transaction.TransactionManager

public java.sql.ConnectiongetNonTransactionalConnection(java.lang.Object resource, java.lang.String username, java.lang.String password)
Called in a managed environment to get a non-transactional Connection from the application server specific resource. In a non-managed environment throws an Exception as it should not be called.

param
resource the application server specific resource.
param
username the resource username. If null, Connection is requested without username and password validation.
param
password the password for the resource username.
return
a Connection.
throw
java.sql.SQLException.

public javax.transaction.TransactiongetTransaction()
Identify the Transaction context for the calling thread, and return a Transaction instance that can be used to register synchronizations, and used as the key for HashMaps. The returned Transaction must implement equals() and hashCode() based on the global transaction id.

All Transaction instances returned by this method called in the same Transaction context must compare equal and return the same hashCode. The Transaction instance returned will be held as the key to an internal HashMap until the Transaction completes. If there is no transaction associated with the current thread, this method returns null.

return
the Transaction instance for the calling thread

public javax.transaction.UserTransactiongetUserTransaction()
Returns the UserTransaction associated with the calling thread. If there is no transaction currently in progress, this method returns null.

return
the UserTransaction instance for the calling thread

public booleanisManaged()
Identifies the managed environment behavior.

return
true if this implementation represents the managed environment.

public voidpostInvoke(java.lang.Object im)
Called at the end of the Transaction.beforeCompletion() to de-register the component with the app server if necessary. The parameter is the return value from preInvoke, and can be any Object.

param
im implementation-specific Object

public java.lang.ObjectpreInvoke(java.lang.Object component)
Called at the beginning of the Transaction.beforeCompletion() to register the component with the app server if necessary. The component argument is an array of Objects. The first element is com.sun.jdo.spi.persistence.support.sqlstore.Transaction object responsible for transaction completion. The second element is com.sun.jdo.api.persistence.support.PersistenceManager object that has been associated with the Transaction context for the calling thread. The third element is javax.transaction.Transaction object that has been associated with the given instance of PersistenceManager. The return value is passed unchanged to the postInvoke method.

param
component an array of Objects
return
implementation-specific Object

public voidregisterApplicationLifeCycleEventListener(ApplicationLifeCycleEventListener listener)
Called to register a ApplicationLifeCycleEventListener. If ApplicationLifeCycle management is active (typically in managed environment), the registered listener will receive a call back for lifecycle events.

param
listener An instance of ApplicationLifeCycleEventListener.

public voidregisterSynchronization(javax.transaction.Transaction jta, javax.transaction.Synchronization sync)
Called in a managed environment to register internal Synchronization object with the Transaction Synchronization. If available, this registration provides special handling of the registered instance, calling it after all user defined Synchronization instances.

param
jta the Transaction instance for the calling thread.
param
sync the internal Synchronization instance to register.
throws
javax.transaction.RollbackException.
throws
javax.transaction.SystemException

public com.sun.jdo.api.persistence.support.PersistenceManagerFactoryreplaceInternalPersistenceManagerFactory(com.sun.jdo.api.persistence.support.PersistenceManagerFactory pmf)
Replace newly created instance of PersistenceManagerFactory with the hashed one if it exists. The replacement is necessary only if the JNDI lookup always returns a new instance. Otherwise this method returns the object passed to it as an argument. PersistenceManagerFactory is uniquely identified by ConnectionFactory.hashCode() if ConnectionFactory is not null; otherwise by ConnectionFactoryName.hashCode() if ConnectionFactoryName is not null; otherwise by the combination of URL.hashCode() + userName.hashCode() + password.hashCode() + driverName.hashCode();

param
pmf PersistenceManagerFactory instance to be replaced
return
the PersistenceManagerFactory known to the runtime

public voidsetPersistenceManagerFactoryDefaults(com.sun.jdo.api.persistence.support.PersistenceManagerFactory pmf)
Set environment specific default values for the given PersistenceManagerFactory.

param
pmf the PersistenceManagerFactory.

public inttranslateStatus(int st)
Translate local representation of the Transaction Status to javax.transaction.Status value if necessary. Otherwise this method should return the value passed to it as an argument.

This method is used during afterCompletion callbacks to translate the parameter value passed by the application server to the afterCompletion method. The return value must be one of: javax.transaction.Status.STATUS_COMMITTED or javax.transaction.Status.STATUS_ROLLED_BACK.

param
st local Status value
return
the javax.transaction.Status value of the status

public java.sql.StatementunwrapStatement(java.sql.Statement stmt)
This method unwrap given Statement and return the Statement from JDBC driver.