org.springframework.osgi.service.importer
Class OsgiSingleServiceProxyFactoryBean

java.lang.Object
  extended by org.springframework.osgi.internal.service.importer.AbstractServiceImporter
      extended by org.springframework.osgi.service.importer.AbstractOsgiServiceProxyFactoryBean
          extended by org.springframework.osgi.service.importer.OsgiSingleServiceProxyFactoryBean
All Implemented Interfaces:
BeanClassLoaderAware, DisposableBean, FactoryBean, InitializingBean, SmartFactoryBean, BundleContextAware, org.springframework.osgi.internal.service.ServiceImporter

public class OsgiSingleServiceProxyFactoryBean
extends AbstractOsgiServiceProxyFactoryBean

Specialized single-service proxy creator. Will return a proxy that will select only one OSGi service which matches the configuration criteria. If the selected service goes away, the proxy will search for a replacement.

Author:
Costin Leau, Adrian Colyer, Hal Hildebrand

Field Summary
protected  org.springframework.osgi.internal.service.support.RetryTemplate retryTemplate
           
 
Fields inherited from class org.springframework.osgi.service.importer.AbstractOsgiServiceProxyFactoryBean
bundleContext, CARDINALITY_ATTRIBUTE, classLoader, contextClassloader, filter, FILTER_ATTRIBUTE, initialized, INTERFACE_ATTRIBUTE, listeners, OBJECTCLASS, serviceBeanName, serviceTypes, unifiedFilter
 
Fields inherited from class org.springframework.osgi.internal.service.importer.AbstractServiceImporter
depedencyListeners, mandatory
 
Constructor Summary
OsgiSingleServiceProxyFactoryBean()
           
 
Method Summary
protected  void addLocalBundleContextSupport(ProxyFactory factory)
          Add the local bundle context support.
protected  void addOsgiRetryInterceptor(ProxyFactory factory, Filter filter, TargetSourceLifecycleListener[] listeners)
          Add the retry interceptor and the ServiceReference aware mixin.
protected  ServiceReferenceAware createSingleServiceProxy(Class[] classes, TargetSourceLifecycleListener[] listeners, ClassLoader loader)
           
 void destroy()
           
 Object getObject()
          Subclasses have to implement this method and return the approapriate service proxy.
 Class getObjectType()
          Subclasses have to implement this method and return the approapriate service proxy type.
 boolean isSatisfied()
           
 void setRetryTimes(int maxRetries)
          How many times should we attempt to rebind to a target service if the service we are currently using is unregistered.
 void setTimeout(long millisBetweenRetries)
          How long should we wait between failed attempts at rebinding to a service that has been unregistered.
 
Methods inherited from class org.springframework.osgi.service.importer.AbstractOsgiServiceProxyFactoryBean
afterPropertiesSet, getUnifiedFilter, isEagerInit, isPrototype, isSingleton, setBeanClassLoader, setBeanName, setBundleContext, setContextClassloader, setFilter, setInterface, setListeners, setServiceBeanName
 
Methods inherited from class org.springframework.osgi.internal.service.importer.AbstractServiceImporter
isMandatory, registerListener, setMandatory
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

retryTemplate

protected org.springframework.osgi.internal.service.support.RetryTemplate retryTemplate
Constructor Detail

OsgiSingleServiceProxyFactoryBean

public OsgiSingleServiceProxyFactoryBean()
Method Detail

destroy

public void destroy()
             throws Exception
Specified by:
destroy in interface DisposableBean
Specified by:
destroy in class AbstractOsgiServiceProxyFactoryBean
Throws:
Exception

getObject

public Object getObject()
Description copied from class: AbstractOsgiServiceProxyFactoryBean
Subclasses have to implement this method and return the approapriate service proxy.

Specified by:
getObject in interface FactoryBean
Specified by:
getObject in class AbstractOsgiServiceProxyFactoryBean

getObjectType

public Class getObjectType()
Description copied from class: AbstractOsgiServiceProxyFactoryBean
Subclasses have to implement this method and return the approapriate service proxy type.

Specified by:
getObjectType in interface FactoryBean
Specified by:
getObjectType in class AbstractOsgiServiceProxyFactoryBean

isSatisfied

public boolean isSatisfied()

createSingleServiceProxy

protected ServiceReferenceAware createSingleServiceProxy(Class[] classes,
                                                         TargetSourceLifecycleListener[] listeners,
                                                         ClassLoader loader)

addOsgiRetryInterceptor

protected void addOsgiRetryInterceptor(ProxyFactory factory,
                                       Filter filter,
                                       TargetSourceLifecycleListener[] listeners)
Add the retry interceptor and the ServiceReference aware mixin.

Parameters:
factory -
filter -
listeners -

addLocalBundleContextSupport

protected void addLocalBundleContextSupport(ProxyFactory factory)
Add the local bundle context support.

Parameters:
factory -

setRetryTimes

public void setRetryTimes(int maxRetries)
How many times should we attempt to rebind to a target service if the service we are currently using is unregistered. Default is 3 times.

Changing this property after initialization is complete has no effect.

Parameters:
maxRetries - The maxRetries to set.

setTimeout

public void setTimeout(long millisBetweenRetries)
How long should we wait between failed attempts at rebinding to a service that has been unregistered.

Parameters:
millisBetweenRetries - The millisBetweenRetries to set.


Copyright © 2006-2007 Spring Framework. All Rights Reserved.