JBoss EJB client 1.0.5.Final

org.jboss.ejb.client
Class EJBClientTransactionContext

java.lang.Object
  extended by org.jboss.ejb.client.Attachable
      extended by org.jboss.ejb.client.EJBClientTransactionContext
Direct Known Subclasses:
EJBClientManagedTransactionContext, EJBClientUserTransactionContext

public abstract class EJBClientTransactionContext
extends Attachable

The transaction context for an EJB client.

Author:
David M. Lloyd

Constructor Summary
EJBClientTransactionContext()
           
 
Method Summary
static EJBClientTransactionContext create(TransactionManager transactionManager, TransactionSynchronizationRegistry synchronizationRegistry)
          Create a transaction context which is controlled by an actual transaction manager.
static EJBClientTransactionContext createLocal()
          Create a local client transaction context which is controlled directly via UserTransaction methods.
protected abstract  TransactionID getAssociatedTransactionID(EJBClientInvocationContext invocationContext)
          Get the transaction ID to associate with the invocation.
static EJBClientTransactionContext getCurrent()
          Get the current client transaction context.
protected abstract  String getTransactionNode()
          Get the node to which this transaction is pinned, if any.
protected  UserTransaction getUserTransaction(String nodeName)
          Get a UserTransaction instance affiliated with a specific remote node to control the transaction state.
static EJBClientTransactionContext requireCurrent()
          Get the current client transaction context, throwing an exception if one is not available.
static void setGlobalContext(EJBClientTransactionContext context)
          Set the singleton, global transaction context.
static void setSelector(ContextSelector<EJBClientTransactionContext> selector)
          Set the client transaction context selector.
 
Methods inherited from class org.jboss.ejb.client.Attachable
getAttachment, putAttachment, putAttachmentIfAbsent, removeAttachment, removeAttachment, replaceAttachment, replaceAttachment
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EJBClientTransactionContext

public EJBClientTransactionContext()
Method Detail

getAssociatedTransactionID

protected abstract TransactionID getAssociatedTransactionID(EJBClientInvocationContext invocationContext)
                                                     throws Exception
Get the transaction ID to associate with the invocation. The transaction ID typically comes from the current thread's transaction context.

Parameters:
invocationContext - the invocation context
Returns:
the transaction ID to associate, or null for none
Throws:
Exception - if an exception occurs

getTransactionNode

protected abstract String getTransactionNode()
Get the node to which this transaction is pinned, if any.

Returns:
the node name or null if the transaction is not pinned

setSelector

public static void setSelector(ContextSelector<EJBClientTransactionContext> selector)
                        throws SecurityException
Set the client transaction context selector.

Parameters:
selector - the selector to set
Throws:
SecurityException - if a security manager is installed and you do not have the setClientTransactionContextSelector RuntimePermission

setGlobalContext

public static void setGlobalContext(EJBClientTransactionContext context)
                             throws SecurityException
Set the singleton, global transaction context. Replaces any selector which was set via setSelector(ContextSelector).

Parameters:
context - the context to set
Throws:
SecurityException - if a security manager is installed and you do not have the setClientTransactionContextSelector RuntimePermission

requireCurrent

public static EJBClientTransactionContext requireCurrent()
                                                  throws IllegalStateException
Get the current client transaction context, throwing an exception if one is not available.

Returns:
the transaction context
Throws:
IllegalStateException - if no context is available

getCurrent

public static EJBClientTransactionContext getCurrent()
Get the current client transaction context.

Returns:
the current client transaction context

createLocal

public static EJBClientTransactionContext createLocal()
Create a local client transaction context which is controlled directly via UserTransaction methods.

Returns:
the local transaction context

create

public static EJBClientTransactionContext create(TransactionManager transactionManager,
                                                 TransactionSynchronizationRegistry synchronizationRegistry)
Create a transaction context which is controlled by an actual transaction manager.

Parameters:
transactionManager - the transaction manager
synchronizationRegistry - the transaction synchronization registry
Returns:
the transaction context

getUserTransaction

protected UserTransaction getUserTransaction(String nodeName)
Get a UserTransaction instance affiliated with a specific remote node to control the transaction state. The instance is only usable while there is an active connection with the given peer.

Parameters:
nodeName - the remote node name
Returns:
the user transaction instance

JBoss EJB client 1.0.5.Final

Copyright © 2012 JBoss by Red Hat. All Rights Reserved.