com.lightstreamer.interfaces.metadata
Class MetadataProviderAdapter

java.lang.Object
  extended by com.lightstreamer.interfaces.metadata.MetadataProviderAdapter
All Implemented Interfaces:
MetadataProvider

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
MetadataProviderAdapter()
           
 
Method Summary
 void customizeUpdate(java.lang.String user, java.lang.String item, CustomizableItemEvent event)
          Called by Lightstreamer Kernel in order to customize events pertaining to an ItemEventBuffer, if such customization has been requested through the enableUpdateCustomization method.
 boolean enableUpdateCustomization(java.lang.String user, java.lang.String item)
          Called by Lightstreamer Kernel to know whether the Metadata Adapter must or must not be given a chance to modify the values carried by the updates for a supplied Item in a push Session owned by a supplied User.
 int getAllowedBufferSize(java.lang.String user, java.lang.String item)
          Called by Lightstreamer Kernel 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 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 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 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 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.
 java.lang.String[] getUserSessions(java.lang.String user)
          Deprecated.  
 void init(java.util.Map params, java.io.File configDir)
          No-op initialization.
 boolean isModeAllowed(java.lang.String user, java.lang.String item, Mode mode)
          Called by Lightstreamer Kernel to ask for the allowance of a publishing Mode for an Item.
 boolean isSelected(java.lang.String user, java.lang.String item, java.lang.String selector, ItemEvent event)
          Called by Lightstreamer Kernel in order to filter events pertaining to an ItemEventBuffer, if the related Item was requested within a table with an associated Selector.
 boolean isSelectorAllowed(java.lang.String user, java.lang.String item, java.lang.String selector)
          Called by Lightstreamer Kernel to ask for the allowance of a Selector for an Item.
 boolean modeMayBeAllowed(java.lang.String item, Mode mode)
          Called by Lightstreamer Kernel to ask for the allowance of a publishing Mode for an Item (for at least one User).
 void notifyNewSession(java.lang.String user, java.lang.String session)
          2-arguments version of the User authentication method.
 void notifyNewSession(java.lang.String user, java.lang.String session, java.util.Map clientContext)
          Called by Lightstreamer Kernel to check that a User is enabled to open a new push Session.
 void notifyNewTables(java.lang.String user, java.lang.String session, TableInfo[] tables)
          Called by Lightstreamer Kernel to check that a User is enabled to add some Tables to a push Session.
 void notifySessionClose(java.lang.String session)
          Called by Lightstreamer Kernel to notify the Metadata Adapter that a push Session has been closed.
 void notifyTablesClose(java.lang.String session, TableInfo[] tables)
          Called by Lightstreamer Kernel to notify the Metadata Adapter that some Tables have been removed from a push Session.
 void notifyUser(java.lang.String user, java.lang.String password)
          2-arguments version of the User authentication method.
 void notifyUser(java.lang.String user, java.lang.String password, java.util.Map httpHeaders)
          Called by Lightstreamer Kernel as a preliminary check that a user is enabled to make Requests to the related Data Providers.
 void notifyUserMessage(java.lang.String user, java.lang.String session, java.lang.String message)
          Called by Lightstreamer Kernel to forward a message received by a User.
 boolean wantsTablesNotification(java.lang.String user)
          Called by Lightstreamer Kernel to know whether the Metadata Adapter must or must not be notified any time a Table 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.interfaces.metadata.MetadataProvider
getItems, getSchema
 

Constructor Detail

MetadataProviderAdapter

public MetadataProviderAdapter()
Method Detail

init

public void init(java.util.Map params,
                 java.io.File configDir)
          throws MetadataProviderException
No-op initialization.

Specified by:
init in interface MetadataProvider
Parameters:
params - not used.
configDir - not used.
Throws:
MetadataProviderException - never thrown.

notifyUser

public void notifyUser(java.lang.String user,
                       java.lang.String password,
                       java.util.Map httpHeaders)
                throws AccessException,
                       CreditsException
Called by Lightstreamer Kernel as a preliminary check that a user is enabled to make Requests to the related Data Providers.
In this default implementation, a simpler 2-arguments version of the method is invoked, where the httpHeaders argument is discarded. This also ensures backward compatibility with old adapter classes derived from this one.
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.
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.

notifyUser

public void notifyUser(java.lang.String user,
                       java.lang.String password)
                throws AccessException,
                       CreditsException
2-arguments version of the User authentication method. In case the 3-arguments version of the method is not overridden, this version of the method is invoked.
In this default implementation, the Metadata Adapter poses no restriction.

Parameters:
user - not used.
password - not used.
Throws:
AccessException - never thrown.
CreditsException - never thrown.

getAllowedMaxBandwidth

public double getAllowedMaxBandwidth(java.lang.String user)
Called by Lightstreamer Kernel 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(java.lang.String user,
                                         java.lang.String item)
Called by Lightstreamer Kernel 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(java.lang.String user,
                                java.lang.String item)
Called by Lightstreamer Kernel 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(java.lang.String user,
                             java.lang.String item,
                             Mode mode)
Called by Lightstreamer Kernel 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(java.lang.String item,
                                Mode mode)
Called by Lightstreamer Kernel 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.

Specified by:
modeMayBeAllowed in interface MetadataProvider
Parameters:
item - not used.
mode - not used.
Returns:
always true.

isSelectorAllowed

public boolean isSelectorAllowed(java.lang.String user,
                                 java.lang.String item,
                                 java.lang.String selector)
