org.springframework.osgi.service.importer.support
Class OsgiServiceProxyFactoryBean

java.lang.Object
  extended by org.springframework.osgi.service.importer.support.AbstractDependableServiceImporter
      extended by org.springframework.osgi.service.importer.support.AbstractOsgiServiceImportFactoryBean
          extended by org.springframework.osgi.service.importer.support.OsgiServiceProxyFactoryBean
All Implemented Interfaces:
BeanClassLoaderAware, DisposableBean, FactoryBean, InitializingBean, SmartFactoryBean, BundleContextAware, DependableServiceImporter, ServiceDependency

public class OsgiServiceProxyFactoryBean
extends AbstractOsgiServiceImportFactoryBean

OSGi (single) service importer. This implementation creates a managed OSGi service proxy that handles the OSGi service dynamics. The returned proxy will select only the best matching OSGi service for the configuration criteria. If the select service goes away (at any point in time), the proxy will automatically search for a replacement without the user intervention. Note that the proxy instance remains the same and only the backing OSGi service changes. Due to the dynamic nature of OSGi, the backing object can change during method invocations.

Author:
Costin Leau, Adrian Colyer, Hal Hildebrand

Constructor Summary
OsgiServiceProxyFactoryBean()
           
 
Method Summary
 Class getObjectType()
           
 int getRetryTimes()
          Returns the number of attempts to rebind a target service before giving up.
 long getTimeout()
          Returns the timeout (in milliseconds) this importer waits while trying to find a backing service.
 boolean isSatisfied()
          Indicates if the dependency is satisified or not.
 void setCardinality(Cardinality cardinality)
          Sets the importer cardinality (0..1, 1..1, 0..N, or 1..N).
 void setRetryTimes(int maxRetries)
          Sets how many times should this importer attempt to rebind to a target service if the backing service currently used is unregistered.
 void setTimeout(long millisBetweenRetries)
          Sets how long (in milliseconds) should this importer wait between failed attempts at rebinding to a service that has been unregistered.
 
Methods inherited from class org.springframework.osgi.service.importer.support.AbstractOsgiServiceImportFactoryBean
afterPropertiesSet, destroy, getBeanClassLoader, getBundleContext, getContextClassLoader, getFilter, getInterfaces, getListeners, getObject, getUnifiedFilter, isEagerInit, isPrototype, isSingleton, setBeanClassLoader, setBundleContext, setContextClassLoader, setFilter, setInterfaces, setListeners, setServiceBeanName
 
Methods inherited from class org.springframework.osgi.service.importer.support.AbstractDependableServiceImporter
getCardinality, isMandatory, registerListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OsgiServiceProxyFactoryBean

public OsgiServiceProxyFactoryBean()
Method Detail

getObjectType

public Class getObjectType()

isSatisfied

public boolean isSatisfied()
Description copied from interface: ServiceDependency
Indicates if the dependency is satisified or not. For optional service imports, this should always return true while for mandatory service imports, should return true if at least one service is available or false otherwise.

Returns:
true if the dependency is satisfied, false otherwise.

setRetryTimes

public void setRetryTimes(int maxRetries)
Sets how many times should this importer attempt to rebind to a target service if the backing service currently used is unregistered. Default is 3 times.

Changing this property after initialization is complete has no effect.

Parameters:
maxRetries - The maxRetries to set.

getRetryTimes

public int getRetryTimes()
Returns the number of attempts to rebind a target service before giving up.

Returns:
number of retries to find a matching service before failing

setTimeout

public void setTimeout(long millisBetweenRetries)
Sets how long (in milliseconds) should this importer wait between failed attempts at rebinding to a service that has been unregistered.

Parameters:
millisBetweenRetries - The millisBetweenRetries to set.

getTimeout

public long getTimeout()
Returns the timeout (in milliseconds) this importer waits while trying to find a backing service.

Returns:
timeout in milliseconds

setCardinality

public void setCardinality(Cardinality cardinality)
Sets the importer cardinality (0..1, 1..1, 0..N, or 1..N). Default is 1..X.

Since this implementation creates a managed proxy, only single cardinalities are accepted.

Overrides:
setCardinality in class AbstractDependableServiceImporter
Parameters:
cardinality - importer cardinality.


Copyright 2006-2008 Spring Framework. All Rights Reserved.