public abstract class SOContainer extends AbstractContainer implements ISharedObjectContainer
Modifier and Type | Field and Description |
---|---|
protected ISharedObjectContainerConfig |
config |
static java.lang.String |
DEFAULT_OBJECT_ARG_KEY |
static java.lang.String |
DEFAULT_OBJECT_ARGTYPES_KEY |
protected org.eclipse.ecf.provider.generic.SOContainerGMM |
groupManager |
protected boolean |
isClosing |
protected java.lang.ThreadGroup |
loadingThreadGroup |
protected ISharedObjectPolicy |
policy |
protected ISynchAsynchEventHandler |
receiver |
protected SOManager |
sharedObjectManager |
protected ISharedObjectMessageSerializer |
sharedObjectMessageSerializer |
protected java.lang.ThreadGroup |
sharedObjectThreadGroup |
Constructor and Description |
---|
SOContainer(ISharedObjectContainerConfig config) |
Modifier and Type | Method and Description |
---|---|
protected boolean |
addNewRemoteMember(ID memberID,
java.lang.Object data) |
protected ISharedObjectContainerTransaction |
addSharedObject0(ID id,
ISharedObject s,
java.util.Map props) |
protected void |
addSharedObjectAndWait(ID id,
ISharedObject s,
java.util.Map properties) |
protected ISharedObjectContainerTransaction |
addSharedObjectWrapper(SOWrapper wrapper) |
protected boolean |
addToLoading(org.eclipse.ecf.provider.generic.SOContainer.LoadingSharedObject lso) |
protected java.lang.Object |
checkRemoteCreate(ID fromID,
ID toID,
ReplicaSharedObjectDescription desc)
Check remote creation of shared objects.
|
abstract void |
connect(ID groupID,
IConnectContext connectContext)
Connect to a target remote process or process group.
|
protected java.util.Map |
createContainerPropertiesForSharedObject(ID sharedObjectID) |
protected SOConfig |
createRemoteSharedObjectConfig(ID fromID,
ReplicaSharedObjectDescription sd,
ISharedObject obj) |
protected SOContext |
createRemoteSharedObjectContext(SOConfig soconfig,
IQueueEnqueue queue) |
protected SOWrapper |
createRemoteSharedObjectWrapper(ID fromID,
ReplicaSharedObjectDescription sd,
ISharedObject s) |
protected SOConfig |
createSharedObjectConfig(ID id,
ISharedObject obj,
java.util.Map props) |
protected SOContext |
createSharedObjectContext(SOConfig soconfig,
IQueueEnqueue queue) |
protected SOWrapper |
createSharedObjectWrapper(ID id,
ISharedObject s,
java.util.Map props) |
protected void |
debug(java.lang.String msg) |
protected java.lang.Object |
defaultDeserializeSharedObjectMessage(byte[] bytes) |
protected byte[] |
defaultSerializeSharedObjectMessage(ID sharedObjectID,
java.lang.Object message) |
static ContainerMessage |
deserializeContainerMessage(byte[] bytes) |
protected java.lang.Object |
deserializeSharedObjectMessage(byte[] bytes) |
protected boolean |
destroySharedObject(ID sharedObjectID) |
abstract void |
disconnect()
Disconnect.
|
protected void |
disconnect(IConnection conn) |
void |
dispose()
Dispose this IContainer instance.
|
protected void |
fireDelegateContainerEvent(IContainerEvent containerEvent) |
protected void |
forward(ID fromID,
ID toID,
ContainerMessage data) |
protected abstract void |
forwardExcluding(ID from,
ID excluding,
ContainerMessage data) |
protected abstract void |
forwardToRemote(ID from,
ID to,
ContainerMessage data) |
java.lang.Object |
getAdapter(java.lang.Class adapter)
This specialization of IAdaptable.getAdapter() returns additional
services supported by this container.
|
protected java.lang.Object[] |
getArgsFromProperties(SharedObjectDescription sd) |
protected java.lang.String[] |
getArgTypesFromProperties(SharedObjectDescription sd) |
protected java.lang.ClassLoader |
getClassLoaderForContainer() |
protected java.lang.ClassLoader |
getClassLoaderForSharedObject(SharedObjectDescription sd) |
ISharedObjectContainerConfig |
getConfig() |
abstract ID |
getConnectedID()
Get the target ID that this container instance has connected to.
|
Namespace |
getConnectNamespace()
Get the Namespace for creating a targetID suitable for use as the first
parameter in subsequent calls to
IContainer.connect(ID, IConnectContext) . |
ID[] |
getGroupMemberIDs()
Get the current membership of the joined group.
|
protected java.lang.Object |
getGroupMembershipLock() |
ID |
getID()
Return the ID for this 'identifiable' object.
|
protected abstract ID |
getIDForConnection(IAsynchConnection connection) |
protected int |
getMaxGroupMembers() |
ISynchAsynchEventHandler |
getMessageReceiver() |
protected java.lang.Thread |
getNewSharedObjectThread(ID sharedObjectID,
java.lang.Runnable runnable) |
protected long |
getNextSequenceNumber() |
protected ID[] |
getOtherMemberIDs() |
protected ISynchAsynchEventHandler |
getReceiver() |
protected ISharedObject |
getSharedObject(ID id) |
protected ID[] |
getSharedObjectIDs() |
ISharedObjectManager |
getSharedObjectManager()
Get SharedObjectManager for this container
|
protected ISharedObjectMessageSerializer |
getSharedObjectMessageSerializer() |
protected SOWrapper |
getSharedObjectWrapper(ID id) |
protected void |
handleAsynchIOException(java.io.IOException except,
AsynchEvent e) |
protected void |
handleCreateMessage(ContainerMessage mess) |
protected void |
handleCreateResponseMessage(ContainerMessage mess) |
protected void |
handleLeave(ID leftID,
IConnection conn) |
protected abstract void |
handleLeaveGroupMessage(ContainerMessage mess) |
protected void |
handleSharedObjectDisposeMessage(ContainerMessage mess) |
protected void |
handleSharedObjectMessage(ContainerMessage mess) |
protected void |
handleUndeliveredSharedObjectMessage(ContainerMessage.SharedObjectMessage resp) |
protected void |
handleUnidentifiedMessage(ContainerMessage mess) |
protected abstract void |
handleViewChangeMessage(ContainerMessage mess) |
protected boolean |
isClosing() |
abstract boolean |
isGroupManager() |
protected ISharedObject |
load(SharedObjectDescription sd) |
protected void |
moveFromLoadingToActive(SOWrapper wrap) |
protected void |
notifySharedObjectActivated(ID sharedObjectID) |
protected void |
notifySharedObjectDeactivated(ID sharedObjectID) |
protected static void |
printToSystemError(java.lang.String message,
java.lang.Throwable t) |
protected void |
processAsynch(AsynchEvent event) |
protected abstract void |
processDisconnect(DisconnectEvent event) |
protected java.io.Serializable |
processSynch(SynchEvent e) |
protected abstract void |
queueContainerMessage(ContainerMessage mess) |
protected void |
removeFromLoading(ID id) |
protected boolean |
removeRemoteMember(ID remoteMember) |
protected ISharedObject |
removeSharedObject(ID id) |
protected void |
sendCreate(ID sharedObjectID,
ID toContainerID,
SharedObjectDescription sd) |
protected void |
sendCreateResponse(ID homeID,
ID sharedObjectID,
java.lang.Throwable t,
long identifier) |
protected void |
sendCreateResponseSharedObjectMessage(ID toContainerID,
ID fromSharedObject,
java.lang.Throwable t,
long ident) |
protected ID[] |
sendCreateSharedObjectMessage(ID toContainerID,
SharedObjectDescription sd) |
protected void |
sendDispose(ID toContainerID,
ID sharedObjectID) |
protected void |
sendDisposeSharedObjectMessage(ID toContainerID,
ID fromSharedObject) |
protected void |
sendMessage(ContainerMessage data) |
protected void |
sendMessage(ID toContainerID,
ID sharedObjectID,
java.lang.Object message) |
protected void |
sendSharedObjectMessage(ID toContainerID,
ID fromSharedObject,
java.io.Serializable data) |
static byte[] |
serialize(java.io.Serializable obj) |
protected byte[] |
serializeSharedObjectMessage(ID sharedObjectID,
java.lang.Object message) |
protected void |
setMaxGroupMembers(int max) |
protected void |
setRemoteAddPolicy(ISharedObjectPolicy policy) |
void |
setSharedObjectMessageSerializer(ISharedObjectMessageSerializer serializer)
Set the shared object message serializer.
|
protected void |
traceStack(java.lang.String msg,
java.lang.Throwable e) |
protected ContainerMessage |
validateContainerMessage(java.lang.Object mess) |
protected boolean |
verifySharedObjectMessageTarget(ID containerID) |
protected boolean |
verifyToIDForSharedObjectMessage(ID toID) |
addListener, fireContainerEvent, getPasswordFromConnectContext, removeListener
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
addListener, removeListener
public static final java.lang.String DEFAULT_OBJECT_ARG_KEY
public static final java.lang.String DEFAULT_OBJECT_ARGTYPES_KEY
protected ISharedObjectContainerConfig config
protected org.eclipse.ecf.provider.generic.SOContainerGMM groupManager
protected boolean isClosing
protected java.lang.ThreadGroup loadingThreadGroup
protected SOManager sharedObjectManager
protected ISharedObjectPolicy policy
protected java.lang.ThreadGroup sharedObjectThreadGroup
protected ISharedObjectMessageSerializer sharedObjectMessageSerializer
protected ISynchAsynchEventHandler receiver
public SOContainer(ISharedObjectContainerConfig config)
public void setSharedObjectMessageSerializer(ISharedObjectMessageSerializer serializer)
ISharedObjectContainer
Set the shared object message serializer. The serializer should not be null
.
Note that users of this method should guarantee that their are not pending messages to be sent/received...typically by only calling this method prior to connecting/being connected to from remote containers.
Note also that the serializer must perform well when it's methods are called, to prevent negatively impacting overall container messaging performance.
setSharedObjectMessageSerializer
in interface ISharedObjectContainer
protected ISharedObjectMessageSerializer getSharedObjectMessageSerializer()
public ID getID()
IIdentifiable
null
.getID
in interface IIdentifiable
null
.public abstract void connect(ID groupID, IConnectContext connectContext) throws ContainerConnectException
IContainer
connect
in interface IContainer
groupID
- the ID of the remote server or group to connect to. See
IContainer.getConnectNamespace()
for a explanation of the
constraints upon this parameter.connectContext
- any required context to allow this container to authenticate.
May be null
if underlying provider does not
have any authentication requirements for connection.ContainerConnectException
- thrown if communication cannot be established with remote
service. Causes can include network connection failure,
authentication failure, server error, or if container is
already connected.public abstract ID getConnectedID()
IContainer
getConnectedID
in interface IContainer
null
if container not connected.public abstract void disconnect()
IContainer
null
.disconnect
in interface IContainer
public Namespace getConnectNamespace()
IContainer
IContainer.connect(ID, IConnectContext)
.
If this method returns null
, then it means that
null
is expected as a valid parameter in subsequent calls
to IContainer.connect(ID, IConnectContext)
. If this method returns a non-null
Namespace, then the targetID
parameter in
IContainer.connect(ID, IConnectContext)
must be non-null
instance created of the returned Namespace.getConnectNamespace
in interface IContainer
IContainer.connect(ID, IConnectContext)
. If null
,
then the targetID
instances passed to
IContainer.connect(ID, IConnectContext)
may be null
.
If not null
, then targetID
instances passed to IContainer.connect(ID, IConnectContext)
must be
instances of the returned Namespace.public void dispose()
IContainer
dispose
in interface IContainer
dispose
in class AbstractContainer
public java.lang.Object getAdapter(java.lang.Class adapter)
IContainer
IContainer
should return them using this method. It is recommended that clients use
this method rather than instanceof checks and downcasts to find out about
the capabilities of a specific container.
Typically, after obtaining an IContainer, a client would use this method as a means to obtain a more meaningful interface to the container. This interface may or may not extend IContainer. For example, a client could use the following code to obtain an instance of ISharedObjectContainer:
IContainer newContainer = ContainerFactory.createContainer(type); ISharedObjectContainer soContainer = (ISharedObjectContainer) newContainer .getAdapter(ISharedObjectContainer.class); if (soContainer == null) throw new ContainerCreateException(message);
Implementations of this method should delegate to
IAdapterManager.loadAdapter()
if the service
cannot be provided directly to ensure extensibility by third-party
plug-ins.
getAdapter
in interface org.eclipse.core.runtime.IAdaptable
getAdapter
in interface IContainer
getAdapter
in class AbstractContainer
adapter
- the service type to look upnull
if this container does not support the given
servicepublic ISharedObjectManager getSharedObjectManager()
ISharedObjectContainer
getSharedObjectManager
in interface ISharedObjectContainer
public ID[] getGroupMemberIDs()
IReliableContainer
getGroupMemberIDs
in interface IReliableContainer
public ISharedObjectContainerConfig getConfig()
public abstract boolean isGroupManager()
isGroupManager
in interface IReliableContainer
protected void setRemoteAddPolicy(ISharedObjectPolicy policy)
protected boolean addNewRemoteMember(ID memberID, java.lang.Object data)
protected ISharedObjectContainerTransaction addSharedObject0(ID id, ISharedObject s, java.util.Map props) throws java.lang.Exception
java.lang.Exception
protected void addSharedObjectAndWait(ID id, ISharedObject s, java.util.Map properties) throws java.lang.Exception
java.lang.Exception
protected ISharedObjectContainerTransaction addSharedObjectWrapper(SOWrapper wrapper) throws java.lang.Exception
java.lang.Exception
protected boolean addToLoading(org.eclipse.ecf.provider.generic.SOContainer.LoadingSharedObject lso)
protected java.lang.Object checkRemoteCreate(ID fromID, ID toID, ReplicaSharedObjectDescription desc) throws java.lang.Exception
fromID
- the ID of the container sending us this create requesttoID
- the ID (or null) of the container intended to receive this
requestdesc
- the SharedObjectDescription that describes the shared object
to be createdjava.lang.Exception
- may throw any Exception to communicate back (via
sendCreateResponse) to the sender that the creation has
failedprotected void debug(java.lang.String msg)
protected void traceStack(java.lang.String msg, java.lang.Throwable e)
protected boolean destroySharedObject(ID sharedObjectID)
protected final void forward(ID fromID, ID toID, ContainerMessage data) throws java.io.IOException
java.io.IOException
protected abstract void forwardExcluding(ID from, ID excluding, ContainerMessage data) throws java.io.IOException
java.io.IOException
protected abstract void forwardToRemote(ID from, ID to, ContainerMessage data) throws java.io.IOException
java.io.IOException
protected java.lang.Object[] getArgsFromProperties(SharedObjectDescription sd)
sd
- shared object descriptionprotected java.lang.String[] getArgTypesFromProperties(SharedObjectDescription sd)
sd
- shared object descriptionpublic static byte[] serialize(java.io.Serializable obj) throws java.io.IOException
java.io.IOException
protected java.lang.ClassLoader getClassLoaderForContainer()
protected java.lang.ClassLoader getClassLoaderForSharedObject(SharedObjectDescription sd)
sd
- shared object descriptionprotected java.lang.Object getGroupMembershipLock()
protected int getMaxGroupMembers()
protected java.lang.Thread getNewSharedObjectThread(ID sharedObjectID, java.lang.Runnable runnable)
protected long getNextSequenceNumber()
public static ContainerMessage deserializeContainerMessage(byte[] bytes) throws java.io.IOException
java.io.IOException
protected static void printToSystemError(java.lang.String message, java.lang.Throwable t)
message
- messaget
- exception to print to system errorprotected ID[] getOtherMemberIDs()
protected ISynchAsynchEventHandler getReceiver()
public ISynchAsynchEventHandler getMessageReceiver()
protected ISharedObject getSharedObject(ID id)
protected ID[] getSharedObjectIDs()
protected void handleAsynchIOException(java.io.IOException except, AsynchEvent e)
protected void handleCreateMessage(ContainerMessage mess) throws java.io.IOException
java.io.IOException
protected void handleCreateResponseMessage(ContainerMessage mess) throws java.io.IOException
java.io.IOException
protected abstract void handleLeaveGroupMessage(ContainerMessage mess)
mess
- leave group messageprotected boolean verifySharedObjectMessageTarget(ID containerID)
containerID
- containerIDprotected void handleSharedObjectDisposeMessage(ContainerMessage mess) throws java.io.IOException
java.io.IOException
protected boolean verifyToIDForSharedObjectMessage(ID toID)
protected void handleSharedObjectMessage(ContainerMessage mess) throws java.io.IOException
java.io.IOException
protected void handleUndeliveredSharedObjectMessage(ContainerMessage.SharedObjectMessage resp)
resp
- response messageprotected void handleUnidentifiedMessage(ContainerMessage mess) throws java.io.IOException
mess
- messagejava.io.IOException
- not thrown by this implementation.protected abstract void handleViewChangeMessage(ContainerMessage mess) throws java.io.IOException
java.io.IOException
protected boolean isClosing()
protected void disconnect(IConnection conn)
protected ISharedObject load(SharedObjectDescription sd) throws java.lang.Exception
java.lang.Exception
protected SOConfig createSharedObjectConfig(ID id, ISharedObject obj, java.util.Map props) throws ECFException
id
- idobj
- objprops
- propsnull
instance.ECFException
- not thrown by this implementation.protected SOConfig createRemoteSharedObjectConfig(ID fromID, ReplicaSharedObjectDescription sd, ISharedObject obj)
protected SOContext createSharedObjectContext(SOConfig soconfig, IQueueEnqueue queue)
protected SOContext createRemoteSharedObjectContext(SOConfig soconfig, IQueueEnqueue queue)
protected SOWrapper createSharedObjectWrapper(ID id, ISharedObject s, java.util.Map props) throws ECFException
ECFException
protected SOWrapper createRemoteSharedObjectWrapper(ID fromID, ReplicaSharedObjectDescription sd, ISharedObject s)
protected void handleLeave(ID leftID, IConnection conn)
protected void moveFromLoadingToActive(SOWrapper wrap)
protected void notifySharedObjectActivated(ID sharedObjectID)
protected void notifySharedObjectDeactivated(ID sharedObjectID)
protected ContainerMessage validateContainerMessage(java.lang.Object mess)
protected void processAsynch(AsynchEvent event) throws java.io.IOException
event
- eventjava.io.IOException
- not thrown by this implementation.protected abstract ID getIDForConnection(IAsynchConnection connection)
protected abstract void processDisconnect(DisconnectEvent event)
protected java.io.Serializable processSynch(SynchEvent e) throws java.io.IOException
java.io.IOException
protected abstract void queueContainerMessage(ContainerMessage mess) throws java.io.IOException
java.io.IOException
protected void removeFromLoading(ID id)
protected boolean removeRemoteMember(ID remoteMember)
protected ISharedObject removeSharedObject(ID id)
protected void sendCreate(ID sharedObjectID, ID toContainerID, SharedObjectDescription sd) throws java.io.IOException
java.io.IOException
protected void sendCreateResponse(ID homeID, ID sharedObjectID, java.lang.Throwable t, long identifier) throws java.io.IOException
java.io.IOException
protected void sendCreateResponseSharedObjectMessage(ID toContainerID, ID fromSharedObject, java.lang.Throwable t, long ident) throws java.io.IOException
java.io.IOException
protected ID[] sendCreateSharedObjectMessage(ID toContainerID, SharedObjectDescription sd) throws java.io.IOException
java.io.IOException
protected java.util.Map createContainerPropertiesForSharedObject(ID sharedObjectID)
protected void sendDispose(ID toContainerID, ID sharedObjectID) throws java.io.IOException
java.io.IOException
protected void sendDisposeSharedObjectMessage(ID toContainerID, ID fromSharedObject) throws java.io.IOException
java.io.IOException
protected void sendMessage(ContainerMessage data) throws java.io.IOException
java.io.IOException
protected byte[] serializeSharedObjectMessage(ID sharedObjectID, java.lang.Object message) throws java.io.IOException
java.io.IOException
protected byte[] defaultSerializeSharedObjectMessage(ID sharedObjectID, java.lang.Object message) throws java.io.IOException
sharedObjectID
- shared object IDmessage
- messagejava.io.IOException
- if some problem serializingprotected java.lang.Object defaultDeserializeSharedObjectMessage(byte[] bytes) throws java.io.IOException, java.lang.ClassNotFoundException
bytes
- data to deserializedjava.io.IOException
- if deserialization cannot be donejava.lang.ClassNotFoundException
- if deserialization cannot be doneprotected java.lang.Object deserializeSharedObjectMessage(byte[] bytes) throws java.io.IOException, java.lang.ClassNotFoundException
java.io.IOException
java.lang.ClassNotFoundException
protected void sendMessage(ID toContainerID, ID sharedObjectID, java.lang.Object message) throws java.io.IOException
java.io.IOException
protected void sendSharedObjectMessage(ID toContainerID, ID fromSharedObject, java.io.Serializable data) throws java.io.IOException
java.io.IOException
protected void setMaxGroupMembers(int max)
protected void fireDelegateContainerEvent(IContainerEvent containerEvent)
containerEvent
- container event