Class RegistrySharedObject

    • Field Detail

      • ADD_REGISTRATION_REQUEST_TIMEOUT

        protected static final int ADD_REGISTRATION_REQUEST_TIMEOUT
        Since:
        3.3
      • PROPAGATE_RESPONSE_ERROR

        protected static final boolean PROPAGATE_RESPONSE_ERROR
        Since:
        4.2
      • remoteRegistrys

        protected final Map remoteRegistrys
        map of registry impls for remote registrys key: ID (identifier of remote container), value: RemoteServiceRegistryImpl (copy of remote service registry for remote container
      • serviceListeners

        protected final List serviceListeners
        List of remote service listeners (added to/removed from by addRemoteServiceListener/removeRemoteServiceListener
      • addRegistrationRequests

        protected Map addRegistrationRequests
        Map of add registration requests. key: Integer (unique Request id), value: AddRegistrationRequest
      • addRegistrationRequestTimeout

        protected int addRegistrationRequestTimeout
        Add registration request default timeout
        Since:
        3.0
      • requests

        protected List requests
        List of invocation requests...instances of Request
      • connectContext

        protected IConnectContext connectContext
        Connect context to be used for connect.
        Since:
        3.0
      • rsConnectLock

        protected final Object rsConnectLock
        Since:
        3.3
      • rsConnected

        protected boolean rsConnected
        Whether or not we are connected
        Since:
        3.3
      • rsConnectTimeout

        protected int rsConnectTimeout
        Add registration request default timeout.
        Since:
        3.3
      • registryUpdateRequestTimeout

        protected long registryUpdateRequestTimeout
        Since:
        3.4
    • Constructor Detail

      • RegistrySharedObject

        public RegistrySharedObject()
    • Method Detail

      • getRemoteServiceReferences

        public IRemoteServiceReference[] getRemoteServiceReferences​(ID target,
                                                                    ID[] idFilter,
                                                                    String clazz,
                                                                    String filter)
                                                             throws InvalidSyntaxException,
                                                                    ContainerConnectException
        Description copied from interface: IRemoteServiceContainerAdapter
        Returns an array of IRemoteServiceReference objects. The returned array of IRemoteServiceReference objects contains services that were registered under the specified class and match the specified idFilter, and filter criteria.

        Note this method assumes that the enclosing container has previously been connected, and uses the idFilter to filter among targets within the previously connected set of container IDs. To request connection as part of reference lookup, see IRemoteServiceContainerAdapter.getRemoteServiceReferences(ID, String, String).

        The list is valid at the time of the call to this method, however since the Framework is a very dynamic environment, services can be modified or unregistered at anytime.

        target is a remote container to connect to. If null, no connection attempt is made.

        idFilter is used to select a registered services that were registered by a given set of containers with id in idFilter. Only services exposed by a container with id in idFilter will be returned. If idFilter is null, all containers are considered to match the filter.

        filter is used to select the registered service whose properties objects contain keys and values which satisfy the filter. See Filter for a description of the filter string syntax. If filter is null, all registered services are considered to match the filter. If filter cannot be parsed, an InvalidSyntaxException will be thrown with a human readable message where the filter became unparsable.

        Specified by:
        getRemoteServiceReferences in interface IRemoteServiceConsumer
        Specified by:
        getRemoteServiceReferences in interface IRemoteServiceContainerAdapter
        Parameters:
        target - a target container to connect to if enclosing container is not already connected. May be null.
        idFilter - an array of ID instances that will restrict the search for matching container ids If null, all remote containers will be considered in search for matching IRemoteServiceReference instances. May be null.
        clazz - the fully qualified name of the interface class that describes the desired service. Must not be null.
        filter - The filter criteria. May be null.
        Returns:
        Array of IRemoteServiceReferences matching given search criteria or null if no services are found that match the search.
        Throws:
        InvalidSyntaxException - If filter contains an invalid filter string that cannot be parsed.
        ContainerConnectException - if container cannot connect
        Since:
        3.4
      • getRemoteServiceReferences

        public IRemoteServiceReference[] getRemoteServiceReferences​(ID[] idFilter,
                                                                    String clazz,
                                                                    String filter)
                                                             throws InvalidSyntaxException
        Description copied from interface: IRemoteServiceContainerAdapter
        Returns an array of IRemoteServiceReference objects. The returned array of IRemoteServiceReference objects contains services that were registered under the specified class and match the specified idFilter, and filter criteria.

        Note this method assumes that the enclosing container has previously been connected, and uses the idFilter to filter among targets within the previously connected set of container IDs. To request connection as part of reference lookup, see IRemoteServiceContainerAdapter.getRemoteServiceReferences(ID, String, String).

        The list is valid at the time of the call to this method, however since the Framework is a very dynamic environment, services can be modified or unregistered at anytime.

        idFilter is used to select a registered services that were registered by a given set of containers with id in idFilter. Only services exposed by a container with id in idFilter will be returned.

        If idFilter is null, all containers are considered to match the filter.

        filter is used to select the registered service whose properties objects contain keys and values which satisfy the filter. See Filter for a description of the filter string syntax.

        If filter is null, all registered services are considered to match the filter. If filter cannot be parsed, an InvalidSyntaxException will be thrown with a human readable message where the filter became unparsable.

        Specified by:
        getRemoteServiceReferences in interface IRemoteServiceConsumer
        Specified by:
        getRemoteServiceReferences in interface IRemoteServiceContainerAdapter
        Parameters:
        idFilter - an array of ID instances that will restrict the search for matching container ids If null, all remote containers will be considered in search for matching IRemoteServiceReference instances. May be null.
        clazz - the fully qualified name of the interface class that describes the desired service. Must not be null.
        filter - The filter criteria. May be null.
        Returns:
        Array of IRemoteServiceReferences matching given search criteria or null if no services are found that match the search.
        Throws:
        InvalidSyntaxException - If filter contains an invalid filter string that cannot be parsed.
      • getRemoteServiceReferences

        public IRemoteServiceReference[] getRemoteServiceReferences​(ID targetID,
                                                                    String clazz,
                                                                    String filter)
                                                             throws InvalidSyntaxException,
                                                                    ContainerConnectException
        Description copied from interface: IRemoteServiceContainerAdapter

        Returns an array of IRemoteServiceReference objects. The returned array of IRemoteServiceReference objects contains services that were registered under the specified class and match the specified idFilter, and filter criteria.

        The list is valid at the time of the call to this method, however since the Framework is a very dynamic environment, services can be modified or unregistered at anytime.

        target is a remote container to connect to.

        filter is used to select the registered service whose properties objects contain keys and values which satisfy the filter. See Filter for a description of the filter string syntax.

        If filter is null, all registered services are considered to match the filter. If filter cannot be parsed, an InvalidSyntaxException will be thrown with a human readable message where the filter became unparsable.

        Specified by:
        getRemoteServiceReferences in interface IRemoteServiceConsumer
        Specified by:
        getRemoteServiceReferences in interface IRemoteServiceContainerAdapter
        Parameters:
        targetID - an target to connect to if enclosing container is not already connected. May be null.
        clazz - the fully qualified name of the interface class that describes the desired service. Must not be null.
        filter - The filter criteria. May be null.
        Returns:
        Array of IRemoteServiceReferences matching given search criteria or null if no services are found that match the search.
        Throws:
        InvalidSyntaxException - If filter contains an invalid filter string that cannot be parsed.
        ContainerConnectException - if container cannot connect
        Since:
        3.0
      • getAllRemoteServiceReferences

        public IRemoteServiceReference[] getAllRemoteServiceReferences​(String clazz,
                                                                       String filter)
                                                                throws InvalidSyntaxException
        Description copied from interface: IRemoteServiceContainerAdapter

        Returns an array of IRemoteServiceReference objects. The returned array of IRemoteServiceReference objects contains services that were registered under the specified class, or if the clazz parameter is null all services registered.

        The list is valid at the time of the call to this method, however since the remote service container is a very dynamic environment, services can be modified or unregistered at anytime.

        filter is used to select the registered service whose properties objects contain keys and values which satisfy the filter. See Filter for a description of the filter string syntax.

        If filter is null, all registered services are considered to match the filter. If filter cannot be parsed, an InvalidSyntaxException will be thrown with a human readable message where the filter became unparsable.

        Specified by:
        getAllRemoteServiceReferences in interface IRemoteServiceConsumer
        Specified by:
        getAllRemoteServiceReferences in interface IRemoteServiceContainerAdapter
        Parameters:
        clazz - the fully qualified name of the interface class that describes the desired service. May be null.
        filter - The filter criteria. May be null.
        Returns:
        Array of IRemoteServiceReferences matching given search criteria or null if no services are found that match the search.
        Throws:
        InvalidSyntaxException - If filter contains an invalid filter string that cannot be parsed.
        Since:
        3.0
      • registerRemoteService

        public IRemoteServiceRegistration registerRemoteService​(String[] clazzes,
                                                                Object service,
                                                                Dictionary properties)
        Description copied from interface: IRemoteServiceContainerAdapter
        Register a new remote service. This method is to be called by the service server...i.e. the client that wishes to make available a service to other client within this container.
        Specified by:
        registerRemoteService in interface IRemoteServiceContainerAdapter
        Specified by:
        registerRemoteService in interface IRemoteServiceHost
        Parameters:
        clazzes - the interface classes that the service exposes to remote clients. Must not be null and must not be an empty array.
        service - the service object. Under normal conditions this object must
        • not be null
        • implement all of the classes specified by the first parameter
        The only situation when the service object may be null is if the service property Constants.SERVICE_REGISTER_PROXY is set in the properties. If Constants.SERVICE_REGISTER_PROXY is set in the properties parameter (to an arbitrary value), then the service object may then be null.
        properties - to be associated with service
        Returns:
        IRemoteServiceRegistration the service registration. Will not return null .
      • asyncGetRemoteServiceReferences

        public org.eclipse.equinox.concurrent.future.IFuture asyncGetRemoteServiceReferences​(ID[] idFilter,
                                                                                             String clazz,
                                                                                             String filter)
        Description copied from interface: IRemoteServiceContainerAdapter
        Asynchronously returns an array of IRemoteServiceReference objects. The returned array of IRemoteServiceReference objects contains services that were registered under the specified class and match the specified idFilter, and filter criteria.

        Note this method assumes that the enclosing container has previously been connected, and uses the idFilter to filter among targets within the previously connected set of container IDs. To request connection as part of reference lookup, see IRemoteServiceContainerAdapter.getRemoteServiceReferences(ID, String, String).

        The IFuture is returned immediately, and subsequent calls to IFuture.get() or IFuture.get(long) will return the actual results received. The type of the Object returned from IFuture.get() will be IRemoteServiceReference [].

        The list is valid at the time of the call to this method, however since the Framework is a very dynamic environment, services can be modified or unregistered at anytime.

        idFilter is used to select a registered services that were registered by a given set of containers with id in idFilter. Only services exposed by a container with id in idFilter will be returned.

        If idFilter is null, all containers are considered to match the filter.

        filter is used to select the registered service whose properties objects contain keys and values which satisfy the filter. See Filter for a description of the filter string syntax.

        Specified by:
        asyncGetRemoteServiceReferences in interface IRemoteServiceConsumer
        Specified by:
        asyncGetRemoteServiceReferences in interface IRemoteServiceContainerAdapter
        Parameters:
        idFilter - an array of ID instances that will restrict the search for matching container ids If null, all remote containers will be considered in search for matching IRemoteServiceReference instances. May be null.
        clazz - the fully qualified name of the interface class that describes the desired service. Must not be null.
        filter - The filter criteria. May be null.
        Returns:
        IFuture that through subsequent calls to IFuture#get() will return IRemoteServiceReference [] with IRemoteServiceReferences matching given search criteria. Will not return null.
        Since:
        3.0
      • asyncGetRemoteServiceReferences

        public org.eclipse.equinox.concurrent.future.IFuture asyncGetRemoteServiceReferences​(ID target,
                                                                                             ID[] idFilter,
                                                                                             String clazz,
                                                                                             String filter)
        Description copied from interface: IRemoteServiceContainerAdapter
        Asynchronously returns an array of IRemoteServiceReference objects. The returned array of IRemoteServiceReference objects contains services that were registered under the specified class and match the specified idFilter, and filter criteria.

        The IFuture is returned immediately, and subsequent calls to IFuture.get() or IFuture.get(long) will return the actual results received. The type of the Object returned from IFuture.get() will be IRemoteServiceReference [].

        The list is valid at the time of the call to this method, however since the Framework is a very dynamic environment, services can be modified or unregistered at anytime.

        target is a remote container to connect to. If null, no connection attempt is made.

        idFilter is used to select a registered services that were registered by a given set of containers with id in idFilter. Only services exposed by a container with id in idFilter will be returned. If idFilter is null, all containers are considered to match the filter.

        filter is used to select the registered service whose properties objects contain keys and values which satisfy the filter. See Filter for a description of the filter string syntax. If filter is null, all registered services are considered to match the filter. If filter cannot be parsed, an InvalidSyntaxException will be thrown with a human readable message where the filter became unparsable.

        Specified by:
        asyncGetRemoteServiceReferences in interface IRemoteServiceConsumer
        Specified by:
        asyncGetRemoteServiceReferences in interface IRemoteServiceContainerAdapter
        Parameters:
        target - an target to connect to if enclosing container is not already connected. May be null.
        idFilter - an array of ID instances that will restrict the search for matching container ids If null, all remote containers will be considered in search for matching IRemoteServiceReference instances. May be null.
        clazz - the fully qualified name of the interface class that describes the desired service. Must not be null.
        filter - The filter criteria. May be null.
        Returns:
        IFuture that through subsequent calls to IFuture#get() will return IRemoteServiceReference [] with IRemoteServiceReferences matching given search criteria. Will not return null.
        Since:
        3.4
      • asyncGetRemoteServiceReferences

        public org.eclipse.equinox.concurrent.future.IFuture asyncGetRemoteServiceReferences​(ID target,
                                                                                             String clazz,
                                                                                             String filter)
        Description copied from interface: IRemoteServiceContainerAdapter
        Asynchronously returns an array of IRemoteServiceReference objects. The returned array of IRemoteServiceReference objects contains services that were registered under the specified class and match the specified idFilter, and filter criteria.

        The IFuture is returned immediately, and subsequent calls to IFuture.get() or IFuture.get(long) will return the actual results received. The type of the Object returned from IFuture.get() will be IRemoteServiceReference [].

        The list is valid at the time of the call to this method, however since the Framework is a very dynamic environment, services can be modified or unregistered at anytime.

        idFilter is used to select a registered services that were registered by a given set of containers with id in idFilter. Only services exposed by a container with id in idFilter will be returned.

        target is a remote container to connect to.

        filter is used to select the registered service whose properties objects contain keys and values which satisfy the filter. See Filter for a description of the filter string syntax.

        Specified by:
        asyncGetRemoteServiceReferences in interface IRemoteServiceConsumer
        Specified by:
        asyncGetRemoteServiceReferences in interface IRemoteServiceContainerAdapter
        Parameters:
        target - an target to connect to if enclosing container is not already connected. May be null.
        clazz - the fully qualified name of the interface class that describes the desired service. Must not be null.
        filter - The filter criteria. May be null.
        Returns:
        IFuture that through subsequent calls to IFuture#get() will return IRemoteServiceReference [] with IRemoteServiceReferences matching given search criteria. Will not return null.
        Since:
        3.0
      • getRemoteServiceID

        public IRemoteServiceID getRemoteServiceID​(ID containerId,
                                                   long containerRelativeId)
        Description copied from interface: IRemoteServiceContainerAdapter
        Get a remote service ID from a containerID and a containerRelative long value. Will return a non-null value if the IRemoteServiceRegistration/Reference is currently 'known' to this container adapter. null if not.
        Specified by:
        getRemoteServiceID in interface IRemoteServiceConsumer
        Specified by:
        getRemoteServiceID in interface IRemoteServiceContainerAdapter
        Specified by:
        getRemoteServiceID in interface IRemoteServiceHost
        Parameters:
        containerId - the containerID that is the server/host for the remote service. Must not be null. This must be the containerID for the server/host of the remote service.
        containerRelativeId - the long value identifying the remote service relative to the container ID.
        Returns:
        IRemoteServiceID instance if the associated IRemoteServiceRegistration/Reference is known to this container adapter, null if it is not.
        Since:
        3.0
      • initialize

        public void initialize()
                        throws SharedObjectInitException
        Description copied from class: BaseSharedObject
        Initialize this shared object. Subclasses may override as appropriate to define custom initialization behavior. If initialization should fail, then a SharedObjectInitException should be thrown by implementing code. Also, subclasses overriding this method should call super.initialize() before running their own code.
        Overrides:
        initialize in class BaseSharedObject
        Throws:
        SharedObjectInitException - if initialization should throw
      • dispose

        public void dispose​(ID containerID)
        Description copied from interface: ISharedObject
        Method called by the ISharedObjectContainer upon ISharedObject destruction. Once this method is called, no more Events will be passed to a ISharedObject until the init method is called again.
        Specified by:
        dispose in interface ISharedObject
        Overrides:
        dispose in class BaseSharedObject
        Parameters:
        containerID - the ID of the container that is disposing this ISharedObject
      • getRSConnectTimeout

        protected int getRSConnectTimeout()
        Returns:
        int connect timeout
        Since:
        3.3
      • getRegistryUpdateRequestTimeout

        protected long getRegistryUpdateRequestTimeout()
        Returns:
        long registry update request timeout
        Since:
        3.4
      • getAddRegistrationRequestTimeout

        protected int getAddRegistrationRequestTimeout()
        Returns:
        int add registration request timeout
        Since:
        3.0
      • connectToRemoteServiceTarget

        protected void connectToRemoteServiceTarget​(ID targetID)
                                             throws ContainerConnectException
        Parameters:
        targetID - target ID to connect to
        Throws:
        ContainerConnectException - if container cannot connect to target ID
        Since:
        3.3 for preventing issues like bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=304427
      • getTargetsFromProperties

        protected ID[] getTargetsFromProperties​(Dictionary properties)
      • handleRegistryActivatedEvent

        protected void handleRegistryActivatedEvent()
        Since:
        3.4
      • handleContainerEjectedEvent

        protected void handleContainerEjectedEvent​(IContainerEjectedEvent event)
        Parameters:
        event - event to handle
        Since:
        3.3
      • clearRemoteRegistrys

        protected void clearRemoteRegistrys()
        Since:
        3.4
      • setRegistryConnected

        protected void setRegistryConnected​(boolean connected)
        Parameters:
        connected - true if registry is connected, false otherwise
        Since:
        3.3
      • sendRegistryUpdate

        protected void sendRegistryUpdate​(ID targetContainerID)
      • sendRegistryUpdate

        protected void sendRegistryUpdate​(ID targetContainerID,
                                          Integer requestId)
        Parameters:
        targetContainerID - target container ID
        requestId - requestId
        Since:
        3.4
      • handleTargetConnected

        protected void handleTargetConnected​(ID targetID)
        Parameters:
        targetID - targetID
        Since:
        3.4
      • fireRemoteServiceListeners

        protected void fireRemoteServiceListeners​(IRemoteServiceEvent event)
      • fireCallCompleteEvent

        protected void fireCallCompleteEvent​(IRemoteCallListener listener,
                                             long requestId,
                                             Object response,
                                             boolean hadException,
                                             Throwable exception)
      • sendRegistryUpdateRequest

        protected void sendRegistryUpdateRequest​(ID receiver,
                                                 Integer requestId)
        Parameters:
        receiver - receiver
        requestId - requestId
        Since:
        3.4
      • handleRegistryUpdateRequest

        protected void handleRegistryUpdateRequest​(ID remoteContainerID,
                                                   Integer requestId)
        Parameters:
        remoteContainerID - remoteContainerID
        requestId - requestId
        Since:
        3.4
      • sendRegistryUpdateRequest

        protected void sendRegistryUpdateRequest()
      • handleRegistryUpdateRequest

        protected void handleRegistryUpdateRequest​(ID remoteContainerID)
      • sendAddRegistrations

        protected void sendAddRegistrations​(ID receiver,
                                            Integer requestId,
                                            RemoteServiceRegistrationImpl[] regs)
        Parameters:
        receiver - receiver
        requestId - requestId
        regs - registrations to send
        Since:
        3.3
      • sendAddRegistrationRequestRefused

        protected void sendAddRegistrationRequestRefused​(ID receiver,
                                                         Integer requestId,
                                                         Exception except)
      • handleAddRegistrationRequestRefused

        protected void handleAddRegistrationRequestRefused​(ID remoteContainerID,
                                                           Integer requestId,
                                                           AccessControlException e)
      • handleAddRegistrations

        protected void handleAddRegistrations​(ID remoteContainerID,
                                              Integer requestId,
                                              RemoteServiceRegistrationImpl[] registrations)
        Parameters:
        remoteContainerID - container id
        requestId - requestId
        registrations - the registrations to add
        Since:
        3.3
      • notifyAddRegistrationResponse

        protected void notifyAddRegistrationResponse​(ID remoteContainerID,
                                                     Integer requestId,
                                                     AccessControlException exception)
        Parameters:
        remoteContainerID - remoteContainerID
        requestId - requestId
        exception - exception
        Since:
        3.2
      • createRequestExecutor

        protected org.eclipse.equinox.concurrent.future.IExecutor createRequestExecutor​(Request request)
        Parameters:
        request - request
        Returns:
        IExcecutor excecutor to use for given request
        Since:
        3.4
      • executeRequest

        protected void executeRequest​(org.eclipse.equinox.concurrent.future.IExecutor executor,
                                      Request request,
                                      ID responseTarget,
                                      RemoteServiceRegistrationImpl localRegistration,
                                      boolean respond)
        Parameters:
        executor - executor to use to execute request
        request - the request to execute
        responseTarget - response target
        localRegistration - the local registration
        respond - true if response is expected, false otherwise
        Since:
        3.4
      • handleCallRequestBytes

        protected void handleCallRequestBytes​(byte[] requestBytes)
        Since:
        4.6
      • handleCallRequest

        protected void handleCallRequest​(Request request)
      • logRemoteCallException

        protected void logRemoteCallException​(String message,
                                              Throwable e)
        Parameters:
        message - message
        e - the exception
        Since:
        3.4
      • sendCallResponse

        protected void sendCallResponse​(ID responseTarget,
                                        Response response)
      • handleCallResponse

        protected void handleCallResponse​(Response response)
      • handleCallResponseBytes

        protected void handleCallResponseBytes​(byte[] responseBytes)
        Since:
        4.6
      • handleFireRequest

        protected void handleFireRequest​(Request request)
      • handleUnregister

        protected void handleUnregister​(ID containerID,
                                        Long serviceId)
      • getLocalRegistrationForRequest

        protected RemoteServiceRegistrationImpl getLocalRegistrationForRequest​(Request request)
        Parameters:
        request - request
        Returns:
        RemoteServiceRegistrationImpl the registration
        Since:
        3.2
      • addRequest

        protected boolean addRequest​(Request request)
        Parameters:
        request - the request to add
        Returns:
        true if added, false if not added
        Since:
        3.2
      • getRequest

        protected Request getRequest​(long requestId)
        Parameters:
        requestId - requestId
        Returns:
        Request the request associated with the given requestId or null
        Since:
        3.2
      • removeRequest

        protected boolean removeRequest​(Request request)
        Parameters:
        request - request
        Returns:
        boolean true if removed, false otherwise
        Since:
        3.2
      • logException

        protected void logException​(int code,
                                    String message,
                                    Throwable e)
      • handleSharedObjectMsg

        protected boolean handleSharedObjectMsg​(SharedObjectMsg msg)
        Description copied from class: BaseSharedObject
        SharedObjectMsg handler method. This method will be called by BaseSharedObject.handleSharedObjectMsgEvent(ISharedObjectMessageEvent) when a SharedObjectMsg is received either from a local source or a remote source. This default implementation simply returns false so that other processing of of the given msg can occur. Subclasses should override this behavior to define custom logic for handling SharedObjectMsgs.
        Overrides:
        handleSharedObjectMsg in class BaseSharedObject
        Parameters:
        msg - the SharedObjectMsg received
        Returns:
        true if the msg has been completely handled and subsequent processing should stop. False if processing should continue
      • getRemoteServiceCallPolicy

        protected IRemoteServiceCallPolicy getRemoteServiceCallPolicy()
        Returns:
        IRemoteServiceCallPolicy the policy. May be null
        Since:
        4.0