Class SpaceRemotingServiceExporter
- All Implemented Interfaces:
EventListener,ClusterInfoAware,EventTemplateProvider,SpaceDataEventListener<SpaceRemotingEntry>,ServiceDetailsProvider,ServiceMonitorsProvider,org.springframework.beans.factory.Aware,org.springframework.beans.factory.BeanNameAware,org.springframework.beans.factory.InitializingBean,org.springframework.context.ApplicationContextAware,org.springframework.context.ApplicationListener
SpaceRemotingInvocation.getLookupName() which are then used to lookup the actual service when a
remote invocation is received. The correct service and its method are then executed and a SpaceRemotingResult is written back to the space. The remote result can
either hold the return value (or null in case of void return value) or an exception
that was thrown by the service.
The exporter implements SpaceDataEventListener which means that
it acts as a listener to data events and should be used with the different event containers such
as SimplePollingEventListenerContainer. This method of
execution is called event driven remote execution (EventDrivenSpaceRemotingProxyFactoryBean).
It also implements EventTemplateProvider which means that within
the event container configuration there is no need to configure the template, as it uses the one
provided by this exported.
Last, the exporter provides services to executor based remoting (ExecutorSpaceRemotingProxyFactoryBean).
By default, the exporter will also autowire and post process all the arguments passed,
allowing to inject them with "server" side beans using Spring Autowired annotation for example. Note, this
variables must be defined as transient so they won't be passed back to the client.
This can be disabled by setting setDisableAutowiredArguments(boolean) to
true.
- Author:
- kimchy
- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddService(String beanId, Object service) voidRetruns one or more service details that the service exposes.Retruns one or more service details that the service exposes.The template used for receiving events.voidonApplicationEvent(org.springframework.context.ApplicationEvent applicationEvent) voidonEvent(SpaceRemotingEntry remotingEntry, GigaSpace gigaSpace, org.springframework.transaction.TransactionStatus txStatus, Object source) Receives aSpaceRemotingEntrywhich holds all the relevant invocation information.voidsetApplicationContext(org.springframework.context.ApplicationContext applicationContext) Application context injected by SpringvoidsetAsyncInterfaceSuffix(String asyncInterfaceSuffix) For async based execution of remote services, this is one of the options to enable this by using two different interfaces.voidsetBeanName(String name) voidsetClusterInfo(ClusterInfo clusterInfo) Cluster Info injectedvoidsetDisableAutowiredArguments(boolean disableAutowiredArguments) Allows to disable (by default it is enabled) the autowiring of method arguments with beans that exists within the server side context.voidsetFifo(boolean fifo) Sets the template used to read async invocation (theSpaceRemotingEntry) to be fifo.voidsetServiceExecutionAspect(ServiceExecutionAspect serviceExecutionAspect) Allows to inject a service execution callback.voidsetServices(List<Object> services) Sets the list of services that will be exported as remote services.voidsetTemplateLookupName(String templateLookupName) Allows to narrow down the async polling container to perform a lookup only on specific lookup name (which is usually the interface that will be used to proxy it on the client side).voidsetUseFastReflection(boolean userFastReflection) Controls if executing the service should use fast reflection or not.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.context.ApplicationListener
supportsAsyncExecution
-
Field Details
-
DEFAULT_ASYNC_INTERFACE_SUFFIX
- See Also:
-
-
Constructor Details
-
SpaceRemotingServiceExporter
public SpaceRemotingServiceExporter()
-
-
Method Details
-
setServices
Sets the list of services that will be exported as remote services. Each service will have all of its interfaces registered as lookups (mapping toSpaceRemotingInvocation.getLookupName()which will then be used to invoke the correct service. -
setAsyncInterfaceSuffix
For async based execution of remote services, this is one of the options to enable this by using two different interfaces. The first is the actual "server side" interface (sync), and the other has the same interface name just with an "async suffix" to it. The exporter will identify the async suffix, and will perform the invocation on the actual interface.This setter allows to set the async suffix which by default is
Async. -
setFifo
public void setFifo(boolean fifo) Sets the template used to read async invocation (theSpaceRemotingEntry) to be fifo. Works in with setting theEventDrivenSpaceRemotingProxyFactoryBeanfifo flag totrueand allows for remoting to work in fifo mode without needing to set the whole Space to work in fifo mode. -
setUseFastReflection
public void setUseFastReflection(boolean userFastReflection) Controls if executing the service should use fast reflection or not. -
setDisableAutowiredArguments
public void setDisableAutowiredArguments(boolean disableAutowiredArguments) Allows to disable (by default it is enabled) the autowiring of method arguments with beans that exists within the server side context. -
setServiceExecutionAspect
Allows to inject a service execution callback. -
setTemplateLookupName
Allows to narrow down the async polling container to perform a lookup only on specific lookup name (which is usually the interface that will be used to proxy it on the client side). Defaults to match on all async remoting invocations.This option allows to create several polling container, each for different service that will perform the actual invocation.
-
setApplicationContext
public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext) Application context injected by Spring- Specified by:
setApplicationContextin interfaceorg.springframework.context.ApplicationContextAware
-
setBeanName
- Specified by:
setBeanNamein interfaceorg.springframework.beans.factory.BeanNameAware
-
setClusterInfo
Cluster Info injected- Specified by:
setClusterInfoin interfaceClusterInfoAware- Parameters:
clusterInfo- The cluster information to be injected
-
addService
- Throws:
IllegalStateException
-
afterPropertiesSet
- Specified by:
afterPropertiesSetin interfaceorg.springframework.beans.factory.InitializingBean- Throws:
Exception
-
onApplicationEvent
public void onApplicationEvent(org.springframework.context.ApplicationEvent applicationEvent) - Specified by:
onApplicationEventin interfaceorg.springframework.context.ApplicationListener
-
getTemplate
The template used for receiving events. Defaults to all objects that are of typeSpaceRemotingEntry.- Specified by:
getTemplatein interfaceEventTemplateProvider
-
getServicesDetails
Description copied from interface:ServiceDetailsProviderRetruns one or more service details that the service exposes.- Specified by:
getServicesDetailsin interfaceServiceDetailsProvider
-
getServicesMonitors
Description copied from interface:ServiceMonitorsProviderRetruns one or more service details that the service exposes.- Specified by:
getServicesMonitorsin interfaceServiceMonitorsProvider
-
onEvent
public void onEvent(SpaceRemotingEntry remotingEntry, GigaSpace gigaSpace, org.springframework.transaction.TransactionStatus txStatus, Object source) Receives aSpaceRemotingEntrywhich holds all the relevant invocation information. Looks up (based onSpaceRemotingInvocation.getLookupName()the interface the service is registered against (which is the interface the service implements) and then invokes the relevant method within it using the provided method name and arguments. Write the result value or invocation exception back to the space usingSpaceRemotingEntry.- Specified by:
onEventin interfaceSpaceDataEventListener<SpaceRemotingEntry>- Parameters:
remotingEntry- The remote entry objectgigaSpace- The GigaSpace interfacetxStatus- A transactional statussource- An optional source event information
-
invokeExecutor
- Throws:
Throwable
-