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

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

public class DefaultProvidingRegistry<K extends java.io.Serializable,V extends java.io.Serializable>
extends AbstractProvidingRegistry<K,V>
implements RegistryEventProcessor<K,V>

Default implementation of ProvidingRegistry. It issues network notifications when item is registered and unregistered, but delegates the actual details of network communication to corresponding CommunicationHelper. In addition, it implements methods from RegistryEventProcessor interface which allows this class to handle requests for items that are published by this provider registry. The CommunicationHelper used by instance of this class is source for events processed by RegistryEventProcessor.

Author:
Andrew Sazonov
See Also:
CommunicationHelper

Nested Class Summary
 
Nested classes/interfaces inherited from class org.softamis.net.registry.impl.AbstractProvidingRegistry
AbstractProvidingRegistry.ItemsStorage<K extends java.io.Serializable,V extends java.io.Serializable>, AbstractProvidingRegistry.MultiValueItemsStorage, AbstractProvidingRegistry.SingleValueItemsStorage
 
Field Summary
protected  CommunicationHelper<K,V> fCommunicationHelper
          Communication helper used to isolate details of network communication
protected  java.lang.String fDefaultMessageSignature
           
protected static org.apache.commons.logging.Log fLog
           
 
Fields inherited from class org.softamis.net.registry.impl.AbstractProvidingRegistry
fItemsStorage
 
Constructor Summary
DefaultProvidingRegistry()
           
DefaultProvidingRegistry(boolean aMultivalued)
           
 
Method Summary
 void close()
          Closes ProvidingRegistry.
protected  void doAfterItemRegistered(K aItemKey, V aItem)
          Simply forces CommunicationHelper to issue notification about item registration
protected  void doAfterItemUnregistered(K aItemKey, V aItem)
          Simply forces CommunicationHelper to issue notification about item unregistration
protected  void doInit()
           
 CommunicationHelper<K,V> getCommunicationHelper()
          Returns communication helper used to isolate details of network communication
 java.lang.String getDefaultMessageSignature()
           
 void init()
          Method that performs initialization of the registry provider by additing it as listener to CommunicationHelper used to perform network communication.
protected  void insureCommunicationHelperSet()
           
 void processItemInvalid(ItemEntry<K,V> aEntry)
          Callback for processing CommunicationHelper.COMMAND_ITEM_INVALID notification
 void processItemRegistered(ItemEntry<K,V> aEntry)
          Callback for processing CommunicationHelper.COMMAND_ITEM_REGISTERED notification
 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)
          Callback for processing CommunicationHelper.COMMAND_ITEM_UNREGISTERED notification
 void setCommunicationHelper(CommunicationHelper<K,V> aCommunicationHelper)
          Sets communication helper used to isolate details of network communication
 void setDefaultMessageSignature(java.lang.String aDefaultMessageSignature)
           
 
Methods inherited from class org.softamis.net.registry.impl.AbstractProvidingRegistry
getOwnItems, isMultivalued, notifyAllRegistrations, registerItem, removeOwnItems, unregisterAllItems, unRegisterItem
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

fLog

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

fCommunicationHelper

protected CommunicationHelper<K extends java.io.Serializable,V extends java.io.Serializable> fCommunicationHelper
Communication helper used to isolate details of network communication


fDefaultMessageSignature

protected java.lang.String fDefaultMessageSignature
Constructor Detail

DefaultProvidingRegistry

public DefaultProvidingRegistry()

DefaultProvidingRegistry

public DefaultProvidingRegistry(boolean aMultivalued)
Method Detail

processItemUnregistered

public void processItemUnregistered(ItemEntry<K,V> aEntry)
Description copied from interface: RegistryEventProcessor
Callback for processing CommunicationHelper.COMMAND_ITEM_UNREGISTERED notification

Specified by:
processItemUnregistered in interface RegistryEventProcessor<K extends java.io.Serializable,V extends java.io.Serializable>
Parameters:
aEntry - recevied item entry

processItemRegistered

public void processItemRegistered(ItemEntry<K,V> aEntry)
Description copied from interface: RegistryEventProcessor
Callback for processing CommunicationHelper.COMMAND_ITEM_REGISTERED notification

Specified by:
processItemRegistered in interface RegistryEventProcessor<K extends java.io.Serializable,V extends java.io.Serializable>
Parameters:
aEntry - recevied item entry

processItemInvalid

public void processItemInvalid(ItemEntry<K,V> aEntry)
Description copied from interface: RegistryEventProcessor
Callback for processing CommunicationHelper.COMMAND_ITEM_INVALID notification

Specified by:
processItemInvalid in interface RegistryEventProcessor<K extends java.io.Serializable,V extends java.io.Serializable>
Parameters:
aEntry - recevied item entry

processItemsRequest

public void processItemsRequest(ItemEntry<K,V> aEntry)
Description copied from interface: RegistryEventProcessor
Callback for processing CommunicationHelper.COMMAND_ITEM_REQUEST notification - typically will be processed by ProvidingRegistry

Specified by:
processItemsRequest in interface RegistryEventProcessor<K extends java.io.Serializable,V extends java.io.Serializable>
Parameters:
aEntry - recevied item entry

insureCommunicationHelperSet

protected void insureCommunicationHelperSet()

init

public void init()
Method that performs initialization of the registry provider by additing it as listener to CommunicationHelper used to perform network communication.

NOTE: This method SHOULD be called to let provider registry to handle request for items published.


doInit

protected void doInit()

close

public void close()
Closes ProvidingRegistry. During closing, ProvidingRegistry first removes iteself from the list of listeners in CommunicationHelper (and thus stopping processing of incoming requests for items) and then issues "item unregistered" notifications for all items were published via this particular ProvidingRegistry.


doAfterItemUnregistered

protected void doAfterItemUnregistered(K aItemKey,
                                       V aItem)
Simply forces CommunicationHelper to issue notification about item unregistration

Specified by:
doAfterItemUnregistered in class AbstractProvidingRegistry<K extends java.io.Serializable,V extends java.io.Serializable>
Parameters:
aItemKey - key of the item which was unregistered
aItem - the item unregistered

doAfterItemRegistered

protected void doAfterItemRegistered(K aItemKey,
                                     V aItem)
Simply forces CommunicationHelper to issue notification about item registration

Specified by:
doAfterItemRegistered in class AbstractProvidingRegistry<K extends java.io.Serializable,V extends java.io.Serializable>
Parameters:
aItemKey - key of the item which was registered
aItem - the item registered

getCommunicationHelper

public CommunicationHelper<K,V> getCommunicationHelper()
Returns communication helper used to isolate details of network communication

Returns:
communication helper used to isolate details of network communication

setCommunicationHelper

public void setCommunicationHelper(CommunicationHelper<K,V> aCommunicationHelper)
Sets communication helper used to isolate details of network communication

Parameters:
aCommunicationHelper - communication helper used to isolate details of network communication

getDefaultMessageSignature

public java.lang.String getDefaultMessageSignature()

setDefaultMessageSignature

public void setDefaultMessageSignature(java.lang.String aDefaultMessageSignature)