org.directwebremoting.datasync
Interface StoreProvider<T>

All Known Implementing Classes:
AbstractPerXStoreProvider, AbstractStoreProvider, MapStoreProvider, PerHttpSessionStoreProvider, PerScriptSessionStoreProvider

public interface StoreProvider<T>

A StoreProvider is something like a Map where the API revolves around getting blocks of entries rather than individual entries and it gives you the ability to subscribe to those blocks of data to ask for change updates. These are the types of changes that you would expect from an interface designed for remote access.

Implementing the StoreProvider interface is likely to be hard for many applications. You are advised to begin by extending the AbstractStoreProvider helper class.

In place of Map.Entry, StoreProvider uses Items as it's way to connect objects with their primary keys.

Author:
Joe Walker [joe at getahead dot ltd dot uk]

Method Summary
 void put(java.lang.String itemId, RawData rawData)
          Similar to Map.put(K, V) in adding items to a Store.
 void put(java.lang.String itemId, T value)
          Similar to Map.put(K, V) in adding items to a Store.
 void unsubscribe(StoreChangeListener<T> listener)
          Remove the declaration of interest previously expressed.
 void update(java.util.List<ItemUpdate> changes)
          Make a series of updates to items in the store.
 Item viewItem(java.lang.String itemId)
          Similar to Map.get(java.lang.Object) in fetching items from a Store.
 Item viewItem(java.lang.String itemId, StoreChangeListener<T> listener)
          Similar to Map.get(java.lang.Object) in fetching items from a Store, and request to stay updated to changes in the region.
 MatchedItems viewRegion(StoreRegion region)
          Extract the data referred to by the given region.
 MatchedItems viewRegion(StoreRegion region, StoreChangeListener<T> listener)
          Extract the data referred to by the given region, and request to stay updated to changes in the region.
 

Method Detail

viewItem

Item viewItem(java.lang.String itemId)
Similar to Map.get(java.lang.Object) in fetching items from a Store.

Parameters:
itemId - The ID of the item to fetch
Returns:
The matched item, or null if it was not found

viewItem

Item viewItem(java.lang.String itemId,
              StoreChangeListener<T> listener)
Similar to Map.get(java.lang.Object) in fetching items from a Store, and request to stay updated to changes in the region.

Parameters:
itemId - The ID of the item to fetch
listener - The listener to be notified of changes
Returns:
The matched item, or null if it was not found

viewRegion

MatchedItems viewRegion(StoreRegion region)
Extract the data referred to by the given region.

Parameters:
region - A set of filter and sort criteria to restrict the fetched data

viewRegion

MatchedItems viewRegion(StoreRegion region,
                        StoreChangeListener<T> listener)
Extract the data referred to by the given region, and request to stay updated to changes in the region.

Parameters:
region - A set of filter and sort criteria to restrict the fetched data
listener - The listener to be notified of changes
Returns:
Data that matches the filtering specified in the region.

unsubscribe

void unsubscribe(StoreChangeListener<T> listener)
Remove the declaration of interest previously expressed.

Parameters:
listener - The listener that should no longer be notified

put

void put(java.lang.String itemId,
         RawData rawData)
Similar to Map.put(K, V) in adding items to a Store. A value of null is equivalent to removing the item from the store. Part of the function of put is to convert the data stored in RawData into alterations to data in the store. This boiler plate code is implemented in AbstractStoreProvider.

See notes on Item.getItemId()

Parameters:
itemId - The key (or some mapping) to it.
rawData - Data from the web to be converted and added to the store

put

void put(java.lang.String itemId,
         T value)
Similar to Map.put(K, V) in adding items to a Store. A value of null is equivalent to removing the item from the store.

Parameters:
itemId - The key (or some mapping) to it.
value - The new object to be added to the store

update

void update(java.util.List<ItemUpdate> changes)
Make a series of updates to items in the store.

Parameters:
changes - A list of item IDs along with the attributes to change and the values to change to

Copyright 2008