|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.softamis.net.registry.impl.AbstractConsumingRegistry<K,V> org.softamis.net.registry.impl.DefaultConsumingRegistry<K,V>
K
- type of keys used to identify registry itemsV
- type of values stored in the registrypublic class DefaultConsumingRegistry<K extends java.io.Serializable,V extends java.io.Serializable>
Default implementation of ConsumingRegistry
.
It issues network notifications
when item for given key should be requested or given item should be invalidated.
To isolate details of network communication, it delegates the actual details
of network communication to corresponding CommunicationHelper
. In addition,
it implements methods from RegistryEventProcessor
interface which allows this
class to handle notifications about item registrations/undregistration that are
issued by provider registry and also notifications about items invalidation which
could be issued by another ConsumerRegistries.
CommunicationHelper
used by instance of this class is source for events
processed by RegistryEventProcessor.
CommunicationHelper
Field Summary | |
---|---|
static long |
DEFAULT_DISCOVERING_TIMEOUT
Default discovering timeout used if timeout is not specified explicitely. |
protected boolean |
fClosed
Method that indicates whether consumer registry was closed |
protected CommunicationHelper<K,V> |
fCommunicationHelper
CommunicationHelper responsible for performing network communications |
protected java.lang.String |
fDefaultMessageSignature
|
protected long |
fDiscoveringTimeout
Timeout (in ms) used during discovering services. |
protected boolean |
fIssueRequestForInvalidatedService
Option which defines policy how " COMMAND_ITEM_INVALIDATED " notification should be processed by
ConsumingRegistry. |
protected java.util.Map<K,java.util.Set<V>> |
fItems
Items stored in distributed registry. |
protected static org.apache.commons.logging.Log |
fLog
|
protected RegistryEventsMulticaster<K,V> |
fRegistryEventsMulticaster
Processors that are responsible for processing of obtaining external notifications |
Fields inherited from class org.softamis.net.registry.impl.AbstractConsumingRegistry |
---|
fDirtyKeys, fRequestItemsOnInit |
Constructor Summary | |
---|---|
DefaultConsumingRegistry()
|
Method Summary | |
---|---|
void |
addRegistryEventProcessor(RegistryEventProcessor<K,V> aListener)
Adds listener to list of registered RegistryEventProcessors which performs further processing of obtained external notifications |
protected boolean |
checkExternalItemUnregistration(ItemEntry<K,V> aEntry)
Tries to perform unregistration of the item issued by ProvidingRegistry. |
void |
close()
Closed consumer registry. |
protected void |
discoverItems(K aItemKey)
Performs discovering of items that are registered for given key. |
protected java.util.Set<V> |
doGetItems(K aItemKey)
Performs acutual obtaining of items for given key from distributed registry. |
protected void |
doInit()
|
protected void |
doMarkItemInvalid(K aItemKey,
V aItem)
Performs marking item invalid. |
protected void |
doRequestItems(K aItemKey)
Perform actual request for items for particular key |
CommunicationHelper<K,V> |
getCommunicationHelper()
Returns communicationHelper responsible for performing network communications |
java.lang.String |
getDefaultMessageSignature()
|
long |
getDiscoveringTimeout()
Returns timeout (in ms) used during discovering services. |
java.util.Set<K> |
getKeys(boolean aForceRefresh)
Returns set of keys which are available in registry |
void |
init()
Method that performs initialization of the consumer registry by additing it as listener to CommunicationHelper used to perform network communication. |
protected void |
insureCommunicationHelperSet()
|
boolean |
isClosed()
Indicated whether registry it in closed state |
boolean |
isIssueRequestForInvalidatedService()
Returns option which defines policy how " COMMAND_ITEM_INVALIDATED " notification should be processed by
ConsumingRegistry. |
void |
processItemInvalid(ItemEntry<K,V> aEntry)
Handles notification about item which was invalidated by another ConsumingRegistry. |
void |
processItemRegistered(ItemEntry<K,V> aEntry)
Processes notification about item registration issues by ProvidingRegistry. |
void |
processItemsRequest(ItemEntry<K,V> aEntry)
Callback for processing CommunicationHelper.COMMAND_ITEM_REQUEST notification - typically will be processed by
ProvidingRegistry |
void |
processItemUnregistered(ItemEntry<K,V> aEntry)
Processes notification about item unregistration issued by ProvidingRegistry |
void |
removeRegistryEventProcessor(RegistryEventProcessor<K,V> aListener)
Removes listener from list of registered RegistryEventProcessors which performs further processing of obtained external notifications |
void |
setCommunicationHelper(CommunicationHelper<K,V> aCommunicationHelper)
Sets communicationHelper responsible for performing network communications |
void |
setDefaultMessageSignature(java.lang.String aDefaultMessageSignature)
|
void |
setDiscoveringTimeout(long aDiscoveringTimeout)
Sets timeout (in ms) used during discovering services. |
void |
setIssueRequestForInvalidatedService(boolean aIssueRequest)
Sets option which defines policy how " COMMAND_ITEM_INVALIDATED " notification should be processed by
ConsumingRegistry. |
Methods inherited from class org.softamis.net.registry.impl.AbstractConsumingRegistry |
---|
getItems, isDirty, isRequestItemsOnInit, markDirty, markItemInvalid, requestItems, setRequestItemsOnInit |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static final org.apache.commons.logging.Log fLog
protected final java.util.Map<K extends java.io.Serializable,java.util.Set<V extends java.io.Serializable>> fItems
protected CommunicationHelper<K extends java.io.Serializable,V extends java.io.Serializable> fCommunicationHelper
protected boolean fIssueRequestForInvalidatedService
COMMAND_ITEM_INVALIDATED
" notification should be processed by
ConsumingRegistry. If this option is set to true, the ConsumingRegistry will invalidate
item and then issue "COMMAND_ITEM_REQUEST
" for invalidated item key. If this
option is set to false, the ConsumingRegistry will simply invalidate item.
CommunicationHelper
protected long fDiscoveringTimeout
public static final long DEFAULT_DISCOVERING_TIMEOUT
protected boolean fClosed
protected RegistryEventsMulticaster<K extends java.io.Serializable,V extends java.io.Serializable> fRegistryEventsMulticaster
protected java.lang.String fDefaultMessageSignature
Constructor Detail |
---|
public DefaultConsumingRegistry()
Method Detail |
---|
protected void insureCommunicationHelperSet()
public void init() throws java.io.IOException
java.io.IOException
protected void doInit()
public void close()
close
in interface ConsumingRegistry<K extends java.io.Serializable,V extends java.io.Serializable>
public boolean isClosed()
ConsumingRegistry
isClosed
in interface ConsumingRegistry<K extends java.io.Serializable,V extends java.io.Serializable>
true
if registry instance is closed, false otherwiseConsumingRegistry.close()
public java.util.Set<K> getKeys(boolean aForceRefresh)
getKeys
in interface ConsumingRegistry<K extends java.io.Serializable,V extends java.io.Serializable>
aForceRefresh
-
protected java.util.Set<V> doGetItems(K aItemKey)
doGetItems
in class AbstractConsumingRegistry<K extends java.io.Serializable,V extends java.io.Serializable>
aItemKey
- key of items
protected void doRequestItems(K aItemKey)
AbstractConsumingRegistry
doRequestItems
in class AbstractConsumingRegistry<K extends java.io.Serializable,V extends java.io.Serializable>
aItemKey
- key for itemsprotected void doMarkItemInvalid(K aItemKey, V aItem)
doMarkItemInvalid
in class AbstractConsumingRegistry<K extends java.io.Serializable,V extends java.io.Serializable>
aItemKey
- key of the itemaItem
- the item itselfprotected void discoverItems(K aItemKey)
aItemKey
- key of the item.public void processItemsRequest(ItemEntry<K,V> aEntry)
RegistryEventProcessor
CommunicationHelper.COMMAND_ITEM_REQUEST
notification - typically will be processed by
ProvidingRegistry
processItemsRequest
in interface RegistryEventProcessor<K extends java.io.Serializable,V extends java.io.Serializable>
aEntry
- recevied item entrypublic void processItemInvalid(ItemEntry<K,V> aEntry)
fIssueRequestForInvalidatedService
option is set to true,
the method tries to discover items for key stored in the entry.
processItemInvalid
in interface RegistryEventProcessor<K extends java.io.Serializable,V extends java.io.Serializable>
aEntry
- entry marked as invalidpublic void processItemUnregistered(ItemEntry<K,V> aEntry)
processItemUnregistered
in interface RegistryEventProcessor<K extends java.io.Serializable,V extends java.io.Serializable>
aEntry
- entry to registerprotected boolean checkExternalItemUnregistration(ItemEntry<K,V> aEntry)
aEntry
- entry to be unregistered
public void processItemRegistered(ItemEntry<K,V> aEntry)
processItemRegistered
in interface RegistryEventProcessor<K extends java.io.Serializable,V extends java.io.Serializable>
aEntry
- entry to be registered.public void removeRegistryEventProcessor(RegistryEventProcessor<K,V> aListener)
removeRegistryEventProcessor
in interface ConsumingRegistry<K extends java.io.Serializable,V extends java.io.Serializable>
aListener
- processor to be removedpublic void addRegistryEventProcessor(RegistryEventProcessor<K,V> aListener)
addRegistryEventProcessor
in interface ConsumingRegistry<K extends java.io.Serializable,V extends java.io.Serializable>
aListener
- processor to be addedpublic CommunicationHelper<K,V> getCommunicationHelper()
public void setCommunicationHelper(CommunicationHelper<K,V> aCommunicationHelper)
aCommunicationHelper
- communication helperpublic long getDiscoveringTimeout()
public void setDiscoveringTimeout(long aDiscoveringTimeout)
aDiscoveringTimeout
- timeout (in ms) used during discovering services.public boolean isIssueRequestForInvalidatedService()
COMMAND_ITEM_INVALIDATED
" notification should be processed by
ConsumingRegistry. If this option is set to true, the ConsumingRegistry will invalidate
item and then issue "COMMAND_ITEM_REQUEST
" for invalidated item key. If this
option is set to false, the ConsumingRegistry will simply invalidate item.
public void setIssueRequestForInvalidatedService(boolean aIssueRequest)
COMMAND_ITEM_INVALIDATED
" notification should be processed by
ConsumingRegistry. If this option is set to true, the ConsumingRegistry will invalidate
item and then issue "COMMAND_ITEM_REQUEST
" for invalidated item key. If this
option is set to false, the ConsumingRegistry will simply invalidate item.
aIssueRequest
- policy for processing item invalidation notificationspublic java.lang.String getDefaultMessageSignature()
public void setDefaultMessageSignature(java.lang.String aDefaultMessageSignature)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |