rcf.core.concurrent.events
Class HashEventSyndicate

java.lang.Object
  extended by rcf.core.util.filter.AbstractFilter<T>
      extended by rcf.core.util.collection.AbstractImmutableCollection<T,I,SI,SC,C>
          extended by rcf.core.util.collection.AbstractCollection<T,I,SI,SC,C>
              extended by rcf.core.util.collection.Hashtable<ImmutablePairInterface<A,B>,rcf.core.util.collection.Hashtable.HashtableIterator,rcf.core.util.map.HashMap.SubHashMapIterator<A,B>,rcf.core.util.map.HashMap.SubHashMap<A,B>,rcf.core.util.map.HashMap<A,B>>
                  extended by rcf.core.util.map.HashMap<Reference<EventSink<? super Event>>,Class<Event>>
                      extended by rcf.core.concurrent.events.HashEventSyndicate
All Implemented Interfaces:
EventSink<Event>, EventSource, EventSyndicate, Transactional<rcf.core.util.collection.transaction.CollectionTransaction<ImmutablePairInterface<Reference<EventSink<? super Event>>,Class<Event>>>>, rcf.core.util.accessor.Accessing<ImmutablePairInterface<Reference<EventSink<? super Event>>,Class<Event>>>, rcf.core.util.adapter.TypeAdapter<ImmutablePairInterface<Reference<EventSink<? super Event>>,Class<Event>>,Class<Event>>, rcf.core.util.adapter.TypeAdapterA<ImmutablePairInterface<Reference<EventSink<? super Event>>,Class<Event>>,Class<Event>>, rcf.core.util.adapter.TypeAdapterB<ImmutablePairInterface<Reference<EventSink<? super Event>>,Class<Event>>,Class<Event>>, rcf.core.util.collection.Collection<ImmutablePairInterface<Reference<EventSink<? super Event>>,Class<Event>>>, rcf.core.util.collection.ImmutableCollection<ImmutablePairInterface<Reference<EventSink<? super Event>>,Class<Event>>>, rcf.core.util.collection.iterator.FixedUniIterable<ImmutablePairInterface<Reference<EventSink<? super Event>>,Class<Event>>>, rcf.core.util.collection.iterator.ImmutableFixedUniIterable<ImmutablePairInterface<Reference<EventSink<? super Event>>,Class<Event>>>, rcf.core.util.collection.ModCount, rcf.core.util.Copyable, rcf.core.util.filter.DynamicFilter<ImmutablePairInterface<Reference<EventSink<? super Event>>,Class<Event>>,rcf.core.util.collection.transaction.CollectionTransaction<ImmutablePairInterface<Reference<EventSink<? super Event>>,Class<Event>>>>, rcf.core.util.filter.Filter<ImmutablePairInterface<Reference<EventSink<? super Event>>,Class<Event>>>, rcf.core.util.Immutable, ImmutableIterable<ImmutablePairInterface<Reference<EventSink<? super Event>>,Class<Event>>>, Iterable<ImmutablePairInterface<Reference<EventSink<? super Event>>,Class<Event>>>, rcf.core.util.map.mixins.ImmutableMapCollection<Reference<EventSink<? super Event>>,Class<Event>,ImmutablePairInterface<Reference<EventSink<? super Event>>,Class<Event>>>, rcf.core.util.map.mixins.ImmutableMultiViewMap<Reference<EventSink<? super Event>>,Class<Event>,ImmutablePairInterface<Reference<EventSink<? super Event>>,Class<Event>>>, rcf.core.util.map.mixins.MapCollection<Reference<EventSink<? super Event>>,Class<Event>,ImmutablePairInterface<Reference<EventSink<? super Event>>,Class<Event>>>, rcf.core.util.map.mixins.MultiViewMap<Reference<EventSink<? super Event>>,Class<Event>,ImmutablePairInterface<Reference<EventSink<? super Event>>,Class<Event>>>, rcf.core.util.map.pair.ImmutablePMapCollection<Reference<EventSink<? super Event>>,Class<Event>,ImmutablePairInterface<Reference<EventSink<? super Event>>,Class<Event>>>, rcf.core.util.map.pair.PMapCollection<Reference<EventSink<? super Event>>,Class<Event>,ImmutablePairInterface<Reference<EventSink<? super Event>>,Class<Event>>>

@Revision(value="$Revision: 1.19 $",
          date="$Date: 2006/12/15 20:37:49 $",
          tag="$Name:  $")
