Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.eclipse.gemini.blueprint.service.exporter.support
Class OsgiServiceFactoryBean

    java.lang.Object
      org.eclipse.gemini.blueprint.service.exporter.support.OsgiServiceFactoryBean

All Implemented Interfaces:
  BundleContextAware, BeanClassLoaderAware, BeanFactoryAware, BeanNameAware, DisposableBean, FactoryBean<ServiceRegistration>, InitializingBean, Ordered

    public class OsgiServiceFactoryBean

extends Object
implements BeanClassLoaderAware, BeanFactoryAware, BeanNameAware, BundleContextAware, FactoryBean<ServiceRegistration>, InitializingBean, Ordered

FactoryBean that transparently publishes other beans in the same application context as OSGi services returning the ServiceRegistration for the given object. Also known as an exporter this class handle the registration and unregistration of an OSGi service for the backing/target object.

The service properties used when publishing the service are determined by the OsgiServicePropertiesResolver. The default implementation uses

- BundleSymbolicName=<bundle symbolic name>
- BundleVersion=<bundle version>
- org.eclipse.gemini.blueprint.bean.name="<bean name>

Note:If thread context class loader management is used ( `setContextClassLoader(ExportContextClassLoader)`, since proxying is required, the target class has to meet certain criterion described in the Spring AOP documentation. In short, final classes are not supported when class enhancement is used.

Author:
  Adrian Colyer, Costin Leau, Hal Hildebrand, Andy Piper

Field Summary

Fields inherited from interface org.springframework.core.Ordered
`HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE`

Constructor Summary
`OsgiServiceFactoryBean()`

Method Summary
`void` | `afterPropertiesSet()`
`void` | `destroy()`
`String` | `getBeanName()` Returns the bean name of this class when configured inside a Spring container.
`Class<?>[]` | `getInterfaces()` Returns the interfaces that will be considered when exporting the target as an OSGi service.
`boolean` | `getLazyListeners()`
`ServiceRegistration` | `getObject()` Returns a `ServiceRegistration` to the OSGi service for the target object.
`Class<? extends ServiceRegistration>` | `getObjectType()`
`int` | `getOrder()`
`int` | `getRanking()` Returns the OSGi ranking used when publishing the service.
`OsgiServicePropertiesResolver` | `getResolver()` Returns the property resolver used for publishing the service.
`Map` | `getServiceProperties()` Returns the properties used when exporting the target as an OSGi service.
`Object` | `getTarget()` Returns the object exported as an OSGi service.
`String` | `getTargetBeanName()` Returns the target bean name.
`boolean` | `isSingleton()`
`void` | `setAutoExport(AutoExport classExporter)` Deprecated.
`void` | `setBeanClassLoader(ClassLoader classLoader)`
`void` | `setBeanFactory(BeanFactory beanFactory)`
`void` | `setBeanName(String name)`
`void` | `setBundleContext(BundleContext context)` Set the `BundleContext` that this bean runs in.
`void` | `setCacheTarget(boolean cacheTarget)` Sets the caching of the exported target object.
`void` | `setContextClassLoader(ExportContextClassLoader ccl)` Deprecated. As of Spring DM 2.0, replaced by `setExportContextClassLoader(ExportContextClassLoaderEnum)`
`void` | `setExportContextClassLoader(ExportContextClassLoaderEnum ccl)` Sets the context class loader management strategy to use when invoking operations on the exposed target bean.
`void` | `setInterfaceDetector(InterfaceDetector detector)` Sets the strategy used for automatically publishing classes.
`void` | `setInterfaces(Class<?>[] interfaces)` Sets the interfaces advertised by the service.These will be advertised in the OSGi space and are considered when looking for a service.
`void` | `setLazyListeners(boolean lazyListeners)` Sets the laziness of the exporter listeners.
`void` | `setListeners(OsgiServiceRegistrationListener[] listeners)` Sets the listeners interested in registration and unregistration events.
`void` | `setOrder(int order)` Set the ordering which will apply to this class's implementation of Ordered, used when applying multiple BeanPostProcessors.
`void` | `setRanking(int ranking)` Shortcut for setting the ranking property of the published service.
`void` | `setRegisterService(boolean register)` Controls whether the service actually gets published or not.
`void` | `setResolver(OsgiServicePropertiesResolver resolver)` Sets the property resolver used when publishing the bean as an OSGi service.
`void` | `setServiceProperties(Map serviceProperties)` Sets the properties used when exposing the target as an OSGi service.
`void` | `setTarget(Object target)` Sets the given object to be export as an OSGi service.
`void` | `setTargetBeanName(String name)` Sets the name of the bean managed by the Spring container, which will be exported as an OSGi service.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### OsgiServiceFactoryBean

    public OsgiServiceFactoryBean()

Method Detail

### afterPropertiesSet

    public void afterPropertiesSet()
                            throws Exception

  Specified by:
    `afterPropertiesSet` in interface `InitializingBean`
  Throws:
    `Exception`

### destroy

    public void destroy()

  Specified by:
    `destroy` in interface `DisposableBean`

### setBeanClassLoader

    public void setBeanClassLoader(ClassLoader classLoader)

  Specified by:
    `setBeanClassLoader` in interface `BeanClassLoaderAware`

### getObject

    public ServiceRegistration getObject()
                                  throws Exception

  Returns a `ServiceRegistration` to the OSGi service for the target object.

  Specified by:
    `getObject` in interface `FactoryBean<ServiceRegistration>`
  Throws:
    `Exception`

### getObjectType

    public Class<? extends ServiceRegistration> getObjectType()

  Specified by:
    `getObjectType` in interface `FactoryBean<ServiceRegistration>`

### isSingleton

    public boolean isSingleton()

  Specified by:
    `isSingleton` in interface `FactoryBean<ServiceRegistration>`

### setContextClassLoader

    public void setContextClassLoader(ExportContextClassLoader ccl)

  Deprecated. As of Spring DM 2.0, replaced by `setExportContextClassLoader(ExportContextClassLoaderEnum)`

  Sets the context class loader management strategy to use when invoking operations on the exposed target bean. By default, `ExportContextClassLoader.UNMANAGED` is used.

  Note: Since proxying is required for context class loader manager, the target class has to meet certain criteria described in the Spring AOP documentation. In short, final classes are not supported when class enhancement is used.

  Parameters:
    `ccl` - context class loader strategy to use
  See Also:
    `ExportContextClassLoader`

### setExportContextClassLoader

    public void setExportContextClassLoader(ExportContextClassLoaderEnum ccl)

  Sets the context class loader management strategy to use when invoking operations on the exposed target bean. By default, `ExportContextClassLoader.UNMANAGED` is used.

  Note: Since proxying is required for context class loader manager, the target class has to meet certain criteria described in the Spring AOP documentation. In short, final classes are not supported when class enhancement is used.

  Parameters:
    `ccl` - context class loader strategy to use
  See Also:
    `ExportContextClassLoader`

### getTarget

    public Object getTarget()

  Returns the object exported as an OSGi service.

  Returns:
    the object exported as an OSGi service

### setTarget

    public void setTarget(Object target)

  Sets the given object to be export as an OSGi service. Normally used when the exported service is a nested bean or an object not managed by the Spring container. Note that the passed target instance is ignored if `setTargetBeanName(String)` is used.

  Parameters:
    `target` - the object to be exported as an OSGi service

### getTargetBeanName

    public String getTargetBeanName()

  Returns the target bean name.

  Returns:
    the target object bean name

### setTargetBeanName

    public void setTargetBeanName(String name)

  Sets the name of the bean managed by the Spring container, which will be exported as an OSGi service. This method is normally what most use-cases need, rather then `setTarget(Object)`.

  Parameters:
    `name` - target bean name

### setAutoExport

    public void setAutoExport(AutoExport classExporter)

  Deprecated.

  Sets the strategy used for automatically publishing classes. This allows the exporter to use the target class hierarchy and/or interfaces for registering the OSGi service. By default, autoExport is disabled `AutoExport.DISABLED`.

  Parameters:
    `classExporter` - class exporter used for automatically publishing service classes.
  See Also:
    `AutoExport`

### setInterfaceDetector

    public void setInterfaceDetector(InterfaceDetector detector)

  Sets the strategy used for automatically publishing classes. This allows the exporter to use the target class hierarchy and/or interfaces for registering the OSGi service. By default, autoExport is disabled `DefaultInterfaceDetector.DISABLED`.

  Parameters:
    `detector` -

### getServiceProperties

    public Map getServiceProperties()

  Returns the properties used when exporting the target as an OSGi service.

  Returns:
    properties used for exporting the target

### setServiceProperties

    public void setServiceProperties(Map serviceProperties)

  Sets the properties used when exposing the target as an OSGi service. If the given argument implements ( `ServicePropertiesChangeListener`), any updates to the properties will be reflected by the service registration.

  Parameters:
    `serviceProperties` - properties used for exporting the target as an OSGi service

### getRanking

    public int getRanking()

  Returns the OSGi ranking used when publishing the service.

  Returns:
    service ranking used when publishing the service

### setRanking

    public void setRanking(int ranking)

  Shortcut for setting the ranking property of the published service.

  Parameters:
    `ranking` - service ranking
  See Also:
    `Constants.SERVICE_RANKING`

### setRegisterService

    public void setRegisterService(boolean register)

  Controls whether the service actually gets published or not. This can be used by application context creators to control service creation without blocking the creation of the context

  Parameters:
    `register` - whether to register the service or not. The default is true.

### setBeanFactory

    public void setBeanFactory(BeanFactory beanFactory)
                        throws BeansException

  Specified by:
    `setBeanFactory` in interface `BeanFactoryAware`
  Throws:
    `BeansException`

### setBundleContext

    public void setBundleContext(BundleContext context)

  Description copied from interface: `BundleContextAware`
  Set the `BundleContext` that this bean runs in. Normally this can be used to initialize an object.

  Specified by:
    `setBundleContext` in interface `BundleContextAware`
  Parameters:
    `context` - the `BundleContext` object to be used by this object

### getResolver

    public OsgiServicePropertiesResolver getResolver()

  Returns the property resolver used for publishing the service.

  Returns:
    service property resolver

### setResolver

    public void setResolver(OsgiServicePropertiesResolver resolver)

  Sets the property resolver used when publishing the bean as an OSGi service.

  Parameters:
    `resolver` - service property resolver

### getInterfaces

    public Class<?>[] getInterfaces()

  Returns the interfaces that will be considered when exporting the target as an OSGi service.

  Returns:
    interfaces under which the target will be published as an OSGi service

### setInterfaces

    public void setInterfaces(Class<?>[] interfaces)

  Sets the interfaces advertised by the service.These will be advertised in the OSGi space and are considered when looking for a service.

  Parameters:
    `interfaces` - array of classes to advertise

### getOrder

    public int getOrder()

  Specified by:
    `getOrder` in interface `Ordered`

### setOrder

    public void setOrder(int order)

  Set the ordering which will apply to this class's implementation of Ordered, used when applying multiple BeanPostProcessors.

  Default value is `Integer.MAX_VALUE`, meaning that it's non-ordered.

  Parameters:
    `order` - ordering value

### getBeanName

    public String getBeanName()

  Returns the bean name of this class when configured inside a Spring container.

  Returns:
    the bean name for this class

### setBeanName

    public void setBeanName(String name)

  Specified by:
    `setBeanName` in interface `BeanNameAware`

### setCacheTarget

    public void setCacheTarget(boolean cacheTarget)

  Sets the caching of the exported target object. When enabled, the exporter will ignore the scope of the target bean and use only the first resolved instance for registration. When disabled (default), the scope of the target bean is considered and each service request, will be directed to the container. Set this option to 'true' to obtain OSGi 4.2 blueprint behaviour.

### setListeners

    public void setListeners(OsgiServiceRegistrationListener[] listeners)

  Sets the listeners interested in registration and unregistration events.

  Parameters:
    `listeners` - registration/unregistration listeners.

### setLazyListeners

    public void setLazyListeners(boolean lazyListeners)

  Sets the laziness of the exporter listeners. Eager listeners (default) will cause the listeners to be called when the service is being exported. In contract, if true is passed, the listeners will be called not when the service is registered but after the first bundle actually requests it or another component requests the service registration. "Lazy listeners" are the equivalent of lazy activated service managers in Blueprint Service (OSGi 4.2).

  Parameters:
    `lazyListeners` - false if the listeners should be called when the service is registered, true if the invocations should occur after the first service/factory bean request

### getLazyListeners

    public boolean getLazyListeners()

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

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