ApplicationContextAware
Provides a reference to ApplicationContext in to the bean;
@Component
public class BeanPostProcessorExtension implements ApplicationContextAware {
private ApplicationContext applicationContext;
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
this.applicationContext = applicationContext;
}
}
BeanNameAware
Provides a reference to the name of the bean derived from it’s bean definition.
public class BeanContextAware extends BaseBean implements BeanNameAware{
public String name;
@Override
public void setBeanName(String name) {
this.name = name;
}
}
DestructionAwareBeanPostProcessor
Subinterface of BeanPostProcessor that adds a before-destruction callback.
public class DestructionAwareBeanPostProcessorExtension implements DestructionAwareBeanPostProcessor {
@Override
public void postProcessBeforeDestruction(Object bean, String beanName) throws BeansException {
}
@Override
public boolean requiresDestruction(Object bean) {
return DestructionAwareBeanPostProcessor.super.requiresDestruction(bean);
}
}
References