org.eclipse.ecf.core
Interface ISharedObjectContext

All Superinterfaces:
org.eclipse.core.runtime.IAdaptable
All Known Implementing Classes:
SOContext, XMPPContainerContext

public interface ISharedObjectContext
extends org.eclipse.core.runtime.IAdaptable

Context reference provided to all ISharedObjects upon initialization. Implementers of this interface provide a runtime context for ISharedObject instances. Upon initialization within a container (see ISharedObject.init(ISharedObjectConfig), ISharedObject instances can access an instance of this context by calling ISharedObjectConfig.getContext(). They then can have access to the functions provided by this context object for use in implementing their behavior.

See Also:
ISharedObject.init(org.eclipse.ecf.core.ISharedObjectConfig), ISharedObjectConfig.getContext()

Method Summary
 void connect(ID groupID, IConnectContext connectContext)
          (non-Javadoc)
 void disconnect()
          (non-Javadoc)
 ID getConnectedID()
          (non-Javadoc)
 Namespace getConnectNamespace()
          Get the Namespace instance that defines the ID type expected by the remote target container
 ID[] getGroupMemberIDs()
          (non-Javadoc)
 ID getLocalContainerID()
          Get the local container instance's ID
 java.util.Map getLocalContainerProperties()
          Get local container properties that it wishes to expose to shared object access
 IQueueEnqueue getQueue()
          Get the IQueueEnqueue instance associated with this ISharedObject.
 IOSGIService getServiceAccess()
          Get a reference to a proxy instance that allows the registration and access to local OSGI-platform-provided services.
 ISharedObjectManager getSharedObjectManager()
          Get the ISharedObjectManager for this context
 boolean isActive()
           
 boolean isGroupManager()
          (non-Javadoc)
 void sendCreate(ID toContainerID, ReplicaSharedObjectDescription sd)
          Send message to create a remote instance of an ISharedObject with the same ID as this instance.
 void sendCreateResponse(ID toContainerID, java.lang.Throwable throwable, long identifier)
          Send create response back to an ISharedObject with the same ID as this instance.
 void sendDispose(ID toContainerID)
          Send message to dispose of a remote instance of the ISharedObject with same ID as this instance.
 void sendMessage(ID toContainerID, java.lang.Object data)
          Send arbitrary message to remote instance of the ISharedObject with same ID as this instance.
 
Methods inherited from interface org.eclipse.core.runtime.IAdaptable
getAdapter
 

Method Detail

isActive

boolean isActive()

getLocalContainerID

ID getLocalContainerID()
Get the local container instance's ID

Returns:
the ID of the enclosing container

getSharedObjectManager

ISharedObjectManager getSharedObjectManager()
Get the ISharedObjectManager for this context

Returns:
ISharedObjectManager the shared object manager instance for this container. Null if none available.

getQueue

IQueueEnqueue getQueue()
Get the IQueueEnqueue instance associated with this ISharedObject. If the given container provides a queue for this ISharedObject, this method will return a IQueueEnqueue reference to the appropriate queue.

Returns:
IQueueEnqueue instance if an active queue is associated with this ISharedObject. If no active queue is associated with the ISharedObject, returns null.

connect

void connect(ID groupID,
             IConnectContext connectContext)
             throws ContainerConnectException
(non-Javadoc)

Throws:
ContainerConnectException
See Also:
IContainer.connect(ID,IConnectContext)

disconnect

void disconnect()
(non-Javadoc)

See Also:
IContainer.disconnect()

getConnectedID

ID getConnectedID()
(non-Javadoc)

See Also:
IContainer.getConnectedID()

isGroupManager

boolean isGroupManager()
(non-Javadoc)

See Also:
IReliableContainer.isGroupManager()

getGroupMemberIDs

ID[] getGroupMemberIDs()
(non-Javadoc)

See Also:
IReliableContainer.getGroupMemberIDs()

sendCreate

void sendCreate(ID toContainerID,
                ReplicaSharedObjectDescription sd)
                throws java.io.IOException
Send message to create a remote instance of an ISharedObject with the same ID as this instance. This method allows ISharedObject instances (with a reference to a valid ISharedObjectContext) to send messages to remote containers asking them to create an instance of a new ISharedObject. The given ReplicaSharedObjectDescription provides the specification of the new object.

Parameters:
toContainerID - the ID of the remote ISharedObjectContainer that is the target of the create request. If this parameter is null, the request is assumed to be made of all remote containers currently in the given group (excepting the local container).
sd - the ReplicaSharedObjectDescription describing the class, constructor and other properties to be associated with the new instance
Throws:
java.io.IOException - thrown if message cannot be sent by container

sendCreateResponse

void sendCreateResponse(ID toContainerID,
                        java.lang.Throwable throwable,
                        long identifier)
                        throws java.io.IOException
Send create response back to an ISharedObject with the same ID as this instance. This method allows ISharedObject instances (with a reference to a valid ISharedObjectContext) to send messages to remote containers asking them to deliver the create response status back to the ISharedObject.

Parameters:
toContainerID - the ID of the container that is to receive this response
throwable - a throwable associated with the creation. Null means that no exception occured
identifier - the identifier used in the original create message (in the shared object description)
Throws:
java.io.IOException - thrown if the create response cannot be sent

sendDispose

void sendDispose(ID toContainerID)
                 throws java.io.IOException
Send message to dispose of a remote instance of the ISharedObject with same ID as this instance. This method allows ISharedObject instances to control the destruction of remote replicas.

Parameters:
toContainerID - the ID of the remote ISharedObjectContainer that is the target of the dispose request. If this parameter is null, the request is assumed to be made of all remote containers currently in the given group (excepting the local container).
Throws:
java.io.IOException - thrown if message cannot be sent by container

sendMessage

void sendMessage(ID toContainerID,
                 java.lang.Object data)
                 throws java.io.IOException
Send arbitrary message to remote instance of the ISharedObject with same ID as this instance. This method allows ISharedObject instances to send arbitrary data to one or more remote replicas of this ISharedObject.

Parameters:
toContainerID - the ID of the remote ISharedObjectContainer that is the target container for the message request. If this parameter is null, the request is assumed to be made of all remote containers currently in the given group (excepting the local container).
data - arbitrary message object. The allowable types of this parameter are dependent upon the type of the underlying implementing container
Throws:
java.io.IOException - thrown if message cannot be sent by container, or if data cannot be serialized

getServiceAccess

IOSGIService getServiceAccess()
Get a reference to a proxy instance that allows the registration and access to local OSGI-platform-provided services. If this method returns null, then such services are not available.

Returns:
null if OSGI platform services cannot be accessed, a valid instance of the given interface if the context allows access to such services

getConnectNamespace

Namespace getConnectNamespace()
Get the Namespace instance that defines the ID type expected by the remote target container

Returns:
Namespace the namespace by the target for a call to connect(). Null if container namespace no longer available

getLocalContainerProperties

java.util.Map getLocalContainerProperties()
Get local container properties that it wishes to expose to shared object access

Returns:
Map of properties available to calling shared object. Map returned must not be null.