Package cl.obcom.desktopfx.netserver
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 void
addListener
(ConnectionListener listener) Adds the supplied connecion listener to this channel.final void
addListener
(MessageListener listener) Adds the supplied message listener to this channel.final void
assignLayout
(NetServerMessage message) Themessage
is assigned the layout identified by itsLayoutName
label.final NetServerClient
createClient
(String description, DesktopTask task) Creates a NetServerClient associatted with aDesktopTask
.final boolean
Returnstrue
if theassignLayout
method is automatically applied to all reply or published messages received from the OBCOM NetServer.final boolean
Returnstrue
if login is performed after connecting to OBCOM NetServer.final Collection
<NetServerClient> Returns a collection with all clients of thisNetServerChannel
.final boolean
Returnstrue
if all messages are sent encrypted to OBCOM NetServer.final Layout
Returns theLayout
with the specifiedname
.final URI
Returns the URI used to download the required messages layouts.final boolean
Returnstrue
ifNetServerChannel
errors are logged.final NetServerManager
Returns the NetServerManager of thisNetServerChannel
.final int
Returns the number of multicast messages this channel has read.final String
getName()
Returns the name of thisNetServerChannel
.final URI
Returns the protocol, host and port of the OBCOM NetServer.final int
Returns the number of bytes this channel has read.final int
Returns the number of messages this channel has read.final String
Returns the name of the station of this channel.final String
Returns the serial number of the station of this channel.final boolean
Returnstrue
if the signatures of downloaded layouts are verified.final int
Returns the number of bytes this channel has written.final int
Returns the number of messages this channel has written.final boolean
isAlive()
Returnstrue
if thisNetServerChannel
is alive.final boolean
Returnstrue
if connected to the OBCOM NetServer.final boolean
Returnstrue
if tracing inbound and outbound messages.protected void
Called once to generate log message with the properties of this channel.void
release()
Closes thisNetServerChannel
, relinquishing any underlying resources.final void
removeListener
(ConnectionListener listener) Removes the supplied connecion listener from this channel.final void
removeListener
(MessageListener listener) Removes the supplied message listener from this channel.final void
setAutoAssignLayout
(boolean value) Changes whether theassignLayout
method is automatically applied to all reply or published messages received from the OBCOM NetServer.final void
setLogChannelErrors
(boolean value) Changes whetherNetServerChannel
errors are logged..final void
setStationName
(String name) Changes the name of the station of this channel.final void
setStationSerial
(String serial) Changes the serial number of the station of this channel.final void
setVerifyLayoutSignatures
(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()Returnstrue
if connected to the OBCOM NetServer.- Returns:
true
if connected to the OBCOM NetServer.
-
isAlive
public final boolean isAlive()Returnstrue
if thisNetServerChannel
is alive. ANetServerChannel
becomes dead when a system operator executes the "kill client
" command in an OBCOM NetServer console.- Returns:
true
if thisNetServerChannel
is alive.
-
getEncryptAll
public final boolean getEncryptAll()Returnstrue
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()Returnstrue
if login is performed after connecting to OBCOM NetServer.- Returns:
true
if 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
- ifname
is 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
- ifserial
is invalid.
-
addListener
Adds the supplied connecion listener to this channel.- Parameters:
listener
- the connecion listener to add to this channel.- Throws:
NullPointerException
- iflistener
isnull
.
-
removeListener
Removes the supplied connecion listener from this channel.- Parameters:
listener
- the connecion listener to remove from this channel.- Throws:
NullPointerException
- iflistener
isnull
.
-
addListener
Adds the supplied message listener to this channel.- Parameters:
listener
- the message listener to add to this channel.- Throws:
NullPointerException
- iflistener
isnull
.
-
removeListener
Removes the supplied message listener from this channel.- Parameters:
listener
- the message listener to remove from this channel.- Throws:
NullPointerException
- iflistener
isnull
.
-
isTracing
public final boolean isTracing()Returnstrue
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()Returnstrue
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
- iftrue
the signatures of downloaded layouts will be verified. Otherwise the signatures will be assigned to layouts without verification.
-
getLayout
Returns theLayout
with 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
Layout
with the specifiedname
. - Throws:
NullPointerException
- ifname
isnull
.Exception
- if an error occurs while loading the layout.
-
getAutoAssignLayout
public final boolean getAutoAssignLayout()Returnstrue
if theassignLayout
method is automatically applied to all reply or published messages received from the OBCOM NetServer.- Returns:
true
if theassignLayout
method is applied to all reply or published messages.
-
setAutoAssignLayout
public final void setAutoAssignLayout(boolean value) Changes whether theassignLayout
method is automatically applied to all reply or published messages received from the OBCOM NetServer.- Parameters:
value
- iftrue
theassignLayout
method will be applied to all reply or published messages.
-
assignLayout
Themessage
is assigned the layout identified by itsLayoutName
label. If themessage
has no such label, then nothing is done. If themessage
has aLayoutSignature
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
- ifmessage
isnull
.IllegalArgumentException
- if the signatures of themessage
and 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
- ifdescription
isnull
.
-
logChannelProperties
protected void logChannelProperties()Called once to generate log message with the properties of this channel. -
getLogChannelErrors
public final boolean getLogChannelErrors()Returnstrue
ifNetServerChannel
errors are logged.- Returns:
true
ifNetServerChannel
errors are logged.
-
setLogChannelErrors
public final void setLogChannelErrors(boolean value) Changes whetherNetServerChannel
errors are logged..- Parameters:
value
- iftrue
channel errors are logged.
-
release
public void release()Closes thisNetServerChannel
, relinquishing any underlying resources. No other method of thisNetServerChannel
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.
-