org.sourceforge.jemm.client.id
Class TrackedIDFactoryImpl
java.lang.Object
org.sourceforge.jemm.client.shared.WeakSingletonFactory<ID,TrackedID>
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
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
listeners
protected final java.util.Set<TrackedIDListener> listeners
TrackedIDFactoryImpl
public TrackedIDFactoryImpl()
- Creates a new Factory with no ids mapped
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.