GigaSpaces XAP 7.0 API

com.j_spaces.core.client
Class LocalTransactionManager

java.lang.Object
  extended by com.j_spaces.core.client.LocalTransactionManager
All Implemented Interfaces:
Externalizable, Serializable, Remote, net.jini.core.transaction.server.TransactionConstants, net.jini.core.transaction.server.TransactionManager

public abstract class LocalTransactionManager
extends Object
implements net.jini.core.transaction.server.TransactionManager, Serializable, Externalizable

A Local Transaction Manager acts as a Transaction Manager for transactions that span a single space instance. It has several advantages over a standard distributed transaction manager:

In order to use it, the application generally getInstance of LocalTransactionManager object and then uses it like a distributed transaction manager:


   JavaSpace space = ... // get instance to a GigaSpaces space instance
   TransactionManager tm = LocalTransactionManager.getInstance((IJSpace) space);
   Transaction tr = ... // obtain transaction through TransactionFactory
   space.write(entry, tr, Lease.FOREVER);
   ...
   tr.commit();
   tr = ... // obtain transaction through TransactionFactory
   space.take(entry, tr, JavaSpace.NO_WAIT);
   ...
   tr.commit();
 

It is important to note that all operations inside a local transaction must be directed to the same space instance - the space instance that was given to the LocalTransactionManager.getInstance( space ).

If you are interested to have multiple spaces as part of the same transaction you should use the Jini Transaction manager - See the TransactionManager. The Jini Transaction manager is mainly used with partitioned space.


 TransactionManager tm = (TransactionManager)LookupFinder.find(
                                null,       // service name
                                new Class[] { net.jini.core.transaction.server.TransactionManager.class },
                                null,       // service attributes
                                "localhost", // unicast lookup host
                               null,       // lookup groups
                                    10*1000     // timeout 10 seconds
                               );
 Transaction.Created tCreated =TransactionFactory.create(trManager, 1000 * 60);
 Transaction  tr = tCreated.transaction;
 

See http://www.gigaspaces.com/wiki/display/GS/Jini+Transaction+Manager for more information.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface net.jini.core.transaction.server.TransactionManager
net.jini.core.transaction.server.TransactionManager.Created
 
Field Summary
 
Fields inherited from interface net.jini.core.transaction.server.TransactionConstants
ABORTED, ACTIVE, COMMITTED, NOTCHANGED, PREPARED, VOTING
 
Constructor Summary
LocalTransactionManager()
           
 
Method Summary
abstract  void destroy()
           
static net.jini.core.transaction.server.TransactionManager getInstance(IJSpace space)
          Returns single instance of LocalTransactionManager per space.
static net.jini.core.transaction.server.TransactionManager getInstance(IMap map)
          Returns single instance of LocalTransactionManager per map.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface net.jini.core.transaction.server.TransactionManager
abort, abort, commit, commit, create, getState, join
 
Methods inherited from interface java.io.Externalizable
readExternal, writeExternal
 

Constructor Detail

LocalTransactionManager

public LocalTransactionManager()
Method Detail

getInstance

public static net.jini.core.transaction.server.TransactionManager getInstance(IMap map)
                                                                       throws RemoteException
Returns single instance of LocalTransactionManager per map.


 

<b>Usage:</b> TransactionManager localTxnManager = LocalTransactionManager( (IMap)map ); Transaction.Created tCreated = TransactionFactory.create(localTxnManager, 60000); Transaction tr = tCreated.transaction;

Parameters:
map - The IMap implementation.
Returns:
Returns instance of LocalTransactionManager.
Throws:
RemoteException - Failed to initialize LocalTransactionManager, or if the passed space proxy is null.
See Also:
TransactionManager

getInstance

public static net.jini.core.transaction.server.TransactionManager getInstance(IJSpace space)
                                                                       throws RemoteException
Returns single instance of LocalTransactionManager per space.


 

<b>Usage:</b> TransactionManager localTxnManager = LocalTransactionManager( (IJSpace)space ); Transaction.Created tCreated = TransactionFactory.create(localTxnManager, 60000); Transaction tr = tCreated.transaction;

Parameters:
space - The space proxy.
Returns:
Returns instance of LocalTransactionManager.
Throws:
RemoteException - Failed to initialize LocalTransactionManager, or if the passed space proxy is null.
See Also:
TransactionManager

destroy

public abstract void destroy()

GigaSpaces XAP 7.0 API

Copyright © GigaSpaces.