org.softamis.cluster4spring.rmi
Class AbstractRmiProxyFactoryBean<SI extends ServiceMoniker>

java.lang.Object
  extended by org.springframework.remoting.support.RemoteAccessor
      extended by org.softamis.cluster4spring.support.RemoteInvocationBasedAccessor
          extended by org.softamis.cluster4spring.support.RemoteClientInterceptor<RmiEndpoint<SI>,SI>
              extended by org.softamis.cluster4spring.rmi.support.RmiClientInterceptor<SI>
                  extended by org.softamis.cluster4spring.rmi.AbstractRmiProxyFactoryBean<SI>
All Implemented Interfaces:
java.util.EventListener, org.aopalliance.aop.Advice, org.aopalliance.intercept.Interceptor, org.aopalliance.intercept.MethodInterceptor, org.springframework.beans.factory.BeanFactoryAware, org.springframework.beans.factory.BeanNameAware, org.springframework.beans.factory.FactoryBean, org.springframework.beans.factory.InitializingBean, org.springframework.context.ApplicationListener
Direct Known Subclasses:
AbstractRmiShortFormProxyFactoryBean, RmiProxyFactoryBean

public abstract class AbstractRmiProxyFactoryBean<SI extends ServiceMoniker>
extends RmiClientInterceptor<SI>
implements org.springframework.beans.factory.FactoryBean, org.springframework.beans.factory.BeanFactoryAware

Abstract class used to implement RMI based proxy factory beans

Author:
Andrew Sazonov

Field Summary
protected  org.springframework.beans.factory.BeanFactory fBeanFactory
          Bean factory where bean is included
protected  java.lang.String[] fInterceptorNames
          List of interceptor names that should be registered
protected  boolean fRegisterTraceInterceptor
          Indicates whether trace interceptor should be registered
protected  org.aopalliance.intercept.MethodInterceptor fRemoteInvocationTraceInterceptor
          Interceptor that should be registered to trace remote calls
protected  java.lang.Object fServiceProxy
          Proxy object
 
Fields inherited from class org.softamis.cluster4spring.rmi.support.RmiClientInterceptor
PROTOCOL_RMI
 
Fields inherited from class org.softamis.cluster4spring.support.RemoteClientInterceptor
fBeanName, fEndpointFactory, fEndpointProvider, fRefreshEndpointsOnConnectFailure, fRefreshEndpointsOnStartup, fSwitchEndpointOnFailure
 
Fields inherited from class org.softamis.cluster4spring.support.RemoteInvocationBasedAccessor
fRemoteInvocationFactory
 
Fields inherited from class org.springframework.remoting.support.RemoteAccessor
logger
 
Constructor Summary
AbstractRmiProxyFactoryBean()
           
 
Method Summary
protected  void addSpecifiedAdvices(org.springframework.aop.framework.ProxyFactory aProxyFactory)
          Discovers advices specified in bean definition and adds them to proxy factory used to obtain proxy.
 void afterPropertiesSet()
          Invoked by Spring as part of bean lifecycle and is used to check whether EndpointProvider is specified and perform other preparations
protected  org.aopalliance.intercept.MethodInterceptor createDefaultRemoteInvocationTraceInterceptor()
          Creates default remote invocation trace method interceptor
 EndpointFactory<RmiEndpoint<SI>,SI> getEndpointFactory()
          Returns factory used to create endpoints
 java.lang.String[] getInterceptorNames()
          Returns list of interceptor names that should be registered in proxy factory.
 java.lang.Object getObject()
           
 java.lang.Class getObjectType()
           
protected  java.lang.String getProxyName()
          Returns name of the proxy
 org.aopalliance.intercept.MethodInterceptor getRemoteInvocationTraceInterceptor()
          Returns interceptor that should be registered to trace remote calls
 boolean isRegisterTraceInterceptor()
          Returns indicates whether trace interceptor should be registered.
 boolean isSingleton()
          Is the bean managed by this factory a singleton or a prototype? That is, will getObject() always return the same object?
