rcf.core.concurrent.transactions
Class AbstractTransaction

java.lang.Object
  extended by rcf.core.concurrent.events.AbstractEventSource
      extended by rcf.core.concurrent.schedule.AbstractTask
          extended by rcf.core.concurrent.transactions.AbstractTransaction
All Implemented Interfaces:
Event, EventSource, Task, Transaction

@Revision(value="$Revision: 1.2 $",
          date="$Date: 2006/11/23 23:07:31 $",
          tag="$Name:  $")
public abstract class AbstractTransaction
extends AbstractTask
implements Transaction

TODO: Javadoc

TODO: Unit tests, Code review, Javadoc review, Seal/Finalize TODO: equals, hashCode, toString

Version:
$Revision: 1.2 $
Author:
Greg Gibeling

Nested Class Summary
 
Nested classes/interfaces inherited from interface rcf.core.concurrent.transactions.Transaction
Transaction.Internal<X extends Transaction>
 
Nested classes/interfaces inherited from interface rcf.core.concurrent.schedule.Task
Task.State
 
Field Summary
protected  int eventSequenceNumber
          TODO: Javadoc
 
Fields inherited from class rcf.core.concurrent.schedule.AbstractTask
taskEventTypes
 
Fields inherited from class rcf.core.concurrent.events.AbstractEventSource
syndicate
 
Constructor Summary
AbstractTransaction(int _eventSequenceNumber)
          TODO: Javadoc
 
Method Summary
 boolean commit()
          TODO: Javadoc
 int getEventSequenceNumber()
          Get the sequence number of this event relative to it's Event.source().
 boolean isCancelled()
          Test if this event has been cancelled.
 boolean isLocked()
          TODO: Javadoc TODO: Transactional Locking
 boolean lock()
          TODO: Javadoc TODO: Transactional Locking
 EventSyndicate syndicate()
          Return the current syndicate for this event source, or allocate one if there isn't one.
 
Methods inherited from class rcf.core.concurrent.schedule.AbstractTask
events, taskEventTypes, taskState, taskState
 
Methods inherited from class rcf.core.concurrent.events.AbstractEventSource
createdSyndicate, destroyedSyndicate, getSequenceNumber, incSequenceNumber, isSyndicated
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface rcf.core.concurrent.transactions.Transaction
abort, source
 
Methods inherited from interface rcf.core.concurrent.schedule.Task
taskState
 
Methods inherited from interface rcf.core.concurrent.events.EventSource
events, getSequenceNumber, incSequenceNumber, isSyndicated
 

Field Detail

eventSequenceNumber

protected final int eventSequenceNumber
TODO: Javadoc

Constructor Detail

AbstractTransaction

public AbstractTransaction(int _eventSequenceNumber)
TODO: Javadoc

Method Detail

commit

public boolean commit()
Description copied from interface: Transaction
TODO: Javadoc

Specified by:
commit in interface Transaction
Returns:
true indicates success. false indicates the transaction couldn't be committed, or already was. if ((state == State.Aborted) || (state == State.Interrupted)) throw new TaskStateException("Cannnot commit a transaction in state \"" + temp + "\"!");

getEventSequenceNumber

public final int getEventSequenceNumber()
Description copied from interface: Event
Get the sequence number of this event relative to it's Event.source().

Specified by:
getEventSequenceNumber in interface Event
Returns:
The sequence number of this event relative to it's Event.source().

isCancelled

public final boolean isCancelled()
Description copied from interface: Event
Test if this event has been cancelled. This method is used to tell the event syndicate reporting this event to stop bothering, because it's been cancelled.

This is used in conjunction with Transaction.abort(). The return value from this method has no meaning outside of the event syndicate reporting loop. Often this method will simply return Task.taskState() == Task.State.Aborted.

Specified by:
isCancelled in interface Event
Specified by:
isCancelled in interface Transaction
Returns:
true if this event has been cancelled, and no longer needs to be reported.
See Also:
Event.isCancelled()

isLocked

public final boolean isLocked()
Description copied from interface: Transaction
TODO: Javadoc TODO: Transactional Locking

Specified by:
isLocked in interface Transaction
Returns:

lock

public final boolean lock()
Description copied from interface: Transaction
TODO: Javadoc TODO: Transactional Locking

Specified by:
lock in interface Transaction
Returns:
true if the lock was acquired for this thread. false if it was already held.

syndicate

public final EventSyndicate syndicate()
Description copied from interface: EventSource
Return the current syndicate for this event source, or allocate one if there isn't one. This method should never return null unless EventSource.events().ImmutableIterable.isEmpty() == true.

Specified by:
syndicate in interface EventSource
Overrides:
syndicate in class AbstractTask
Returns:
The event syndicate which an EventSink should register with (EventSyndicate.add(rcf.core.util.reference.Reference, Class)) to receive events from this source.