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

EJBHelper

public class EJBHelper extends Object
Provides helper methods for a Forte for Java implementation with the application server specific information in the distributed transaction environment. Calls corresponding methods on the registered class which implements TransactionHelper interface.

Fields Summary
private static final ResourceBundle
messages
I18N message handler
private static com.sun.jdo.spi.persistence.utility.logging.Logger
logger
The logger
static TransactionHelper
myHelper
Reference to a class that implements TransactionHelper interface for this particular application server, or DefaultTransactionHelper for a non-managed environment.
Constructors Summary
Methods Summary
public static 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.

        return myHelper.getConnection(resource, username, password);
    
public static 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.

        return myHelper.getDDLNamePrefix(info);
    
public static javax.transaction.TransactionManagergetLocalTransactionManager()
Called in a managed environment to access a TransactionManager for managing local transaction boundaries and synchronization for local transaction completion.

return
javax.transaction.TransactionManager

        return myHelper.getLocalTransactionManager();
    
public static 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.


        return myHelper.getNonTransactionalConnection(resource, 
            username, password);
    
public static javax.transaction.TransactiongetTransaction()
Returns Transaction instance that can be used to register synchronizations. In a non-managed environment or if there is no transaction associated with the current thread, this method returns null.

see
TransactionHelper#getTransaction()
return
the Transaction instance for the calling thread

        return myHelper.getTransaction();
    
public static javax.transaction.UserTransactiongetUserTransaction()
Returns the UserTransaction associated with the calling thread. In a non-managed environment or if there is no transaction currently in progress, this method returns null.

see
TransactionHelper#getUserTransaction()
return
the UserTransaction instance for the calling thread

        return myHelper.getUserTransaction();
    
public static booleanisManaged()
Identifies the managed environment behavior.

return
true if this implementation represents the managed environment.

        return myHelper.isManaged();
    
public static voidpostInvoke(java.lang.Object im)
Called in a managed environment at the end of the Transaction.beforeCompletion() to de-register the component with the app server if necessary.

see
TransactionHelper#postInvoke(Object im)
param
im implementation-specific Object

        myHelper.postInvoke(im);
    
public static 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. In a non-managed environment or if the postInvoke method does not use the value, this method returns null.

see
TransactionHelper#preInvoke(Object component)
param
component an array of Objects
return
implementation-specific Object

        return myHelper.preInvoke(component);
    
public static 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.

        myHelper.registerApplicationLifeCycleEventListener(listener);        
    
public static 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.

see
Transaction#registerSynchronization(Synchronization sync)
see
TransactionHelper#registerSynchronization(Transaction jta, Synchronization sync)
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.

        myHelper.registerSynchronization(jta, sync);
    
public static voidregisterTransactionHelper(TransactionHelper h)
Register class that implements TransactionHelper interface Should be called by a static method at class initialization time. If null is passed, sets the reference to the DefaultTransactionHelper.

param
h application server specific implemetation of the TransactionHelper interface.


                                	 	       			    
          
        myHelper = h;
        if (myHelper == null) {
            myHelper = DefaultTransactionHelper.getInstance();
        }
    
public static com.sun.jdo.api.persistence.support.PersistenceManagerFactoryreplaceInternalPersistenceManagerFactory(com.sun.jdo.api.persistence.support.PersistenceManagerFactory pmf)
Returns the hashed instance of PersistenceManagerFactory that compares equal to the newly created instance or the instance itself if it is not found. In a non-managed environment returns the value passed to it as an argument.

see
TransactionHelper#replaceInternalPersistenceManagerFactory( PersistenceManagerFactory pmf)
param
pmf PersistenceManagerFactory instance to be replaced
return
the PersistenceManagerFactory known to the runtime

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

param
pmf the PersistenceManagerFactory.

        myHelper.setPersistenceManagerFactoryDefaults(pmf);
    
public static inttranslateStatus(int st)
Translates local representation of the Transaction Status to javax.transaction.Status value. In a non-managed environment returns the value passed to it as an argument.

see
TransactionHelper#translateStatus(int st)
param
local Status value
return
the javax.transaction.Status value of the status

        return myHelper.translateStatus(st);
    
public static java.sql.StatementunwrapStatement(java.sql.Statement stmt)
This method unwraps given Statement and return the Statement from JDBC driver if possible.

        return myHelper.unwrapStatement(stmt);