Class NetServerChannel

java.lang.Object
cl.obcom.desktopfx.netserver.NetServerChannel

public abstract class NetServerChannel extends Object
Bidirectional TCP/IP communication channel with an OBCOM NetServer. Through this channel, an application can send transactions, receive published messages, and request other services from the OBCOM NetServer or other custom made servers. This communication channel is established as late as possible. Yet, once established, it is kept running until a System Operator executes the "kill client" command in an OBCOM NetServer console. If the communication channel is lost for any other reason, it is automatically re-established as soon as required.

In order to maximize reusability and to reduce the number of physical network connections, the NetServerChannel communication link is implemented as a shared (multiplexed) channel. For this reason, a client application cannot use a NetServerChannel directly, but it has to acquire a NetServerClient instance using the createClient method. It is through this NetServerClient that the client application communicates with the OBCOM NetServer server environment.

  • Method Details

    • getManager

      public final NetServerManager getManager()
      Returns the NetServerManager of this NetServerChannel.
      Returns:
      the NetServerManager of this NetServerChannel.
    • getName

      public final String getName()
      Returns the name of this NetServerChannel.
      Returns:
      the name of this NetServerChannel.
    • getNetServerURI

      public final URI getNetServerURI()
      Returns the protocol, host and port of the OBCOM NetServer.
      Returns:
      the protocol, host and port of the OBCOM NetServer.
    • getLayoutURI

      public final URI getLayoutURI()
      Returns the URI used to download the required messages layouts.
      Returns:
      the URI used to download the required messages layouts.
    • isConnected

      public final boolean isConnected()
      Returns true if connected to the OBCOM NetServer.
      Returns:
      true if connected to the OBCOM NetServer.
    • isAlive

      public final boolean isAlive()
      Returns true if this NetServerChannel is alive. A NetServerChannel becomes dead when a system operator executes the "kill client" command in an OBCOM NetServer console.
      Returns:
      true if this NetServerChannel is alive.
    • getEncryptAll

      public final boolean getEncryptAll()
      Returns true if all messages are sent encrypted to OBCOM NetServer.
      Returns:
      true if all messages are sent encrypted to OBCOM NetServer.
    • getAutoLogin

      public final boolean getAutoLogin()
      Returns true if login is performed after connecting to OBCOM NetServer.
      Returns:
      true if login is performed after connecting to OBCOM NetServer.
    • getStationName

      public final String getStationName()
      Returns the name of the station of this channel.
      Returns:
      the name of the station of this channel.
    • setStationName

      public final void setStationName(String name)
      Changes the name of the station of this channel.
      Parameters:
      name - the name of the station of this channel.
      Throws:
      IllegalArgumentException - if name is invalid.
    • getStationSerial

      public final String getStationSerial()
      Returns the serial number of the station of this channel.
      Returns:
      the serial number of the station of this channel.
    • setStationSerial

      public final void setStationSerial(String serial)
      Changes the serial number of the station of this channel.
      Parameters:
      serial - the serial number of the station of this channel.
      Throws:
      IllegalArgumentException - if serial is invalid.
    • addListener

      public final void addListener(ConnectionListener listener)
      Adds the supplied connecion listener to this channel.
      Parameters:
      listener - the connecion listener to add to this channel.
      Throws:
      NullPointerException - if listener is null.
    • removeListener

      public final void removeListener(ConnectionListener listener)
      Removes the supplied connecion listener from this channel.
      Parameters:
      listener - the connecion listener to remove from this channel.
      Throws:
      NullPointerException - if listener is null.
    • addListener

      public final void addListener(MessageListener listener)
      Adds the supplied message listener to this channel.
      Parameters:
      listener - the message listener to add to this channel.
      Throws:
      NullPointerException - if listener is null.
    • removeListener

      public final void removeListener(MessageListener listener)
      Removes the supplied message listener from this channel.
      Parameters:
      listener - the message listener to remove from this channel.
      Throws:
      NullPointerException - if listener is null.
    • isTracing

      public final boolean isTracing()
      Returns true if tracing inbound and outbound messages.
      Returns:
      true if tracing inbound and outbound messages.
    • getMulticastMessages

      public final int getMulticastMessages()
      Returns the number of multicast messages this channel has read.
      Returns:
      the number of multicast messages this channel has read.
    • getReaderBytes

      public final int getReaderBytes()
      Returns the number of bytes this channel has read.
      Returns:
      the number of bytes this channel has read.
    • getReaderMessages

      public final int getReaderMessages()
      Returns the number of messages this channel has read.
      Returns:
      the number of messages this channel has read.
    • getWriterBytes

      public final int getWriterBytes()
      Returns the number of bytes this channel has written.
      Returns:
      the number of bytes this channel has written.
    • getWriterMessages

      public final int getWriterMessages()
      Returns the number of messages this channel has written.
      Returns:
      the number of messages this channel has written.
    • getVerifyLayoutSignatures

      public final boolean getVerifyLayoutSignatures()
      Returns true if the signatures of downloaded layouts are verified.
      Returns:
      true if the signatures of downloaded layouts are verified.
    • setVerifyLayoutSignatures

      public final void setVerifyLayoutSignatures(boolean value)
      Changes whether the signatures of downloaded layouts are verified.
      Parameters:
      value - if true the signatures of downloaded layouts will be verified. Otherwise the signatures will be assigned to layouts without verification.
    • getLayout

      public final Layout getLayout(String name) throws Exception
      Returns the Layout with the specified name. If the layout is not available in the cache, it is downloaded, compiled, stored in the cache and returned to the caller of this method. The signature of the downloaded layout will be verified if getVerifyLayoutSignatures() returns true, otherwise the signature will be assigned to the layout without verification.
      Parameters:
      name - name of the required Layout.
      Returns:
      the Layout with the specified name.
      Throws:
      NullPointerException - if name is null.
      Exception - if an error occurs while loading the layout.
    • getAutoAssignLayout

      public final boolean getAutoAssignLayout()
      Returns true if the assignLayout method is automatically applied to all reply or published messages received from the OBCOM NetServer.
      Returns:
      true if the assignLayout method is applied to all reply or published messages.
    • setAutoAssignLayout

      public final void setAutoAssignLayout(boolean value)
      Changes whether the assignLayout method is automatically applied to all reply or published messages received from the OBCOM NetServer.
      Parameters:
      value - if true the assignLayout method will be applied to all reply or published messages.
    • assignLayout

      public final void assignLayout(NetServerMessage message) throws Exception
      The message is assigned the layout identified by its LayoutName label. If the message has no such label, then nothing is done. If the message has a LayoutSignature label, it is compared with the signature of the assigned layout, and an exception if thrown if the signatures are not equal.
      Parameters:
      message - the message that will be assigned a layout.
      Throws:
      NullPointerException - if message is null.
      IllegalArgumentException - if the signatures of the message and the layout are not equal.
      Exception - if another error occurs.
    • getClients

      public final Collection<NetServerClient> getClients()
      Returns a collection with all clients of this NetServerChannel.
      Returns:
      a collection with all clients of this NetServerChannel.
    • createClient

      public final NetServerClient createClient(String description, DesktopTask task)
      Creates a NetServerClient associatted with a DesktopTask.
      Parameters:
      description - the description of the NetServerClient.
      task - a desktop task instance (can be null).
      Returns:
      a new NetServerClient associatted with the desktop task.
      Throws:
      NullPointerException - if description is null.
    • logChannelProperties

      protected void logChannelProperties()
      Called once to generate log message with the properties of this channel.
    • getLogChannelErrors

      public final boolean getLogChannelErrors()
      Returns true if NetServerChannel errors are logged.
      Returns:
      true if NetServerChannel errors are logged.
    • setLogChannelErrors

      public final void setLogChannelErrors(boolean value)
      Changes whether NetServerChannel errors are logged..
      Parameters:
      value - if true channel errors are logged.
    • release

      public void release()
      Closes this NetServerChannel, relinquishing any underlying resources. No other method of this NetServerChannel can be used after this method has been issued. Calling this method more than once is allowed but has no effect after the first invocation.