Called by Lightstreamer Kernel to ask for the allowance of a Selector for an Item. Typically, a Selector is intended for one Item or for a specific set of Items with some characteristics. In this default implementation, selectors are always allowed.

Specified by:
isSelectorAllowed in interface MetadataProvider
Parameters:
user - not used.
item - not used.
selector - not used.
Returns:
always true, to mean that the Selector is allowed.

isSelected

public boolean isSelected(java.lang.String user,
                          java.lang.String item,
                          java.lang.String selector,
                          ItemEvent event)
Called by Lightstreamer Kernel in order to filter events pertaining to an ItemEventBuffer, if the related Item was requested within a table with an associated Selector. If the return value is true, the event is dispatched to the ItemEventBuffer; otherwise, it is filtered out. In this default implementation, no event is filtered out, regardless of the Selector.

Specified by:
isSelected in interface MetadataProvider
Parameters:
user - not used.
item - not used.
selector - not used.
event - not used.
Returns:
always true, to mean that the event is to be processed by the ItemEventBuffer.

enableUpdateCustomization

public boolean enableUpdateCustomization(java.lang.String user,
                                         java.lang.String item)
Called by Lightstreamer Kernel to know whether the Metadata Adapter must or must not be given a chance to modify the values carried by the updates for a supplied Item in a push Session owned by a supplied User. In this default implementation, updates are never to be modified.

Specified by:
enableUpdateCustomization in interface MetadataProvider
Parameters:
user - not used.
item - not used.
Returns:
always false, to mean that the Kernel should never ask for update values modifications.

customizeUpdate

public void customizeUpdate(java.lang.String user,
                            java.lang.String item,
                            CustomizableItemEvent event)
Called by Lightstreamer Kernel in order to customize events pertaining to an ItemEventBuffer, if such customization has been requested through the enableUpdateCustomization method. In this default implementation, updates are never modified.

Specified by:
customizeUpdate in interface MetadataProvider
Parameters:
user - not used.
item - not used.
event - not used.

getMinSourceFrequency

public double getMinSourceFrequency(java.lang.String item)
Called by Lightstreamer Kernel 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(java.lang.String item)
Called by Lightstreamer Kernel 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 - An Item Name.
Returns:
a value of 0, to mean that no events will be kept in order to satisfy snapshot requests.

notifyUserMessage

public void notifyUserMessage(java.lang.String user,
                              java.lang.String session,
                              java.lang.String message)
                       throws CreditsException,
                              NotificationException
Called by Lightstreamer Kernel 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.
session - not used.
message - not used.
Throws:
CreditsException - always thrown.
NotificationException - never thrown.

getUserSessions

public java.lang.String[] getUserSessions(java.lang.String user)
                                   throws AccessException
Deprecated. 

Called by Lightstreamer Kernel to get the names of the Sessions currently owned by a User. In this default implementation, the Metadata Adapter doesn't provide the functionality.

Specified by:
getUserSessions in interface MetadataProvider
Parameters:
user - not used.
Returns:
never returns.
Throws:
AccessException - always thrown.

notifyNewSession

public void notifyNewSession(java.lang.String user,
                             java.lang.String session,
                             java.util.Map clientContext)
                      throws CreditsException,
                             NotificationException
Called by Lightstreamer Kernel to check that a User is enabled to open a new push Session.
In this default implementation, a simpler 2-arguments version of the method is invoked, where the clientContext argument is discarded. This also ensures backward compatibility with old adapter classes derived from this one.

Specified by:
notifyNewSession in interface MetadataProvider
Parameters:
user - A User name.
session - The name of a new Session.
clientContext - not used.
Throws:
CreditsException
NotificationException

notifyNewSession

public void notifyNewSession(java.lang.String user,
                             java.lang.String session)
                      throws CreditsException,
                             NotificationException
2-arguments version of the User authentication method. In case the 3-arguments version of the method is not overridden, this version of the method is invoked.
In this default implementation, the Metadata Adapter poses no restriction.

Parameters:
user - not used.
session - not used.
Throws:
CreditsException - never thrown.
NotificationException - never thrown.

notifySessionClose

public void notifySessionClose(java.lang.String session)
                        throws NotificationException
Called by Lightstreamer Kernel 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:
session - not used.
Throws:
NotificationException - never thrown.

wantsTablesNotification

public boolean wantsTablesNotification(java.lang.String user)
Called by Lightstreamer Kernel to know whether the Metadata Adapter must or must not be notified any time a Table 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(java.lang.String user,
                            java.lang.String session,
                            TableInfo[] tables)
                     throws CreditsException,
                            NotificationException
Called by Lightstreamer Kernel to check that a User is enabled to add some Tables to a push Session. In this default implementation, the Metadata Adapter poses no restriction. Unless the wantsTablesNotification method is overridden, this method will never be called by Lightstreamer Kernel.

Specified by:
notifyNewTables in interface MetadataProvider
Parameters:
user - not used.
session - not used.
tables - not used.
Throws:
CreditsException - never thrown.
NotificationException - never thrown.

notifyTablesClose

public void notifyTablesClose(java.lang.String session,
                              TableInfo[] tables)
                       throws NotificationException
Called by Lightstreamer Kernel to notify the Metadata Adapter that some Tables 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 method is overridden, this method will never be called by Lightstreamer Kernel.

Specified by:
notifyTablesClose in interface MetadataProvider
Parameters:
session - not used.
tables - not used.
Throws:
NotificationException - never thrown.