GigaSpaces XAP 7.0 API

org.openspaces.remoting
Class SpaceRemotingServiceExporter

java.lang.Object
  extended by org.openspaces.remoting.SpaceRemotingServiceExporter
All Implemented Interfaces:
EventListener, ClusterInfoAware, FilterProviderFactory, EventTemplateProvider, SpaceDataEventListener<EventDrivenSpaceRemotingEntry>, ServiceDetailsProvider, ServiceMonitorsProvider, BeanNameAware, InitializingBean, ApplicationContextAware, ApplicationListener

public class SpaceRemotingServiceExporter
extends Object
implements SpaceDataEventListener<EventDrivenSpaceRemotingEntry>, InitializingBean, ApplicationContextAware, BeanNameAware, EventTemplateProvider, FilterProviderFactory, ClusterInfoAware, ApplicationListener, ServiceDetailsProvider, ServiceMonitorsProvider

Exports a list of services (beans) as remote services with the Space as the transport layer. All the interfaces each service implements are registered as lookup names (matching 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.

The exporter also implements FilterProviderFactory and allows to execute services in a sync manner (SyncSpaceRemotingProxyFactoryBean).

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 setDisableAutowiredArguements(boolean) to true.

Author:
kimchy
See Also:
SimplePollingEventListenerContainer, EventDrivenSpaceRemotingEntry, EventDrivenSpaceRemotingProxyFactoryBean

Field Summary
static String DEFAULT_ASYNC_INTERFACE_SUFFIX
           
 
Constructor Summary
SpaceRemotingServiceExporter()
           
 
Method Summary
 void addService(String beanId, Object service)
           
 void afterPropertiesSet()
           
 com.j_spaces.core.filters.FilterProvider getFilterProvider()
          Returns an instance of SpaceRemotingServiceExporter.RemotingServiceInvoker filter for sync remote service execution.
 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(ApplicationEvent applicationEvent)
           
 void onEvent(EventDrivenSpaceRemotingEntry remotingEntry, GigaSpace gigaSpace, TransactionStatus txStatus, Object source)
          Receives a EventDrivenSpaceRemotingEntry which holds all the relevant invocation information.
 void setApplicationContext(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 setDisableAutowiredArguements(boolean disableAutowiredArguements)
          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 EventDrivenSpaceRemotingEntry) 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 setSyncEntryWriteLease(long syncEntryWriteLease)
          Sets the sync entry write lease.
 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).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_ASYNC_INTERFACE_SUFFIX

public static final String DEFAULT_ASYNC_INTERFACE_SUFFIX
See Also:
Constant Field Values
Constructor Detail

SpaceRemotingServiceExporter

public SpaceRemotingServiceExporter()
Method Detail

setServices

public void setServices(List<Object> services)
Sets the list of services that will be exported as remote services. Each service will have all of its interfaces registered as lookups (mapping to EventDrivenSpaceRemotingEntry.getLookupName() which will then be used to invoke the correct service.


setAsyncInterfaceSuffix

public 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. 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 (the EventDrivenSpaceRemotingEntry) 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.


setDisableAutowiredArguements

public void setDisableAutowiredArguements(boolean disableAutowiredArguements)
Allows to disable (by default it is enabled) the autowiring of method arguments with beans that exists within the server side context.


setServiceExecutionAspect

public void setServiceExecutionAspect(ServiceExecutionAspect serviceExecutionAspect)
Allows to inject a service execution callback.


setSyncEntryWriteLease

public void setSyncEntryWriteLease(long syncEntryWriteLease)
Sets the sync entry write lease. Defaults to Lease.FOREVER.


setTemplateLookupName

public 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). 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(ApplicationContext applicationContext)
Application context injected by Spring

Specified by:
setApplicationContext in interface ApplicationContextAware

setBeanName

public void setBeanName(String name)
Specified by:
setBeanName in interface BeanNameAware

setClusterInfo

public void setClusterInfo(ClusterInfo clusterInfo)
Cluster Info injected

Specified by:
setClusterInfo in interface ClusterInfoAware
Parameters:
clusterInfo - The cluster information to be injected

addService

public void addService(String beanId,
                       Object service)
                throws IllegalStateException
Throws:
IllegalStateException

afterPropertiesSet

public void afterPropertiesSet()
                        throws Exception
Specified by:
afterPropertiesSet in interface InitializingBean
Throws:
Exception

onApplicationEvent

public void onApplicationEvent(ApplicationEvent applicationEvent)
Specified by:
onApplicationEvent in interface ApplicationListener

getTemplate

public Object getTemplate()
The template used for receiving events. Defaults to all objects that are of type EventDrivenSpaceRemotingEntry.

Specified by:
getTemplate in interface EventTemplateProvider

getServicesDetails

public ServiceDetails[] getServicesDetails()
Description copied from interface: ServiceDetailsProvider
Retruns one or more service details that the service exposes.

Specified by:
getServicesDetails in interface ServiceDetailsProvider

getServicesMonitors

public ServiceMonitors[] getServicesMonitors()
Description copied from interface: ServiceMonitorsProvider
Retruns one or more service details that the service exposes.

Specified by:
getServicesMonitors in interface ServiceMonitorsProvider

onEvent

public void onEvent(EventDrivenSpaceRemotingEntry remotingEntry,
                    GigaSpace gigaSpace,
                    TransactionStatus txStatus,
                    Object source)
             throws RemoteAccessException
Receives a EventDrivenSpaceRemotingEntry which holds all the relevant invocation information. Looks up (based on EventDrivenSpaceRemotingEntry.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 EventDrivenSpaceRemotingEntry.

Specified by:
onEvent in interface SpaceDataEventListener<EventDrivenSpaceRemotingEntry>
Parameters:
remotingEntry - The remote entry object
gigaSpace - The GigaSpace interface
txStatus - A transactional status
source - An optional source event information
Throws:
RemoteAccessException

invokeExecutor

public Object invokeExecutor(ExecutorRemotingTask task)
                      throws Throwable
Throws:
Throwable

getFilterProvider

public com.j_spaces.core.filters.FilterProvider getFilterProvider()
Returns an instance of SpaceRemotingServiceExporter.RemotingServiceInvoker filter for sync remote service execution.

Specified by:
getFilterProvider in interface FilterProviderFactory

GigaSpaces XAP 7.0 API

Copyright © GigaSpaces.