public abstract class TransactionHelperImpl extends Object implements TransactionHelper
getTransaction
and getUserTransaction methods and replace any other method
implementation if it is necessary.
Such class must register itself by a static method at class initialization time.
For example,
import com.sun.jdo.spi.persistence.support.sqlstore.ejb.*;
class blackHerringTransactionHelper extends TransactionHelperImpl {
static EJBHelper.register(new blackHerringTransactionHelper());
...
}
| Constructor and Description |
|---|
TransactionHelperImpl() |
| Modifier and Type | Method and Description |
|---|---|
Connection |
getConnection(Object resource,
String username,
String password)
Called in a managed environment to get a Connection from the application
server specific resource.
|
String |
getDDLNamePrefix(Object info)
Returns name prefix for DDL files extracted from the info instance by the
application server specific code.
|
abstract TransactionManager |
getLocalTransactionManager()
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.
|
abstract Connection |
getNonTransactionalConnection(Object resource,
String username,
String password)
Called in a managed environment to get a non-transactional Connection
from the application server specific resource.
|
abstract Transaction |
getTransaction()
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.
|
abstract UserTransaction |
getUserTransaction()
Returns the UserTransaction associated with the calling thread.
|
boolean |
isManaged()
Identifies the managed environment behavior.
|
void |
notifyApplicationUnloaded(ClassLoader cl)
Called to notify a ApplicationLifeCycleEventListeners that an application
is unloaded.
|
void |
postInvoke(Object im)
Called at the end of the Transaction.beforeCompletion() to
de-register the component with the app server if necessary.
|
Object |
preInvoke(Object component)
Called at the beginning of the Transaction.beforeCompletion() to
register the component with the app server only if necessary.
|
void |
registerApplicationLifeCycleEventListener(ApplicationLifeCycleEventListener listener)
Called to register a ApplicationLifeCycleEventListener.
|
void |
registerSynchronization(Transaction jta,
Synchronization sync)
Called in a managed environment to register internal Synchronization object
with the Transaction Synchronization.
|
PersistenceManagerFactory |
replaceInternalPersistenceManagerFactory(PersistenceManagerFactory pmf)
Replace newly created instance of PersistenceManagerFactory
with the hashed one if it exists.
|
void |
setPersistenceManagerFactoryDefaults(PersistenceManagerFactory pmf)
Set environment specific default values for the given PersistenceManagerFactory.
|
int |
translateStatus(int st)
Translate local representation of the Transaction Status to
javax.transaction.Status value if necessary.
|
Statement |
unwrapStatement(Statement stmt)
This method unwraps given Statement and return the Statement from
JDBC driver if possible.
|
public boolean isManaged()
isManaged in interface TransactionHelperpublic abstract Transaction getTransaction()
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.
getTransaction in interface TransactionHelperpublic abstract UserTransaction getUserTransaction()
getUserTransaction in interface TransactionHelperpublic int translateStatus(int st)
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.
translateStatus in interface TransactionHelperst - local Status valuepublic PersistenceManagerFactory replaceInternalPersistenceManagerFactory(PersistenceManagerFactory pmf)
replaceInternalPersistenceManagerFactory in interface TransactionHelperpmf - PersistenceManagerFactory instance to be replacedpublic Object preInvoke(Object component)
preInvoke in interface TransactionHelpercomponent - an array of Objectspublic void postInvoke(Object im)
postInvoke in interface TransactionHelperim - implementation-specific Objectpublic void registerSynchronization(Transaction jta, Synchronization sync) throws RollbackException, SystemException
registerSynchronization in interface TransactionHelperjta - the Transaction instance for the calling thread.sync - the internal Synchronization instance to register.javax.transaction.RollbackException.SystemExceptionRollbackExceptionpublic Connection getConnection(Object resource, String username, String password) throws SQLException
getConnection in interface TransactionHelperresource - the application server specific resource.username - the resource username. If null, Connection is requested
without username and password validation.password - the password for the resource username.java.sql.SQLException.SQLExceptionpublic abstract Connection getNonTransactionalConnection(Object resource, String username, String password) throws SQLException
getNonTransactionalConnection in interface TransactionHelperresource - the application server specific resource.username - the resource username. If null, Connection is requested
without username and password validation.password - the password for the resource username.java.sql.SQLException.SQLExceptionpublic abstract TransactionManager getLocalTransactionManager()
getLocalTransactionManager in interface TransactionHelperpublic Statement unwrapStatement(Statement stmt)
unwrapStatement in interface TransactionHelperpublic void setPersistenceManagerFactoryDefaults(PersistenceManagerFactory pmf)
setPersistenceManagerFactoryDefaults in interface TransactionHelperpmf - the PersistenceManagerFactory.public String getDDLNamePrefix(Object info)
getDDLNamePrefix in interface TransactionHelperinfo - the instance to use for the name generation.public void registerApplicationLifeCycleEventListener(ApplicationLifeCycleEventListener listener)
TransactionHelperregisterApplicationLifeCycleEventListener in interface TransactionHelperlistener - An instance of ApplicationLifeCycleEventListener.public void notifyApplicationUnloaded(ClassLoader cl)
TransactionHelpernotifyApplicationUnloaded in interface TransactionHelpercl - An instance of the ClassLoader that loaded the application.Copyright © 2017. All rights reserved.