public class HashEventSyndicate
extends rcf.core.util.map.HashMap<Reference<EventSink<? super Event>>,Class<Event>>
implements EventSyndicate

TODO: Javadoc

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

Version:
$Revision: 1.19 $
Author:
Greg Gibeling

Nested Class Summary
 
Nested classes/interfaces inherited from class rcf.core.util.map.HashMap
rcf.core.util.map.HashMap.SubHashMap<A,B>, rcf.core.util.map.HashMap.SubHashMapIterator<A,B>
 
Nested classes/interfaces inherited from class rcf.core.util.collection.Hashtable
rcf.core.util.collection.Hashtable.HashtableIterator, rcf.core.util.collection.Hashtable.HashtableNode<T>
 
Nested classes/interfaces inherited from class rcf.core.util.collection.AbstractCollection
rcf.core.util.collection.AbstractCollection.AbstractSubCollection<T,I extends rcf.core.util.collection.iterator.FixedUniIterator<T>,SI extends rcf.core.util.collection.AbstractCollection.AbstractSubCollectionIterator<T,I,SI,SC,C>,SC extends rcf.core.util.collection.AbstractCollection.AbstractSubCollection<T,I,SI,SC,C>,C extends rcf.core.util.collection.AbstractCollection<T,I,SI,SC,C>>, rcf.core.util.collection.AbstractCollection.AbstractSubCollectionIterator<T,I extends rcf.core.util.collection.iterator.FixedUniIterator<T>,SI extends rcf.core.util.collection.AbstractCollection.AbstractSubCollectionIterator<T,I,SI,SC,C>,SC extends rcf.core.util.collection.AbstractCollection.AbstractSubCollection<T,I,SI,SC,C>,C extends rcf.core.util.collection.AbstractCollection<T,I,SI,SC,C>>, rcf.core.util.collection.AbstractCollection.SubCollection<T,I extends rcf.core.util.collection.iterator.FixedUniIterator<T>,SI extends rcf.core.util.collection.AbstractCollection.SubCollectionIterator<T,I,SI,SC,C>,SC extends rcf.core.util.collection.AbstractCollection.SubCollection<T,I,SI,SC,C>,C extends rcf.core.util.collection.AbstractCollection<T,I,SI,SC,C>>, rcf.core.util.collection.AbstractCollection.SubCollectionIterator<T,I extends rcf.core.util.collection.iterator.FixedUniIterator<T>,SI extends rcf.core.util.collection.AbstractCollection.SubCollectionIterator<T,I,SI,SC,C>,SC extends rcf.core.util.collection.AbstractCollection.SubCollection<T,I,SI,SC,C>,C extends rcf.core.util.collection.AbstractCollection<T,I,SI,SC,C>>
 
Nested classes/interfaces inherited from class rcf.core.util.collection.AbstractImmutableCollection
rcf.core.util.collection.AbstractImmutableCollection.AbstractImmutableSubCollection<T,I extends rcf.core.util.collection.iterator.ImmutableFixedUniIterator<T>,SI extends rcf.core.util.collection.AbstractImmutableCollection.AbstractImmutableSubCollectionIterator<T,I,SI,SC,C>,SC extends rcf.core.util.collection.AbstractImmutableCollection.AbstractImmutableSubCollection<T,I,SI,SC,C>,C extends rcf.core.util.collection.AbstractImmutableCollection<T,I,SI,SC,C>>, rcf.core.util.collection.AbstractImmutableCollection.AbstractImmutableSubCollectionIterator<T,I extends rcf.core.util.collection.iterator.ImmutableFixedUniIterator<T>,SI extends rcf.core.util.collection.AbstractImmutableCollection.AbstractImmutableSubCollectionIterator<T,I,SI,SC,C>,SC extends rcf.core.util.collection.AbstractImmutableCollection.AbstractImmutableSubCollection<T,I,SI,SC,C>,C extends rcf.core.util.collection.AbstractImmutableCollection<T,I,SI,SC,C>>, rcf.core.util.collection.AbstractImmutableCollection.ImmutableSubCollection<T,I extends rcf.core.util.collection.iterator.ImmutableFixedUniIterator<T>,SI extends rcf.core.util.collection.AbstractImmutableCollection.ImmutableSubCollectionIterator<T,I,SI,SC,C>,SC extends rcf.core.util.collection.AbstractImmutableCollection.ImmutableSubCollection<T,I,SI,SC,C>,C extends rcf.core.util.collection.AbstractImmutableCollection<T,I,SI,SC,C>>, rcf.core.util.collection.AbstractImmutableCollection.ImmutableSubCollectionIterator<T,I extends rcf.core.util.collection.iterator.ImmutableFixedUniIterator<T>,SI extends rcf.core.util.collection.AbstractImmutableCollection.ImmutableSubCollectionIterator<T,I,SI,SC,C>,SC extends rcf.core.util.collection.AbstractImmutableCollection.ImmutableSubCollection<T,I,SI,SC,C>,C extends rcf.core.util.collection.AbstractImmutableCollection<T,I,SI,SC,C>>
 