protected  org.aopalliance.intercept.MethodInterceptor obtainRemoteInvocationTraceInterceptor()
          Utility method that returns interceptor used to trace remote invocation.
 void setBeanFactory(org.springframework.beans.factory.BeanFactory aBeanFactory)
          Callback that supplies the owning factory to a bean instance.
 void setEndpointFactory(EndpointFactory<RmiEndpoint<SI>,SI> aEndpointFactory)
          Sets factory used to create endpoints.
 void setInterceptorNames(java.lang.String[] aInterceptorNames)
          Sets list of interceptor names that should be registered
 void setRegisterTraceInterceptor(boolean aRegisterTraceInterceptor)
          Specifies whether trace interceptor should be created for this factory.
 void setRemoteInvocationTraceInterceptor(org.aopalliance.intercept.MethodInterceptor aRemoteInvocationTraceInterceptor)
          Sets interceptor that should be registered to trace remote calls
 
Methods inherited from class org.softamis.cluster4spring.rmi.support.RmiClientInterceptor
convertRmiAccessException, createDefaultEndpointFactory, doInvoke, getProtocol, isConnectFailure, isConnectFailureOnRemoteException, throwRmiAccessException
 
Methods inherited from class org.softamis.cluster4spring.support.RemoteClientInterceptor
doInvoke, doPreprocessApplicationEvent, getBeanName, handleRemoteConnectFailure, invoke, isRefreshEndpointsOnConnectFailure, isRefreshEndpointsOnStartup, isSwitchEndpointOnFailure, markServiceInvalid, obtainEndpointToExecute, onApplicationEvent, onContextClosed, onContextRefreshed, prepare, refreshAndRetry, refreshEndpointProvider, retry, setBeanName, setEndpointProvider, setRefreshEndpointsOnConnectFailure, setRefreshEndpointsOnStartup, setSwitchEndpointOnFailure, throwRemoteLookupFailureException, throwServiceException
 
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

fServiceProxy

protected java.lang.Object fServiceProxy
Proxy object


fRegisterTraceInterceptor

protected boolean fRegisterTraceInterceptor
Indicates whether trace interceptor should be registered


fBeanFactory

protected org.springframework.beans.factory.BeanFactory fBeanFactory
Bean factory where bean is included


fInterceptorNames

protected java.lang.String[] fInterceptorNames
List of interceptor names that should be registered


fRemoteInvocationTraceInterceptor

protected org.aopalliance.intercept.MethodInterceptor fRemoteInvocationTraceInterceptor
Interceptor that should be registered to trace remote calls

Constructor Detail

AbstractRmiProxyFactoryBean

public AbstractRmiProxyFactoryBean()
Method Detail

setBeanFactory

public void setBeanFactory(org.springframework.beans.factory.BeanFactory aBeanFactory)
                    throws org.springframework.beans.BeansException
Callback that supplies the owning factory to a bean instance.

Invoked after population of normal bean properties but before an init callback like InitializingBean's afterPropertiesSet or a custom init-method.

Specified by:
setBeanFactory in interface org.springframework.beans.factory.BeanFactoryAware
Parameters:
aBeanFactory - owning BeanFactory (may not be null). The bean can immediately call methods on the factory.
Throws:
org.springframework.beans.BeansException - in case of initialization errors
See Also:
BeanInitializationException

afterPropertiesSet

public void afterPropertiesSet()
                        throws java.lang.Exception
Description copied from class: RemoteClientInterceptor
Invoked by Spring as part of bean lifecycle and is used to check whether EndpointProvider is specified and perform other preparations

Specified by:
afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
Overrides:
afterPropertiesSet in class RemoteClientInterceptor<RmiEndpoint<SI extends ServiceMoniker>,SI extends ServiceMoniker>
Throws:
java.lang.Exception

addSpecifiedAdvices

protected void addSpecifiedAdvices(org.springframework.aop.framework.ProxyFactory aProxyFactory)
Discovers advices specified in bean definition and adds them to proxy factory used to obtain proxy.

Parameters:
aProxyFactory - proxy factory used to create proxy for remote invocation
See Also:
getInterceptorNames()

obtainRemoteInvocationTraceInterceptor

