GigaSpaces XAP 7.0 API

org.openspaces.core.jini
Class JiniServiceFactoryBean

java.lang.Object
  extended by org.springframework.beans.factory.config.AbstractFactoryBean
      extended by org.openspaces.core.jini.JiniServiceFactoryBean
All Implemented Interfaces:
Advice, Interceptor, MethodInterceptor, BeanClassLoaderAware, BeanFactoryAware, DisposableBean, FactoryBean, InitializingBean

public class JiniServiceFactoryBean
extends AbstractFactoryBean
implements MethodInterceptor

JiniServiceFactoryBean for Jini environments. The class is made up from various samples found on jini.org customized in a Spring specific way. The search will be executed using the provided ServiceTemplate or, if it is null, one will be created using the serviceClass and serviceName. If the lookup operation times out (30 seconds by default), a null service will be returned. For most cases the serviceClass and serviceNames are enough and hide the jini details from the client.

The factoryBean can be configured to do a lookup each time before returning the object type by setting the "singleton" property to false.

The service factory can be configured to return a smart proxy that will try and perform another lookup in case of an invocation exception (see setSmartProxy(boolean). The retry count can be controlled using setRetryCountOnFailure(int).

Author:
kimchy

Constructor Summary
JiniServiceFactoryBean()
           
 
Method Summary
protected  Object createInstance()
          Creates an instance of the service.
 String[] getGroups()
          Returns the groups.
 String[] getLocators()
          Returns the locators.
 Class<?> getObjectType()
           
 Class<?> getServiceClass()
           
 String getServiceName()
           
 net.jini.core.lookup.ServiceTemplate getTemplate()
           
 long getTimeout()
          The timeout to wait looking up the service
 Object invoke(MethodInvocation methodInvocation)
          When using smart proxy, wraps the invocation of a service method and in case of failure will try and perform another lookup for the service.
protected  Object lookupService()
          A helper method to lookup the service.
 void setGroups(String[] groups)
          The groups to set
 void setLocators(String[] locators)
          Sets the locators.
 void setRetryCountOnFailure(int retryCountOnFailure)
          Sets the number of successive method invocation lookup retry count in case of a failure.
 void setServiceClass(Class<?> serviceClass)
           
 void setServiceName(String serviceName)
           
 void setSmartProxy(boolean smartProxy)
          Sets if this proxy will be a smart proxy.
 void setTemplate(net.jini.core.lookup.ServiceTemplate template)
           
 void setTimeout(long timeout)
          The timeout to wait looking up the service
 
Methods inherited from class org.springframework.beans.factory.config.AbstractFactoryBean
afterPropertiesSet, destroy, destroyInstance, getBeanFactory, getBeanTypeConverter, getEarlySingletonInterfaces, getObject, isSingleton, setBeanClassLoader, setBeanFactory, setSingleton
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JiniServiceFactoryBean

public JiniServiceFactoryBean()
Method Detail

getObjectType

public Class<?> getObjectType()
Specified by:
getObjectType in interface FactoryBean
Specified by:
getObjectType in class AbstractFactoryBean

createInstance

protected Object createInstance()
                         throws Exception
Creates an instance of the service. Performs a lookup (using lookupService() and if smart proxy is used, will wrap the returned service with a proxy that performs lookups in case of failures.

Specified by:
createInstance in class AbstractFactoryBean
Throws:
Exception

invoke

public Object invoke(MethodInvocation methodInvocation)
              throws Throwable
When using smart proxy, wraps the invocation of a service method and in case of failure will try and perform another lookup for the service.

Specified by:
invoke in interface MethodInterceptor
Throws:
Throwable

lookupService

protected Object lookupService()
                        throws Exception
A helper method to lookup the service.

Throws:
Exception

setSmartProxy

public void setSmartProxy(boolean smartProxy)
Sets if this proxy will be a smart proxy. When this value is set to true the service found will be wrapped with a smart proxy that will detect failuers and try to lookup the service again in such cases. Defaults to false.


setRetryCountOnFailure

public void setRetryCountOnFailure(int retryCountOnFailure)
Sets the number of successive method invocation lookup retry count in case of a failure. Defaults to 3.


getGroups

public String[] getGroups()
Returns the groups.


setGroups

public void setGroups(String[] groups)
The groups to set


getLocators

public String[] getLocators()
Returns the locators.


setLocators

public void setLocators(String[] locators)
Sets the locators.


getServiceClass

public Class<?> getServiceClass()
Returns:
Returns the serviceClass.

setServiceClass

public void setServiceClass(Class<?> serviceClass)
Parameters:
serviceClass - The serviceClass to set.

getServiceName

public String getServiceName()
Returns:
Returns the serviceName.

setServiceName

public void setServiceName(String serviceName)
Parameters:
serviceName - The serviceName to set.

getTemplate

public net.jini.core.lookup.ServiceTemplate getTemplate()
Returns:
Returns the template.

setTemplate

public void setTemplate(net.jini.core.lookup.ServiceTemplate template)
Parameters:
template - The template to set.

getTimeout

public long getTimeout()
The timeout to wait looking up the service


setTimeout

public void setTimeout(long timeout)
The timeout to wait looking up the service


GigaSpaces XAP 7.0 API

Copyright © GigaSpaces.