org.softamis.cluster4spring.support.provider
Class MultiURLEndpointProvider<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>
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
Direct Known Subclasses:
AbstractUrlListEndpointProvider

public abstract class MultiURLEndpointProvider<E extends Endpoint<SI>,SI extends ServiceMoniker>
extends BaseEndpointProvider<E,SI>
implements org.springframework.beans.factory.InitializingBean

Base abstract class to implement endpoint providers that hangle situation with several endpoints available for the same service. Since the same service could exists in several locations, it is possible that there will be several endpoints for the same service available.

Author:
Andrew Sazonov

Field Summary
protected  EndpointSelectionPolicy<E,SI> fEndpointSelectionPolicy
          Policy used to select endpoints for invocation
 
Fields inherited from class org.softamis.cluster4spring.support.provider.BaseEndpointProvider
fCacheEndpoints
 
Constructor Summary
protected MultiURLEndpointProvider()
           
 
Method Summary
 void afterPropertiesSet()
          Invoked by Spring as part of bean lifecycle.
protected  void createDefaultEndpointSelectionPolicy()
          Creates default endpoints selection policy if one is not specified explicitely.
 E getEndpoint(org.springframework.remoting.support.RemoteInvocationFactory aRemoteInvocationFactory, EndpointFactory<E,SI> aEndpointFactory, java.lang.String aBeanName)
          Returns endpoint that will be used for remote service invocation.
protected abstract  java.util.List<E> getServiceEndpointsList(org.springframework.remoting.support.RemoteInvocationFactory aRemoteInvocationFactory, EndpointFactory<E,SI> aEndpointFactory, java.lang.String aBeanName)
          Performs actual obtaining of list of available endpoints.
 void setEndpointSelectionPolicy(EndpointSelectionPolicy<E,SI> aEndpointSelectionPolicy)
          Sets endpoint selection policy used to select endpoints from the list of endpoints available
 
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
 
Methods inherited from interface org.softamis.cluster4spring.support.EndpointProvider
markInvalid, refresh
 

Field Detail

fEndpointSelectionPolicy

protected EndpointSelectionPolicy<E extends Endpoint<SI>,SI extends ServiceMoniker> fEndpointSelectionPolicy
Policy used to select endpoints for invocation

Constructor Detail

MultiURLEndpointProvider

protected MultiURLEndpointProvider()
Method Detail

afterPropertiesSet

public void afterPropertiesSet()
                        throws java.lang.Exception
Invoked by Spring as part of bean lifecycle. Used to check whether endpoints selection policy is specified during bean configuration. If one is not specified, default endpoints selection policy is created.

Specified by:
afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
Throws:
java.lang.Exception
See Also:
createDefaultEndpointSelectionPolicy()

getEndpoint

public E getEndpoint(org.springframework.remoting.support.RemoteInvocationFactory aRemoteInvocationFactory,
                     EndpointFactory<E,SI> aEndpointFactory,
                     java.lang.String aBeanName)
                                   throws org.springframework.remoting.RemoteAccessException
Returns endpoint that will be used for remote service invocation. First, method obtains list of available endpoints. If list is obtained, it delegates selection of endpoint for invocation to EndpointSelectionPolicy and returns accepted endpoint.

Specified by:
getEndpoint in interface EndpointProvider<E extends Endpoint<SI>,SI extends ServiceMoniker>
Parameters:
aRemoteInvocationFactory - factory used to create remote invocations
aEndpointFactory - factory used to create endpoints
aBeanName - name of bean that is used as proxy for remote service
Returns:
endpoint that should be used to remote invocation
Throws:
org.springframework.remoting.RemoteAccessException - thrown if endpoint could not be selected of if there are not currently available endpoints for remote service
See Also:
createDefaultEndpointSelectionPolicy(), setEndpointSelectionPolicy(org.softamis.cluster4spring.support.EndpointSelectionPolicy), getServiceEndpointsList(org.springframework.remoting.support.RemoteInvocationFactory,org.softamis.cluster4spring.support.EndpointFactory,String)

getServiceEndpointsList

protected abstract java.util.List<E> getServiceEndpointsList(org.springframework.remoting.support.RemoteInvocationFactory aRemoteInvocationFactory,
                                                             EndpointFactory<E,SI> aEndpointFactory,
                                                             java.lang.String aBeanName)
                                                                           throws org.springframework.remoting.RemoteAccessException
Performs actual obtaining of list of available endpoints. Inherited classes will implement it to provide implementation-specific functionality.

Parameters:
aRemoteInvocationFactory - factory used for remote invocation
aEndpointFactory - factory used for endpoints creation
aBeanName -
Returns:
list of endpoints available for service
Throws:
org.springframework.remoting.RemoteAccessException

createDefaultEndpointSelectionPolicy

protected void createDefaultEndpointSelectionPolicy()
Creates default endpoints selection policy if one is not specified explicitely.

See Also:
LastAccessTimeEndpointSelectionPolicy

setEndpointSelectionPolicy

public void setEndpointSelectionPolicy(EndpointSelectionPolicy<E,SI> aEndpointSelectionPolicy)
Sets endpoint selection policy used to select endpoints from the list of endpoints available

Parameters:
aEndpointSelectionPolicy -