org.directwebremoting.datasync
Class AbstractPerXStoreProvider<T>

java.lang.Object
  extended by org.directwebremoting.datasync.AbstractPerXStoreProvider<T>
All Implemented Interfaces:
StoreProvider<T>
Direct Known Subclasses:
PerHttpSessionStoreProvider, PerScriptSessionStoreProvider

public abstract class AbstractPerXStoreProvider<T>
extends java.lang.Object
implements StoreProvider<T>

A raw StoreProvider works on a global basis, so all users share the same data. We envisage a number of ways to sub-divide this. For example, one store per HttpSession, one store per ScriptSession, etc. (The PerX versions of the StoreProvider class). This provides an abstract implementation of the PerX behavior.

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

Constructor Summary
AbstractPerXStoreProvider()
           
 
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.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractPerXStoreProvider

public AbstractPerXStoreProvider()
Method Detail

put

public void put(java.lang.String itemId,
                RawData rawData)
Description copied from interface: StoreProvider
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()

Specified by:
put in interface StoreProvider<T>
Parameters:
itemId - The key (or some mapping) to it.
rawData - Data from the web to be converted and added to the store

put

public void put(java.lang.String itemId,
                T value)
Description copied from interface: StoreProvider
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.

Specified by:
put in interface StoreProvider<T>
Parameters:
itemId - The key (or some mapping) to it.
value - The new object to be added to the store

unsubscribe

public void unsubscribe(StoreChangeListener<T> listener)
Description copied from interface: StoreProvider
Remove the declaration of interest previously expressed.

Specified by:
unsubscribe in interface StoreProvider<T>
Parameters:
listener - The listener that should no longer be notified

update

public void update(java.util.List<ItemUpdate> changes)
Description copied from interface: StoreProvider
Make a series of updates to items in the store.

Specified by:
update in interface StoreProvider<T>
Parameters:
changes - A list of item IDs along with the attributes to change and the values to change to

viewItem

public Item viewItem(java.lang.String itemId)
Description copied from interface: StoreProvider
Similar to Map.get(java.lang.Object) in fetching items from a Store.

Specified by:
viewItem in interface StoreProvider<T>
Parameters:
itemId - The ID of the item to fetch
Returns:
The matched item, or null if it was not found

viewItem

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

Specified by:
viewItem in interface StoreProvider<T>
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

public MatchedItems viewRegion(StoreRegion region)
Description copied from interface: StoreProvider
Extract the data referred to by the given region.

Specified by:
viewRegion in interface StoreProvider<T>
Parameters:
region - A set of filter and sort criteria to restrict the fetched data

viewRegion

public MatchedItems viewRegion(StoreRegion region,
                               StoreChangeListener<T> listener)
Description copied from interface: StoreProvider
Extract the data referred to by the given region, and request to stay updated to changes in the region.

Specified by:
viewRegion in interface StoreProvider<T>
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.

Copyright 2008