com.j_spaces.core.client
Class LocalTransactionManager
java.lang.Object
  
com.j_spaces.core.client.LocalTransactionManager
- All Implemented Interfaces: 
 - Externalizable, Serializable, Remote, TransactionConstants, TransactionManager
 
- Direct Known Subclasses: 
 - LocalTransactionManagerImpl
 
public abstract class LocalTransactionManager
- extends Object
- implements 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:
 
 - It is instantiated locally in the client JVM
 
 - It eliminates most of the remote calls involved in distributed
 transactions
 
 
 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
 
 
 
 
 
 
 
 
 
 
LocalTransactionManager
public LocalTransactionManager()
getInstance
public static 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 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