Class RemoteClientImpl

  • All Implemented Interfaces:
    org.refcodes.component.Closable, org.refcodes.component.Closable.CloseAutomaton, org.refcodes.component.ClosedAccessor, org.refcodes.component.Component, org.refcodes.component.ConnectableComponent, org.refcodes.component.ConnectableComponent.ConnectableAutomaton, org.refcodes.component.ConnectionComponent<org.refcodes.io.DatagramTransceiver<java.io.Serializable>>, org.refcodes.component.ConnectionComponent.ConnectionAutomaton<org.refcodes.io.DatagramTransceiver<java.io.Serializable>>, org.refcodes.component.ConnectionOpenable<org.refcodes.io.DatagramTransceiver<java.io.Serializable>>, org.refcodes.component.ConnectionOpenable.ConnectionOpenAutomaton<org.refcodes.io.DatagramTransceiver<java.io.Serializable>>, org.refcodes.component.ConnectionStatusAccessor, org.refcodes.component.Destroyable, org.refcodes.component.OpenedAccessor, org.refcodes.mixin.BusyAccessor, Remote, RemoteClient, org.refcodes.structure.Clearable, org.refcodes.structure.Containable

    public class RemoteClientImpl
    extends org.refcodes.component.AbstractConnectableAutomaton
    implements RemoteClient
    Abstract implementation of the RemoteClient's base functionality.
    • Nested Class Summary

      • Nested classes/interfaces inherited from interface org.refcodes.mixin.BusyAccessor

        org.refcodes.mixin.BusyAccessor.BusyMutator, org.refcodes.mixin.BusyAccessor.BusyProperty
      • Nested classes/interfaces inherited from interface org.refcodes.component.Closable

        org.refcodes.component.Closable.CloseAutomaton, org.refcodes.component.Closable.CloseBuilder<B extends org.refcodes.component.Closable.CloseBuilder<B>>
      • Nested classes/interfaces inherited from interface org.refcodes.component.ClosedAccessor

        org.refcodes.component.ClosedAccessor.ClosedMutator, org.refcodes.component.ClosedAccessor.ClosedProperty
      • Nested classes/interfaces inherited from interface org.refcodes.component.ConnectableComponent

        org.refcodes.component.ConnectableComponent.ConnectableAutomaton
      • Nested classes/interfaces inherited from interface org.refcodes.component.ConnectionComponent

        org.refcodes.component.ConnectionComponent.ConnectionAutomaton<CON extends java.lang.Object>, org.refcodes.component.ConnectionComponent.ConnectionComponentBuilder<CON extends java.lang.Object,B extends org.refcodes.component.ConnectionComponent.ConnectionComponentBuilder<CON,B>>
      • Nested classes/interfaces inherited from interface org.refcodes.component.ConnectionOpenable

        org.refcodes.component.ConnectionOpenable.ConnectionOpenAutomaton<CON extends java.lang.Object>, org.refcodes.component.ConnectionOpenable.ConnectionOpenBuilder<CON extends java.lang.Object,B extends org.refcodes.component.ConnectionOpenable.ConnectionOpenBuilder<CON,B>>
      • Nested classes/interfaces inherited from interface org.refcodes.component.ConnectionStatusAccessor

        org.refcodes.component.ConnectionStatusAccessor.ConnectionStatusMutator, org.refcodes.component.ConnectionStatusAccessor.ConnectionStatusProperty
      • Nested classes/interfaces inherited from interface org.refcodes.component.Destroyable

        org.refcodes.component.Destroyable.DestroyAutomaton
      • Nested classes/interfaces inherited from interface org.refcodes.component.OpenedAccessor

        org.refcodes.component.OpenedAccessor.OpenedMutator, org.refcodes.component.OpenedAccessor.OpenedProperty
    • Constructor Summary

      Constructors 
      Constructor Description
      RemoteClientImpl()
      Instantiates a new remote client impl.
      RemoteClientImpl​(java.util.concurrent.ExecutorService aExecutorService)
      Instantiates a new remote client impl.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void clear()
      void close()
      protected void close​(CloseConnectionMessage aJob)
      Closes the Remote upon a received CloseConnectionMessage.
      void destroy()
      protected void digest​(Message aJob)
      The digest(Message) method is invoked in order to trigger processing of the provided Message, e.g. start execution depending on the Message instance being provided from the outside.
      protected void doSendJob​(Message aJob)
      For testing purposes, any job can be manually pushed into the job process to the receiver.
      protected void fromSender​(Message aJob)
      Provides an Message from another sender to this receiver.
      protected java.util.concurrent.ExecutorService getExecutorService()
      Hook method for retrieving the ExecutorService.
      <T> T getProxy​(java.lang.Class<T> aType)
      Gets the proxy.
      boolean hasProxy​(java.lang.Class<?> aType)
      Returns true if there is at least one proxy of the given type.
      boolean hasProxy​(java.lang.Object proxy)
      Returns true if the provided proxy is contained inside the RemoteClient.
      boolean isBusy()
      protected boolean isDestroyed()
      Hook to support the Destroyable interface, determines the destroyed status property; set to true when destroy() is called.
      boolean isEmpty()
      boolean isOpenable​(org.refcodes.io.DatagramTransceiver<java.io.Serializable> aConnection)
      protected void onClosed()
      Hook when the connection has been closed.
      protected void onOpened()
      Hook when the connection has been opened.
      protected void onProxyPublished​(java.lang.Object aProxy)
      Hook when a proxy has been published.
      protected void onProxySignedOff​(java.lang.Object aProxy)
      Hook when a proxy has been signed-off.
      protected void onPublishProxy​(java.lang.Class<?> aType)
      Hook when a proxy is about to be published.
      void open​(org.refcodes.io.DatagramTransceiver<java.io.Serializable> aTransceiver)
      java.util.Iterator<java.lang.Object> proxies()
      Returns a read-only iterator containing all the proxy objects previously being published.
      boolean signOffProxy​(java.lang.Object aProxy)
      Signs off an instance previously published using the publishClassDescriptor() method.
      int size()
      protected void toReceiver​(Message aJob)
      Forwards an Message from this sender to another receiver.
      • Methods inherited from class org.refcodes.component.AbstractConnectableAutomaton

        getConnectionStatus, isClosable, isClosed, isOpenable, isOpened, open, setConnectionStatus
      • Methods inherited from interface org.refcodes.component.Closable

        closeIn, closeQuietly, closeUnchecked
      • Methods inherited from interface org.refcodes.component.Closable.CloseAutomaton

        isClosable
      • Methods inherited from interface org.refcodes.component.ClosedAccessor

        isClosed
      • Methods inherited from interface org.refcodes.component.ConnectionOpenable

        open, openUnchecked
      • Methods inherited from interface org.refcodes.component.ConnectionOpenable.ConnectionOpenAutomaton

        isOpenable
      • Methods inherited from interface org.refcodes.component.ConnectionStatusAccessor

        getConnectionStatus, isConnectionOpened
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface org.refcodes.component.OpenedAccessor

        isOpened
    • Constructor Detail

      • RemoteClientImpl

        public RemoteClientImpl()
        Instantiates a new remote client impl.
      • RemoteClientImpl

        public RemoteClientImpl​(java.util.concurrent.ExecutorService aExecutorService)
        Instantiates a new remote client impl.
        Parameters:
        aExecutorService - the executor service
    • Method Detail

      • clear

        public void clear()
        Specified by:
        clear in interface org.refcodes.structure.Clearable
      • close

        public void close()
        Specified by:
        close in interface org.refcodes.component.Closable
      • isBusy

        public boolean isBusy()
        Specified by:
        isBusy in interface org.refcodes.mixin.BusyAccessor
      • hasProxy

        public boolean hasProxy​(java.lang.Object proxy)
        Returns true if the provided proxy is contained inside the RemoteClient.
        Specified by:
        hasProxy in interface RemoteClient
        Parameters:
        proxy - The proxy to be tested if it is contained inside the RemoteClient.
        Returns:
        True if the given proxy is contained inside the RemoteClient.
      • hasProxy

        public boolean hasProxy​(java.lang.Class<?> aType)
        Returns true if there is at least one proxy of the given type.
        Specified by:
        hasProxy in interface RemoteClient
        Parameters:
        aType - the type
        Returns:
        True in case there is at least one proxy of the given type.
      • proxies

        public java.util.Iterator<java.lang.Object> proxies()
        Returns a read-only iterator containing all the proxy objects previously being published. Use the sign-off methods in order to remove a published proxy object.
        Specified by:
        proxies in interface RemoteClient
        Returns:
        An iterator containing the published proxy objects.
      • isEmpty

        public boolean isEmpty()
        Specified by:
        isEmpty in interface org.refcodes.structure.Containable
      • signOffProxy

        public boolean signOffProxy​(java.lang.Object aProxy)
                             throws org.refcodes.component.OpenException
        Signs off an instance previously published using the publishClassDescriptor() method.
        Specified by:
        signOffProxy in interface RemoteClient
        Parameters:
        aProxy - An object of type GenericInstanceDescriptor containing the information needed to sign-off an instance.
        Returns:
        True is returned if the instance described by the proxy object could be signed off, else false is returned
        Throws:
        org.refcodes.component.OpenException - Thrown in case opening or accessing an open line (connection, junction, link) caused problems.
      • size

        public int size()
        Specified by:
        size in interface org.refcodes.structure.Containable
      • destroy

        public void destroy()
        Specified by:
        destroy in interface org.refcodes.component.Destroyable
      • doSendJob

        protected void doSendJob​(Message aJob)
                          throws org.refcodes.component.OpenException
        For testing purposes, any job can be manually pushed into the job process to the receiver.
        Parameters:
        aJob - The job to be pushed to the receiver.
        Throws:
        org.refcodes.component.OpenException - Thrown in case the operation failed due to an I/O malfunction such as the input- or output-connection (of an input- and output-connection pair) is not available or being disconnected.
      • digest

        protected void digest​(Message aJob)
                       throws org.refcodes.component.DigestException
        The digest(Message) method is invoked in order to trigger processing of the provided Message, e.g. start execution depending on the Message instance being provided from the outside. A RemoteClient digests such a Message different than a RemoteServer. This method is inspired by the Digester.digest(Object) method.
        Parameters:
        aJob - The Message to be digested.
        Throws:
        org.refcodes.component.DigestException - Thrown in case digesting (processing) a job by a Digester.digest(Object) caused problems; the cause is usually wrapped by this Exception.
        See Also:
        Digester
      • close

        protected void close​(CloseConnectionMessage aJob)
        Closes the Remote upon a received CloseConnectionMessage. Some client ID might be considered in order to determine whether to close all or just one of many connections. This default implementation calls close() (setting the ConnectionStatus to be ConnectionStatus.CLOSED); advanced implementations just closing dedicated connections may keep the Remote itself open (and skip calling close() and close only a dedicated connection identified by the Meta-Data of the CloseConnectionMessage.
        Parameters:
        aJob - The CloseConnectionMessage being received for closing the connection.
      • onPublishProxy

        protected void onPublishProxy​(java.lang.Class<?> aType)
                               throws org.refcodes.exception.VetoException
        Hook when a proxy is about to be published.
        Parameters:
        aType - The type to be stored by the property.
        Throws:
        org.refcodes.exception.VetoException - Thrown to signal that an operation is being vetoed by a third party observing the invocation of the given operation.
      • onProxyPublished

        protected void onProxyPublished​(java.lang.Object aProxy)
        Hook when a proxy has been published.
        Parameters:
        aProxy - The proxy to being published.
      • onProxySignedOff

        protected void onProxySignedOff​(java.lang.Object aProxy)
        Hook when a proxy has been signed-off.
        Parameters:
        aProxy - The proxy which has been signed-off.
      • isOpenable

        public boolean isOpenable​(org.refcodes.io.DatagramTransceiver<java.io.Serializable> aConnection)
        Specified by:
        isOpenable in interface org.refcodes.component.ConnectionOpenable.ConnectionOpenAutomaton<org.refcodes.io.DatagramTransceiver<java.io.Serializable>>
      • open

        public void open​(org.refcodes.io.DatagramTransceiver<java.io.Serializable> aTransceiver)
                  throws org.refcodes.component.OpenException
        Specified by:
        open in interface org.refcodes.component.ConnectionOpenable<org.refcodes.io.DatagramTransceiver<java.io.Serializable>>
        Throws:
        org.refcodes.component.OpenException
      • toReceiver

        protected void toReceiver​(Message aJob)
                           throws org.refcodes.component.OpenException
        Forwards an Message from this sender to another receiver. A sub-class invokes this method when it sends an Message to the receiver counterpart. The communication path is to be implemented by the sub-class.
        Parameters:
        aJob - the Message to be forwarded to this receiver from the sender counterpart.
        Throws:
        org.refcodes.component.OpenException - Thrown in case opening or accessing an open line (connection, junction, link) caused problems.
      • fromSender

        protected void fromSender​(Message aJob)
        Provides an Message from another sender to this receiver. A sub-class invokes this method when it receives an Message from a sender counterpart. The communication path is to be implemented by the sub-class.
        Parameters:
        aJob - the Message to be forwarded to this receiver from the sender counterpart.
      • getExecutorService

        protected java.util.concurrent.ExecutorService getExecutorService()
        Hook method for retrieving the ExecutorService.
        Returns:
        The ExecutorService as used by this implementation.
      • isDestroyed

        protected boolean isDestroyed()
        Hook to support the Destroyable interface, determines the destroyed status property; set to true when destroy() is called.
        Returns:
        The destroyed status property.
      • onOpened

        protected void onOpened()
        Hook when the connection has been opened.
      • onClosed

        protected void onClosed()
        Hook when the connection has been closed.