public class SpaceRemotingServiceExporter extends Object implements SpaceDataEventListener<SpaceRemotingEntry>, org.springframework.beans.factory.InitializingBean, org.springframework.context.ApplicationContextAware, org.springframework.beans.factory.BeanNameAware, EventTemplateProvider, ClusterInfoAware, org.springframework.context.ApplicationListener, ServiceDetailsProvider, ServiceMonitorsProvider
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.
SimplePollingEventListenerContainer,
SpaceRemotingEntry,
EventDrivenSpaceRemotingProxyFactoryBean| Modifier and Type | Field and Description |
|---|---|
static String |
DEFAULT_ASYNC_INTERFACE_SUFFIX |
| Constructor and Description |
|---|
SpaceRemotingServiceExporter() |
| Modifier and Type | Method and Description |
|---|---|
void |
addService(String beanId,
Object service) |
void |
afterPropertiesSet() |
ServiceDetails[] |
getServicesDetails()
Retruns one or more service details that the service exposes.
|
ServiceMonitors[] |
getServicesMonitors()
Retruns one or more service details that the service exposes.
|
Object |
getTemplate()
The template used for receiving events.
|
Object |
invokeExecutor(ExecutorRemotingTask task) |
void |
onApplicationEvent(org.springframework.context.ApplicationEvent applicationEvent) |
void |
onEvent(SpaceRemotingEntry remotingEntry,
GigaSpace gigaSpace,
org.springframework.transaction.TransactionStatus txStatus,
Object source)
Receives a
SpaceRemotingEntry which holds all the relevant invocation information. |
void |
setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
Application context injected by Spring
|
void |
setAsyncInterfaceSuffix(String asyncInterfaceSuffix)
For async based execution of remote services, this is one of the options to enable this by
using two different interfaces.
|
void |
setBeanName(String name) |
void |
setClusterInfo(ClusterInfo clusterInfo)
Cluster Info injected
|
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.
|
void |
setFifo(boolean fifo)
Sets the template used to read async invocation (the
SpaceRemotingEntry) to be fifo. |
void |
setServiceExecutionAspect(ServiceExecutionAspect serviceExecutionAspect)
Allows to inject a service execution callback.
|
void |
setServices(List<Object> services)
Sets the list of services that will be exported as remote services.
|
void |
setTemplateLookupName(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).
|
void |
setUseFastReflection(boolean userFastReflection)
Controls if executing the service should use fast reflection or not.
|
public static final String DEFAULT_ASYNC_INTERFACE_SUFFIX
public void setServices(List<Object> services)
SpaceRemotingInvocation.getLookupName()
which will then be used to invoke the correct service.public void setAsyncInterfaceSuffix(String asyncInterfaceSuffix)
This setter allows to set the async suffix which by default is Async.
public void setFifo(boolean fifo)
SpaceRemotingEntry) to be fifo.
Works in with setting the EventDrivenSpaceRemotingProxyFactoryBean fifo flag to
true and allows for remoting to work in fifo mode without needing to set the
whole Space to work in fifo mode.public void setUseFastReflection(boolean userFastReflection)
public void setDisableAutowiredArguments(boolean disableAutowiredArguments)
public void setServiceExecutionAspect(ServiceExecutionAspect serviceExecutionAspect)
public void setTemplateLookupName(String templateLookupName)
This option allows to create several polling container, each for different service that will perform the actual invocation.
public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
setApplicationContext in interface org.springframework.context.ApplicationContextAwarepublic void setBeanName(String name)
setBeanName in interface org.springframework.beans.factory.BeanNameAwarepublic void setClusterInfo(ClusterInfo clusterInfo)
setClusterInfo in interface ClusterInfoAwareclusterInfo - The cluster information to be injectedpublic void addService(String beanId, Object service) throws IllegalStateException
IllegalStateExceptionpublic void afterPropertiesSet()
throws Exception
afterPropertiesSet in interface org.springframework.beans.factory.InitializingBeanExceptionpublic void onApplicationEvent(org.springframework.context.ApplicationEvent applicationEvent)
onApplicationEvent in interface org.springframework.context.ApplicationListenerpublic Object getTemplate()
SpaceRemotingEntry.getTemplate in interface EventTemplateProviderpublic ServiceDetails[] getServicesDetails()
ServiceDetailsProvidergetServicesDetails in interface ServiceDetailsProviderpublic ServiceMonitors[] getServicesMonitors()
ServiceMonitorsProvidergetServicesMonitors in interface ServiceMonitorsProviderpublic void onEvent(SpaceRemotingEntry remotingEntry, GigaSpace gigaSpace, org.springframework.transaction.TransactionStatus txStatus, Object source) throws org.springframework.remoting.RemoteAccessException
SpaceRemotingEntry which holds all the relevant invocation information.
Looks up (based on SpaceRemotingInvocation.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 using SpaceRemotingEntry.onEvent in interface SpaceDataEventListener<SpaceRemotingEntry>remotingEntry - The remote entry objectgigaSpace - The GigaSpace interfacetxStatus - A transactional statussource - An optional source event informationorg.springframework.remoting.RemoteAccessExceptionpublic Object invokeExecutor(ExecutorRemotingTask task) throws Throwable
ThrowableCopyright © GigaSpaces.