Class Server

java.lang.Object
com.lightstreamer.adapters.remote.Server
Direct Known Subclasses:
DataProviderServer, MetadataProviderServer

public abstract class Server extends Object
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 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

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    final void
    Stops the management of the Remote Adapter and destroys the threads used by this Server.
    Gets the handler for error conditions occurring on the Remote Server.
    final String
    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.
    Gets the stream used by the Remote Adapter in order to forward the answers to the Proxy Adapter.
    Gets the stream used by the Proxy Adapter in order to forward the requests to the Remote Adapter.
    final void
    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
    Sets the password credential to be sent to the Proxy Adapter upon connection.
    final void
    Sets the user-name credential to be sent to the Proxy Adapter upon connection.
    final void
    Sets the stream used by the Remote Adapter in order to forward the answers to the Proxy Adapter.
    final void
    Sets the stream used by the Proxy Adapter in order to forward the requests to the Remote Adapter.
    final void
    Starts the communication between the Remote Adapter and the Proxy Adapter through the supplied streams.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Server

      public Server()
  • Method Details

    • setName

      public final void setName(@Nonnull 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 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 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 default value is null.
      Parameters:
      user - a user name.
    • setRemotePassword

      public final void setRemotePassword(@Nullable 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 default value is null.
      Parameters:
      password - a password.
    • getRemoteUser

      @Nullable public final String 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

      @Nullable public final String 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

      public final void setRequestStream(@Nonnull 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 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 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 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.
    • 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

      Starts 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.