Nested classes/interfaces inherited from interface rcf.core.util.filter.Filter
rcf.core.util.filter.Filter.Type
 
Nested classes/interfaces inherited from interface rcf.core.util.filter.Filter
rcf.core.util.filter.Filter.Type
 
Nested classes/interfaces inherited from interface rcf.core.util.filter.Filter
rcf.core.util.filter.Filter.Type
 
Field Summary
protected static SoftReference<rcf.core.util.accessor.Accessor<? super Reference<EventSink>>> accessor
          TODO: Javadoc
protected  Event current
          TODO: Javadoc The current event, used to reduce the possibility for infinite loops of events which include multiple syndicates.
 
Fields inherited from class rcf.core.util.map.HashMap
adapterInverse, core
 
Fields inherited from class rcf.core.util.collection.Hashtable
isImmutable, loadFactor, max, min, resizeLower, resizeUpper, size, table
 
Fields inherited from class rcf.core.util.collection.AbstractCollection
collectionEventTypes, currTrans, factory, prevTrans, sequenceNumber, syndicate
 
Fields inherited from class rcf.core.util.collection.AbstractImmutableCollection
filter, hashCodeCache
 
Fields inherited from class rcf.core.util.filter.AbstractFilter
filterInverse
 
Constructor Summary
  HashEventSyndicate()
          TODO: Javadoc
protected HashEventSyndicate(HashEventSyndicate _copyFrom)
          TODO: Javadoc
 
Method Summary
<E extends Event>
rcf.core.util.collection.iterator.FixedUniIterator<ImmutablePairInterface<Reference<EventSink<? super E>>,Class<E>>>
add(Reference<EventSink<? super E>> _sinkReference, Class<E> _class)
          Register an event sink to receive all of the events from the EventSource for this syndicate, which are assignable to the specified class.
protected  rcf.core.util.collection.Hashtable.HashtableNode<ImmutablePairInterface<Reference<EventSink<? super Event>>,Class<Event>>> addHashNode(ImmutablePairInterface<Reference<EventSink<? super Event>>,Class<Event>> o, int robustHashCode, boolean resize)
           
protected static rcf.core.util.accessor.Accessor<? super Reference<EventSink<? super Event>>> cachedAccessor()
          TODO: Javadoc
protected  void changeHashNode(rcf.core.util.collection.Hashtable.HashtableNode<ImmutablePairInterface<Reference<EventSink<? super Event>>,Class<Event>>> node, ImmutablePairInterface<Reference<EventSink<? super Event>>,Class<Event>> o, int robustHashCode)
           
 HashEventSyndicate copy()
           
 boolean event(Event event)
          Called by an EventSyndicate to notify this sink that an event has occured.
<E extends Event>
rcf.core.util.collection.iterator.FixedUniIterator<ImmutablePairInterface<Reference<EventSink<? super E>>,Class<E>>>
remove(Reference<EventSink<? super E>> _sinkReference, Class<E> _class)
          Deregister an event sink to stop receiving events from the EventSource for this syndicate.
 
Methods inherited from class rcf.core.util.map.HashMap
add, collectionA, collectionB, collectionPA, collectionPB, createIterator, createSubCollection, mapA, mapB, mapDefaultAdapter, post, pre, put, remove, typeAdapterInverse
 
Methods inherited from class rcf.core.util.collection.Hashtable
add, addAll, clear, complement, createHashNode, filter, getStructuralModCount, hash, hashElement, incStructuralModCount, isImmutable, isUnique, lookupHashNode, remove, removeHashNode, resizeHashTable, robustHashCode, robustHashCode, size
 
Methods inherited from class rcf.core.util.collection.AbstractCollection
archivableTransaction, collectionEventTypes, commitTransaction, complementAll, createCompositeTransaction, createdSyndicate, destroyedSyndicate, events, factory, filterInverse, getSequenceNumber, getValueModCount, incSequenceNumber, incValueModCount, isSyndicated, newTransaction, prepTransaction, syndicate, transaction, transaction
 
