Class SOContainer

    • Method Detail

      • setSharedObjectMessageSerializer

        public void setSharedObjectMessageSerializer​(ISharedObjectMessageSerializer serializer)
        Description copied from interface: 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.

        Specified by:
        setSharedObjectMessageSerializer in interface ISharedObjectContainer
        Since:
        2.0
      • getSharedObjectMessageSerializer

        protected ISharedObjectMessageSerializer getSharedObjectMessageSerializer()
        Returns:
        ISharedObjectMessageSerializer the shared object message serializer
        Since:
        2.0
      • getID

        public ID getID()
        Description copied from interface: IIdentifiable
        Return the ID for this 'identifiable' object. The returned ID should be unique within its namespace. May return null.
        Specified by:
        getID in interface IIdentifiable
        Returns:
        the ID for this identifiable object. May return null.
      • connect

        public abstract void connect​(ID groupID,
                                     IConnectContext connectContext)
                              throws ContainerConnectException
        Description copied from interface: IContainer
        Connect to a target remote process or process group. The target identified by the first parameter (targetID) is connected the implementation class. If authentication information is required, the required information is given via via the second parameter (connectContext). Callers note that depending upon the provider implementation this method may block. It is suggested that callers use a separate thread to call this method. This method provides an implementation independent way for container implementations to connect, authenticate, and communicate with a remote service or group of services. Providers are responsible for implementing this operation in a way appropriate to the given remote service (or group) via expected protocol.
        Specified by:
        connect in interface IContainer
        Parameters:
        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.
        Throws:
        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.
      • getConnectedID

        public abstract ID getConnectedID()
        Description copied from interface: IContainer
        Get the target ID that this container instance has connected to. Returns null if not connected.
        Specified by:
        getConnectedID in interface IContainer
        Returns:
        ID of the target we are connected to. Returns null if container not connected.
      • disconnect

        public abstract void disconnect()
        Description copied from interface: IContainer
        Disconnect. This operation will disconnect the local container instance from any previously joined target or group. Subsequent calls to getConnectedID() will return null.
        Specified by:
        disconnect in interface IContainer
      • dispose

        public void dispose()
        Description copied from interface: IContainer
        Dispose this IContainer instance. The container instance will be made inactive after the completion of this method and will be unavailable for subsequent usage.
        Specified by:
        dispose in interface IContainer
        Overrides:
        dispose in class AbstractContainer
      • getAdapter

        public Object getAdapter​(Class adapter)
        Description copied from interface: IContainer
        This specialization of IAdaptable.getAdapter() returns additional services supported by this container. A container that supports additional services over and above the methods on 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.

        Specified by:
        getAdapter in interface org.eclipse.core.runtime.IAdaptable
        Specified by:
        getAdapter in interface IContainer
        Overrides:
        getAdapter in class AbstractContainer
        Parameters:
        adapter - the service type to look up
        Returns:
        the service instance castable to the given class, or null if this container does not support the given service
      • getGroupMemberIDs

        public ID[] getGroupMemberIDs()
        Description copied from interface: IReliableContainer
        Get the current membership of the joined group. This method will accurately report the current group membership of the connected group.
        Specified by:
        getGroupMemberIDs in interface IReliableContainer
        Returns:
        ID[] the IDs of the current group membership
      • isGroupManager

        public abstract boolean isGroupManager()
        Specified by:
        isGroupManager in interface IReliableContainer
        Returns:
        true if this IReliableContainer instance is in the 'manager' role for the group, false otherwise.
      • addNewRemoteMember

        protected boolean addNewRemoteMember​(ID memberID,
                                             Object data)
      • addToLoading

        protected boolean addToLoading​(org.eclipse.ecf.provider.generic.SOContainer.LoadingSharedObject lso)
      • checkRemoteCreate

        protected Object checkRemoteCreate​(ID fromID,
                                           ID toID,
                                           ReplicaSharedObjectDescription desc)
                                    throws Exception
        Check remote creation of shared objects. This method is called by the remote shared object creation message handler, to verify that the shared object from container 'fromID' to container 'toID' with description 'desc' is to be allowed to be created within the current container. If this method throws, a failure (and exception will be sent back to caller If this method returns null, the create message is ignored. If this method returns a non-null object, the creation is allowed to proceed. The default implementation is to return a non-null object
        Parameters:
        fromID - the ID of the container sending us this create request
        toID - the ID (or null) of the container intended to receive this request
        desc - the SharedObjectDescription that describes the shared object to be created
        Returns:
        Object null if the create message is to be ignored, non-null if the creation should continue
        Throws:
        Exception - may throw any Exception to communicate back (via sendCreateResponse) to the sender that the creation has failed
      • debug

        protected void debug​(String msg)
      • destroySharedObject

        protected boolean destroySharedObject​(ID sharedObjectID)
      • getArgsFromProperties

        protected Object[] getArgsFromProperties​(SharedObjectDescription sd)
        Parameters:
        sd - shared object description
        Returns:
        Object[] arguments from the shared object description properties
      • getArgTypesFromProperties

        protected String[] getArgTypesFromProperties​(SharedObjectDescription sd)
        Parameters:
        sd - shared object description
        Returns:
        String[] arguments types from shared object description properties
      • getClassLoaderForContainer

        protected ClassLoader getClassLoaderForContainer()
      • getClassLoaderForSharedObject

        protected ClassLoader getClassLoaderForSharedObject​(SharedObjectDescription sd)
        Parameters:
        sd - shared object description
        Returns:
        ClassLoader classloader to used for given shared object description
      • getGroupMembershipLock

        protected Object getGroupMembershipLock()
      • getMaxGroupMembers

        protected int getMaxGroupMembers()
      • getNewSharedObjectThread

        protected Thread getNewSharedObjectThread​(ID sharedObjectID,
                                                  Runnable runnable)
      • getNextSequenceNumber

        protected long getNextSequenceNumber()
      • printToSystemError

        protected static void printToSystemError​(String message,
                                                 Throwable t)
        Parameters:
        message - message
        t - exception to print to system error
        Since:
        2.0
      • getOtherMemberIDs

        protected ID[] getOtherMemberIDs()
      • getMessageReceiver

        public ISynchAsynchEventHandler getMessageReceiver()
        Returns:
        ISynchAsyncEventHandler message receiver
        Since:
        4.7
      • getSharedObjectIDs

        protected ID[] getSharedObjectIDs()
      • getSharedObjectWrapper

        protected SOWrapper getSharedObjectWrapper​(ID id)
      • handleLeaveGroupMessage

        protected abstract void handleLeaveGroupMessage​(ContainerMessage mess)
        Parameters:
        mess - leave group message
      • verifySharedObjectMessageTarget

        protected boolean verifySharedObjectMessageTarget​(ID containerID)
        Parameters:
        containerID - containerID
        Returns:
        boolean true if verified, false otherwise
        Since:
        4.0
      • verifyToIDForSharedObjectMessage

        protected boolean verifyToIDForSharedObjectMessage​(ID toID)
      • handleUndeliveredSharedObjectMessage

        protected void handleUndeliveredSharedObjectMessage​(ContainerMessage.SharedObjectMessage resp)
        Parameters:
        resp - response message
        Since:
        4.0
      • handleUnidentifiedMessage

        protected void handleUnidentifiedMessage​(ContainerMessage mess)
                                          throws IOException
        Parameters:
        mess - message
        Throws:
        IOException - not thrown by this implementation.
      • isClosing

        protected boolean isClosing()
      • disconnect

        protected void disconnect​(IConnection conn)
      • createSharedObjectConfig

        protected SOConfig createSharedObjectConfig​(ID id,
                                                    ISharedObject obj,
                                                    Map props)
                                             throws ECFException
        Parameters:
        id - id
        obj - obj
        props - props
        Returns:
        SOConfig a non-null instance.
        Throws:
        ECFException - not thrown by this implementation.
      • handleLeave

        protected void handleLeave​(ID leftID,
                                   IConnection conn)
      • moveFromLoadingToActive

        protected void moveFromLoadingToActive​(SOWrapper wrap)
      • notifySharedObjectActivated

        protected void notifySharedObjectActivated​(ID sharedObjectID)
      • notifySharedObjectDeactivated

        protected void notifySharedObjectDeactivated​(ID sharedObjectID)
      • processAsynch

        protected void processAsynch​(AsynchEvent event)
                              throws IOException
        Parameters:
        event - event
        Throws:
        IOException - not thrown by this implementation.
      • getIDForConnection

        protected abstract ID getIDForConnection​(IAsynchConnection connection)
      • processDisconnect

        protected abstract void processDisconnect​(DisconnectEvent event)
      • removeFromLoading

        protected void removeFromLoading​(ID id)
      • removeRemoteMember

        protected boolean removeRemoteMember​(ID remoteMember)
      • removeSharedObject

        protected ISharedObject removeSharedObject​(ID id)
      • sendCreateResponseSharedObjectMessage

        protected void sendCreateResponseSharedObjectMessage​(ID toContainerID,
                                                             ID fromSharedObject,
                                                             Throwable t,
                                                             long ident)
                                                      throws IOException
        Throws:
        IOException
      • createContainerPropertiesForSharedObject

        protected Map createContainerPropertiesForSharedObject​(ID sharedObjectID)
      • sendDisposeSharedObjectMessage

        protected void sendDisposeSharedObjectMessage​(ID toContainerID,
                                                      ID fromSharedObject)
                                               throws IOException
        Throws:
        IOException
      • serializeSharedObjectMessage

        protected byte[] serializeSharedObjectMessage​(ID sharedObjectID,
                                                      Object message)
                                               throws IOException
        Throws:
        IOException
      • defaultSerializeSharedObjectMessage

        protected byte[] defaultSerializeSharedObjectMessage​(ID sharedObjectID,
                                                             Object message)
                                                      throws IOException
        Parameters:
        sharedObjectID - shared object ID
        message - message
        Returns:
        byte[] serialized message
        Throws:
        IOException - if some problem serializing
        Since:
        2.0
      • defaultDeserializeSharedObjectMessage

        protected Object defaultDeserializeSharedObjectMessage​(byte[] bytes)
                                                        throws IOException,
                                                               ClassNotFoundException
        Parameters:
        bytes - data to deserialized
        Returns:
        Object the deserialized shared object message
        Throws:
        IOException - if deserialization cannot be done
        ClassNotFoundException - if deserialization cannot be done
        Since:
        2.0
      • setMaxGroupMembers

        protected void setMaxGroupMembers​(int max)
      • fireDelegateContainerEvent

        protected void fireDelegateContainerEvent​(IContainerEvent containerEvent)
        Parameters:
        containerEvent - container event