com.threerings.presents.dobj
Class CompoundEvent

java.lang.Object
  extended by com.threerings.presents.dobj.DEvent
      extended by com.threerings.presents.dobj.CompoundEvent
All Implemented Interfaces:
Streamable

public class CompoundEvent
extends DEvent

Used to manage and submit groups of events on a collection of distributed objects in a single transaction.

See Also:
DObject.startTransaction()

Nested Class Summary
 
Nested classes/interfaces inherited from interface com.threerings.io.Streamable
Streamable.Closure
 
Field Summary
protected  StreamableArrayList<DEvent> _events
          A list of the events associated with this compound event.
protected  DObjectManager _omgr
          The object manager that we'll post ourselves to when we're committed.
protected  DObject _target
          The object for which we're managing a transaction.
 
Fields inherited from class com.threerings.presents.dobj.DEvent
_actualTransport, _soid, _toid, _transport, eventId, UNSET_OLD_ENTRY, UNSET_OLD_VALUE
 
Constructor Summary
CompoundEvent()
          Used when unserializing.
CompoundEvent(DObject target, DObjectManager omgr)
          Constructs a compound event and prepares it for operation.
 
Method Summary
 boolean applyToObject(DObject target)
          Applies the attribute modifications represented by this event to the specified target object.
 void cancel()
          Cancels this transaction.
protected  void clearTarget()
          Calls out to our target object, clearing its transaction reference.
 void commit()
          Commits this transaction by posting this event to the distributed object event queue.
 List<DEvent> getEvents()
          Returns the list of events contained within this compound event.
 void postEvent(DEvent event)
          Posts an event to this transaction.
 void setSourceOid(int sourceOid)
          Do not call this method.
 void setTargetOid(int targetOid)
          Do not call this method.
 DEvent setTransport(Transport transport)
          Sets the transport parameters.
protected  void toString(StringBuilder buf)
          This should be overridden by derived classes (which should be sure to call super.toString()) to append the derived class specific event information to the string buffer.
 
Methods inherited from class com.threerings.presents.dobj.DEvent
alreadyApplied, getActualTransport, getSourceOid, getTargetOid, getTransport, isPrivate, noteActualTransport, notifyListener, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_omgr

protected transient DObjectManager _omgr
The object manager that we'll post ourselves to when we're committed.


_target

protected transient DObject _target
The object for which we're managing a transaction.


_events

protected StreamableArrayList<DEvent> _events
A list of the events associated with this compound event.

Constructor Detail

CompoundEvent

public CompoundEvent(DObject target,
                     DObjectManager omgr)
Constructs a compound event and prepares it for operation.


CompoundEvent

public CompoundEvent()
Used when unserializing.

Method Detail

postEvent

public void postEvent(DEvent event)
Posts an event to this transaction. The event will be delivered as part of the entire transaction if it is committed or discarded if the transaction is cancelled.


getEvents

public List<DEvent> getEvents()
Returns the list of events contained within this compound event. Don't mess with it.


commit

public void commit()
Commits this transaction by posting this event to the distributed object event queue. All participating dobjects will have their transaction references cleared and will go back to normal operation.


cancel

public void cancel()
Cancels this transaction. All events posted to this transaction will be discarded.


setSourceOid

public void setSourceOid(int sourceOid)
Description copied from class: DEvent
Do not call this method. Sets the source oid of the client that generated this event. It is automatically called by the client management code when a client forwards an event to the server.

Overrides:
setSourceOid in class DEvent

setTargetOid

public void setTargetOid(int targetOid)
Description copied from class: DEvent
Do not call this method. Sets the oid of the object on which this event operates. It is only used when rewriting events during object proxying.

Overrides:
setTargetOid in class DEvent

setTransport

public DEvent setTransport(Transport transport)
Description copied from class: DEvent
Sets the transport parameters. For events received over the network, these indicate the mode of transport over which the event was received. When an event is sent over the network, these act as a hint as to the type of transport desired.

Overrides:
setTransport in class DEvent

applyToObject

public boolean applyToObject(DObject target)
                      throws ObjectAccessException
Description copied from class: DEvent
Applies the attribute modifications represented by this event to the specified target object. This is called by the distributed object manager in the course of dispatching events and should not be called directly.

Specified by:
applyToObject in class DEvent
Returns:
true if the object manager should go on to notify the object's listeners of this event, false if the event should be treated silently and the listeners should not be notified.
Throws:
ObjectAccessException - thrown if there is any problem applying the event to the object (invalid attribute, etc.).

clearTarget

protected void clearTarget()
Calls out to our target object, clearing its transaction reference.


toString

protected void toString(StringBuilder buf)
Description copied from class: DEvent
This should be overridden by derived classes (which should be sure to call super.toString()) to append the derived class specific event information to the string buffer.

Overrides:
toString in class DEvent