|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.remoting.support.RemoteAccessor org.softamis.cluster4spring.support.RemoteInvocationBasedAccessor org.softamis.cluster4spring.support.RemoteClientInterceptor<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 abstract class RemoteClientInterceptor<E extends Endpoint<SI>,SI extends ServiceMoniker>
Interceptor for accessing remote services. It contains only general logic related to invoking remote services.
Field Summary | |
---|---|
protected java.lang.String |
fBeanName
Name of proxy bean registered in spring context |
protected EndpointFactory<E,SI> |
fEndpointFactory
Factory used to create endpoints |
protected EndpointProvider<E,SI> |
fEndpointProvider
Provider for endpoints used for remote services invocation |
protected static org.apache.commons.logging.Log |
fLog
|
protected boolean |
fRefreshEndpointsOnConnectFailure
Specifies whether endpoints provider should be refreshed if connection failure occurs |
protected boolean |
fRefreshEndpointsOnStartup
Specifies whether endpoints should be refreshed on startup |
protected boolean |
fSwitchEndpointOnFailure
Specifies whether different endpoint shoudl be selected if connection failure occurs |
Fields inherited from class org.softamis.cluster4spring.support.RemoteInvocationBasedAccessor |
---|
fRemoteInvocationFactory |
Fields inherited from class org.springframework.remoting.support.RemoteAccessor |
---|
logger |
Constructor Summary | |
---|---|
protected |
RemoteClientInterceptor()
|
Method Summary | |
---|---|
void |
afterPropertiesSet()
Invoked by Spring as part of bean lifecycle and is used to check whether EndpointProvider is specified and perform other
preparations |
protected abstract EndpointFactory<E,SI> |
createDefaultEndpointFactory()
Creates default endpoint factory used to create endpoints. |
protected java.lang.Object |
doInvoke(org.aopalliance.intercept.MethodInvocation aInvocation)
First obtains endpoint for invocation. |
protected abstract java.lang.Object |
doInvoke(org.aopalliance.intercept.MethodInvocation aInvocation,
E aServiceEndpoint)
Performs invocation of given method invocation using given service endpoint |
protected void |
doPreprocessApplicationEvent(org.springframework.context.ApplicationEvent aEvent)
Utility method that is called during processing of application events. |
java.lang.String |
getBeanName()
Returns name of proxy bean registered in spring context |
protected EndpointFactory<E,SI> |
getEndpointFactory()
Returns factory used to create endpoints |
protected abstract java.lang.String |
getProtocol()
Returns protocol which identifies interceptor. |
protected java.lang.Object |
handleRemoteConnectFailure(org.aopalliance.intercept.MethodInvocation aInvocation,
java.lang.Exception aException,
E aServiceEndpoint)
Handles remote connection failure according to specified policies. |
java.lang.Object |
invoke(org.aopalliance.intercept.MethodInvocation aInvocation)
Performs invocation of remote service method. |
protected abstract boolean |
isConnectFailure(org.springframework.remoting.RemoteAccessException aException)
Utility method that is used to determine whether exception represents connect failure or is "normal" application logic specific exception. |
boolean |
isRefreshEndpointsOnConnectFailure()
Returns trues if endpoints provider should be refreshed if connection failure occurs |
boolean |
isRefreshEndpointsOnStartup()
Returns true if endpoints should be refreshed on startup |
boolean |
isSwitchEndpointOnFailure()
Returns specifies whether different endpoint should be selected if connection failure occurs |
protected void |
markServiceInvalid(E aServiceEndpoint)
Marks service denoted by given endpoint as invalid by calling by notifying EndpointProvider |
protected E |
obtainEndpointToExecute()
Provides endpoint that should be used for remote service invocation. |
void |
onApplicationEvent(org.springframework.context.ApplicationEvent aEvent)
Called by Spring and handles application events |
protected void |
onContextClosed()
Handles ContextClosedEvent event. |
protected void |
onContextRefreshed()
Handles ContextRefreshedEvent event. |
void |
prepare()
Called as part of afterPropertiesSet() |
protected java.lang.Object |
refreshAndRetry(org.aopalliance.intercept.MethodInvocation aInvocation)
Refreshes EndpointProvider and tries to invoke invocation again. |
protected void |
refreshEndpointProvider()
Forces refresh of endpoint provider. |
protected java.lang.Object |
retry(org.aopalliance.intercept.MethodInvocation aInvocation)
Invokes given method invocation. |
void |
setBeanName(java.lang.String aName)
Sets name of proxy bean registered in spring context |
protected void |
setEndpointFactory(EndpointFactory<E,SI> aEndpointFactory)
Sets factory used to create endpoints. |
protected void |
setEndpointProvider(EndpointProvider<E,SI> aEndpointProvider)
Sets provider for endpoints used for remote services invocation |
void |
setRefreshEndpointsOnConnectFailure(boolean aRefreshOnFailure)
Set whether to refresh the endpoints on connect failure. |
void |
setRefreshEndpointsOnStartup(boolean aRefreshEndpointsOnStartup)
Sets whether endpoints should be refreshed on startup Default is true |
void |
setSwitchEndpointOnFailure(boolean aSwitchEndpointOnFailure)
Set whether to switch endponts on connect failure (ignore connect failure and simply select different endpoint, if any). |
protected void |
throwRemoteLookupFailureException(java.lang.Throwable aException)
Utility name used to throw RemoteLookupFailureException |
protected void |
throwServiceException(org.springframework.remoting.RemoteAccessException aException)
Utility method that is used to throw reason of RemoteAccessException (if any) or given exception itself. |
Methods inherited from class org.softamis.cluster4spring.support.RemoteInvocationBasedAccessor |
---|
getRemoteInvocationFactory, setRemoteInvocationFactory |
Methods inherited from class org.springframework.remoting.support.RemoteAccessor |
---|
getServiceInterface, setServiceInterface |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static final org.apache.commons.logging.Log fLog
protected java.lang.String fBeanName
protected EndpointProvider<E extends Endpoint<SI>,SI extends ServiceMoniker> fEndpointProvider
protected EndpointFactory<E extends Endpoint<SI>,SI extends ServiceMoniker> fEndpointFactory
protected boolean fRefreshEndpointsOnConnectFailure
protected boolean fSwitchEndpointOnFailure
protected boolean fRefreshEndpointsOnStartup
Constructor Detail |
---|
protected RemoteClientInterceptor()
Method Detail |
---|
public void afterPropertiesSet() throws java.lang.Exception
EndpointProvider
is specified and perform other
preparations
afterPropertiesSet
in interface org.springframework.beans.factory.InitializingBean
java.lang.Exception
public void prepare()
afterPropertiesSet() procedure and
checks whether endpoint factory is specified. If one is not specified,
creates default one.
public void onApplicationEvent(org.springframework.context.ApplicationEvent aEvent)
onApplicationEvent
in interface org.springframework.context.ApplicationListener
aEvent
- application eventprotected void doPreprocessApplicationEvent(org.springframework.context.ApplicationEvent aEvent)
aEvent
- application eventonApplicationEvent(ApplicationEvent)
protected void onContextRefreshed()
ContextRefreshedEvent
event. If specified by appropriate
property, performs refreshing of endpoints.
setRefreshEndpointsOnStartup(boolean)
,
onApplicationEvent(ApplicationEvent)
protected void onContextClosed()
ContextClosedEvent
event. May be overriden by inherited
classes to add additional processing of this event.
onApplicationEvent(ApplicationEvent)
protected void refreshEndpointProvider() throws org.springframework.remoting.RemoteAccessException
org.springframework.remoting.RemoteAccessException
- thrown if occured during refreshing providerpublic java.lang.Object invoke(org.aopalliance.intercept.MethodInvocation aInvocation) throws java.lang.Throwable
toString()
method and delegates further processing to doInvoke()
invoke
in interface org.aopalliance.intercept.MethodInterceptor
aInvocation
- method invocation to invoke remote method
java.lang.Throwable
doInvoke(MethodInvocation)
protected java.lang.Object doInvoke(org.aopalliance.intercept.MethodInvocation aInvocation) throws java.lang.Throwable
aInvocation
- method invocation to invoke
java.lang.Throwable
- application logic specific exception or RemoteAccessException
RemoteAccessException
,
setRefreshEndpointsOnConnectFailure(boolean)
,
setSwitchEndpointOnFailure(boolean)
,
invoke(MethodInvocation)
,
EndpointProvider
protected void throwServiceException(org.springframework.remoting.RemoteAccessException aException) throws java.lang.Throwable
aException
- exception to analyze
java.lang.Throwable
- reason of remote exception or given exceptiondoInvoke(MethodInvocation)
protected java.lang.Object handleRemoteConnectFailure(org.aopalliance.intercept.MethodInvocation aInvocation, java.lang.Exception aException, E aServiceEndpoint) throws java.lang.Throwable
EndpointProvider
.
Actual processing of failure depends on current configuration:
EndpointProvider
and perform invocation again using fresh endpoint.
aInvocation
- the aInvocation that failedaException
- the exception raised on remote aInvocationaServiceEndpoint
- service endpoint with failed invocation
java.lang.Throwable
- an exception raised by the new aInvocation, if failed too.markServiceInvalid(Endpoint)
,
setRefreshEndpointsOnConnectFailure(boolean)
,
setSwitchEndpointOnFailure(boolean)
,
doInvoke(MethodInvocation)
protected java.lang.Object refreshAndRetry(org.aopalliance.intercept.MethodInvocation aInvocation) throws java.lang.Throwable
EndpointProvider
and tries to invoke invocation again.
Called by invoke on connect failure.
aInvocation
- the AOP method aInvocation
java.lang.Throwable
- in case of aInvocation failurehandleRemoteConnectFailure(org.aopalliance.intercept.MethodInvocation,Exception,Endpoint)
,
doInvoke(org.aopalliance.intercept.MethodInvocation)
protected java.lang.Object retry(org.aopalliance.intercept.MethodInvocation aInvocation) throws java.lang.Throwable
aInvocation
- the AOP method aInvocation
java.lang.Throwable
- in case of aInvocation failurehandleRemoteConnectFailure(org.aopalliance.intercept.MethodInvocation,Exception,Endpoint)
,
doInvoke(org.aopalliance.intercept.MethodInvocation)
protected void markServiceInvalid(E aServiceEndpoint)
EndpointProvider
aServiceEndpoint
- service endpoint that should be invalidateddoInvoke(MethodInvocation)
protected abstract java.lang.String getProtocol()
protected abstract EndpointFactory<E,SI> createDefaultEndpointFactory()
protected abstract boolean isConnectFailure(org.springframework.remoting.RemoteAccessException aException)
aException
- exception to analyze
true
if given exception represents connect failureprotected abstract java.lang.Object doInvoke(org.aopalliance.intercept.MethodInvocation aInvocation, E aServiceEndpoint) throws java.lang.Throwable
aInvocation
- the AOP method aInvocationaServiceEndpoint
- endpoint used for remote service invocation
java.lang.Throwable
- in case of aInvocation failureprotected E obtainEndpointToExecute() throws org.springframework.remoting.RemoteLookupFailureException
EndpointProvider
.
org.springframework.remoting.RemoteLookupFailureException
- thrown if EndpointProvider is unable to
provide endpointprotected void throwRemoteLookupFailureException(java.lang.Throwable aException) throws org.springframework.remoting.RemoteLookupFailureException
RemoteLookupFailureException
aException
- original exception
org.springframework.remoting.RemoteLookupFailureException
- thrown exceptionpublic void setRefreshEndpointsOnConnectFailure(boolean aRefreshOnFailure)
false
.
Can be turned on to allow for hot restart of the RMI server.
If a cached RMI stub throws an RMI exception that indicates a
remote connect failure, a fresh proxy will be fetched and the
invocation will be retried.
aRefreshOnFailure
- value of policy, if true - interceptor will
refresh service endpoints if remote failure occured.public boolean isSwitchEndpointOnFailure()
public void setSwitchEndpointOnFailure(boolean aSwitchEndpointOnFailure)
true
aSwitchEndpointOnFailure
- specifies whether different endpoint shoudl be selected if connection failure occurspublic void setRefreshEndpointsOnStartup(boolean aRefreshEndpointsOnStartup)
true
aRefreshEndpointsOnStartup
- specifies whether endpoints should be refreshed on startuppublic void setBeanName(java.lang.String aName)
setBeanName
in interface org.springframework.beans.factory.BeanNameAware
aName
- name of proxy beanprotected void setEndpointProvider(EndpointProvider<E,SI> aEndpointProvider)
aEndpointProvider
- provider for endpointsprotected EndpointFactory<E,SI> getEndpointFactory()
protected void setEndpointFactory(EndpointFactory<E,SI> aEndpointFactory)
aEndpointFactory
- factory used to create endpointscreateDefaultEndpointFactory()
public java.lang.String getBeanName()
public boolean isRefreshEndpointsOnConnectFailure()
public boolean isRefreshEndpointsOnStartup()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |