org.springframework.osgi.service.importer
Class AbstractOsgiServiceProxyFactoryBean

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

public abstract class AbstractOsgiServiceProxyFactoryBean
extends org.springframework.osgi.internal.service.importer.AbstractServiceImporter
implements SmartFactoryBean, InitializingBean, DisposableBean, BundleContextAware, BeanClassLoaderAware

Base class for importing OSGi services. Provides most of the constructs required for assembling the service proxies, leaving subclasses to decide on the service cardinality (one service or multiple).

Author:
Costin Leau, Adrian Colyer, Hal Hildebrand

Field Summary
protected  BundleContext bundleContext
           
static String CARDINALITY_ATTRIBUTE
           
protected  ClassLoader classLoader
           
protected  int contextClassloader
           
protected  String filter
           
static String FILTER_ATTRIBUTE
           
protected  boolean initialized
           
static String INTERFACE_ATTRIBUTE
           
protected  TargetSourceLifecycleListener[] listeners
           
static String OBJECTCLASS
           
protected  String serviceBeanName
          Service Bean property of the OSGi service *
protected  Class[] serviceTypes
           
protected  Filter unifiedFilter
           
 
Fields inherited from class org.springframework.osgi.internal.service.importer.AbstractServiceImporter
depedencyListeners, mandatory
 
Constructor Summary
AbstractOsgiServiceProxyFactoryBean()
           
 
Method Summary
 void afterPropertiesSet()
           
abstract  void destroy()
           
abstract  Object getObject()
          Subclasses have to implement this method and return the approapriate service proxy.
abstract  Class getObjectType()
          Subclasses have to implement this method and return the approapriate service proxy type.
 Filter getUnifiedFilter()
          Assemble configuration properties to create an OSGi filter.
 boolean isEagerInit()
           
 boolean isPrototype()
           
 boolean isSingleton()
           
 void setBeanClassLoader(ClassLoader classLoader)
           
 void setBeanName(String beanName)
           
 void setBundleContext(BundleContext context)
           
 void setContextClassloader(String classLoaderManagementOption)
           
 void setFilter(String filter)
           
 void setInterface(Class[] serviceType)
          The type that the OSGi service was registered with
 void setListeners(TargetSourceLifecycleListener[] listeners)
           
 void setServiceBeanName(String serviceBeanName)
          To find a bean published as a service by the OsgiServiceExporter, simply set this property.
 
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
 
Methods inherited from interface org.springframework.osgi.internal.service.ServiceImporter
isSatisfied
 

Field Detail

FILTER_ATTRIBUTE

public static final String FILTER_ATTRIBUTE
See Also:
Constant Field Values

INTERFACE_ATTRIBUTE

public static final String INTERFACE_ATTRIBUTE
See Also:
Constant Field Values

CARDINALITY_ATTRIBUTE

public static final String CARDINALITY_ATTRIBUTE
See Also:
Constant Field Values

OBJECTCLASS

public static final String OBJECTCLASS
See Also:
Constant Field Values

classLoader

protected ClassLoader classLoader

bundleContext

protected BundleContext bundleContext

contextClassloader

protected int contextClassloader

serviceTypes

protected Class[] serviceTypes

filter

protected String filter

unifiedFilter

protected Filter unifiedFilter

listeners

protected TargetSourceLifecycleListener[] listeners

serviceBeanName

protected String serviceBeanName
Service Bean property of the OSGi service *


initialized

protected boolean initialized
Constructor Detail

AbstractOsgiServiceProxyFactoryBean

public AbstractOsgiServiceProxyFactoryBean()
Method Detail

getObject

public abstract Object getObject()
Subclasses have to implement this method and return the approapriate service proxy.

Specified by:
getObject in interface FactoryBean

getObjectType

public abstract Class getObjectType()
Subclasses have to implement this method and return the approapriate service proxy type.

Specified by:
getObjectType in interface FactoryBean

isSingleton

public boolean isSingleton()
Specified by:
isSingleton in interface FactoryBean

isEagerInit

public boolean isEagerInit()
Specified by:
isEagerInit in interface SmartFactoryBean

isPrototype

public boolean isPrototype()
Specified by:
isPrototype in interface SmartFactoryBean

afterPropertiesSet

public void afterPropertiesSet()
Specified by:
afterPropertiesSet in interface InitializingBean

getUnifiedFilter

public Filter getUnifiedFilter()
Assemble configuration properties to create an OSGi filter. Manages internally the unifiedFilter field as a cache, so the filter creation happens only once.

Returns:
osgi filter

destroy

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

setInterface

public void setInterface(Class[] serviceType)
The type that the OSGi service was registered with


setContextClassloader

public void setContextClassloader(String classLoaderManagementOption)

setBundleContext

public void setBundleContext(BundleContext context)
Specified by:
setBundleContext in interface BundleContextAware

setFilter

public void setFilter(String filter)
Parameters:
filter - The filter to set.

setListeners

public void setListeners(TargetSourceLifecycleListener[] listeners)
Parameters:
listeners - The listeners to set.

setServiceBeanName

public void setServiceBeanName(String serviceBeanName)
To find a bean published as a service by the OsgiServiceExporter, simply set this property. You may specify additional filtering criteria if needed (using the filter property) but this is not required.

Parameters:
serviceBeanName - The serviceBeanName to set.

setBeanName

public void setBeanName(String beanName)

setBeanClassLoader

public void setBeanClassLoader(ClassLoader classLoader)
Specified by:
setBeanClassLoader in interface BeanClassLoaderAware


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