protected org.aopalliance.intercept.MethodInterceptor obtainRemoteInvocationTraceInterceptor()
Utility method that returns interceptor used to trace remote invocation. Method called if registerTraceInterceptor property is set to true.

Returns:
interceptor that should be used to trace remote invocations. If interceptor specified explicitely, returns it. Otherwise, creates default one.
See Also:
createDefaultRemoteInvocationTraceInterceptor(), isRegisterTraceInterceptor()

createDefaultRemoteInvocationTraceInterceptor

protected org.aopalliance.intercept.MethodInterceptor createDefaultRemoteInvocationTraceInterceptor()
Creates default remote invocation trace method interceptor

Returns:
created interceptor
See Also:
ClientRemoteInvocationTraceInterceptor

getProxyName

protected java.lang.String getProxyName()
Returns name of the proxy

Returns:
proxy name

getObject

public java.lang.Object getObject()
Specified by:
getObject in interface org.springframework.beans.factory.FactoryBean

getObjectType

public java.lang.Class getObjectType()
Specified by:
getObjectType in interface org.springframework.beans.factory.FactoryBean

isSingleton

public boolean isSingleton()
Is the bean managed by this factory a singleton or a prototype? That is, will getObject() always return the same object?

The singleton status of the FactoryBean itself will generally be provided by the owning BeanFactory; usually, it has to be defined as singleton there.

Specified by:
isSingleton in interface org.springframework.beans.factory.FactoryBean
Returns:
alwas returns true

setRegisterTraceInterceptor

public void setRegisterTraceInterceptor(boolean aRegisterTraceInterceptor)
Specifies whether trace interceptor should be created for this factory. If this option is set, either interceptor specified as trace one will be registered or default trace interceptor will be created.

Parameters:
aRegisterTraceInterceptor - true if interceptor should be created
See Also:
createDefaultRemoteInvocationTraceInterceptor()

isRegisterTraceInterceptor

public boolean isRegisterTraceInterceptor()
Returns indicates whether trace interceptor should be registered.

Returns:
indicates whether trace interceptor should be registered

getInterceptorNames

public java.lang.String[] getInterceptorNames()
Returns list of interceptor names that should be registered in proxy factory. These interceptors could be used, for example, to add custom processing or profiling functionality.

Returns:
list of interceptor names that should be registered

setInterceptorNames

public void setInterceptorNames(java.lang.String[] aInterceptorNames)
Sets list of interceptor names that should be registered

Parameters:
aInterceptorNames - list of interceptor names that should be registered

getRemoteInvocationTraceInterceptor

public org.aopalliance.intercept.MethodInterceptor getRemoteInvocationTraceInterceptor()
Returns interceptor that should be registered to trace remote calls

Returns:
interceptor that should be registered to trace remote calls
See Also:
isRegisterTraceInterceptor(), setRegisterTraceInterceptor(boolean)

setRemoteInvocationTraceInterceptor

public void setRemoteInvocationTraceInterceptor(org.aopalliance.intercept.MethodInterceptor aRemoteInvocationTraceInterceptor)
Sets interceptor that should be registered to trace remote calls

Parameters:
aRemoteInvocationTraceInterceptor - interceptor that should be registered to trace remote calls

getEndpointFactory

public EndpointFactory<RmiEndpoint<SI>,SI> getEndpointFactory()
Description copied from class: RemoteClientInterceptor
Returns factory used to create endpoints

Overrides:
getEndpointFactory in class RemoteClientInterceptor<RmiEndpoint<SI extends ServiceMoniker>,SI extends ServiceMoniker>
Returns:
factory

setEndpointFactory

public void setEndpointFactory(EndpointFactory<RmiEndpoint<SI>,SI> aEndpointFactory)
Description copied from class: RemoteClientInterceptor
Sets factory used to create endpoints. If factory is not set explicitely, default one will be created.

Overrides:
setEndpointFactory in class RemoteClientInterceptor<RmiEndpoint<SI extends ServiceMoniker>,SI extends ServiceMoniker>
Parameters:
aEndpointFactory - factory used to create endpoints
See Also:
RemoteClientInterceptor.createDefaultEndpointFactory()