Class LiteralBasedProvider

  • All Implemented Interfaces:
    MetadataProvider

    public class LiteralBasedProvider
    extends MetadataProviderAdapter
    Simple full implementation of a Metadata Adapter, made available in Lightstreamer SDK.
    The class handles Item List specifications, a special case of Item Group name formed by simply concatenating the names of the Items contained in a List in a space separated way. Similarly, the class handles Field List specifications, a special case of Field Schema name formed by concatenating the names of the contained Fields.
    The resource levels are assigned the same for all Items and Users, according with values that can be supplied together with adapter configuration, inside the "metadata_provider" element that defines the Adapter.
    The return of the getAllowedMaxBandwidth method can be supplied in a "max_bandwidth" parameter; the return of the getAllowedMaxItemFrequency method can be supplied in a "max_frequency" parameter; the return of the getAllowedBufferSize method can be supplied in a "buffer_size" parameter; the return of the getDistinctSnapshotLength method can be supplied in a "distinct_snapshot_length" parameter. All resource limits not supplied are granted as unlimited, but for distinct_snapshot_length, which defaults as 10.
    There are no access restrictions, but an optional User name check is performed if a comma separated list of User names is supplied in an "allowed_users" parameter.
    • Constructor Detail

      • LiteralBasedProvider

        public LiteralBasedProvider()
        Void constructor required by the Remote Server.
    • Method Detail

      • init

        public void init​(java.util.Map<java.lang.String,​java.lang.String> parameters,
                         java.lang.String configFile)
                  throws MetadataProviderException
        Reads configuration settings for user and resource constraints. If some setting is missing, the corresponding constraint is not set.
        Specified by:
        init in interface MetadataProvider
        Overrides:
        init in class MetadataProviderAdapter
        Parameters:
        parameters - Can contain the configuration settings.
        configFile - Not used.
        Throws:
        MetadataProviderException - in case of configuration errors.
      • getItems

        public java.lang.String[] getItems​(java.lang.String user,
                                           java.lang.String sessionID,
                                           java.lang.String itemList)
        Resolves an Item List specification supplied in a Request. The names of the Items in the List are returned.
        Item List Specifications are expected to be formed by simply concatenating the names of the contained Items, in a space separated way.
        Parameters:
        user - A User name.
        sessionID - A Session ID. Not used.
        itemList - An Item List specification.
        Returns:
        An array with the names of the Items in the List.
      • getSchema

        public java.lang.String[] getSchema​(java.lang.String user,
                                            java.lang.String sessionID,
                                            java.lang.String itemList,
                                            java.lang.String fieldList)
        Resolves a Field List specification supplied in a Request. The names of the Fields in the List are returned.
        Field List specifications are expected to be formed by simply concatenating the names of the contained Fields, in a space separated way.
        Parameters:
        user - A User name. Not used.
        sessionID - A Session ID. Not used.
        itemList - The specification of the Item List whose Items the Field List is to be applied to.
        fieldList - A Field List specification.
        Returns:
        An array with the names of the Fields in the List.
      • notifyUser

        public void notifyUser​(java.lang.String user,
                               java.lang.String password,
                               java.util.Map<java.lang.String,​java.lang.String> httpHeaders)
                        throws AccessException
        Checks if a user is enabled to make Requests to the related Data Providers. If a list of User names has been configured, this list is checked. Otherwise, any User name is allowed. No password check is performed.
        Specified by:
        notifyUser in interface MetadataProvider
        Overrides:
        notifyUser in class MetadataProviderAdapter
        Parameters:
        user - A User name.
        password - An optional password. Not used.
        httpHeaders - A Map that contains a name-value pair for each header found in the HTTP request that originated the call. Not used.
        Throws:
        AccessException - if a list of User names has been configured and the supplied name does not belong to the list.
        See Also:
        MetadataProvider.notifyUser(String, String, Map, String)
      • getAllowedMaxBandwidth

        public double getAllowedMaxBandwidth​(java.lang.String user)
        Returns the bandwidth level to be allowed to a User for a push Session.
        Specified by:
        getAllowedMaxBandwidth in interface MetadataProvider
        Overrides:
        getAllowedMaxBandwidth in class MetadataProviderAdapter
        Parameters:
        user - A User name. Not used.
        Returns:
        The bandwidth, in Kbit/sec, as supplied in the Metadata Adapter configuration.
      • getAllowedMaxItemFrequency

        public double getAllowedMaxItemFrequency​(java.lang.String user,
                                                 java.lang.String item)
        Returns the ItemUpdate frequency to be allowed to a User for a specific Item.
        Specified by:
        getAllowedMaxItemFrequency in interface MetadataProvider
        Overrides:
        getAllowedMaxItemFrequency in class MetadataProviderAdapter
        Parameters:
        user - A User name. Not used.
        item - An Item Name. Not used.
        Returns:
        The allowed Update frequency, in Updates/sec, as supplied in the Metadata Adapter configuration.
      • getAllowedBufferSize

        public int getAllowedBufferSize​(java.lang.String user,
                                        java.lang.String item)
        Returns the size of the buffer internally used to enqueue subsequent ItemUpdates for the same Item.
        Specified by:
        getAllowedBufferSize in interface MetadataProvider
        Overrides:
        getAllowedBufferSize in class MetadataProviderAdapter
        Parameters:
        user - A User name. Not used.
        item - An Item Name. Not used.
        Returns:
        The allowed buffer size, as supplied in the Metadata Adapter configuration.
      • getDistinctSnapshotLength

        public int getDistinctSnapshotLength​(java.lang.String item)
        Returns the maximum allowed length for a Snapshot of any Item that has been requested with publishing Mode DISTINCT.
        Specified by:
        getDistinctSnapshotLength in interface MetadataProvider
        Overrides:
        getDistinctSnapshotLength in class MetadataProviderAdapter
        Parameters:
        item - An Item Name.
        Returns:
        The maximum allowed length for the Snapshot, as supplied in the Metadata Adapter configuration. In case no value has been supplied, a default value of 10 events is returned, which is thought to be enough to satisfy typical Client requests.