mandala.jacob
Class SORFactory

java.lang.Object
  extended bymandala.rami.AbstractARFactory
      extended bymandala.rami.impl.AbstractARImplFactory
          extended bymandala.jacob.SORFactory
All Implemented Interfaces:
Framework.Factory

public class SORFactory
extends AbstractARImplFactory

Creates asynchronous references of object stored in a given active map.

Note that when calling getInstance(), objects are inserted into ActiveMap using Map.put(Object, Object) method whereas an Instanciator is used when newInstance() is called.
The consequence is that if the related active map is remote, getInstance() can only insert serializable objects whereas using newInstance() allows non serializable objects to be created remotely.

Notice that in the case of a RemoteActiveMap, since object are serialized, the singleton pattern is still achieve but with the following difference:
The object returned by StoredObjectReference.getObject() is the serialized version of the object refered by the sor. Hence, consider the following code:

 
   Object o1 = new String("Dummy");
   StoredObjectReference sor = new SORFactory(activeMap).getInstance(o1);
   Object o2 = sor.getObject();
   
In the local case, o1 == o2 returns true whereas it returns false in the remote case. The reason is that in the latter case, getInstance() insert a serialized version - called o3 of the object o1 in the specified remote activeMap. Then, the getObject() returns the serialized version of the object o3 and returns o2. Hence, even if o2.equals(o1), o2 != o1.

Users may pay attention of both methods Object.equals(Object) and Object.hashCode() of the object they insert in a remote active map.

Version:
1.0
Author:
eipi
See Also:
Framework.Factory, AsynchronousReference, StoredObjectReference, ActiveMap, Instanciator

Field Summary
 
Fields inherited from class mandala.rami.impl.AbstractARImplFactory
futureFactory
 
Fields inherited from class mandala.rami.AbstractARFactory
callbackManager
 
Constructor Summary
SORFactory(ActiveMap activeMap)
          Creates a new SORFactory instance.
SORFactory(ActiveMap activeMap, CallbackManager callbackManager)
          Creates a new SORFactory instance.
SORFactory(ActiveMap activeMap, CallbackManager callbackManager, FutureFactory futureFactory)
          Creates a new SORFactory instance.
SORFactory(ActiveMap activeMap, FutureFactory futureFactory)
          Creates a new SORFactory instance.
 
Method Summary
 ActiveMap getActiveMap()
          Returns the ActiveMap this factory uses.
protected  AsynchronousReference getInstance(java.lang.Object object, CallbackManager callbackManager, FutureFactory futureFactory)
          Gets a StoredObjectReference on the specified object.
 AsynchronousReference newInstance(ConstructorOp constructor, java.lang.Object[] args)
          Returns a StoredObjectReference on a new object.
 
Methods inherited from class mandala.rami.impl.AbstractARImplFactory
getDefaultFutureFactory, getInstance, getInstance
 
Methods inherited from class mandala.rami.AbstractARFactory
getDefaultCallbackManager
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SORFactory

public SORFactory(ActiveMap activeMap)

Creates a new SORFactory instance.

Equivalent to this(activeMap, getDefaultCallbackManager(), getDefaultFutureFactory());.

Parameters:
activeMap - an ActiveMap value

SORFactory

public SORFactory(ActiveMap activeMap,
                  FutureFactory futureFactory)

Creates a new SORFactory instance.

Equivalent to this(activeMap, getDefaultCallbackManager(), futureFactory);.

Parameters:
activeMap - an ActiveMap value
futureFactory - a FutureFactory value

SORFactory

public SORFactory(ActiveMap activeMap,
                  CallbackManager callbackManager)

Creates a new SORFactory instance.

Equivalent to this(activeMap, callbackManager, getDefaultFutureFactory());.

Parameters:
activeMap - an ActiveMap value
callbackManager - a CallbackManager value

SORFactory

public SORFactory(ActiveMap activeMap,
                  CallbackManager callbackManager,
                  FutureFactory futureFactory)

Creates a new SORFactory instance.

If the given activeMap is in fact a remote active map (activeMap instanceof RemoteActiveMap returns true), and if the given futureFactory is not a RemoteFutureFactory (futureFactory instanceof RemoteFutureFactory returns false), then the futureFactory is wrapped into the remote one returned by:
RemoteActiveMap.getDefaultFutureFactoryWrapper(FutureFactory futureFactory);

Parameters:
activeMap - the ActiveMap where stored objects must be inserted and referenced.
callbackManager - the CallbackManager to use on asynchronous method invocation
futureFactory - the FutureFactory to use on asynchronous method invocation
Method Detail

getInstance

protected AsynchronousReference getInstance(java.lang.Object object,
                                            CallbackManager callbackManager,
                                            FutureFactory futureFactory)

Gets a StoredObjectReference on the specified object.

If the object is not already stored into the ActiveMap returned by getActiveMap() it is inserted in it with a unique key.
The consequence is that when the ActiveMap is remote, object must must be serializable.

Specified by:
getInstance in class AbstractARImplFactory
Parameters:
object - an Object value
callbackManager - a CallbackManager value
futureFactory - a FutureFactory value
Returns:
a StoredObjectReference on the stored object
See Also:
StoredObjectReference

newInstance

public AsynchronousReference newInstance(ConstructorOp constructor,
                                         java.lang.Object[] args)

Returns a StoredObjectReference on a new object.

Note that the object is created using an Instanciator so if the active map is remote (getActiveMap() instanceof mandala.jacob.remote.RemoteActiveMap) returns true), the instanciation is done remotely.

Specified by:
newInstance in interface Framework.Factory
Overrides:
newInstance in class AbstractARFactory
Parameters:
constructor - a ConstructorOp value
args - an Object[] value
Returns:
an AsynchronousReference value

getActiveMap

public ActiveMap getActiveMap()

Returns the ActiveMap this factory uses.

Returns:
an ActiveMap value


Mandala help mailing list