static class AbstractTypeAwareSupport.BeansOfTypeTargetSource
extends java.lang.Object
implements org.springframework.aop.TargetSource
TargetSource implementation that returns all beans of the configured type from the
ListableBeanFactory the instance was set up with. Allows freezing the lookup as calls to
ListableBeanFactory.getBeansOfType(Class, boolean, boolean) are potentially expensive as the entire factory
has to be scanned for type information.| Modifier and Type | Field and Description |
|---|---|
private java.util.Collection<java.lang.Object> |
components |
private org.springframework.beans.factory.ListableBeanFactory |
context |
private boolean |
eagerInit |
private java.util.Collection<java.lang.Class<?>> |
exclusions |
private boolean |
frozen |
private java.lang.Class<?> |
type |
| Constructor and Description |
|---|
BeansOfTypeTargetSource(org.springframework.beans.factory.ListableBeanFactory context,
java.lang.Class<?> type,
boolean eagerInit,
java.util.Collection<java.lang.Class<?>> exclusions)
Creates a new
AbstractTypeAwareSupport.BeansOfTypeTargetSource using the given ListableBeanFactory to lookup beans of the
given type. |
| Modifier and Type | Method and Description |
|---|---|
void |
freeze()
Freezes the
TargetSource so that the next access to getTarget() will get the results cached and
reused. |
private java.util.Collection<java.lang.Object> |
getBeansOfTypeExcept(java.lang.Class<?> type,
java.util.Collection<java.lang.Class<?>> exceptions) |
java.lang.Object |
getTarget() |
java.lang.Class<?> |
getTargetClass() |
boolean |
isStatic() |
void |
releaseTarget(java.lang.Object target) |
private final org.springframework.beans.factory.ListableBeanFactory context
private final java.lang.Class<?> type
private final boolean eagerInit
private final java.util.Collection<java.lang.Class<?>> exclusions
private boolean frozen
private java.util.Collection<java.lang.Object> components
public BeansOfTypeTargetSource(org.springframework.beans.factory.ListableBeanFactory context,
java.lang.Class<?> type,
boolean eagerInit,
java.util.Collection<java.lang.Class<?>> exclusions)
AbstractTypeAwareSupport.BeansOfTypeTargetSource using the given ListableBeanFactory to lookup beans of the
given type.context - must not be null.type - must not be null.eagerInit - whether to eagerly init FactoryBeans, defaults to false.public void freeze()
TargetSource so that the next access to getTarget() will get the results cached and
reused.public java.lang.Class<?> getTargetClass()
getTargetClass in interface org.springframework.aop.TargetClassAwaregetTargetClass in interface org.springframework.aop.TargetSourcepublic boolean isStatic()
isStatic in interface org.springframework.aop.TargetSourcepublic java.lang.Object getTarget()
throws java.lang.Exception
getTarget in interface org.springframework.aop.TargetSourcejava.lang.Exceptionpublic void releaseTarget(java.lang.Object target)
throws java.lang.Exception
releaseTarget in interface org.springframework.aop.TargetSourcejava.lang.Exceptionprivate java.util.Collection<java.lang.Object> getBeansOfTypeExcept(java.lang.Class<?> type,
java.util.Collection<java.lang.Class<?>> exceptions)