eaf55336c185f74afc0d72de41a0da54cc3afdfb
[utils] / system / spring / src / main / java / org / wamblee / system / spring / RequiredServiceBean.java
1 package org.wamblee.system.spring;
2
3 import org.springframework.beans.factory.FactoryBean;
4
5 /**
6  * Bean which adds a service required by the spring component to 
7  * the application context so that other spring beans can use it.  
8  *  
9  * @author Erik Brakkee
10  */
11 class RequiredServiceBean implements FactoryBean {
12         
13         private String _id;
14         
15         /**
16          * Constructs the bean. 
17          * @param aId Id of the bean in the service registry.  
18          */
19         public RequiredServiceBean(String aId) { 
20                 _id = aId; 
21         }
22
23         @Override
24         public Object getObject() throws Exception {
25                 return SpringComponent.REGISTRY.get().find(_id).reference(Object.class);
26         }
27
28         @Override
29         public Class getObjectType() {
30                 return null;
31         }
32
33         @Override
34         public boolean isSingleton() {
35                 return true; 
36         }
37
38 }