org.apache.jackrabbit.core
Class XASessionImpl

java.lang.Object
  extended by org.apache.jackrabbit.commons.AbstractSession
      extended by org.apache.jackrabbit.core.SessionImpl
          extended by org.apache.jackrabbit.core.XASessionImpl
All Implemented Interfaces:
Session, XAResource, JackrabbitSession, XASession, Dumpable, IdentifierResolver, NamePathResolver, NameResolver, PathResolver, NamespaceResolver

public class XASessionImpl
extends SessionImpl
implements XASession, XAResource

Session extension that provides XA support.


Field Summary
static String SYSTEM_PROPERTY_DEFAULT_TRANSACTION_TIMEOUT
          System property specifying the default Transaction Timeout
 
Fields inherited from class org.apache.jackrabbit.core.SessionImpl
accessMgr, alive, attributes, DISABLE_CLUSTER_SYNC_ON_REFRESH, hierMgr, itemMgr, itemStateMgr, listeners, loginContext, namePathResolver, ntInstanceHandler, ntMgr, rep, subject, userId, valueFactory, versionMgr, wsp
 
Fields inherited from interface javax.jcr.Session
ACTION_ADD_NODE, ACTION_READ, ACTION_REMOVE, ACTION_SET_PROPERTY
 
Fields inherited from interface javax.transaction.xa.XAResource
TMENDRSCAN, TMFAIL, TMJOIN, TMNOFLAGS, TMONEPHASE, TMRESUME, TMSTARTRSCAN, TMSUCCESS, TMSUSPEND, XA_OK, XA_RDONLY
 
Constructor Summary
protected XASessionImpl(RepositoryImpl rep, AuthContext loginContext, WorkspaceConfig wspConfig)
          Create a new instance of this class.
protected XASessionImpl(RepositoryImpl rep, Subject subject, WorkspaceConfig wspConfig)
          Create a new instance of this class.
 
Method Summary
 void associate(TransactionContext tx)
          Associate this session with a global transaction.
 void commit(Xid xid, boolean onePhase)
          
protected  InternalVersionManager createVersionManager(RepositoryImpl rep)
          Create the version manager.
protected  WorkspaceImpl createWorkspaceInstance(WorkspaceConfig wspConfig, SharedItemStateManager stateMgr, RepositoryImpl rep, SessionImpl session)
          Creates the workspace instance backing this session.
 void end(Xid xid, int flags)
          

If TMSUCCESS is specified, we disassociate this session from the transaction specified.

 void forget(Xid xid)
          

No recovery support yet.

 LockManager getLockManager()
          Return the lock manager for this session.
 int getTransactionTimeout()
          
 XAResource getXAResource()
          Retrieves an XAResource object that the transaction manager will use to manage this XASession object's participation in a distributed transaction.
 boolean isSameRM(XAResource xares)
          

