uka.transport
Class DefaultSharedObjectSpace

java.lang.Object
  extended byuka.util.IDConstants
      extended byuka.util.IDMap
          extended byuka.transport.DefaultObjectSpace
              extended byuka.transport.DefaultSharedObjectSpace
All Implemented Interfaces:
ObjectSpace, Printable, java.io.Serializable, SharedObjectSpace

public class DefaultSharedObjectSpace
extends DefaultObjectSpace
implements SharedObjectSpace

See Also:
Serialized Form

Field Summary
(package private)  IntSet newIDs
           
(package private)  IntSet sharedIDs
           
 
Fields inherited from class uka.util.IDMap
idToObject, INVALID_INDEX, space
 
Fields inherited from class uka.util.IDConstants
FIRST_NEW_ID, FIRST_VALID_ID, INVALID_ID, UNUSED_ID
 
Constructor Summary
DefaultSharedObjectSpace()
           
 
Method Summary
 void checkConsistency(java.util.logging.Logger log)
           
 IntIterator getNewIDs()
          The creation of new identifiers in calls to DefaultObjectSpace.getID(java.lang.Object) and IDMap.setObject(int, java.lang.Object) is logged in a set newIDs.
 IntIterator getNewlySharedIDs()
          If an identifier of this object space becomes shared, it is first inserted into the set newlySharedIDs.
 IntIterator getNewlyUnsharedIDs()
           
 IntIterator getSharedIDs()
          Objects corresponding to identifiers in this object space can eiter be shared or non-shared.
private  void initTransient()
           
private  void readObject(java.io.ObjectInputStream s)
           
 void resetNewIDs()
          Empties the set newIDs and flushes the information in newlySharedIDs and newlyUnsharedIDs to sharedIDs.
private  void restoreAfterUnmarshal()
           
protected  void restoreBeforeReadObject()
           
protected  void set(int id, java.lang.Object obj)
          Access to the underlying IDMap.idToObject array is encapsulated through the set(int, java.lang.Object) and IDMap.get(int) methods.
 
Methods inherited from class uka.transport.DefaultObjectSpace
getID, includeID, isAccepted, isIncluded, isShared
 
Methods inherited from class uka.util.IDMap
appendTo, clear, dump, findID, get, getHash, getIndexForHash, getIndexForID, getObject, getObjects, getSize, getUsedIDs, isUsed, rawFindID, remove, resetObject, setObject
 
Methods inherited from class uka.util.IDConstants
isNew, isValid, normalizeID, toggleNew
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface uka.transport.ObjectSpace
clear, findID, getID, getObject, getUsedIDs, includeID, isAccepted, isIncluded, isShared, isUsed, remove, resetObject, setObject
 

Field Detail

sharedIDs

IntSet sharedIDs

newIDs

transient IntSet newIDs
Constructor Detail

DefaultSharedObjectSpace

public DefaultSharedObjectSpace()
Method Detail

initTransient

private void initTransient()

set

protected void set(int id,
                   java.lang.Object obj)
Description copied from class: IDMap
Access to the underlying IDMap.idToObject array is encapsulated through the IDMap.set(int, java.lang.Object) and IDMap.get(int) methods. Subclasses may use this hooks to add functionality whenever an object is stored or retrieved.

Overrides:
set in class IDMap

getSharedIDs

public IntIterator getSharedIDs()
Description copied from interface: SharedObjectSpace

Objects corresponding to identifiers in this object space can eiter be shared or non-shared. If an object is consedered shared or non-shared depends on the concrete object space.

Operation on this object space (inclusion of objects, adding objects to sub-spaces, and so on) never modify the set of shared identifiers directly. Instead, the two journals newlySharedIDs and newlyUnsharedIDs are updated. These journals are flushed into the shared identifier set via a call to SharedObjectSpace.resetNewIDs().

Specified by:
getSharedIDs in interface SharedObjectSpace
Returns:
an iterator over currently shared identifiers.

getNewlySharedIDs

public IntIterator getNewlySharedIDs()
Description copied from interface: SharedObjectSpace
If an identifier of this object space becomes shared, it is first inserted into the set newlySharedIDs. A call to SharedObjectSpace.resetNewIDs() flushes this information to sharedIDs.

Specified by:
getNewlySharedIDs in interface SharedObjectSpace
Returns:
an iterator over all newly shared identifiers in this object space.

getNewlyUnsharedIDs

public IntIterator getNewlyUnsharedIDs()
Specified by:
getNewlyUnsharedIDs in interface SharedObjectSpace
See Also:
SharedObjectSpace.getNewlySharedIDs()

getNewIDs

public IntIterator getNewIDs()
Description copied from interface: SharedObjectSpace
The creation of new identifiers in calls to ObjectSpace.getID(java.lang.Object) and ObjectSpace.setObject(int, java.lang.Object) is logged in a set newIDs.

Specified by:
getNewIDs in interface SharedObjectSpace
Returns:
an iterator over all identifiers that have been assigned in this object space after the last call to SharedObjectSpace.resetNewIDs().

resetNewIDs

public void resetNewIDs()
Description copied from interface: SharedObjectSpace
Empties the set newIDs and flushes the information in newlySharedIDs and newlyUnsharedIDs to sharedIDs.

Specified by:
resetNewIDs in interface SharedObjectSpace

restoreBeforeReadObject

protected void restoreBeforeReadObject()
                                throws java.io.IOException,
                                       java.lang.ClassNotFoundException
Overrides:
restoreBeforeReadObject in class IDMap
Throws:
java.io.IOException
java.lang.ClassNotFoundException

restoreAfterUnmarshal

private void restoreAfterUnmarshal()
                            throws java.lang.ClassNotFoundException,
                                   java.io.IOException
Throws:
java.lang.ClassNotFoundException
java.io.IOException

readObject

private void readObject(java.io.ObjectInputStream s)
                 throws java.io.IOException,
                        java.lang.ClassNotFoundException
Throws:
java.io.IOException
java.lang.ClassNotFoundException

checkConsistency

public void checkConsistency(java.util.logging.Logger log)
Specified by:
checkConsistency in interface SharedObjectSpace