Methods inherited from class rcf.core.util.collection.AbstractImmutableCollection
accessor, asAbstract, count, equals, filter, filterType, first, hashCode, isCompatible, isEmpty, isNative, ordering, toArray, toString
 
Methods inherited from class rcf.core.util.filter.AbstractFilter
filterAll, filterAny
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface rcf.core.concurrent.events.EventSyndicate
isEmpty, size
 
Methods inherited from interface rcf.core.util.collection.Collection
add, addAll, clear, complement, complementAll, factory, remove
 
Methods inherited from interface rcf.core.util.collection.ImmutableCollection
asAbstract, count, filter, filter, filterAll, filterAny, first, isUnique, ordering, toArray
 
Methods inherited from interface rcf.core.util.iterator.ImmutableIterable
isCompatible, isEmpty, isNative, size
 
Methods inherited from interface rcf.core.util.filter.Filter
equals, filterType
 
Methods inherited from interface rcf.core.util.accessor.Accessing
accessor
 
Methods inherited from interface rcf.core.util.Immutable
isImmutable
 
Methods inherited from interface rcf.core.util.collection.ModCount
getStructuralModCount, getValueModCount, incStructuralModCount, incValueModCount
 
Methods inherited from interface rcf.core.util.iterator.ImmutableIterable
isCompatible, isEmpty, isNative, size
 
Methods inherited from interface rcf.core.util.iterator.ImmutableIterable
isCompatible, isEmpty, isNative, size
 
Methods inherited from interface rcf.core.util.filter.DynamicFilter
filterInverse
 
Methods inherited from interface rcf.core.util.filter.Filter
equals, filterType
 
Methods inherited from interface rcf.core.concurrent.transactions.Transactional
transaction, transaction
 
Methods inherited from interface rcf.core.concurrent.events.EventSource
events, getSequenceNumber, incSequenceNumber, isSyndicated, syndicate
 
Methods inherited from interface rcf.core.util.Immutable
isImmutable
 
Methods inherited from interface rcf.core.util.collection.ImmutableCollection
asAbstract, count, filter, filter, filterAll, filterAny, first, isUnique, ordering, toArray
 
Methods inherited from interface rcf.core.util.iterator.ImmutableIterable
isCompatible, isEmpty, isNative, size
 
Methods inherited from interface rcf.core.util.filter.Filter
equals, filterType
 
Methods inherited from interface rcf.core.util.accessor.Accessing
accessor
 
Methods inherited from interface rcf.core.util.Immutable
isImmutable
 

Field Detail

current

