01: package org.kuali.rice.kns.config;
02:
03: import org.kuali.rice.config.ConfigurationException;
04: import org.kuali.rice.resourceloader.GlobalResourceLoader;
05: import org.springframework.beans.factory.FactoryBean;
06: import org.springframework.beans.factory.InitializingBean;
07:
08: /**
09: * Exports services in the {@link GlobalResourceLoader} as beans available to Spring.
10: *
11: * @author Kuali Rice Team (kuali-rice@googlegroups.com)
12: *
13: */
14: public class GlobalResourceLoaderServiceFactoryBean implements
15: FactoryBean, InitializingBean {
16:
17: private String serviceName;
18: private boolean singleton;
19:
20: public Object getObject() throws Exception {
21: return GlobalResourceLoader.getService(this .getServiceName());
22: }
23:
24: public Class getObjectType() {
25: return Object.class;
26: }
27:
28: public boolean isSingleton() {
29: return singleton;
30: }
31:
32: public String getServiceName() {
33: return serviceName;
34: }
35:
36: public void setServiceName(String serviceName) {
37: this .serviceName = serviceName;
38: }
39:
40: public void setSingleton(boolean singleton) {
41: this .singleton = singleton;
42: }
43:
44: public void afterPropertiesSet() throws Exception {
45: if (this .getServiceName() == null) {
46: throw new ConfigurationException("No serviceName given.");
47: }
48: }
49:
50: }
|