AbstractServiceLoaderBasedFactoryBean (Spring Framework 3.2.1.RELEASE API)
Date: 2013-01-24

org.springframework.beans.factory.serviceloader

## Class AbstractServiceLoaderBasedFactoryBean

- java.lang.Object
- - org.springframework.beans.factory.config.AbstractFactoryBean
  - - org.springframework.beans.factory.serviceloader.AbstractServiceLoaderBasedFactoryBean

- All Implemented Interfaces:
    Aware, BeanClassLoaderAware, BeanFactoryAware, DisposableBean, FactoryBean, InitializingBean
  Direct Known Subclasses:
    ServiceFactoryBean, ServiceListFactoryBean, ServiceLoaderFactoryBean

      public abstract class AbstractServiceLoaderBasedFactoryBean
      extends AbstractFactoryBean
      implements BeanClassLoaderAware

  Abstract base class for FactoryBeans operating on the JDK 1.6 `ServiceLoader` facility.
  Since:
    2.5
  Author:
    Juergen Hoeller
  See Also:
    `ServiceLoader`

- - ### Field Summary

    - ### Fields inherited from class org.springframework.beans.factory.config.AbstractFactoryBean

      `logger`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `AbstractServiceLoaderBasedFactoryBean()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected Object` | `createInstance()` Delegates to `getObjectToExpose(java.util.ServiceLoader)`.
    `protected abstract Object` | `getObjectToExpose(ServiceLoader serviceLoader)` Determine the actual object to expose for the given ServiceLoader.
    `Class` | `getServiceType()` Return the desired service type.
    `void` | `setBeanClassLoader(ClassLoader beanClassLoader)` Callback that supplies the bean `class loader` to a bean instance.
    `void` | `setServiceType(Class serviceType)` Specify the desired service type (typically the service's public API).

    - ### Methods inherited from class org.springframework.beans.factory.config.AbstractFactoryBean

      `afterPropertiesSet, destroy, destroyInstance, getBeanFactory, getBeanTypeConverter, getEarlySingletonInterfaces, getObject, getObjectType, isSingleton, setBeanFactory, setSingleton`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### AbstractServiceLoaderBasedFactoryBean

          public AbstractServiceLoaderBasedFactoryBean()

  - ### Method Detail

    - #### setServiceType

          public void setServiceType(Class serviceType)

      Specify the desired service type (typically the service's public API).

    - #### getServiceType

          public Class getServiceType()

      Return the desired service type.

    - #### setBeanClassLoader

          public void setBeanClassLoader(ClassLoader beanClassLoader)

      Description copied from interface: `BeanClassLoaderAware`
      Callback that supplies the bean `class loader` to a bean instance.

      Invoked after the population of normal bean properties but before an initialization callback such as `InitializingBean's` `InitializingBean.afterPropertiesSet()` method or a custom init-method.

      Specified by:
        `setBeanClassLoader` in interface `BeanClassLoaderAware`
      Overrides:
        `setBeanClassLoader` in class `AbstractFactoryBean`
      Parameters:
        `beanClassLoader` - the owning class loader; may be `null` in which case a default `ClassLoader` must be used, for example the `ClassLoader` obtained via `ClassUtils.getDefaultClassLoader()`

    - #### createInstance

          protected Object createInstance()

      Delegates to `getObjectToExpose(java.util.ServiceLoader)`.
      Specified by:
        `createInstance` in class `AbstractFactoryBean`
      Returns:
        the object to expose
      See Also:
        `AbstractFactoryBean.getObject()`

    - #### getObjectToExpose

          protected abstract Object getObjectToExpose(ServiceLoader serviceLoader)

      Determine the actual object to expose for the given ServiceLoader.

      Left to concrete subclasses.

      Parameters:
        `serviceLoader` - the ServiceLoader for the configured service class
      Returns:
        the object to expose