01: /*
02: * Created on 2 Aug 2007
03: */
04: package uk.org.ponder.springutil;
05:
06: import org.springframework.beans.factory.BeanFactory;
07: import org.springframework.beans.factory.BeanFactoryAware;
08:
09: import uk.org.ponder.beanutil.BeanLocator;
10:
11: /** Adapts the Spring BeanFactory interface to the PUC BeanLocator interface **/
12:
13: public class BeanFactoryBeanLocator implements BeanLocator,
14: BeanFactoryAware {
15: private BeanFactory beanfactory;
16:
17: public BeanFactoryBeanLocator() {
18: }
19:
20: public BeanFactoryBeanLocator(BeanFactory beanfactory) {
21: this .beanfactory = beanfactory;
22: }
23:
24: public void setBeanFactory(BeanFactory beanfactory) {
25: this .beanfactory = beanfactory;
26: }
27:
28: public Object locateBean(String name) {
29: return beanfactory.containsBean(name) ? beanfactory
30: .getBean(name) : null;
31: }
32:
33: }
|