Class MetadataProviderAdapter

java.lang.Object
com.lightstreamer.adapters.remote.MetadataProviderAdapter
All Implemented Interfaces:
MetadataProvider
Direct Known Subclasses:
LiteralBasedProvider

public abstract class MetadataProviderAdapter
extends java.lang.Object
implements MetadataProvider
Provides a default implementation of all the MetadataProvider interface methods. Overriding this class may facilitate the coding of simple Metadata Adapters.
  • Constructor Summary

    Constructors
    Constructor Description
    MetadataProviderAdapter()  
  • Method Summary

    Modifier and Type Method Description
    int getAllowedBufferSize​(java.lang.String user, java.lang.String item)
    Called by Lightstreamer Kernel through the Remote Server to ask for the maximum allowed size of the buffer internally used to enqueue subsequent ItemUpdates for the same Item.
    double getAllowedMaxBandwidth​(java.lang.String user)
    Called by Lightstreamer Kernel through the Remote Server to ask for the bandwidth amount to be allowed to a User for a push Session.
    double getAllowedMaxItemFrequency​(java.lang.String user, java.lang.String item)
    Called by Lightstreamer Kernel through the Remote Server to ask for the ItemUpdate frequency to be allowed to a User for a specific Item.
    int getDistinctSnapshotLength​(java.lang.String item)
    Called by Lightstreamer Kernel through the Remote Server to ask for the maximum allowed length for a Snapshot of an Item that has been requested with publishing Mode DISTINCT.
    double getMinSourceFrequency​(java.lang.String item)
    Called by Lightstreamer Kernel through the Remote Server to ask for the minimum ItemEvent frequency from the supplier Data Adapter at which the events for an Item are guaranteed to be delivered to the Clients without loss of information.
    void init​(java.util.Map<java.lang.String,​java.lang.String> parameters, java.lang.String configFile)
    No-op initialization.
    boolean isModeAllowed​(java.lang.String user, java.lang.String item, Mode mode)
    Called by Lightstreamer Kernel through the Remote Server to ask for the allowance of a publishing Mode for an Item.
    boolean modeMayBeAllowed​(java.lang.String item, Mode mode)
    Called by Lightstreamer Kernel through the Remote Server to ask for the allowance of a publishing Mode for an Item (for at least one User).
    void notifyMpnDeviceAccess​(java.lang.String user, java.lang.String sessionID, MpnDeviceInfo device)
    Called by Lightstreamer Kernel through the Remote Server to check that a User is enabled to access the specified MPN device.
    void notifyMpnDeviceTokenChange​(java.lang.String user, java.lang.String sessionID, MpnDeviceInfo device, java.lang.String newDeviceToken)
    Called by Lightstreamer Kernel through the Remote Server to check that a User is enabled to change the token of a MPN device.
    void notifyMpnSubscriptionActivation​(java.lang.String user, java.lang.String sessionID, TableInfo table, MpnSubscriptionInfo mpnSubscription)
    Called by Lightstreamer Kernel through the Remote Server to check that a User is enabled to activate a Push Notification subscription.
    void notifyNewSession​(java.lang.String user, java.lang.String sessionID, java.util.Map<java.lang.String,​java.lang.String> clientContext)
    Called by Lightstreamer Kernel through the Remote Server to check that a User is enabled to open a new push Session.
    void notifyNewTables​(java.lang.String user, java.lang.String sessionID, TableInfo[] tables)
    Called by Lightstreamer Kernel through the Remote Server to check that a User is enabled to add some Tables (i.e.: Subscriptions) to a push Session.
    void notifySessionClose​(java.lang.String sessionID)
    Called by Lightstreamer Kernel through the Remote Server to notify the Metadata Adapter that a push Session has been closed.
    void notifyTablesClose​(java.lang.String sessionID, TableInfo[] tables)
    Called by Lightstreamer Kernel through the Remote Server to notify the Metadata Adapter that some Tables (i.e.: Subscriptions) have been removed from a push Session.
    void notifyUser​(java.lang.String user, java.lang.String password, java.util.Map<java.lang.String,​java.lang.String> httpHeaders)
    Called by Lightstreamer Kernel through the Remote Server as a preliminary check that a user is enabled to make Requests to the related Data Providers.
    void notifyUser​(java.lang.String user, java.lang.String password, java.util.Map<java.lang.String,​java.lang.String> httpHeaders, java.lang.String clientPrincipal)
    Extended version of the User authentication method, invoked by the Server, through the Remote Server, in case the Server has been instructed (through the <use_client_auth> configuration flag) to acquire the client principal from the client TLS/SSL certificate, if available.
    void notifyUserMessage​(java.lang.String user, java.lang.String sessionID, java.lang.String message)
    Called by Lightstreamer Kernel through the Remote Server to forward a message received by a User.
    boolean wantsTablesNotification​(java.lang.String user)
    Called by Lightstreamer Kernel through the Remote Server to know whether the Metadata Adapter must or must not be notified any time a Table (i.e.: Subscription) is added or removed from a push Session owned by a supplied User.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface com.lightstreamer.adapters.remote.MetadataProvider

    getItems, getSchema
  • Constructor Details

    • MetadataProviderAdapter

      public MetadataProviderAdapter()
  • Method Details

    • init

      public void init​(@Nonnull java.util.Map<java.lang.String,​java.lang.String> parameters, @Nullable java.lang.String configFile) throws MetadataProviderException
      No-op initialization.
      Specified by:
      init in interface MetadataProvider
      Parameters:
      parameters - not used.
      configFile - not used.
      Throws:
      MetadataProviderException - never thrown.
    • notifyUser

      public void notifyUser​(@Nullable java.lang.String user, @Nullable java.lang.String password, @Nonnull java.util.Map<java.lang.String,​java.lang.String> httpHeaders) throws AccessException, CreditsException
      Called by Lightstreamer Kernel through the Remote Server as a preliminary check that a user is enabled to make Requests to the related Data Providers.
      In this default implementation, the Metadata Adapter poses no restriction.
      Note that, for authentication purposes, only the user and password arguments should be consulted.
      Specified by:
      notifyUser in interface MetadataProvider
      Parameters:
      user - A User name. Not used.
      password - A password optionally required to validate the User.
      httpHeaders - A Map-type value object that contains a name-value pair for each header found in the HTTP request that originated the call. Not used.
      Throws:
      AccessException - never thrown.
      CreditsException - never thrown.
      See Also:
      MetadataProvider.notifyUser(String, String, Map, String)
    • notifyUser

      public void notifyUser​(@Nullable java.lang.String user, @Nullable java.lang.String password, @Nonnull java.util.Map<java.lang.String,​java.lang.String> httpHeaders, @Nullable java.lang.String clientPrincipal) throws AccessException, CreditsException
      Extended version of the User authentication method, invoked by the Server, through the Remote Server, in case the Server has been instructed (through the <use_client_auth> configuration flag) to acquire the client principal from the client TLS/SSL certificate, if available.
      In this default implementation, the base 3-arguments version of the method is invoked, where the clientPrincipal argument is discarded.
      Edition Note:
      https connections is an optional feature, available depending on Edition and License Type. To know what features are enabled by your license, please see the License tab of the Monitoring Dashboard (by default, available at /dashboard).
      Specified by:
      notifyUser in interface MetadataProvider
      Parameters:
      user - A User name. Not used.
      password - A password optionally required to validate the User.
      httpHeaders - A Map-type value object that contains a name-value pair for each header found in the HTTP request that originated the call.
      clientPrincipal - the identification name reported in the client TLS/SSL certificate supplied on the socket connection used to issue the request that originated the call; it can be null if client has not authenticated itself or the authentication has failed. Not used.
      Throws:
      AccessException - never thrown.
      CreditsException - never thrown.
      See Also:
      MetadataProvider.notifyUser(String, String, Map, String)
    • getAllowedMaxBandwidth

      public double getAllowedMaxBandwidth​(@Nullable java.lang.String user)
      Called by Lightstreamer Kernel through the Remote Server to ask for the bandwidth amount to be allowed to a User for a push Session. In this default implementation, the Metadata Adapter poses no restriction.
      Specified by:
      getAllowedMaxBandwidth in interface MetadataProvider
      Parameters:
      user - not used.
      Returns:
      always zero, to mean no bandwidth limit.
    • getAllowedMaxItemFrequency

      public double getAllowedMaxItemFrequency​(@Nullable java.lang.String user, @Nonnull java.lang.String item)
      Called by Lightstreamer Kernel through the Remote Server to ask for the ItemUpdate frequency to be allowed to a User for a specific Item. In this default implementation, the Metadata Adapter poses no restriction; this also enables unfiltered dispatching for Items subscribed in MERGE or DISTINCT mode.
      Specified by:
      getAllowedMaxItemFrequency in interface MetadataProvider
      Parameters:
      user - not used.
      item - not used.
      Returns:
      always zero, to mean no frequency limit.
    • getAllowedBufferSize

      public int getAllowedBufferSize​(@Nullable java.lang.String user, @Nonnull java.lang.String item)
      Called by Lightstreamer Kernel through the Remote Server to ask for the maximum allowed size of the buffer internally used to enqueue subsequent ItemUpdates for the same Item. In this default implementation, the Metadata Adapter poses no restriction.
      Specified by:
      getAllowedBufferSize in interface MetadataProvider
      Parameters:
      user - not used.
      item - not used.
      Returns:
      always zero, to mean no size limit.
    • isModeAllowed

      public boolean isModeAllowed​(@Nullable java.lang.String user, @Nonnull java.lang.String item, @Nonnull Mode mode)
      Called by Lightstreamer Kernel through the Remote Server to ask for the allowance of a publishing Mode for an Item. A publishing Mode can or cannot be allowed depending on the User. In this default implementation, the Metadata Adapter poses no restriction. As a consequence, conflicting Modes may be both allowed for the same Item, so the Clients should ensure that the same Item cannot be requested in two conflicting Modes.
      Specified by:
      isModeAllowed in interface MetadataProvider
      Parameters:
      user - not used.
      item - not used.
      mode - not used.
      Returns:
      always true.
    • modeMayBeAllowed

      public boolean modeMayBeAllowed​(@Nonnull java.lang.String item, @Nonnull Mode mode)
      Called by Lightstreamer Kernel through the Remote Server to ask for the allowance of a publishing Mode for an Item (for at least one User). In this default implementation, the Metadata Adapter poses no restriction. As a consequence, conflicting Modes may be both allowed for the same Item, so the Clients should ensure that the same Item cannot be requested in two conflicting Modes.
      This is just to simplify the development phase; the final implementation of the method MUST be different, to ensure that conflicting modes (i.e. MERGE, DISTINCT and COMMAND) are not both allowed for the same Item.
      Specified by:
      modeMayBeAllowed in interface MetadataProvider
      Parameters:
      item - not used.
      mode - not used.
      Returns:
      always true.
    • getMinSourceFrequency

      public double getMinSourceFrequency​(@Nonnull java.lang.String item)
      Called by Lightstreamer Kernel through the Remote Server to ask for the minimum ItemEvent frequency from the supplier Data Adapter at which the events for an Item are guaranteed to be delivered to the Clients without loss of information. In case of an incoming ItemEvent frequency greater than the specified frequency, Lightstreamer Kernel may prefilter the events flow down to this frequency. In this default implementation, the Metadata Adapter can't set any minimum frequency; this also enables unfiltered dispatching for Items subscribed in MERGE or DISTINCT mode.
      Specified by:
      getMinSourceFrequency in interface MetadataProvider
      Parameters:
      item - not used.
      Returns:
      always zero, to mean that incoming ItemEvents must not be prefiltered.
    • getDistinctSnapshotLength

      public int getDistinctSnapshotLength​(@Nonnull java.lang.String item)
      Called by Lightstreamer Kernel through the Remote Server to ask for the maximum allowed length for a Snapshot of an Item that has been requested with publishing Mode DISTINCT. In this default implementation, 0 events are specified, so snapshot will not be managed.
      Specified by:
      getDistinctSnapshotLength in interface MetadataProvider
      Parameters:
      item - not used.
      Returns:
      a value of 0, to mean that no events will be kept in order to satisfy snapshot requests.
    • notifyUserMessage

      public void notifyUserMessage​(@Nullable java.lang.String user, @Nonnull java.lang.String sessionID, @Nonnull java.lang.String message) throws CreditsException, NotificationException
      Called by Lightstreamer Kernel through the Remote Server to forward a message received by a User. In this default implementation, the Metadata Adapter does never accept the message.
      Specified by:
      notifyUserMessage in interface MetadataProvider
      Parameters:
      user - not used.
      sessionID - not used.
      message - not used.
      Throws:
      CreditsException - always thrown.
      NotificationException - never thrown.
    • notifyNewSession

      public void notifyNewSession​(@Nullable java.lang.String user, @Nonnull java.lang.String sessionID, @Nonnull java.util.Map<java.lang.String,​java.lang.String> clientContext) throws CreditsException, NotificationException
      Called by Lightstreamer Kernel through the Remote Server to check that a User is enabled to open a new push Session.
      In this default implementation, the Metadata Adapter poses no restriction.
      Specified by:
      notifyNewSession in interface MetadataProvider
      Parameters:
      user - not used.
      sessionID - not used.
      clientContext - not used.
      Throws:
      CreditsException - never thrown.
      NotificationException - never thrown.
    • notifySessionClose

      public void notifySessionClose​(@Nonnull java.lang.String sessionID) throws NotificationException
      Called by Lightstreamer Kernel through the Remote Server to notify the Metadata Adapter that a push Session has been closed. In this default implementation, the Metadata Adapter does nothing, because it doesn't need to remember the open Sessions.
      Specified by:
      notifySessionClose in interface MetadataProvider
      Parameters:
      sessionID - not used.
      Throws:
      NotificationException - never thrown.
    • wantsTablesNotification

      public boolean wantsTablesNotification​(@Nullable java.lang.String user)
      Called by Lightstreamer Kernel through the Remote Server to know whether the Metadata Adapter must or must not be notified any time a Table (i.e.: Subscription) is added or removed from a push Session owned by a supplied User. In this default implementation, the Metadata Adapter doesn't require such notifications.
      Specified by:
      wantsTablesNotification in interface MetadataProvider
      Parameters:
      user - not used.
      Returns:
      always false, to prevent being notified with notifyNewTables and notifyTablesClose.
    • notifyNewTables

      public void notifyNewTables​(@Nullable java.lang.String user, @Nonnull java.lang.String sessionID, @Nonnull TableInfo[] tables) throws CreditsException, NotificationException
      Called by Lightstreamer Kernel through the Remote Server to check that a User is enabled to add some Tables (i.e.: Subscriptions) to a push Session. If the check succeeds, this also notifies the Metadata Adapter that the Tables are being added to the Session. In this default implementation, the Metadata Adapter poses no restriction. Unless the wantsTablesNotification(java.lang.String) method is overridden, this method will never be called.
      Specified by:
      notifyNewTables in interface MetadataProvider
      Parameters:
      user - not used.
      sessionID - not used.
      tables - not used.
      Throws:
      CreditsException - never thrown.
      NotificationException - never thrown.
    • notifyTablesClose

      public void notifyTablesClose​(@Nonnull java.lang.String sessionID, @Nonnull TableInfo[] tables) throws NotificationException
      Called by Lightstreamer Kernel through the Remote Server to notify the Metadata Adapter that some Tables (i.e.: Subscriptions) have been removed from a push Session. In this default implementation, the Metadata Adapter does nothing, because it doesn't need to remember the Tables used. Unless the wantsTablesNotification(java.lang.String) method is overridden, this method will never be called.
      Specified by:
      notifyTablesClose in interface MetadataProvider
      Parameters:
      sessionID - not used.
      tables - not used.
      Throws:
      NotificationException - never thrown.
    • notifyMpnDeviceAccess

      public void notifyMpnDeviceAccess​(@Nullable java.lang.String user, @Nonnull java.lang.String sessionID, @Nonnull MpnDeviceInfo device) throws CreditsException, NotificationException
      Called by Lightstreamer Kernel through the Remote Server to check that a User is enabled to access the specified MPN device. In this default implementation, the Metadata Adapter poses no restriction.
      Edition Note:
      Push Notifications is an optional feature, available depending on Edition and License Type. To know what features are enabled by your license, please see the License tab of the Monitoring Dashboard (by default, available at /dashboard).
      Specified by:
      notifyMpnDeviceAccess in interface MetadataProvider
      Parameters:
      user - not used.
      sessionID - not used.
      device - not used.
      Throws:
      CreditsException - never thrown.
      NotificationException - never thrown.
    • notifyMpnSubscriptionActivation

      public void notifyMpnSubscriptionActivation​(@Nullable java.lang.String user, @Nonnull java.lang.String sessionID, @Nonnull TableInfo table, @Nonnull MpnSubscriptionInfo mpnSubscription) throws CreditsException, NotificationException
      Called by Lightstreamer Kernel through the Remote Server to check that a User is enabled to activate a Push Notification subscription. In this default implementation, the Metadata Adapter poses no restriction.
      Edition Note:
      Push Notifications is an optional feature, available depending on Edition and License Type. To know what features are enabled by your license, please see the License tab of the Monitoring Dashboard (by default, available at /dashboard).
      Specified by:
      notifyMpnSubscriptionActivation in interface MetadataProvider
      Parameters:
      user - not used.
      sessionID - not used.
      table - not used.
      mpnSubscription - not used.
      Throws:
      CreditsException - never thrown.
      NotificationException - never thrown.
    • notifyMpnDeviceTokenChange

      public void notifyMpnDeviceTokenChange​(@Nullable java.lang.String user, @Nonnull java.lang.String sessionID, @Nonnull MpnDeviceInfo device, @Nonnull java.lang.String newDeviceToken) throws CreditsException, NotificationException
      Called by Lightstreamer Kernel through the Remote Server to check that a User is enabled to change the token of a MPN device. In this default implementation, the Metadata Adapter poses no restriction.
      Edition Note:
      Push Notifications is an optional feature, available depending on Edition and License Type. To know what features are enabled by your license, please see the License tab of the Monitoring Dashboard (by default, available at /dashboard).
      Specified by:
      notifyMpnDeviceTokenChange in interface MetadataProvider
      Parameters:
      user - not used.
      sessionID - not used.
      device - not used.
      newDeviceToken - not used.
      Throws:
      CreditsException - never thrown.
      NotificationException - never thrown.