org.softamis.cluster4spring.support
Interface EndpointProvider<E extends Endpoint<SI>,SI extends ServiceMoniker>

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 Known Implementing Classes:
AbstractDiscoveringEndpointProvider, AbstractUrlListEndpointProvider, BaseEndpointProvider, DiscoveringEndpointProvider, DiscoveringEndpointProviderEx, MultiURLEndpointProvider, RmiDiscoveringEndpointProvider, SingleUrlEndpointProvider, UrlListEndpointProvider

public interface EndpointProvider<E extends Endpoint<SI>,SI extends ServiceMoniker>

Provides endpoints for remote service. Since the same service could exists in several locations, it is possible that there will be several endpoints for the same service available. This class provides endpoint via which remote call will be executed (based on list of available service locations).

Since in the distributed environment some servers that provide service could become unavailable, endpoints may become invalid. If cluster4spring-related exception occured during endpoint invocation, the calling code may be aware about this fact and mark particular endpoint invalid (so it will not be selected during subsequent invocations of service). As side effect of marking service invalid (if service is autodiscovered), appropriate network notification could be issued to other clients in cluster which use the same remote services.

If there are several endpoints for the same service exist, the problem of selecting particular one of them for invocation occurs. In general, EndpointProvider delegates selection of endpoint to invocation to appropriate EndpointSelectionPolicy

Author:
Andrew Sazonov
See Also:
EndpointSelectionPolicy

Method Summary
 E getEndpoint(org.springframework.remoting.support.RemoteInvocationFactory aRemoteInvocationFactory, EndpointFactory<E,SI> aEndpointFactory, java.lang.String aBeanName)
          Returns endpoint that should be used for remote service invocation
 void markInvalid(java.lang.String aBeanName, E aEndpoint)
          Marks given endpoint invalid.
 void refresh(org.springframework.remoting.support.RemoteInvocationFactory aRemoteInvocationFactory, EndpointFactory<E,SI> aEndpointFactory, java.lang.String aBeanName)
          Refreshes internal state of provider.
 

Method Detail

getEndpoint

E getEndpoint(org.springframework.remoting.support.RemoteInvocationFactory aRemoteInvocationFactory,
              EndpointFactory<E,SI> aEndpointFactory,
              java.lang.String aBeanName)
                                   throws org.springframework.remoting.RemoteAccessException
Returns endpoint that should be used for remote service invocation

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

markInvalid

void markInvalid(java.lang.String aBeanName,
                 E aEndpoint)
Marks given endpoint invalid. This endpoint will not be later used for methods invocation.

Parameters:
aBeanName - name of bean that is used as proxy for remote service
aEndpoint - endpoint to be marked invalid

refresh

void refresh(org.springframework.remoting.support.RemoteInvocationFactory aRemoteInvocationFactory,
             EndpointFactory<E,SI> aEndpointFactory,
             java.lang.String aBeanName)
             throws org.springframework.remoting.RemoteAccessException
Refreshes internal state of provider. As result of this method call, provider may lookup and create underlying endpoints for remote service, update own internal caches etc.

Parameters:
aRemoteInvocationFactory - factory used to create remote invocation
aEndpointFactory - factory used to create endpoints
aBeanName - name of bean that is used as proxy for remote service
Throws:
org.springframework.remoting.RemoteAccessException - throw if exception occured during refreshing