public abstract class AbstractSpringReferenceSupporter extends Object
Abstract base class for spring bean finding. Used by AbstractSpringReference
.
This class is intended to be used in a singleton/service way because it maintains caches to speed up lookups. Subclasses must implement the getApplicationContext() method used to locate the spring context. This class does not depend on wicket or spring-web. So in theory subclasses can be used in non-wicket, non-web spring applications too.
Constructor and Description |
---|
AbstractSpringReferenceSupporter() |
Modifier and Type | Method and Description |
---|---|
void |
clearCache()
Clears the internal cache.
|
<T> T |
findAndSetInstance(AbstractSpringReference<T> ref)
Looks up the spring bean from a spring
ApplicationContext . |
protected <T> String |
findBeanName(AbstractSpringReference<T> ref)
Finds out the exact name for a spring bean.
|
protected abstract org.springframework.context.ApplicationContext |
getApplicationContext() |
protected org.springframework.beans.factory.config.BeanDefinition |
getBeanDefinition(org.springframework.beans.factory.config.ConfigurableListableBeanFactory fact,
String name)
Tries to get the
BeanDefinition of a spring bean. |
public <T> T findAndSetInstance(AbstractSpringReference<T> ref)
ApplicationContext
. The bean is set in the
reference. If the name was not given for the reference this method will fill that too. Throws
a RuntimeException
if the bean could not be found.T
- type of the wrapped spring beanref
- reference where the instance will be setRuntimeException
if loading failed.protected <T> String findBeanName(AbstractSpringReference<T> ref)
T
- type of the wrapped spring beanref
- reference to find name forIllegalStateException
if there is not exactly one
candidate.protected org.springframework.beans.factory.config.BeanDefinition getBeanDefinition(org.springframework.beans.factory.config.ConfigurableListableBeanFactory fact, String name)
BeanDefinition
of a spring bean.fact
- spring bean factoryname
- spring bean name to find definition forprotected abstract org.springframework.context.ApplicationContext getApplicationContext()
public void clearCache()
Copyright © 2015. All rights reserved.