|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.softamis.cluster4spring.support.provider.BaseEndpointProvider<E,SI> org.softamis.cluster4spring.support.provider.MultiURLEndpointProvider<E,SI> org.softamis.cluster4spring.support.provider.AbstractUrlListEndpointProvider<E,SI> org.softamis.cluster4spring.support.provider.AbstractDiscoveringEndpointProvider<E,SI> org.softamis.cluster4spring.support.provider.DiscoveringEndpointProvider<E,SI> org.softamis.cluster4spring.support.provider.DiscoveringEndpointProviderEx<E,SI>
SI
- type of data used to invoke remote service (such as remote service URL)E
- type of endpoints that could be created by this factorypublic class DiscoveringEndpointProviderEx<E extends Endpoint<SI>,SI extends ServiceMoniker>
Implementation of EndpointProvider
that automatically discovers
services based on service name and service group. Such auto-discoverable
services are published via appropriate ServicePublisher
.
To discover urls for service, class relies on ConsumingRegistry
that handles details of networking communications.
DiscoveringEndpointProvider
determines when refresh of
endpoints should be performed (if configured to cache endpoints) based on
state of networking registry, this class (if configured to cache endpoints)
acts as listener of ConsumingRegistry
and is able to create/remove
service endpoints as soon as appropriate service url is registered/unregistered
in distributed registry.
If configured not to cache endpoints, it behaves exatly as DiscoveringEndpointProvider
ConsumingRegistry
,
BaseEndpointProvider.setCacheEndpoints(boolean)
Field Summary | |
---|---|
protected boolean |
fCheckRegistryDirty
|
protected EndpointFactory<E,SI> |
fEndpointFactory
Factory used to create endpoints |
protected boolean |
fListenRegistry
Option that specifies whether provider should register itself as listener for ConsumingRegistry |
protected org.springframework.remoting.support.RemoteInvocationFactory |
fRemoteInvocationFactory
Factory used to create remote invocations |
Fields inherited from class org.softamis.cluster4spring.support.provider.DiscoveringEndpointProvider |
---|
fClientServicesRegistry, fLog |
Fields inherited from class org.softamis.cluster4spring.support.provider.AbstractDiscoveringEndpointProvider |
---|
fProtocolName, fServiceGroup, fServiceKey, fServiceName |
Fields inherited from class org.softamis.cluster4spring.support.provider.AbstractUrlListEndpointProvider |
---|
fCacheLock, fEndpointsCache |
Fields inherited from class org.softamis.cluster4spring.support.provider.MultiURLEndpointProvider |
---|
fEndpointSelectionPolicy |
Fields inherited from class org.softamis.cluster4spring.support.provider.BaseEndpointProvider |
---|
fCacheEndpoints |
Constructor Summary | |
---|---|
DiscoveringEndpointProviderEx()
|
Method Summary | |
---|---|
void |
afterPropertiesSet()
Invoked by Spring as part of bean lifecycle. |
protected void |
checkRemoteInvocationFactory()
|
protected void |
checkServiceName()
|
void |
close()
If provider added itself as listener to the registry, removes listener. |
protected void |
createAndAddEndpointToCache(org.softamis.net.exchange.spi.ItemEntry<java.lang.String,SI> aEntry)
Creates endpoint and adds it to endpoints cache based on service key and service url. |
protected boolean |
equals(java.lang.String aFirst,
java.lang.String aSecond)
|
EndpointFactory<E,SI> |
getEndpointFactory()
Returns factory used to create endpoints. |
org.springframework.remoting.support.RemoteInvocationFactory |
getRemoteInvocationFactory()
Returns factory used to create remote invocations |
void |
init()
Method used for initialization of provider. |
protected boolean |
isApplicableEntry(org.softamis.net.exchange.spi.ItemEntry<java.lang.String,SI> aEntry)
Utility method used to determine whether url obtained as part of ConsumingRegistry notification
is related to service which is processed by current provider. |
boolean |
isListenRegistry()
Returns option that specifies whether provider should register itself as listener for ConsumingRegistry |
protected boolean |
isRefreshRequiredForCachedEndpoints(java.lang.String aServiceKey)
Determines whether refresh for cached endpoints is required. |
protected void |
onContextClosed()
Handles ContextClosed application event. |
protected void |
onContextRefreshed()
Handles ContextRefreshed application event. |
void |
processItemInvalid(org.softamis.net.exchange.spi.ItemEntry<java.lang.String,SI> aEntry)
Callback for processing CommunicationHelper.COMMAND_ITEM_INVALID notification
If url is registered for service that is processed by given provider, removes endpoint from endpoints cache. |
void |
processItemRegistered(org.softamis.net.exchange.spi.ItemEntry<java.lang.String,SI> aEntry)
Callback for processing CommunicationHelper.COMMAND_ITEM_REGISTERED notification. |
void |
processItemsRequest(org.softamis.net.exchange.spi.ItemEntry<java.lang.String,SI> aEntry)
Callback for processing CommunicationHelper.COMMAND_ITEM_REQUEST notification - typically will be processed by
ProvidingRegistry . |
void |
processItemUnregistered(org.softamis.net.exchange.spi.ItemEntry<java.lang.String,SI> aEntry)
Callback for processing CommunicationHelper.COMMAND_ITEM_UNREGISTERED notification. |
protected void |
removeEndpointFromCache(SI aServiceInfo)
Removes endpoint that corresponds to given service url from endpoints cache. |
void |
setEndpointFactory(EndpointFactory<E,SI> aEndpointFactory)
Sets factory used to create endpoints.- should be specified only provider is configured to be listener for registry. |
void |
setListenRegistry(boolean aListenRegistry)
Sets option that specifies whether provider should register itself as listener for ConsumingRegistry |
void |
setRemoteInvocationFactory(org.springframework.remoting.support.RemoteInvocationFactory aRemoteInvocationFactory)
Sets factory used to create remote invocations - should be specified only provider is configured to be listener for registry. |
Methods inherited from class org.softamis.cluster4spring.support.provider.DiscoveringEndpointProvider |
---|
getClientServicesRegistry, invalidateServiceInRegistry, obtainServiceUrlsFromRegistry, saveFreshEndpointsToCache, setClientServicesRegistry |
Methods inherited from class org.softamis.cluster4spring.support.provider.AbstractDiscoveringEndpointProvider |
---|
createServiceKey, doRefreshServiceEndpointsList, getCachedEndpoints, getProtocolName, getServiceGroup, getServiceName, markInvalid, markServiceInvalidInternal, obtainServiceKey, onApplicationEvent, setProtocolName, setServiceGroup, setServiceName |
Methods inherited from class org.softamis.cluster4spring.support.provider.AbstractUrlListEndpointProvider |
---|
doGetCachedEndpoints, getServiceEndpointsList, refresh |
Methods inherited from class org.softamis.cluster4spring.support.provider.MultiURLEndpointProvider |
---|
createDefaultEndpointSelectionPolicy, getEndpoint, setEndpointSelectionPolicy |
Methods inherited from class org.softamis.cluster4spring.support.provider.BaseEndpointProvider |
---|
doCreateServiceEndpoint, isCacheEndpoints, setCacheEndpoints |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected boolean fListenRegistry
ConsumingRegistry
protected org.springframework.remoting.support.RemoteInvocationFactory fRemoteInvocationFactory
protected EndpointFactory<E extends Endpoint<SI>,SI extends ServiceMoniker> fEndpointFactory
protected boolean fCheckRegistryDirty
Constructor Detail |
---|
public DiscoveringEndpointProviderEx()
Method Detail |
---|
public void processItemUnregistered(org.softamis.net.exchange.spi.ItemEntry<java.lang.String,SI> aEntry)
CommunicationHelper.COMMAND_ITEM_UNREGISTERED
notification.
If url is registered for service that is processed by given provider, removes endpoint from endpoints cache.
processItemUnregistered
in interface org.softamis.net.exchange.spi.RegistryEventProcessor<java.lang.String,SI extends ServiceMoniker>
aEntry
- recevied item entrypublic void processItemRegistered(org.softamis.net.exchange.spi.ItemEntry<java.lang.String,SI> aEntry)
CommunicationHelper.COMMAND_ITEM_REGISTERED
notification.
If url is registered for service that is processed by given provider, creates endpoint for obtained url and
adds it to endpoints cache.
processItemRegistered
in interface org.softamis.net.exchange.spi.RegistryEventProcessor<java.lang.String,SI extends ServiceMoniker>
aEntry
- recevied item entryprotected void createAndAddEndpointToCache(org.softamis.net.exchange.spi.ItemEntry<java.lang.String,SI> aEntry)
aEntry
- entry that contains information about service key and service url.public void processItemsRequest(org.softamis.net.exchange.spi.ItemEntry<java.lang.String,SI> aEntry)
CommunicationHelper.COMMAND_ITEM_REQUEST
notification - typically will be processed by
ProvidingRegistry
. In this implementation intentionally does nothing.
processItemsRequest
in interface org.softamis.net.exchange.spi.RegistryEventProcessor<java.lang.String,SI extends ServiceMoniker>
aEntry
- recevied item entrypublic void processItemInvalid(org.softamis.net.exchange.spi.ItemEntry<java.lang.String,SI> aEntry)
CommunicationHelper.COMMAND_ITEM_INVALID
notification
If url is registered for service that is processed by given provider, removes endpoint from endpoints cache.
processItemInvalid
in interface org.softamis.net.exchange.spi.RegistryEventProcessor<java.lang.String,SI extends ServiceMoniker>
aEntry
- recevied item entryprotected void removeEndpointFromCache(SI aServiceInfo)
aServiceInfo
- service urlprotected boolean isRefreshRequiredForCachedEndpoints(java.lang.String aServiceKey)
ConsumingRegistry
,
determines whether endpoints case is empty and if so, returns true.
If is not configured to listen registry, simple checks registry state.
isRefreshRequiredForCachedEndpoints
in class DiscoveringEndpointProvider<E extends Endpoint<SI>,SI extends ServiceMoniker>
aServiceKey
- key used to check whether cahe should be refreshed
ConsumingRegistry.isDirty(java.io.Serializable)
,
setListenRegistry(boolean)
protected boolean isApplicableEntry(org.softamis.net.exchange.spi.ItemEntry<java.lang.String,SI> aEntry)
ConsumingRegistry
notification
is related to service which is processed by current provider.
aEntry
- entry that contains information about service key and service url
true
if obtained entry corresponds service processed by providerprotected boolean equals(java.lang.String aFirst, java.lang.String aSecond)
public void afterPropertiesSet() throws java.lang.Exception
DiscoveringEndpointProvider
afterPropertiesSet
in interface org.springframework.beans.factory.InitializingBean
afterPropertiesSet
in class DiscoveringEndpointProvider<E extends Endpoint<SI>,SI extends ServiceMoniker>
java.lang.Exception
MultiURLEndpointProvider.createDefaultEndpointSelectionPolicy()
protected void checkRemoteInvocationFactory()
protected void checkServiceName()
checkServiceName
in class AbstractDiscoveringEndpointProvider<E extends Endpoint<SI>,SI extends ServiceMoniker>
protected void onContextRefreshed()
AbstractDiscoveringEndpointProvider
ContextRefreshed
application event.
onContextRefreshed
in class AbstractDiscoveringEndpointProvider<E extends Endpoint<SI>,SI extends ServiceMoniker>
AbstractDiscoveringEndpointProvider.onApplicationEvent(ApplicationEvent)
protected void onContextClosed()
AbstractDiscoveringEndpointProvider
ContextClosed
application event. On closing context
clears endpoints cache
onContextClosed
in class AbstractDiscoveringEndpointProvider<E extends Endpoint<SI>,SI extends ServiceMoniker>
AbstractDiscoveringEndpointProvider.onApplicationEvent(ApplicationEvent)
public void init()
init-method
of Spring bean.
public void close()
destroy-method
in Spring definition of bean.
public boolean isListenRegistry()
ConsumingRegistry
true
if provider listens registrypublic void setListenRegistry(boolean aListenRegistry)
ConsumingRegistry
aListenRegistry
- option that specifies that provider should listen registrypublic org.springframework.remoting.support.RemoteInvocationFactory getRemoteInvocationFactory()
public void setRemoteInvocationFactory(org.springframework.remoting.support.RemoteInvocationFactory aRemoteInvocationFactory)
aRemoteInvocationFactory
- factory used to create remote invocationssetListenRegistry(boolean)
public EndpointFactory<E,SI> getEndpointFactory()
public void setEndpointFactory(EndpointFactory<E,SI> aEndpointFactory)
aEndpointFactory
- factory used to create endpointssetListenRegistry(boolean)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |