org.softamis.cluster4spring.support.provider
Class UrlListEndpointProvider<E extends Endpoint<SI>,SI extends ServiceMoniker>

java.lang.Object
  extended by org.softamis.cluster4spring.support.provider.BaseEndpointProvider<E,SI>
      extended by org.softamis.cluster4spring.support.provider.MultiURLEndpointProvider<E,SI>
          extended by org.softamis.cluster4spring.support.provider.AbstractUrlListEndpointProvider<E,SI>
              extended by org.softamis.cluster4spring.support.provider.UrlListEndpointProvider<E,SI>
Type Parameters:
SI - type of data used to invoke remote service (such as remote service URL)
E - type of endpoints that could be created by this factory
All Implemented Interfaces:
EndpointProvider<E,SI>, org.springframework.beans.factory.InitializingBean

public class UrlListEndpointProvider<E extends Endpoint<SI>,SI extends ServiceMoniker>
extends AbstractUrlListEndpointProvider<E,SI>

Implementation of EndpointProvider which uses the list of explicitely specified "url" of the service to create service endpoint. Basically, any object may represent service "url" - it is responsibility of concrete implementation of EndpointFactory to interpret given object and create appropriate endpoint for remote service that could be located based on given "url".

Author:
Andrew Sazonov

Field Summary
protected static org.apache.commons.logging.Log fLog
           
protected  java.util.List<SI> fServiceMonikers
          List of urls used to discover remote service and create service endpoints
 
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
UrlListEndpointProvider()
           
 
Method Summary
 void afterPropertiesSet()
          Invoked by Spring as part of bean' lifecycle.
protected  java.util.List<E> doRefreshServiceEndpointsList(org.springframework.remoting.support.RemoteInvocationFactory aRemoteInvocationFactory, EndpointFactory<E,SI> aEndpointFactory, java.lang.String aBeanName)
          Creates list of endpoints available for service.
 java.util.List<SI> getServiceMonikers()
          Returns list of ServiceMonikers used to discover remote service and create service endpoints
 void markInvalid(java.lang.String aBeanName, E aEndpoint)
          Marks given endpoint invalid.
 void setServiceMonikers(java.util.List<SI> aServiceMonikers)
          Sets list of urls (in form of ServiceMoniker) used to discover remote service and create service endpoints
 void setServiceURLs(java.util.List<java.lang.String> aServiceURL)
          Utility method which allows to specify list of URL when URL of service locations is specified in simple string form.
 
Methods inherited from class org.softamis.cluster4spring.support.provider.AbstractUrlListEndpointProvider
doGetCachedEndpoints, getCachedEndpoints, getServiceEndpointsList, refresh, saveFreshEndpointsToCache
 
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

fLog

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

fServiceMonikers

protected java.util.List<SI extends ServiceMoniker> fServiceMonikers
List of urls used to discover remote service and create service endpoints

Constructor Detail

UrlListEndpointProvider

public UrlListEndpointProvider()
Method Detail

afterPropertiesSet

public void afterPropertiesSet()
                        throws java.lang.Exception
Invoked by Spring as part of bean' lifecycle. In addition to inherited checks, adds checking that list of service urls is specified.

Specified by:
afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
Overrides:
afterPropertiesSet in class AbstractUrlListEndpointProvider<E extends Endpoint<SI>,SI extends ServiceMoniker>
Throws:
java.lang.Exception
See Also:
MultiURLEndpointProvider.createDefaultEndpointSelectionPolicy()

doRefreshServiceEndpointsList

protected java.util.List<E> doRefreshServiceEndpointsList(org.springframework.remoting.support.RemoteInvocationFactory aRemoteInvocationFactory,
                                                          EndpointFactory<E,SI> aEndpointFactory,
                                                          java.lang.String aBeanName)
                                                                        throws org.springframework.remoting.RemoteAccessException
Creates list of endpoints available for service. Method walks on list of specified urls for service and tries to create service endpoint for every url. If creation of service endpoint is failed for some url, method silently handles this and endpoint that corresponds to failed url is not included into resulting list.

Specified by:
doRefreshServiceEndpointsList in class AbstractUrlListEndpointProvider<E extends Endpoint<SI>,SI extends ServiceMoniker>
Parameters:
aRemoteInvocationFactory - factory used to create remote invocation
aEndpointFactory - factory used to create endpoints
aBeanName -
Returns:
list of created endpoints
Throws:
org.springframework.remoting.RemoteAccessException - thrown if after processing of all urls the resulting list of endpoints is empty

markInvalid

public void markInvalid(java.lang.String aBeanName,
                        E aEndpoint)
Marks given endpoint invalid. This endpoint will not be later used for methods invocation. If configured to cache endpoints, removes endpoint from the list of cached endpoints. Otherwise, does nothing.

Parameters:
aBeanName - name of bean that is used as proxy for remote service
aEndpoint - endpoint to be marked invalid
See Also:
BaseEndpointProvider.setCacheEndpoints(boolean)

setServiceMonikers

public void setServiceMonikers(java.util.List<SI> aServiceMonikers)
Sets list of urls (in form of ServiceMoniker) used to discover remote service and create service endpoints

Parameters:
aServiceMonikers - list of urls
See Also:
ServiceMoniker

getServiceMonikers

public java.util.List<SI> getServiceMonikers()
Returns list of ServiceMonikers used to discover remote service and create service endpoints

Returns:
list of urls
See Also:
ServiceMoniker

setServiceURLs

public void setServiceURLs(java.util.List<java.lang.String> aServiceURL)
Utility method which allows to specify list of URL when URL of service locations is specified in simple string form.

Parameters:
aServiceURL -