public abstract class SOContainer extends AbstractContainer implements ISharedObjectContainer
| Modifier and Type | Field and Description |
|---|---|
protected ISharedObjectContainerConfig |
config |
static String |
DEFAULT_OBJECT_ARG_KEY |
static String |
DEFAULT_OBJECT_ARGTYPES_KEY |
protected org.eclipse.ecf.provider.generic.SOContainerGMM |
groupManager |
protected boolean |
isClosing |
protected ThreadGroup |
loadingThreadGroup |
protected ISharedObjectPolicy |
policy |
protected ISynchAsynchEventHandler |
receiver |
protected SOManager |
sharedObjectManager |
protected ISharedObjectMessageSerializer |
sharedObjectMessageSerializer |
protected ThreadGroup |
sharedObjectThreadGroup |
| Constructor and Description |
|---|
SOContainer(ISharedObjectContainerConfig config) |
addListener, fireContainerEvent, getPasswordFromConnectContext, removeListenerclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitaddListener, removeListenerpublic static final String DEFAULT_OBJECT_ARG_KEY
public static final String DEFAULT_OBJECT_ARGTYPES_KEY
protected ISharedObjectContainerConfig config
protected org.eclipse.ecf.provider.generic.SOContainerGMM groupManager
protected boolean isClosing
protected ThreadGroup loadingThreadGroup
protected SOManager sharedObjectManager
protected ISharedObjectPolicy policy
protected 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 ISharedObjectContainerprotected ISharedObjectMessageSerializer getSharedObjectMessageSerializer()
public ID getID()
IIdentifiablenull.getID in interface IIdentifiablenull.public abstract void connect(ID groupID, IConnectContext connectContext) throws ContainerConnectException
IContainerconnect in interface IContainergroupID - 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()
IContainergetConnectedID in interface IContainernull
if container not connected.public abstract void disconnect()
IContainernull.disconnect in interface IContainerpublic Namespace getConnectNamespace()
IContainerIContainer.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 IContainerIContainer.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()
IContainerdispose in interface IContainerdispose in class AbstractContainerpublic Object getAdapter(Class adapter)
IContainerIContainer
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.IAdaptablegetAdapter in interface IContainergetAdapter in class AbstractContaineradapter - the service type to look upnull if this container does not support the given
servicepublic ISharedObjectManager getSharedObjectManager()
ISharedObjectContainergetSharedObjectManager in interface ISharedObjectContainerpublic ID[] getGroupMemberIDs()
IReliableContainergetGroupMemberIDs in interface IReliableContainerpublic ISharedObjectContainerConfig getConfig()
public abstract boolean isGroupManager()
isGroupManager in interface IReliableContainerprotected void setRemoteAddPolicy(ISharedObjectPolicy policy)
protected ISharedObjectContainerTransaction addSharedObject0(ID id, ISharedObject s, Map props) throws Exception
Exceptionprotected void addSharedObjectAndWait(ID id, ISharedObject s, Map properties) throws Exception
Exceptionprotected ISharedObjectContainerTransaction addSharedObjectWrapper(SOWrapper wrapper) throws Exception
Exceptionprotected boolean addToLoading(org.eclipse.ecf.provider.generic.SOContainer.LoadingSharedObject lso)
protected Object checkRemoteCreate(ID fromID, ID toID, ReplicaSharedObjectDescription desc) throws 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 createdException - may throw any Exception to communicate back (via
sendCreateResponse) to the sender that the creation has
failedprotected void debug(String msg)
protected boolean destroySharedObject(ID sharedObjectID)
protected final void forward(ID fromID, ID toID, ContainerMessage data) throws IOException
IOExceptionprotected abstract void forwardExcluding(ID from, ID excluding, ContainerMessage data) throws IOException
IOExceptionprotected abstract void forwardToRemote(ID from, ID to, ContainerMessage data) throws IOException
IOExceptionprotected Object[] getArgsFromProperties(SharedObjectDescription sd)
sd - shared object descriptionprotected String[] getArgTypesFromProperties(SharedObjectDescription sd)
sd - shared object descriptionpublic static byte[] serialize(Serializable obj) throws IOException
IOExceptionprotected ClassLoader getClassLoaderForContainer()
protected ClassLoader getClassLoaderForSharedObject(SharedObjectDescription sd)
sd - shared object descriptionprotected Object getGroupMembershipLock()
protected int getMaxGroupMembers()
protected Thread getNewSharedObjectThread(ID sharedObjectID, Runnable runnable)
protected long getNextSequenceNumber()
public static ContainerMessage deserializeContainerMessage(byte[] bytes) throws IOException
IOExceptionprotected static void printToSystemError(String message, 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(IOException except, AsynchEvent e)
protected void handleCreateMessage(ContainerMessage mess) throws IOException
IOExceptionprotected void handleCreateResponseMessage(ContainerMessage mess) throws IOException
IOExceptionprotected abstract void handleLeaveGroupMessage(ContainerMessage mess)
mess - leave group messageprotected boolean verifySharedObjectMessageTarget(ID containerID)
containerID - containerIDprotected void handleSharedObjectDisposeMessage(ContainerMessage mess) throws IOException
IOExceptionprotected boolean verifyToIDForSharedObjectMessage(ID toID)
protected void handleSharedObjectMessage(ContainerMessage mess) throws IOException
IOExceptionprotected void handleUndeliveredSharedObjectMessage(ContainerMessage.SharedObjectMessage resp)
resp - response messageprotected void handleUnidentifiedMessage(ContainerMessage mess) throws IOException
mess - messageIOException - not thrown by this implementation.protected abstract void handleViewChangeMessage(ContainerMessage mess) throws IOException
IOExceptionprotected boolean isClosing()
protected void disconnect(IConnection conn)
protected ISharedObject load(SharedObjectDescription sd) throws Exception
Exceptionprotected SOConfig createSharedObjectConfig(ID id, ISharedObject obj, 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, Map props) throws ECFException
ECFExceptionprotected 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(Object mess)
protected void processAsynch(AsynchEvent event) throws IOException
event - eventIOException - not thrown by this implementation.protected abstract ID getIDForConnection(IAsynchConnection connection)
protected abstract void processDisconnect(DisconnectEvent event)
protected Serializable processSynch(SynchEvent e) throws IOException
IOExceptionprotected abstract void queueContainerMessage(ContainerMessage mess) throws IOException
IOExceptionprotected void removeFromLoading(ID id)
protected boolean removeRemoteMember(ID remoteMember)
protected ISharedObject removeSharedObject(ID id)
protected void sendCreate(ID sharedObjectID, ID toContainerID, SharedObjectDescription sd) throws IOException
IOExceptionprotected void sendCreateResponse(ID homeID, ID sharedObjectID, Throwable t, long identifier) throws IOException
IOExceptionprotected void sendCreateResponseSharedObjectMessage(ID toContainerID, ID fromSharedObject, Throwable t, long ident) throws IOException
IOExceptionprotected ID[] sendCreateSharedObjectMessage(ID toContainerID, SharedObjectDescription sd) throws IOException
IOExceptionprotected Map createContainerPropertiesForSharedObject(ID sharedObjectID)
protected void sendDispose(ID toContainerID, ID sharedObjectID) throws IOException
IOExceptionprotected void sendDisposeSharedObjectMessage(ID toContainerID, ID fromSharedObject) throws IOException
IOExceptionprotected void sendMessage(ContainerMessage data) throws IOException
IOExceptionprotected byte[] serializeSharedObjectMessage(ID sharedObjectID, Object message) throws IOException
IOExceptionprotected byte[] defaultSerializeSharedObjectMessage(ID sharedObjectID, Object message) throws IOException
sharedObjectID - shared object IDmessage - messageIOException - if some problem serializingprotected Object defaultDeserializeSharedObjectMessage(byte[] bytes) throws IOException, ClassNotFoundException
bytes - data to deserializedIOException - if deserialization cannot be doneClassNotFoundException - if deserialization cannot be doneprotected Object deserializeSharedObjectMessage(byte[] bytes) throws IOException, ClassNotFoundException
IOExceptionClassNotFoundExceptionprotected void sendMessage(ID toContainerID, ID sharedObjectID, Object message) throws IOException
IOExceptionprotected void sendSharedObjectMessage(ID toContainerID, ID fromSharedObject, Serializable data) throws IOException
IOExceptionprotected void setMaxGroupMembers(int max)
protected void fireDelegateContainerEvent(IContainerEvent containerEvent)
containerEvent - container eventCopyright © 2004–2020 Eclipse Foundation. All rights reserved.