mandala.jacob
Class StoredObjectReference

java.lang.Object
  extended bymandala.rami.AbstractAsynchronousReference
      extended bymandala.jacob.StoredObjectReference
All Implemented Interfaces:
AsynchronousReference, Reference, java.io.Serializable

public class StoredObjectReference
extends AbstractAsynchronousReference

Convenience class for stored object manipulation.

In a set of active maps, a reference to a stored object is a pair (activeMap, key). An instance of this class represents such a reference.

Instanciating a StoredObjectReference doesn't mean mapping an object in an active map.

Moreover, this class implements the singleton design pattern. For any pair (activeMap, key), only one instance of this class exist in the JVM. So, getting a reference of an instance of this class is done by the call :


   StoredObjectReference storedObjectReference =
   StoredObjectReference.getInstance(activeMap, key)

   
where activeMap is the active map reference where an object is already mapped to key.

An instance of this class may be unusable if its related stored object has been removed or doesn't exist. In such a case the reference represented by the pair (activeMap, key) is called invalid.

Each instance of this class uses the Syslog facility for logging.

Version:
$Revision: 1.9 $
Author:
eipi
See Also:
ActiveMap, AsynchronousReference, FutureFactory, CallbackManager, Syslog, Serialized Form

Field Summary
protected  ActiveMap activeMap
          The active map reference where the stored object is mapped to key.
protected  FutureFactory futureFactory
          The FutureFactory instance used to create our future objects.
protected  java.lang.Object key
          The key of the mapped object.
 
Fields inherited from class mandala.rami.AbstractAsynchronousReference
callbackManager, syslog
 
Constructor Summary
protected StoredObjectReference(ActiveMap activeMap, java.lang.Object key, CallbackManager callbackManager, FutureFactory futureFactory)
          Creates a new StoredObjectReference instance.
 
Method Summary
 FutureClient call(MethodOp method, java.lang.Object[] args, Callback callback)
          Call a method asynchronously.
 java.lang.Object get()
          Gets the object this reference refers to.
 ActiveMap getActiveMap()
          Gets the active map this reference is linked to.
 FutureFactory getFutureFactory()
          Returns the factory used to construct futures.
static java.lang.Object getGlobalUniqueKey(ActiveMap activeMap, java.lang.Object object)
           
static StoredObjectReference getInstance(ActiveMap activeMap, java.lang.Object key, CallbackManager callbackManager, FutureFactory futureFactory)
          Gets the instance related to the pair (activeMap, key).
 java.lang.Object getKey()
          Gets the key this reference is linked to.
 java.lang.Object getObject()
          Returns the object this StoredObjectReference refers to.
 boolean isValid()
           
 java.lang.Object put(java.lang.Object object)
          Replace the stored object by a new one.
 java.lang.Object remove()
          Unmmap the stored object from its key in the active map.
 java.lang.String toString()
           
 
Methods inherited from class mandala.rami.AbstractAsynchronousReference
call, getCallbackManager, getSyslog, setSyslog
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

key

protected java.lang.Object key

The key of the mapped object.

See Also:
ActiveMap

activeMap

protected ActiveMap activeMap

The active map reference where the stored object is mapped to key.

See Also:
ActiveMap

futureFactory

protected FutureFactory futureFactory

The FutureFactory instance used to create our future objects.

See Also:
FutureFactory
Constructor Detail

StoredObjectReference

protected StoredObjectReference(ActiveMap activeMap,
                                java.lang.Object key,
                                CallbackManager callbackManager,
                                FutureFactory futureFactory)

Creates a new StoredObjectReference instance.

Parameters:
activeMap - the active map where the stored object resides
key - the key of the stored object
futureFactory - the builder of future objects
callbackManager - the manager of Callback for this instance.
See Also:
ActiveMap, FutureFactory, Callback
Method Detail

call

public FutureClient call(MethodOp method,
                         java.lang.Object[] args,
                         Callback callback)
Description copied from interface: AsynchronousReference

Call a method asynchronously.

Since the call is asynchronous, exceptions are not handled in an usual way. Implementations must provide a mechanism conform to the FutureClient specification.

The method done of the specified Callback is called once the reflexive asynchronous method invocation is done. The Callback instance returned by CallbackManager.getCallback() is not used. If multiple callbacks are needed, see CallbackList.

Specified by:
call in interface AsynchronousReference
Specified by:
call in class AbstractAsynchronousReference

getObject

public java.lang.Object getObject()

Returns the object this StoredObjectReference refers to.

This implementation of the AsynchronousReference.getObject() method returns the same value as get().

Returns:
the object this StoredObjectReference refers to.
See Also:
Map.get(Object ket)

put

public java.lang.Object put(java.lang.Object object)

Replace the stored object by a new one.

Parameters:
object - the object this reference must refer to.
Returns:
The replaced object.

get

public java.lang.Object get()

Gets the object this reference refers to.

Returns:
the object this reference refers to.

remove

public java.lang.Object remove()

Unmmap the stored object from its key in the active map.

This reference object is invalid upon the return of this method.

Returns:
The object this reference previously refered to.

isValid

public boolean isValid()

getActiveMap

public ActiveMap getActiveMap()

Gets the active map this reference is linked to.

Returns:
the active map

getKey

public java.lang.Object getKey()

Gets the key this reference is linked to.

Returns:
the key

getFutureFactory

public FutureFactory getFutureFactory()

Returns the factory used to construct futures.

Returns:
the factory used to construct futures

toString

public java.lang.String toString()
Overrides:
toString in class AbstractAsynchronousReference

getInstance

public static StoredObjectReference getInstance(ActiveMap activeMap,
                                                java.lang.Object key,
                                                CallbackManager callbackManager,
                                                FutureFactory futureFactory)

Gets the instance related to the pair (activeMap, key).

This class implements the singleton design pattern. If the related instance doesn't exist, it is created. If the related instance exist, the futureFactory and the callbackManager arguments are unused.

No call to active map's methods are done.

Future calls to the returned instance are unspecified if this storedObjectReference is invalid i.e. if no object is mapped to key in the specified activeMap.

Parameters:
activeMap - the active map where the stored object resides
key - the key of the stored object
futureFactory - the builder of future objects
callbackManager - the manager of Callback for this instance.
Returns:
the StoredObjectReference instance which handles reflexive asynchronous method invocation on the specified stored object pair (activeMap, key).
See Also:
ActiveMap, FutureFactory, CallbackManager

getGlobalUniqueKey

public static java.lang.Object getGlobalUniqueKey(ActiveMap activeMap,
                                                  java.lang.Object object)


Mandala help mailing list