1 package nl.hippo.componentcontainers; 2 3 import org.springframework.beans.factory.BeanFactory; 4 import org.springframework.beans.factory.NoSuchBeanDefinitionException; 5 6 public class SpringReference implements ComponentReference 7 { 8 9 private BeanFactory m_beanFactory; 10 11 private String m_componentName; 12 13 public SpringReference(BeanFactory beanFactory, String componentName) 14 { 15 super(); 16 17 m_beanFactory = beanFactory; 18 m_componentName = componentName; 19 } 20 21 public Object get() throws NoSuchComponentException 22 { 23 Object result; 24 25 try 26 { 27 result = m_beanFactory.getBean(m_componentName); 28 } 29 catch (NoSuchBeanDefinitionException e) 30 { 31 throw new NoSuchComponentException(e); 32 } 33 return result; 34 } 35 36 public void release() 37 { 38 } 39 40 } 41 | Popular Tags |