Class Server
- java.lang.Object
-
- com.lightstreamer.adapters.remote.Server
-
- Direct Known Subclasses:
DataProviderServer,MetadataProviderServer
public abstract class Server extends java.lang.ObjectA 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 initialization parameters and established connections, then activated throughstart()and finally disposed throughclose(). 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
Constructors Constructor Description Server()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Stops the management of the Remote Adapter and destroys the threads used by this Server.ExceptionHandlergetExceptionHandler()Gets the handler for error conditions occurring on the Remote Server.java.lang.StringgetName()Gets the name, used for logging purposes, associated to the Server instance.java.io.OutputStreamgetNotifyStream()Gets the stream used by the Remote Adapter in order to send asyncronous data to the Remote Adapter.java.lang.StringgetRemotePassword()Gets the password credential to be sent to the Proxy Adapter upon connection.java.lang.StringgetRemoteUser()Gets the user-name credential to be sent to the Proxy Adapter upon connection.java.io.OutputStreamgetReplyStream()Gets the stream used by the Remote Adapter in order to forward the answers to the Proxy Adapter.java.io.InputStreamgetRequestStream()Gets the stream used by the Proxy Adapter in order to forward the requests to the Remote Adapter.voidsetExceptionHandler(ExceptionHandler handler)Sets the handler for error conditions occurring on the Remote Server.static voidsetLoggerProvider(com.lightstreamer.log.LoggerProvider loggerProvider)Sets the LoggerProvider instance that will be used by the classes of the library to obtain Logger instances used to propagate internal logging.voidsetName(java.lang.String name)Sets a name for the Server instance; used for logging purposes.voidsetNotifyStream(java.io.OutputStream outputStream)Sets the stream used by the Remote Adapter in order to send asyncronous data to the Remote Adapter.voidsetRemotePassword(java.lang.String password)Sets the password credential to be sent to the Proxy Adapter upon connection.voidsetRemoteUser(java.lang.String user)Sets the user-name credential to be sent to the Proxy Adapter upon connection.voidsetReplyStream(java.io.OutputStream outputStream)Sets the stream used by the Remote Adapter in order to forward the answers to the Proxy Adapter.voidsetRequestStream(java.io.InputStream inputStream)Sets the stream used by the Proxy Adapter in order to forward the requests to the Remote Adapter.voidstart()Starts the communication between the Remote Adapter and the Proxy Adapter through the supplied streams.
-
-
-
Method Detail
-
setName
public final void setName(@Nonnull java.lang.String name)Sets a name for the Server instance; used for logging purposes.- Parameters:
name- a name to identify the instance.
-
getName
@Nonnull public final java.lang.String getName()
Gets the name, used for logging purposes, associated to the Server instance.- Returns:
- the name for the Server instance.
-
setRemoteUser
public final void setRemoteUser(@Nullable java.lang.String user)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 credentials will be sent only if both are non-null.
The default value is null.- Parameters:
user- a user name.
-
setRemotePassword
public final void setRemotePassword(@Nullable java.lang.String password)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 credentials will be sent only if both are non-null.
The default value is null.- Parameters:
password- a password.
-
getRemoteUser
@Nullable public final java.lang.String getRemoteUser()
Gets the user-name credential to be sent to the Proxy Adapter upon connection. The credentials will be sent only if both are non-null.
The default value is null.- Returns:
- the user-name credential or null.
-
getRemotePassword
@Nullable public final java.lang.String getRemotePassword()
Gets the password credential to be sent to the Proxy Adapter upon connection. The credentials will be sent only if both are non-null.
The default value is null.- Returns:
- the password credential or null.
-
setRequestStream
public final void setRequestStream(@Nonnull java.io.InputStream inputStream)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
@Nonnull public final java.io.InputStream 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
public final void setReplyStream(@Nonnull java.io.OutputStream outputStream)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
@Nonnull public final java.io.OutputStream 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.
-
setNotifyStream
public final void setNotifyStream(@Nonnull java.io.OutputStream outputStream)Sets the stream used by the Remote Adapter in order to send asyncronous data to the Remote Adapter. Currently not used and not needed by the Remote Metadata Adapter.- Parameters:
outputStream- the stream used by the Remote Adapter in order to send asyncronous data to the Remote Adapter.
-
getNotifyStream
@Nonnull public final java.io.OutputStream getNotifyStream()
Gets the stream used by the Remote Adapter in order to send asyncronous data to the Remote Adapter. Currently not used and not needed by the Remote Metadata Adapter.- Returns:
- the stream used by the Remote Adapter in order to send asyncronous data to the Remote Adapter.
-
setExceptionHandler
public final void setExceptionHandler(@Nullable ExceptionHandler handler)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
@Nullable public final ExceptionHandler 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. If requested by the initializeOnStart flag in the instance constructor, the Remote Adapter is initialized immediately. Then, requests issued by the Proxy Adapter are received and forwarded to the Remote Adapter. If the Remote Adapter is not initialized immediately, initialization will be triggered by the Proxy Adapter and any initialization error will be just notified to the Proxy Adapter.- Throws:
RemotingException- An error occurred in the initialization phase. The adapter was not started.DataProviderException- An error occurred in the initialization phase. The adapter was not started. Only possible when the Adapter is initialized immediately.MetadataProviderException- An error occurred in the initialization phase. The adapter was not started. Only possible when the Adapter is initialized immediately.
-
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)Sets the LoggerProvider instance that will be used by the classes of the library to obtain Logger instances used to propagate internal logging. Providing a new provider to the library permits to consume the log produced through custom Logger implementation.
As soon as a new LoggerProvider is provided all the instances of Logger already in use in the library are discarded and substituted with instanced obtained from this new instance. If a null value is provided, the default consumers, that discard all the log, are enabled.- Parameters:
loggerProvider- Will be responsible to provide Logger instances to the various classes of the library.
-
-