Class NetServerChannel
java.lang.Object
cl.obcom.desktopfx.netserver.NetServerChannel
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 Summary
Modifier and TypeMethodDescriptionfinal voidaddListener(ConnectionListener listener) Adds the supplied connecion listener to this channel.final voidaddListener(MessageListener listener) Adds the supplied message listener to this channel.final voidassignLayout(NetServerMessage message) Themessageis assigned the layout identified by itsLayoutNamelabel.final NetServerClientcreateClient(String description, DesktopTask task) Creates a NetServerClient associatted with aDesktopTask.final booleanReturnstrueif theassignLayoutmethod is automatically applied to all reply or published messages received from the OBCOM NetServer.final booleanReturnstrueif login is performed after connecting to OBCOM NetServer.final Collection<NetServerClient> Returns a collection with all clients of thisNetServerChannel.final booleanReturnstrueif all messages are sent encrypted to OBCOM NetServer.final LayoutReturns theLayoutwith the specifiedname.final URIReturns the URI used to download the required messages layouts.final booleanReturnstrueifNetServerChannelerrors are logged.final NetServerManagerReturns the NetServerManager of thisNetServerChannel.final intReturns the number of multicast messages this channel has read.final StringgetName()Returns the name of thisNetServerChannel.final URIReturns the protocol, host and port of the OBCOM NetServer.final intReturns the number of bytes this channel has read.final intReturns the number of messages this channel has read.final StringReturns the name of the station of this channel.final StringReturns the serial number of the station of this channel.final booleanReturnstrueif the signatures of downloaded layouts are verified.final intReturns the number of bytes this channel has written.final intReturns the number of messages this channel has written.final booleanisAlive()Returnstrueif thisNetServerChannelis alive.final booleanReturnstrueif connected to the OBCOM NetServer.final booleanReturnstrueif tracing inbound and outbound messages.final voidrelease()Closes thisNetServerChannel, relinquishing any underlying resources.final voidremoveListener(ConnectionListener listener) Removes the supplied connecion listener from this channel.final voidremoveListener(MessageListener listener) Removes the supplied message listener from this channel.final voidsetAutoAssignLayout(boolean value) Changes whether theassignLayoutmethod is automatically applied to all reply or published messages received from the OBCOM NetServer.final voidsetLogChannelErrors(boolean value) Changes whetherNetServerChannelerrors are logged..final voidsetStationName(String name) Changes the name of the station of this channel.final voidsetStationSerial(String serial) Changes the serial number of the station of this channel.final voidsetVerifyLayoutSignatures(boolean value) Changes whether the signatures of downloaded layouts are verified.
-
Method Details
-
getManager
Returns the NetServerManager of thisNetServerChannel.- Returns:
- the NetServerManager of this
NetServerChannel.
-
getName
Returns the name of thisNetServerChannel.- Returns:
- the name of this
NetServerChannel.
-
getNetServerURI
Returns the protocol, host and port of the OBCOM NetServer.- Returns:
- the protocol, host and port of the OBCOM NetServer.
-
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()Returnstrueif connected to the OBCOM NetServer.- Returns:
trueif connected to the OBCOM NetServer.
-
isAlive
public final boolean isAlive()Returnstrueif thisNetServerChannelis alive. ANetServerChannelbecomes dead when a system operator executes the "kill client" command in an OBCOM NetServer console.- Returns:
trueif thisNetServerChannelis alive.
-
getEncryptAll
public final boolean getEncryptAll()Returnstrueif all messages are sent encrypted to OBCOM NetServer.- Returns:
trueif all messages are sent encrypted to OBCOM NetServer.
-
getAutoLogin
public final boolean getAutoLogin()Returnstrueif login is performed after connecting to OBCOM NetServer.- Returns:
trueif login is performed after connecting to OBCOM NetServer.
-
getStationName
Returns the name of the station of this channel.- Returns:
- the name of the station of this channel.
-
setStationName
Changes the name of the station of this channel.- Parameters:
name- the name of the station of this channel.- Throws:
IllegalArgumentException- ifnameis invalid.
-
getStationSerial
Returns the serial number of the station of this channel.- Returns:
- the serial number of the station of this channel.
-
setStationSerial
Changes the serial number of the station of this channel.- Parameters:
serial- the serial number of the station of this channel.- Throws:
IllegalArgumentException- ifserialis invalid.
-
addListener
Adds the supplied connecion listener to this channel.- Parameters:
listener- the connecion listener to add to this channel.- Throws:
NullPointerException- iflistenerisnull.
-
removeListener
Removes the supplied connecion listener from this channel.- Parameters:
listener- the connecion listener to remove from this channel.- Throws:
NullPointerException- iflistenerisnull.
-
addListener
Adds the supplied message listener to this channel.- Parameters:
listener- the message listener to add to this channel.- Throws:
NullPointerException- iflistenerisnull.
-
removeListener
Removes the supplied message listener from this channel.- Parameters:
listener- the message listener to remove from this channel.- Throws:
NullPointerException- iflistenerisnull.
-
isTracing
public final boolean isTracing()Returnstrueif tracing inbound and outbound messages.- Returns:
trueif 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()Returnstrueif the signatures of downloaded layouts are verified.- Returns:
trueif 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- iftruethe signatures of downloaded layouts will be verified. Otherwise the signatures will be assigned to layouts without verification.
-
getLayout
Returns theLayoutwith the specifiedname. 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 ifgetVerifyLayoutSignatures()returnstrue, otherwise the signature will be assigned to the layout without verification.- Parameters:
name- name of the requiredLayout.- Returns:
- the
Layoutwith the specifiedname. - Throws:
NullPointerException- ifnameisnull.Exception- if an error occurs while loading the layout.
-
getAutoAssignLayout
public final boolean getAutoAssignLayout()Returnstrueif theassignLayoutmethod is automatically applied to all reply or published messages received from the OBCOM NetServer.- Returns:
trueif theassignLayoutmethod is applied to all reply or published messages.
-
setAutoAssignLayout
public final void setAutoAssignLayout(boolean value) Changes whether theassignLayoutmethod is automatically applied to all reply or published messages received from the OBCOM NetServer.- Parameters:
value- iftruetheassignLayoutmethod will be applied to all reply or published messages.
-
assignLayout
Themessageis assigned the layout identified by itsLayoutNamelabel. If themessagehas no such label, then nothing is done. If themessagehas aLayoutSignaturelabel, 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- ifmessageisnull.IllegalArgumentException- if the signatures of themessageand the layout are not equal.Exception- if another error occurs.
-
getClients
Returns a collection with all clients of thisNetServerChannel.- Returns:
- a collection with all clients of this
NetServerChannel.
-
createClient
Creates a NetServerClient associatted with aDesktopTask.- 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- ifdescriptionisnull.
-
getLogChannelErrors
public final boolean getLogChannelErrors()ReturnstrueifNetServerChannelerrors are logged.- Returns:
trueifNetServerChannelerrors are logged.
-
setLogChannelErrors
public final void setLogChannelErrors(boolean value) Changes whetherNetServerChannelerrors are logged..- Parameters:
value- iftruechannel errors are logged.
-
release
public final void release()Closes thisNetServerChannel, relinquishing any underlying resources. No other method of thisNetServerChannelcan be used after this method has been issued. Calling this method more than once is allowed but has no effect after the first invocation.
-