Class EventDrivenSpaceRemotingProxyFactoryBean
- All Implemented Interfaces:
org.aopalliance.aop.Advice,org.aopalliance.intercept.Interceptor,org.aopalliance.intercept.MethodInterceptor,RemotingInvoker,org.springframework.beans.factory.Aware,org.springframework.beans.factory.FactoryBean,org.springframework.beans.factory.InitializingBean,org.springframework.context.ApplicationContextAware
SpaceRemotingServiceExporter which in turn is registered with an event container.
This proxy builds a representation of the remote invocation using SpaceRemotingEntry and
waits for a remoting response represented by SpaceRemotingEntry.
The proxy requires a setGigaSpace(org.openspaces.core.GigaSpace) interface to be set
in order to write the remote invocation and wait for a response using the space API. It also
requires a which represents the interface that will be
proxied.
Allows for one way invocations (i.e. not waiting for a response). The one way invocation can
be set globally for all of the service methods by setting setGlobalOneWay(boolean) or
can be enabled only for methods that return void by setting setVoidOneWay(boolean). Note, if using one way invocation and an exception is raised by the
remote service, it won't be raised by this proxy.
A timeout which controls how long the proxy will wait for the response can be set using setTimeout(long). The timeout value if in milliseconds.
The space remote proxy supports a future based invocation. This means that if, on the client
side, one of the service interface methods returns Future, it can be
used for async execution. Note, this means that in terms of interfaces there will have to be two
different service interfaces (under the same package and with the same name). One for the server
side service that returns the actual value, and one on the client side that for the same method
simply returns the future. Another option is not having two different interfaces, but having the
same interface with async methods (returning Future). The async methods should start
with a specified prefix (defaults to async) and should have no implementation on the
server side (simply return null).
In case of remote invocation over a partitioned space the default partitioned routing index
will be random (the hashCode of the newly created SpaceRemotingEntry class). The proxy
allows for a pluggable routing handler implementation by setting setRemoteRoutingHandler(RemoteRoutingHandler).
The actual remote invocation can be replaced with an aspect implementing RemoteInvocationAspect which can be set using setRemoteInvocationAspect(RemoteInvocationAspect). It is up the aspect to then call the actual
remote invocation.
Note that it is also possible to configure method level fifo behavior, one way behavior,
RemoteResultReducer, RemoteRoutingHandler, RemoteInvocationAspect and
MetaArgumentsHandler using the EventDrivenRemotingMethod annotation.
- Author:
- kimchy
- See Also:
-
Field Summary
FieldsFields inherited from interface org.springframework.beans.factory.FactoryBean
OBJECT_TYPE_ATTRIBUTE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidClass<?>invoke(org.aopalliance.intercept.MethodInvocation methodInvocation) invokeRemote(org.aopalliance.intercept.MethodInvocation methodInvocation) This invocation will cause the actual remote invocation.booleanvoidsetApplicationContext(org.springframework.context.ApplicationContext applicationContext) voidsetAsyncMethodPrefix(String asyncMethodPrefix) Sets the async method prefix.voidsetFifo(boolean fifo) Sets the remote invocation objects written to the Space to work in FIFO.voidsetGigaSpace(GigaSpace gigaSpace) Sets the GigaSpace interface that will be used to work with the space as the transport layer for both writing and takingSpaceRemotingEntry.voidsetGlobalOneWay(boolean globalOneWay) If set totrue(defaults tofalse) all of the service methods will be invoked and the proxy will not wait for a return value.voidsetMetaArgumentsHandler(MetaArgumentsHandler metaArgumentsHandler) Allows to set a meta argument handler that will controlSpaceRemotingInvocation.getMetaArguments().voidsetRemoteInvocationAspect(RemoteInvocationAspect remoteInvocationAspect) The actual remote invocation can be replaced with an aspect implementingRemoteInvocationAspectwhich can be set usingsetRemoteInvocationAspect(RemoteInvocationAspect).voidsetRemoteRoutingHandler(RemoteRoutingHandler remoteRoutingHandler) In case of remote invocation over a partitioned space the default partitioned routing index will be random (the hashCode of the newly createdSpaceRemotingEntryclass).voidsetServiceInterface(Class serviceInterface) voidsetTimeout(long timeout) Sets the timeout that will be used to wait for the remote invocation response.voidsetVoidOneWay(boolean voidOneWay) If set totrue(defaults tofalse) service methods that return void will be invoked and the proxy will not wait for a return value.
-
Field Details
-
DEFAULT_ASYNC_METHOD_PREFIX
- See Also:
-
-
Constructor Details
-
EventDrivenSpaceRemotingProxyFactoryBean
public EventDrivenSpaceRemotingProxyFactoryBean()
-
-
Method Details
-
setServiceInterface
-
setApplicationContext
public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext) throws org.springframework.beans.BeansException - Specified by:
setApplicationContextin interfaceorg.springframework.context.ApplicationContextAware- Throws:
org.springframework.beans.BeansException
-
setGigaSpace
Sets the GigaSpace interface that will be used to work with the space as the transport layer for both writing and takingSpaceRemotingEntry. -
setTimeout
public void setTimeout(long timeout) Sets the timeout that will be used to wait for the remote invocation response. The timeout value is in milliseconds and defaults to60000(60 seconds). -
setRemoteRoutingHandler
In case of remote invocation over a partitioned space the default partitioned routing index will be random (the hashCode of the newly createdSpaceRemotingEntryclass). ThisRemoteRoutingHandlerallows for custom routing computation (for example, based on one of the service method parameters). -
setMetaArgumentsHandler
Allows to set a meta argument handler that will controlSpaceRemotingInvocation.getMetaArguments(). -
setGlobalOneWay
public void setGlobalOneWay(boolean globalOneWay) If set totrue(defaults tofalse) all of the service methods will be invoked and the proxy will not wait for a return value. Note, any exception raised by the remote service will be logged on the server side and not propagated to the client. -
setVoidOneWay
public void setVoidOneWay(boolean voidOneWay) If set totrue(defaults tofalse) service methods that return void will be invoked and the proxy will not wait for a return value. Note, any exception raised by the remote service will be logged on the server side and not propagated to the client. -
setFifo
public void setFifo(boolean fifo) Sets the remote invocation objects written to the Space to work in FIFO. Note, when setting this setting make sure to set it on theSpaceRemotingServiceExporter. This allows for remoting to work in fifo mode without needing to set the whole Space to work in fifo mode. -
setAsyncMethodPrefix
Sets the async method prefix. Defaults toDEFAULT_ASYNC_METHOD_PREFIX. -
setRemoteInvocationAspect
The actual remote invocation can be replaced with an aspect implementingRemoteInvocationAspectwhich can be set usingsetRemoteInvocationAspect(RemoteInvocationAspect). It is up the aspect to then call the actual remote invocation. -
afterPropertiesSet
public void afterPropertiesSet()- Specified by:
afterPropertiesSetin interfaceorg.springframework.beans.factory.InitializingBean
-
getServiceInterface
-
getObject
- Specified by:
getObjectin interfaceorg.springframework.beans.factory.FactoryBean
-
getObjectType
- Specified by:
getObjectTypein interfaceorg.springframework.beans.factory.FactoryBean
-
isSingleton
public boolean isSingleton()- Specified by:
isSingletonin interfaceorg.springframework.beans.factory.FactoryBean
-
invoke
- Specified by:
invokein interfaceorg.aopalliance.intercept.MethodInterceptor- Throws:
Throwable
-
invokeRemote
public Object invokeRemote(org.aopalliance.intercept.MethodInvocation methodInvocation) throws Throwable Description copied from interface:RemotingInvokerThis invocation will cause the actual remote invocation.- Specified by:
invokeRemotein interfaceRemotingInvoker- Throws:
Throwable
-