Class RemoteClient

All Implemented Interfaces:
Closable, Closable.CloseAutomaton, ClosedAccessor, Component, ConnectableComponent, ConnectableComponent.ConnectableAutomaton, ConnectionComponent<DatagramTransceiver<Serializable>>, ConnectionComponent.ConnectionAutomaton<DatagramTransceiver<Serializable>>, ConnectionOpenable<DatagramTransceiver<Serializable>>, ConnectionOpenable.ConnectionOpenAutomaton<DatagramTransceiver<Serializable>>, ConnectionStatusAccessor, Destroyable, OpenedAccessor, BusyAccessor, Clearable, EmptyAccessor, Remote, Containable

public class RemoteClient extends AbstractConnectableAutomaton
A RemoteClient promotes subjects to be operated on by a RemoteServer.
  • Constructor Details

  • Method Details

    • clear

      public void clear()
    • close

      public void close() throws IOException
      Specified by:
      close in interface Closable
      Throws:
      IOException
    • isBusy

      public boolean isBusy()
    • hasProxy

      public boolean hasProxy(Object aProxy)
      Returns true if the provided proxy is contained inside the RemoteClient.
      Parameters:
      aProxy - The proxy to be tested if it is contained inside the RemoteClient.
      Returns:
      True if the given proxy is contained inside the RemoteClient.
    • getProxy

      public <T> T getProxy(Class<T> aType) throws AmbiguousProxyException, NoSuchProxyException
      Returns the proxy which can be cast to the given type. Note that this method may throw an AmbiguousProxyException even if hasProxy(Class) returns true! The method hasProxy(Class) returns true in case at least one proxy of the given type was found whereas this method only returns a proxy in case there is exactly one proxy of the required type is present.
      Type Parameters:
      T - the generic type
      Parameters:
      aType - the type
      Returns:
      The proxy for an instance of the given type.
      Throws:
      AmbiguousProxyException - Thrown in case a proxy for a given type was requested but more than one proxies matched the requested type.
      NoSuchProxyException - Thrown in case a proxy for a given type was requested but not any proxy matched the requested type.
    • hasProxy

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

      public Iterator<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.
      Returns:
      An iterator containing the published proxy objects.
    • isEmpty

      public boolean isEmpty()
    • signOffProxy

      public boolean signOffProxy(Object aProxy) throws IOException
      Signs off an instance previously published using the publishClassDescriptor() method.
      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:
      IOException - Thrown in case opening or accessing an open line (connection, junction, link) caused problems.
    • size

      public int size()
    • destroy

      public void destroy()
      Specified by:
      destroy in interface Destroyable
    • doSendJob

      protected void doSendJob(Message aJob) throws IOException
      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:
      IOException - 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 DigestException
      This 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:
      DigestException - Thrown in case digesting (processing) a job by a Digester.digest(Object) caused problems; the aCause is usually wrapped by this Exception.
      See Also:
    • close

      protected void close(org.refcodes.remoting.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 Closable.close() (setting the ConnectionStatus to be ConnectionStatus.CLOSED); advanced implementations just closing dedicated connections may keep the Remote itself open (and skip calling Closable.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(Class<?> aType) throws VetoException
      Hook when a proxy is about to be published.
      Parameters:
      aType - The type to be stored by the property.
      Throws:
      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(Object aProxy)
      Hook when a proxy has been published.
      Parameters:
      aProxy - The proxy to being published.
    • onProxySignedOff

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

      public boolean isOpenable(DatagramTransceiver<Serializable> aConnection)
      Specified by:
      isOpenable in interface ConnectionOpenable.ConnectionOpenAutomaton<DatagramTransceiver<Serializable>>
    • open

      public void open(DatagramTransceiver<Serializable> aTransceiver) throws IOException
      Specified by:
      open in interface ConnectionOpenable<DatagramTransceiver<Serializable>>
      Throws:
      IOException
    • toReceiver

      protected void toReceiver(Message aJob) throws IOException
      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:
      IOException - 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 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 Destroyable.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.