Class Server
java.lang.Object
com.lightstreamer.adapters.remote.Server
- Direct Known Subclasses:
DataProviderServer
,MetadataProviderServer
A generic Remote Server object, which can run a Remote Data or Metadata Adapter
and connect it to the Proxy Adapter running on Lightstreamer Server.
The object should be provided with a suitable Adapter instance and with suitable local initialization parameters and established connections, then activated through
The Remote Server will take care of sending keepalive packets on the connections when needed. The interval can be configured through the custom "lightstreamer.keepalive.millis" system property, where a value of 0 or negative means no keepalives. By default, it is set to 10000 ms.
However, if a stricter interval is requested by the Proxy Adapter on startup, it will be obeyed (with a safety minimum of 1 second). This should ensure that the Proxy Adapter activity checks will always succeed, but for some old versions of the Proxy Adapter.
The object should be provided with a suitable Adapter instance and with suitable local initialization parameters and established connections, then activated through
start()
and finally disposed through close()
.
If any preliminary initialization on the supplied Adapter
implementation object has to be performed, it should be done through
a custom, dedicated method before invoking start()
.
Further reuse of the same instance is not supported.The Remote Server will take care of sending keepalive packets on the connections when needed. The interval can be configured through the custom "lightstreamer.keepalive.millis" system property, where a value of 0 or negative means no keepalives. By default, it is set to 10000 ms.
However, if a stricter interval is requested by the Proxy Adapter on startup, it will be obeyed (with a safety minimum of 1 second). This should ensure that the Proxy Adapter activity checks will always succeed, but for some old versions of the Proxy Adapter.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionfinal void
close()
Stops the management of the Remote Adapter and destroys the threads used by this Server.final ExceptionHandler
Gets the handler for error conditions occurring on the Remote Server.final String
getName()
Gets the name, used for logging purposes, associated to the Server instance.final String
Gets the password credential to be sent to the Proxy Adapter upon connection.
The default value is null.final String
Gets the user-name credential to be sent to the Proxy Adapter upon connection.
The default value is null.final OutputStream
Gets the stream used by the Remote Adapter in order to forward the answers to the Proxy Adapter.final InputStream
Gets the stream used by the Proxy Adapter in order to forward the requests to the Remote Adapter.final void
setExceptionHandler
(ExceptionHandler handler) Sets the handler for error conditions occurring on the Remote Server.static void
setLoggerProvider
(com.lightstreamer.log.LoggerProvider loggerProvider) Static method that permits to configure the logging system used by the library.final void
Sets a name for the Server instance; used for logging purposes.final void
setRemotePassword
(String password) Sets the password credential to be sent to the Proxy Adapter upon connection.final void
setRemoteUser
(String user) Sets the user-name credential to be sent to the Proxy Adapter upon connection.final void
setReplyStream
(OutputStream outputStream) Sets the stream used by the Remote Adapter in order to forward the answers to the Proxy Adapter.final void
setRequestStream
(InputStream inputStream) Sets the stream used by the Proxy Adapter in order to forward the requests to the Remote Adapter.final void
start()
Starts the communication between the Remote Adapter and the Proxy Adapter through the supplied streams.
-
Constructor Details
-
Server
public Server()
-
-
Method Details
-
setName
Sets a name for the Server instance; used for logging purposes.- Parameters:
name
- a name to identify the instance.
-
getName
Gets the name, used for logging purposes, associated to the Server instance.- Returns:
- the name for the Server instance.
-
setRemoteUser
Sets the user-name credential to be sent to the Proxy Adapter upon connection. The credentials are needed only if the Proxy Adapter is configured to require Remote Adapter authentication.
The default value is null.- Parameters:
user
- a user name.
-
setRemotePassword
Sets the password credential to be sent to the Proxy Adapter upon connection. The credentials are needed only if the Proxy Adapter is configured to require Remote Adapter authentication.
The default value is null.- Parameters:
password
- a password.
-
getRemoteUser
Gets the user-name credential to be sent to the Proxy Adapter upon connection.
The default value is null.- Returns:
- the user-name credential or null.
-
getRemotePassword
Gets the password credential to be sent to the Proxy Adapter upon connection.
The default value is null.- Returns:
- the password credential or null.
-
setRequestStream
Sets the stream used by the Proxy Adapter in order to forward the requests to the Remote Adapter.- Parameters:
inputStream
- the stream used by the Proxy Adapter in order to forward the requests to the Remote Adapter
-
getRequestStream
Gets the stream used by the Proxy Adapter in order to forward the requests to the Remote Adapter.- Returns:
- the stream used by the Proxy Adapter in order to forward the requests to the Remote Adapter
-
setReplyStream
Sets the stream used by the Remote Adapter in order to forward the answers to the Proxy Adapter.- Parameters:
outputStream
- the stream used by the Remote Adapter in order to forward the answers to the Proxy Adapter.
-
getReplyStream
Gets the stream used by the Remote Adapter in order to forward the answers to the Proxy Adapter.- Returns:
- the stream used by the Remote Adapter in order to forward the answers to the Proxy Adapter.
-
setExceptionHandler
Sets the handler for error conditions occurring on the Remote Server. By setting the handler, it's possible to override the default exception handling.- Parameters:
handler
- the handler for error conditions occurring on the Remote Server.
-
getExceptionHandler
Gets the handler for error conditions occurring on the Remote Server.- Returns:
- the handler for error conditions occurring on the Remote Server.
-
start
public final void start() throws RemotingException, DataProviderException, MetadataProviderExceptionStarts the communication between the Remote Adapter and the Proxy Adapter through the supplied streams. Then, requests issued by the Proxy Adapter are received and forwarded to the Remote Adapter. Note that the Remote Adapter initialization is not done now, but it will be triggered by the Proxy Adapter and any initialization error will be just notified to the Proxy Adapter.- Throws:
RemotingException
- An error occurred while setting up the communication channels. The adapter was not started.DataProviderException
- No longer thrown.MetadataProviderException
- No longer thrown.
-
close
public final void close()Stops the management of the Remote Adapter and destroys the threads used by this Server. This instance can no longer be used.
The streams supplied to this instance are also closed.
Note that this does not stop the supplied Remote Adapter, as no close method is available in the Remote Adapter interface. If the process is not terminating, then the Remote Adapter cleanup should be performed by accessing the supplied Adapter instance directly and calling custom methods. -
setLoggerProvider
public static void setLoggerProvider(@Nullable com.lightstreamer.log.LoggerProvider loggerProvider) Static method that permits to configure the logging system used by the library. The logging system must respect the LoggerProvider interface. A custom class can be used to wrap any third-party Java logging system.
If no logging system is specified, all the generated log is discarded.
The following categories are available to be consumed:- com.lightstreamer.adapters.remote.Server:
with various subloggers, logs the activity of this class and its subclasses;
at INFO level, adapter lifecycle events are logged;
at DEBUG level, request handling is logged. - com.lightstreamer.adapters.remote.RequestReply:
with various subloggers, logs the message exchange activity;
at INFO level, connection handling lifecycle events are logged;
at DEBUG level, inbound and outbound message details are logged.
- Parameters:
loggerProvider
- A LoggerProvider instance that will be used to generate log messages by the library classes.
- com.lightstreamer.adapters.remote.Server:
-