org.sourceforge.jemm.client.id
Class TrackedIDFactoryImpl

java.lang.Object
  extended by org.sourceforge.jemm.client.shared.WeakSingletonFactory<ID,TrackedID>
      extended by org.sourceforge.jemm.client.id.TrackedIDFactoryImpl
All Implemented Interfaces:
TrackedIDFactory

public class TrackedIDFactoryImpl
extends WeakSingletonFactory<ID,TrackedID>
implements TrackedIDFactory

A Factory which creates a Flyweight of TrackedIDs such that two different ID objects, new ID(1) and new ID(1) will both map to the same TrackedID(1) object. This is flyweight like pattern is used to allow reliable tracking of IDs on the client side such that when an ID is no longer being used the server can be told that this client is no longer holding a reference to an object with that ID or the ID itself for some purpose. It is important that TrackedID's never get created any other way than via this Factory, and that normal ID instances do not get into the ShadowObject. This class is thread safe.

Author:
Paul Keeble

Field Summary
protected  java.util.Set<TrackedIDListener> listeners
           
 
Fields inherited from class org.sourceforge.jemm.client.shared.WeakSingletonFactory
keysToWeakRefs, queue, queueListener, refsToKeys
 
Constructor Summary
TrackedIDFactoryImpl()
          Creates a new Factory with no ids mapped
 
Method Summary
 void addListener(TrackedIDListener listener)
          Adds a listener which receives notification if a trackedID is enqueued for garbage collection.
protected  TrackedID createValue(ID id)
           
protected  void notifyExpired(ID id)
           
 void removeListener(TrackedIDListener listener)
          Removes the listener
 
Methods inherited from class org.sourceforge.jemm.client.shared.WeakSingletonFactory
contains, create, get, put, remove, shutdown, size
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.sourceforge.jemm.client.id.TrackedIDFactory
contains, create, get, remove
 

Field Detail

listeners

protected final java.util.Set<TrackedIDListener> listeners
Constructor Detail

TrackedIDFactoryImpl

public TrackedIDFactoryImpl()
Creates a new Factory with no ids mapped

Method Detail

notifyExpired

protected void notifyExpired(ID id)
Specified by:
notifyExpired in class WeakSingletonFactory<ID,TrackedID>

addListener

public void addListener(TrackedIDListener listener)
Description copied from interface: TrackedIDFactory
Adds a listener which receives notification if a trackedID is enqueued for garbage collection.

Specified by:
addListener in interface TrackedIDFactory

removeListener

public void removeListener(TrackedIDListener listener)
Description copied from interface: TrackedIDFactory
Removes the listener

Specified by:
removeListener in interface TrackedIDFactory

createValue

protected TrackedID createValue(ID id)
Specified by:
createValue in class WeakSingletonFactory<ID,TrackedID>


Copyright © 2009. All Rights Reserved.