protected Event current
TODO: Javadoc The current event, used to reduce the possibility for infinite loops of events which include multiple syndicates. Single syndicate loops (where this syndicate would send events to itself, will cause an exception in add(Reference, Class).

When this field is not null, no event is being reported. Before actually reporting an event the syndicate should check that it is not == current in which case an exception should be thrown. When an event is done being reported, this field should be set back to null, but only if it is == to the event which has just finished being reported. This check will ensure correctness under multi-threading, but it does decrease the utility of these checks, meaning that they are for debugging only, and cannot be relied upon to catch all cases of infinite event loops.

Note that access to this field must be synchronized on this syndicate.


accessor

protected static SoftReference<rcf.core.util.accessor.Accessor<? super Reference<EventSink>>> accessor
TODO: Javadoc

Constructor Detail

HashEventSyndicate

public HashEventSyndicate()
TODO: Javadoc


HashEventSyndicate

protected HashEventSyndicate(HashEventSyndicate _copyFrom)
TODO: Javadoc

Parameters:
_copyFrom -
Method Detail

cachedAccessor

protected static final rcf.core.util.accessor.Accessor<? super Reference<EventSink<? super Event>>> cachedAccessor()
TODO: Javadoc

Returns:

copy

public HashEventSyndicate copy()
Specified by:
copy in interface rcf.core.util.collection.Collection<ImmutablePairInterface<Reference<EventSink<? super Event>>,Class<Event>>>
Specified by:
copy in interface rcf.core.util.collection.ImmutableCollection<ImmutablePairInterface<Reference<EventSink<? super Event>>,Class<Event>>>
Specified by:
copy in interface rcf.core.util.Copyable
Specified by:
copy in interface rcf.core.util.filter.DynamicFilter<ImmutablePairInterface<Reference<EventSink<? super Event>>,Class<Event>>,rcf.core.util.collection.transaction.CollectionTransaction<ImmutablePairInterface<Reference<EventSink<? super Event>>,Class<Event>>>>
Specified by:
copy in interface rcf.core.util.map.pair.ImmutablePMapCollection<Reference<EventSink<? super Event>>,Class<Event>,ImmutablePairInterface<Reference<EventSink<? super Event>>,Class<Event>>>
Specified by:
copy in interface rcf.core.util.map.pair.PMapCollection<Reference<EventSink<? super Event>>,Class<Event>,ImmutablePairInterface<Reference<EventSink<? super Event>>,Class<Event>>>
Overrides:
copy in class rcf.core.util.map.HashMap<Reference<EventSink<? super Event>>,Class<Event>>

addHashNode

protected rcf.core.util.collection.Hashtable.HashtableNode<ImmutablePairInterface<Reference<EventSink<? super Event>>,Class<Event>>> addHashNode(ImmutablePairInterface<Reference<EventSink<? super Event>>,Class<Event>> o,
                                                                                                                                                 int robustHashCode,
                                                                                                                                                 boolean resize)
Overrides:
addHashNode in class rcf.core.util.collection.Hashtable<ImmutablePairInterface<Reference<EventSink<? super Event>>,Class<Event>>,rcf.core.util.collection.Hashtable.HashtableIterator,rcf.core.util.map.HashMap.SubHashMapIterator<Reference<EventSink<? super Event>>,Class<Event>>,rcf.core.util.map.HashMap.SubHashMap<Reference<EventSink<? super Event>>,Class<Event>>,rcf.core.util.map.HashMap<Reference<EventSink<? super Event>>,Class<Event>>>

changeHashNode

protected void changeHashNode(rcf.core.util.collection.Hashtable.HashtableNode<ImmutablePairInterface<Reference<EventSink<? super Event>>,Class<Event>>> node,
                              ImmutablePairInterface<Reference<EventSink<? super Event>>,Class<Event>> o,
                              int robustHashCode)
Overrides:
changeHashNode in class rcf.core.util.collection.Hashtable<ImmutablePairInterface<Reference<EventSink<? super Event>>,Class<Event>>,rcf.core.util.collection.Hashtable.HashtableIterator,rcf.core.util.map.HashMap.SubHashMapIterator<Reference<EventSink<? super Event>>,Class<Event>>,rcf.core.util.map.HashMap.SubHashMap<Reference<EventSink<? super Event>>,Class<Event>>,rcf.core.util.map.HashMap<Reference<EventSink<? super Event>>,Class<Event>>>

add

public <E extends Event> rcf.core.util.collection.iterator.FixedUniIterator<ImmutablePairInterface<Reference<EventSink<? super E>>,Class<E>>> add(Reference<EventSink<? super E>> _sinkReference,
                                                                                                                                                  Class<E> _class)
Description copied from interface: EventSyndicate
Register an event sink to receive all of the events from the EventSource for this syndicate, which are assignable to the specified class.

Specified by:
add in interface EventSyndicate
Parameters:
_sinkReference - A reference to the event sink, which this syndicate is supposed to call EventSink.event(Event) on. Notice that this is a reference, so that WeakReferences can be used to avoid having this syndicate send events to an event sink which would otherwise have been garbage collected.
_class - The class of events the EventSink specified by _sinkReference wants to receive from this syndicate.
Returns:
An iterator which can be used to remove this sink from the syndicate. This return type is also chosen to be compatible with Collection and MapCollection.

remove

public <E extends Event> rcf.core.util.collection.iterator.FixedUniIterator<ImmutablePairInterface<Reference<EventSink<? super E>>,Class<E>>> remove(Reference<EventSink<? super E>> _sinkReference,
                                                                                                                                                     Class<E> _class)
Description copied from interface: EventSyndicate
Deregister an event sink to stop receiving events from the EventSource for this syndicate.

Specified by:
remove in interface EventSyndicate
Parameters:
_sinkReference - A reference to the event sink, which this syndicate should no longer report events to. Note that the Reference.type() of the reference is immaterial.
_class - The class of events the EventSink specified by _sinkReference was to receiving from this syndicate.
Returns:
An iterator which can be used to remove this sink from the syndicate. This return type is also chosen to be compatible with Collection and MapCollection.

event

public boolean event(Event event)
Description copied from interface: EventSink
Called by an EventSyndicate to notify this sink that an event has occured.

Specified by:
event in interface EventSink<Event>
Specified by:
event in interface EventSyndicate
Parameters:
event - The event which has occured.
Returns:
true to keep receiving events from the source of this event. false to stop receiving events from the source of this event.
See Also:
EventSink.event(rcf.core.concurrent.events.Event)