Class LiteralBasedProvider
java.lang.Object
com.lightstreamer.adapters.remote.MetadataProviderAdapter
com.lightstreamer.adapters.remote.metadata.LiteralBasedProvider
- All Implemented Interfaces:
MetadataProvider
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.
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 Summary
-
Method Summary
Modifier and TypeMethodDescriptionint
getAllowedBufferSize
(String user, String item) Returns the size of the buffer internally used to enqueue subsequent ItemUpdates for the same Item.double
getAllowedMaxBandwidth
(String user) Returns the bandwidth level to be allowed to a User for a push Session.double
getAllowedMaxItemFrequency
(String user, String item) Returns the ItemUpdate frequency to be allowed to a User for a specific Item.int
Returns the maximum allowed length for a Snapshot of any Item that has been requested with publishing Mode DISTINCT.String[]
Resolves an Item List specification supplied in a Request.String[]
Resolves a Field List specification supplied in a Request.void
Reads configuration settings for user and resource constraints.void
Checks if a user is enabled to make Requests to the related Data Providers.Methods inherited from class com.lightstreamer.adapters.remote.MetadataProviderAdapter
getMinSourceFrequency, isModeAllowed, modeMayBeAllowed, notifyMpnDeviceAccess, notifyMpnDeviceTokenChange, notifyMpnSubscriptionActivation, notifyNewSession, notifyNewTables, notifySessionClose, notifyTablesClose, notifyUser, notifyUserMessage, wantsTablesNotification
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
enableTableUnsubscription, getSessionTimeToLive, setListener, wantsFinalTableStatistics
-
Constructor Details
-
LiteralBasedProvider
public LiteralBasedProvider()Void constructor required by the Remote Server.
-
-
Method Details
-
init
Reads configuration settings for user and resource constraints. If some setting is missing, the corresponding constraint is not set.- Specified by:
init
in interfaceMetadataProvider
- Overrides:
init
in classMetadataProviderAdapter
- Parameters:
parameters
- Can contain the configuration settings.configFile
- Not used.- Throws:
MetadataProviderException
- in case of configuration errors.
-
getItems
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
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(String user, String password, Map<String, String> httpHeaders) throws AccessExceptionChecks 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 interfaceMetadataProvider
- Overrides:
notifyUser
in classMetadataProviderAdapter
- 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:
-
getAllowedMaxBandwidth
Returns the bandwidth level to be allowed to a User for a push Session.- Specified by:
getAllowedMaxBandwidth
in interfaceMetadataProvider
- Overrides:
getAllowedMaxBandwidth
in classMetadataProviderAdapter
- Parameters:
user
- A User name. Not used.- Returns:
- The bandwidth, in Kbit/sec, as supplied in the Metadata Adapter configuration.
-
getAllowedMaxItemFrequency
Returns the ItemUpdate frequency to be allowed to a User for a specific Item.- Specified by:
getAllowedMaxItemFrequency
in interfaceMetadataProvider
- Overrides:
getAllowedMaxItemFrequency
in classMetadataProviderAdapter
- 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
Returns the size of the buffer internally used to enqueue subsequent ItemUpdates for the same Item.- Specified by:
getAllowedBufferSize
in interfaceMetadataProvider
- Overrides:
getAllowedBufferSize
in classMetadataProviderAdapter
- 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
Returns the maximum allowed length for a Snapshot of any Item that has been requested with publishing Mode DISTINCT.- Specified by:
getDistinctSnapshotLength
in interfaceMetadataProvider
- Overrides:
getDistinctSnapshotLength
in classMetadataProviderAdapter
- 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.
-