com.sun.sgs.impl.service.transaction
Class TransactionCoordinatorImpl

java.lang.Object
  extended by com.sun.sgs.impl.service.transaction.TransactionCoordinatorImpl
All Implemented Interfaces:
TransactionCoordinator

public final class TransactionCoordinatorImpl
extends Object
implements TransactionCoordinator

Provides an implementation of TransactionCoordinator. This class is thread safe, but the TransactionHandle returned by the createTransaction method, and the Transaction associated with the handle, are not thread safe. Callers should provide their own synchronization to insure that those objects are not accessed concurrently from multiple threads.

Transactions created by this class can only support at most a single durable participant — one that does not implement NonDurableTransactionParticipant. The join method on transactions created using this class will throw UnsupportedOperationException if more than one durable participant attempts to join the transaction.

The Transaction instances created by this class are not synchronized; methods on those instances should only be called from a single thread.

The default timeout for bounded transactions created by this class is 100ms. The default timeout for unbounded transactions created by this class is Long.MAX_VALUE. These defaults may be overridden using the properties TransactionCoordinator.TXN_TIMEOUT_PROPERTY and TransactionCoordinator.TXN_UNBOUNDED_TIMEOUT_PROPERTY respectively.


Field Summary
static long BOUNDED_TIMEOUT_DEFAULT
          The default for bounded timeout.
static long UNBOUNDED_TIMEOUT_DEFAULT
          The default for unbounded timeout.
 
Fields inherited from interface com.sun.sgs.impl.service.transaction.TransactionCoordinator
TXN_DISABLE_PREPAREANDCOMMIT_OPT_PROPERTY, TXN_TIMEOUT_PROPERTY, TXN_UNBOUNDED_TIMEOUT_PROPERTY
 
Constructor Summary
TransactionCoordinatorImpl(Properties properties, ProfileCollectorHandle collectorHandle)
          Creates an instance of this class configured with the specified properties.
 
Method Summary
 TransactionHandle createTransaction(long timeout)
          Creates a new transaction, and returns a handle for managing it.
 long getDefaultTimeout()
          Returns the default transaction timeout to use for bounded transactions.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BOUNDED_TIMEOUT_DEFAULT

public static final long BOUNDED_TIMEOUT_DEFAULT
The default for bounded timeout.

See Also:
Constant Field Values

UNBOUNDED_TIMEOUT_DEFAULT

public static final long UNBOUNDED_TIMEOUT_DEFAULT
The default for unbounded timeout.

See Also:
Constant Field Values
Constructor Detail

TransactionCoordinatorImpl

public TransactionCoordinatorImpl(Properties properties,
                                  ProfileCollectorHandle collectorHandle)
Creates an instance of this class configured with the specified properties.

Parameters:
properties - the properties for configuring this service
collectorHandle - the ProfileCollectorHandle used to report participant detail
Throws:
IllegalArgumentException - if the bounded or unbounded timeout properties are less than 1
Method Detail

createTransaction

public TransactionHandle createTransaction(long timeout)
Creates a new transaction, and returns a handle for managing it. If a timeout of ScheduledTask.UNBOUNDED is given, a transaction will be created with the timeout value specified by the property "com.sun.sgs.txn.timeout.unbounded".

Specified by:
createTransaction in interface TransactionCoordinator
Parameters:
timeout - the timeout, in milliseconds, to be used for this transaction
Returns:
a handle for managing the newly created transaction.

getDefaultTimeout

public long getDefaultTimeout()
Returns the default transaction timeout to use for bounded transactions. This value is specified using the property "com.sun.sgs.txn.timeout"

Specified by:
getDefaultTimeout in interface TransactionCoordinator
Returns:
the default transaction timeout

RedDwarf, Version 0.10.1
2010-03-14 10:56:12

Copyright © 2010 The RedDwarf Authors. All rights reserved
Copyright © 2007-2010 Sun Microsystems, Inc. All rights reserved