org.softamis.net.registry.impl
Class AbstractConsumingRegistry<K extends java.io.Serializable,V extends java.io.Serializable>

java.lang.Object
  extended by org.softamis.net.registry.impl.AbstractConsumingRegistry<K,V>
Type Parameters:
K - type of keys used to identify registry items
V - type of values stored in the registry
All Implemented Interfaces:
ConsumingRegistry<K,V>
Direct Known Subclasses:
DefaultConsumingRegistry

public abstract class AbstractConsumingRegistry<K extends java.io.Serializable,V extends java.io.Serializable>
extends java.lang.Object
implements ConsumingRegistry<K,V>

Base abstract implementation of ConsumingRegistry. Contains all logic related to working with items and marking them as dirty, but leaves actual details of requesting and obtining items to inherited classes.

Author:
Andrew Sazonov
See Also:
ProvidingRegistry

Field Summary
protected  java.util.Set<K> fDirtyKeys
          Set that contains information about "dirty" keys - ones, that were changed due to synchronization
protected static org.apache.commons.logging.Log fLog
           
protected  boolean fRequestItemsOnInit
          Flag that indicates whether items should be requested right after initialization of registry
 
Constructor Summary
protected AbstractConsumingRegistry()
           
 
Method Summary
protected abstract  java.util.Set<V> doGetItems(K aItemKey)
          Performs actual obtaining of items for consumer registry.
protected abstract  void doMarkItemInvalid(K aItemKey, V aItem)
          Actual method that performs marking item as invalid
protected abstract  void doRequestItems(K aItemKey)
          Perform actual request for items for particular key
 java.util.Set<V> getItems(K aItemKey)
          Returns the set of items stored in the distributed registry under given key.
 boolean isDirty(K aItemKey)
          Indicates whether there were any changes in distributed registry occurred due to synchronization since the last call of the getItems() for given key.
 boolean isRequestItemsOnInit()
          Returns flag that indicates whether items should be requested right after initialization of registry
 void markDirty(K aItemKey)
          Method allows to mark some key of items as dirty.
 void markItemInvalid(K aItemKey, V aItem)
          Provides ability to mark specific item stored in the distributed registry as invalid one.
 void requestItems(K aItemKey)
          Initiates requesting of items for given key by sending appropriate notifications to ProvidingRegistries
 void setRequestItemsOnInit(boolean aRequestItemsOnInit)
          Sets flag that indicates whether items should be requested right after initialization of registry
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.softamis.net.registry.ConsumingRegistry
addRegistryEventProcessor, close, getKeys, isClosed, removeRegistryEventProcessor
 

Field Detail

fLog

protected static final org.apache.commons.logging.Log fLog

fDirtyKeys

protected final java.util.Set<K extends java.io.Serializable> fDirtyKeys
Set that contains information about "dirty" keys - ones, that were changed due to synchronization

See Also:
isDirty(K)

fRequestItemsOnInit

protected boolean fRequestItemsOnInit
Flag that indicates whether items should be requested right after initialization of registry

Constructor Detail

AbstractConsumingRegistry

protected AbstractConsumingRegistry()
Method Detail

isDirty

public boolean isDirty(K aItemKey)
Description copied from interface: ConsumingRegistry
Indicates whether there were any changes in distributed registry occurred due to synchronization since the last call of the getItems() for given key.

Specified by:
isDirty in interface ConsumingRegistry<K extends java.io.Serializable,V extends java.io.Serializable>
Parameters:
aItemKey - key for items
Returns:
true if the set of data items stored under the given key was changed since the last call of ConsumingRegistry.getItems(K)
See Also:
ConsumingRegistry.getItems(K)

markDirty

public void markDirty(K aItemKey)
Method allows to mark some key of items as dirty.

Parameters:
aItemKey - key of item

requestItems

public void requestItems(K aItemKey)
Description copied from interface: ConsumingRegistry
Initiates requesting of items for given key by sending appropriate notifications to ProvidingRegistries

Specified by:
requestItems in interface ConsumingRegistry<K extends java.io.Serializable,V extends java.io.Serializable>
Parameters:
aItemKey - if null, will request items for all available keys

doRequestItems

protected abstract void doRequestItems(K aItemKey)
Perform actual request for items for particular key

Parameters:
aItemKey - key for items

getItems

public java.util.Set<V> getItems(K aItemKey)
Description copied from interface: ConsumingRegistry
Returns the set of items stored in the distributed registry under given key.

Specified by:
getItems in interface ConsumingRegistry<K extends java.io.Serializable,V extends java.io.Serializable>
Parameters:
aItemKey - key of items
Returns:
set of items stored under given key

doMarkItemInvalid

protected abstract void doMarkItemInvalid(K aItemKey,
                                          V aItem)
Actual method that performs marking item as invalid

Parameters:
aItemKey - key of item
aItem - particular item

doGetItems

protected abstract java.util.Set<V> doGetItems(K aItemKey)
Performs actual obtaining of items for consumer registry.

Parameters:
aItemKey - key for items
Returns:
set of items stored under given key

markItemInvalid

public void markItemInvalid(K aItemKey,
                            V aItem)
Description copied from interface: ConsumingRegistry
Provides ability to mark specific item stored in the distributed registry as invalid one. It there are several ConsumingRegistries in the same distributed registry, they can be notified of and be handled properly. It's assumed that this call will not affect ProvidingRegistries somehow.

Specified by:
markItemInvalid in interface ConsumingRegistry<K extends java.io.Serializable,V extends java.io.Serializable>
Parameters:
aItemKey - key of the item
aItem - the item which should be marked invalid

isRequestItemsOnInit

public boolean isRequestItemsOnInit()
Returns flag that indicates whether items should be requested right after initialization of registry

Returns:
true if request should be performed after intialization

setRequestItemsOnInit

public void setRequestItemsOnInit(boolean aRequestItemsOnInit)
Sets flag that indicates whether items should be requested right after initialization of registry

Parameters:
aRequestItemsOnInit - true if request should be performed after intialization