Two resources belong to the same resource manager if both connections (i.e.

 void logout()
          Clears the local namespace mappings.
 int prepare(Xid xid)
          
 Xid[] recover(int flags)
          

No recovery support yet.

 void rollback(Xid xid)
          
 boolean setTransactionTimeout(int seconds)
          
 void start(Xid xid, int flags)
          

If TMNOFLAGS is specified, we create a new transaction context and associate it with this resource.

 
Methods inherited from class org.apache.jackrabbit.core.SessionImpl
addListener, addLockToken, checkFormat, checkPermission, clusterSyncOnRefresh, createAccessManager, createDataStoreGarbageCollector, createItemManager, createSession, createSessionItemStateManager, createWorkspace, createWorkspace, dump, finalize, getAccessControlManager, getAccessManager, getAttribute, getAttributeNames, getHierarchyManager, getImportContentHandler, getInternalVersionManager, getItem, getItemManager, getItemStateManager, getJCRName, getJCRPath, getLocks, getLockTokens, getNode, getNodeById, getNodeByIdentifier, getNodeByUUID, getNodeTypeInstanceHandler, getNodeTypeManager, getPath, getPrefix, getPrincipalManager, getProperty, getQName, getQPath, getQPath, getRepository, getRetentionManager, getRetentionRegistry, getRootNode, getSubject, getURI, getUserID, getUserManager, getValidator, getValueFactory, getWorkspace, getWorkspaceNames, hasCapability, hasPendingChanges, hasPermission, impersonate, isLive, itemExists, move, nodeExists, notifyLoggedOut, notifyLoggingOut, propertyExists, refresh, removeItem, removeListener, removeLockToken, retrieveUserId, sanityCheck, save, setAttribute, setNamespacePrefix
 
Methods inherited from class org.apache.jackrabbit.commons.AbstractSession
exportDocumentView, exportDocumentView, exportSystemView, exportSystemView, getNamespacePrefix, getNamespacePrefixes, getNamespaceURI, importXML
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.jcr.Session
addLockToken, checkPermission, exportDocumentView, exportDocumentView, exportSystemView, exportSystemView, getAccessControlManager, getAttribute, getAttributeNames, getImportContentHandler, getItem, getLockTokens, getNamespacePrefix, getNamespacePrefixes, getNamespaceURI, getNode, getNodeByIdentifier, getNodeByUUID, getProperty, getRepository, getRetentionManager, getRootNode, getUserID, getValueFactory, getWorkspace, hasCapability, hasPendingChanges, hasPermission, impersonate, importXML, isLive, itemExists, move, nodeExists, propertyExists, refresh, removeItem, removeLockToken, save, setNamespacePrefix
 

Field Detail

SYSTEM_PROPERTY_DEFAULT_TRANSACTION_TIMEOUT

public static final String SYSTEM_PROPERTY_DEFAULT_TRANSACTION_TIMEOUT
System property specifying the default Transaction Timeout

See Also:
Constant Field Values
Constructor Detail

XASessionImpl

protected XASessionImpl(RepositoryImpl rep,
                        AuthContext loginContext,
                        WorkspaceConfig wspConfig)
                 throws AccessDeniedException,
                        RepositoryException
Create a new instance of this class.

Parameters:
rep - repository
loginContext - login context containing authenticated subject
wspConfig - workspace configuration
Throws:
AccessDeniedException - if the subject of the given login context is not granted access to the specified workspace
RepositoryException - if another error occurs

XASessionImpl

protected XASessionImpl(RepositoryImpl rep,
                        Subject subject,
                        WorkspaceConfig wspConfig)
                 throws AccessDeniedException,
                        RepositoryException
Create a new instance of this class.

Parameters:
rep - repository
subject - authenticated subject
wspConfig - workspace configuration
Throws:
AccessDeniedException - if the given subject is not granted access to the specified workspace
RepositoryException - if another error occurs
Method Detail

createWorkspaceInstance

protected WorkspaceImpl createWorkspaceInstance(WorkspaceConfig wspConfig,
                                                SharedItemStateManager stateMgr,
                                                RepositoryImpl rep,
                                                SessionImpl session)
Creates the workspace instance backing this session.

Overrides:
createWorkspaceInstance in class SessionImpl
Parameters:
wspConfig - The workspace configuration
stateMgr - The shared item state manager
rep - The repository
session - The session
Returns:
An instance of the WorkspaceImpl class or an extension thereof.

createVersionManager

protected InternalVersionManager createVersionManager(RepositoryImpl rep)
                                               throws RepositoryException
Create the version manager. If we are not using XA, we may safely use the repository version manager.

Overrides:
createVersionManager in class SessionImpl
Returns:
version manager
Throws:
RepositoryException

getLockManager

public LockManager getLockManager()
                           throws RepositoryException
Return the lock manager for this session.

Overrides:
getLockManager in class SessionImpl
Returns:
lock manager for this session
Throws:
RepositoryException

getXAResource

public XAResource getXAResource()
Retrieves an XAResource object that the transaction manager will use to manage this XASession object's participation in a distributed transaction.

Specified by:
getXAResource in interface XASession
Returns:
the XAResource object.

getTransactionTimeout

public int getTransactionTimeout()

Specified by:
getTransactionTimeout in interface XAResource

setTransactionTimeout

public boolean setTransactionTimeout(int seconds)

Specified by:
setTransactionTimeout in interface XAResource

isSameRM

public boolean isSameRM(XAResource xares)
                 throws XAException

Two resources belong to the same resource manager if both connections (i.e. sessions) have the same credentials.

Specified by:
isSameRM in interface XAResource
Throws:
XAException

start

public void start(Xid xid,
                  int flags)
           throws XAException

If TMNOFLAGS is specified, we create a new transaction context and associate it with this resource. If TMJOIN is specified, this resource should use the same transaction context as another, already known transaction. If TMRESUME is specified, we should resume work on a transaction context that was suspended earlier. All other flags generate an XAException of type XAER_INVAL

Specified by:
start in interface XAResource
Throws:
XAException

end

public void end(Xid xid,
                int flags)
         throws XAException

If TMSUCCESS is specified, we disassociate this session from the transaction specified. If TMFAIL is specified, we disassociate this session from the transaction specified and mark the transaction rollback only. If TMSUSPEND is specified, we disassociate this session from the transaction specified. All other flags generate an XAException of type XAER_INVAL

It is legal for a transaction association to be suspended and then ended (either with TMSUCCESS or TMFAIL) without having been resumed again.

Specified by:
end in interface XAResource
Throws:
XAException

prepare

public int prepare(Xid xid)
            throws XAException

Specified by:
prepare in interface XAResource
Throws:
XAException

commit

public void commit(Xid xid,
                   boolean onePhase)
            throws XAException

Specified by:
commit in interface XAResource
Throws:
XAException

rollback

public void rollback(Xid xid)
              throws XAException

Specified by:
rollback in interface XAResource
Throws:
XAException

recover

public Xid[] recover(int flags)
              throws XAException

No recovery support yet.

Specified by:
recover in interface XAResource
Throws:
XAException

forget

public void forget(Xid xid)
            throws XAException

No recovery support yet.

Specified by:
forget in interface XAResource
Throws:
XAException

associate

public void associate(TransactionContext tx)
Associate this session with a global transaction. Internally, set the transaction containing all transaction-local objects to be used when performing item retrieval and store.


logout

public void logout()
Clears the local namespace mappings. Subclasses that for example want to participate in a session pools should remember to call super.logout() when overriding this method to avoid namespace mappings to be carried over to a new session.

Specified by:
logout in interface Session
Overrides:
logout in class SessionImpl


Copyright © 2004-2010 The Apache Software Foundation. All Rights Reserved.