public abstract class DependencyInjectionAspectSupport extends Object implements org.springframework.beans.factory.InitializingBean, org.springframework.beans.factory.BeanFactoryAware
There are two ways of doing this: by mapping managed classes to prototype bean definitions in the factory; and by identifying classes of which instances should be autowired into the factory using the autowiring capables of AutowireCapableBeanFactory. If your managed class implements Spring lifecycle interfaces such as BeanFactoryAware or ApplicationContextAware, you must use the former method. With the latter method, only properties will be set, based on automatic satisfaction of dependencies from other beans (singleton or non-singleton) defined in the factory.
Could also use attributes on persistent classes to identify those eligible for autowiring, or even the prototype bean name.
AutowireCapableBeanFactory
Modifier and Type | Class and Description |
---|---|
protected class |
DependencyInjectionAspectSupport.NoAutowiringConfigurationForClassException |
Modifier and Type | Field and Description |
---|---|
protected List |
autowireByTypeClasses
List of Class
|
protected org.apache.log4j.Logger |
log |
Constructor and Description |
---|
DependencyInjectionAspectSupport() |
Modifier and Type | Method and Description |
---|---|
void |
addAutowireByNameClass(Class clazz) |
void |
addAutowireByTypeClass(Class clazz) |
void |
addManagedClassToPrototypeMapping(Class clazz,
String beanName) |
void |
afterPropertiesSet()
Check that mandatory properties were set
|
protected void |
autowireProperties(Object o)
Subclasses can call this to autowire properties on an existing object
|
protected Object |
createAndConfigure(Class clazz)
Subclasses will call this to create an object of the requisite class
|
List |
getAutowireByNameClasses()
Return classes autowired by name
|
List |
getAutowireByTypeClasses()
Return classes autowired by type
|
protected org.springframework.beans.factory.BeanFactory |
getBeanFactory()
Expose the owning bean factory to subclasses.
|
int |
getDefaultAutowireMode() |
Map |
getManagedClassToPrototypeNames()
Return a Map of managed classes to prototype names
|
void |
setAutowireByNameClasses(List autowireByNameClasses)
Set the Classes or class names that will be autowired by name
|
void |
setAutowireByTypeClasses(List autowireByTypeClasses)
Set the Classes or class names that will be autowired by type
|
void |
setBeanFactory(org.springframework.beans.factory.BeanFactory beanFactory) |
void |
setDefaultAutowireMode(int mode)
Convenient property enabling autowiring of all instances.
|
void |
setManagedClassNamesToPrototypeNames(Properties persistentClassBeanNames)
Property key is class FQN, value is prototype name to use to obtain a new instance
|
protected void |
validateConfiguration() |
protected abstract void |
validateProperties()
Subclasses should implement this to validate their configuration
|
protected final org.apache.log4j.Logger log
protected List autowireByTypeClasses
public int getDefaultAutowireMode()
public void setDefaultAutowireMode(int mode)
mode
- The autowireAll to set.public void setBeanFactory(org.springframework.beans.factory.BeanFactory beanFactory)
setBeanFactory
in interface org.springframework.beans.factory.BeanFactoryAware
protected org.springframework.beans.factory.BeanFactory getBeanFactory()
public void setAutowireByTypeClasses(List autowireByTypeClasses)
autowireByTypeClasses
- list of Class or String classnamepublic List getAutowireByTypeClasses()
public void addAutowireByTypeClass(Class clazz)
public void setAutowireByNameClasses(List autowireByNameClasses)
autowireByNameClasses
- list of Class or String classnamepublic List getAutowireByNameClasses()
public void addAutowireByNameClass(Class clazz)
public void setManagedClassNamesToPrototypeNames(Properties persistentClassBeanNames)
persistentClassBeanNames
- public Map getManagedClassToPrototypeNames()
public void addManagedClassToPrototypeMapping(Class clazz, String beanName)
public final void afterPropertiesSet()
afterPropertiesSet
in interface org.springframework.beans.factory.InitializingBean
InitializingBean.afterPropertiesSet()
protected abstract void validateProperties()
protected void validateConfiguration()
protected void autowireProperties(Object o) throws DependencyInjectionAspectSupport.NoAutowiringConfigurationForClassException, org.springframework.beans.BeansException
o
- org.springframework.beans.BeansException
DependencyInjectionAspectSupport.NoAutowiringConfigurationForClassException
protected Object createAndConfigure(Class clazz) throws DependencyInjectionAspectSupport.NoAutowiringConfigurationForClassException
clazz
- DependencyInjectionAspectSupport.NoAutowiringConfigurationForClassException
Copyright © 2020 Atlassian Software Systems Pty Ltd. All rights reserved.