public abstract class AbstractServiceLoaderBasedFactoryBean extends AbstractFactoryBean<java.lang.Object> implements BeanClassLoaderAware
ServiceLoader
facility.ServiceLoader
Modifier and Type | Field and Description |
---|---|
private java.lang.ClassLoader |
beanClassLoader |
private java.lang.Class<?> |
serviceType |
logger
Constructor and Description |
---|
AbstractServiceLoaderBasedFactoryBean() |
Modifier and Type | Method and Description |
---|---|
protected java.lang.Object |
createInstance()
Delegates to
getObjectToExpose(java.util.ServiceLoader) . |
protected abstract java.lang.Object |
getObjectToExpose(java.util.ServiceLoader<?> serviceLoader)
Determine the actual object to expose for the given ServiceLoader.
|
java.lang.Class<?> |
getServiceType()
Return the desired service type.
|
void |
setBeanClassLoader(java.lang.ClassLoader beanClassLoader)
Callback that supplies the bean
class loader to
a bean instance. |
void |
setServiceType(java.lang.Class<?> serviceType)
Specify the desired service type (typically the service's public API).
|
afterPropertiesSet, destroy, destroyInstance, getBeanFactory, getBeanTypeConverter, getEarlySingletonInterfaces, getObject, getObjectType, isSingleton, setBeanFactory, setSingleton
private java.lang.Class<?> serviceType
private java.lang.ClassLoader beanClassLoader
public AbstractServiceLoaderBasedFactoryBean()
public void setServiceType(java.lang.Class<?> serviceType)
public java.lang.Class<?> getServiceType()
public void setBeanClassLoader(java.lang.ClassLoader beanClassLoader)
BeanClassLoaderAware
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.
setBeanClassLoader
in interface BeanClassLoaderAware
setBeanClassLoader
in class AbstractFactoryBean<java.lang.Object>
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()
protected java.lang.Object createInstance()
getObjectToExpose(java.util.ServiceLoader)
.createInstance
in class AbstractFactoryBean<java.lang.Object>
AbstractFactoryBean.getObject()
protected abstract java.lang.Object getObjectToExpose(java.util.ServiceLoader<?> serviceLoader)
Left to concrete subclasses.
serviceLoader
- the ServiceLoader for the configured service class