1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.kns.web.servlet.dwr;
17
18 import org.directwebremoting.spring.SpringCreator;
19 import org.kuali.rice.core.api.config.property.ConfigContext;
20 import org.kuali.rice.core.api.resourceloader.GlobalResourceLoader;
21 import org.kuali.rice.kew.api.doctype.DocumentTypeService;
22 import org.springframework.beans.factory.BeanFactory;
23
24 import java.lang.reflect.InvocationHandler;
25 import java.lang.reflect.Method;
26 import java.lang.reflect.Proxy;
27
28
29
30
31
32
33
34
35
36 public class GlobalResourceDelegatingSpringCreator extends SpringCreator {
37
38 public static final String KEW_RUN_MODE_PROPERTY = "kew.mode";
39 public static final String DOCUMENT_TYPE_SERVICE = "enDocumentTypeService";
40
41 @Override
42 public Object getInstance() throws InstantiationException {
43
44
45 if(ConfigContext.getCurrentContextConfig().getProperty(KEW_RUN_MODE_PROPERTY).equals("REMOTE") &&
46 this.getBeanName().equals(DOCUMENT_TYPE_SERVICE))
47 {
48 return Proxy.newProxyInstance(getClass().getClassLoader(), new Class<?>[]{DocumentTypeService.class},
49
50 new InvocationHandler() {
51 @Override
52 public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
53 return null;
54 }
55 }
56 );
57 }
58
59 Object bean = GlobalResourceLoader.getService(this.getBeanName());
60
61 if (bean == null) {
62 throw new InstantiationException("Unable to find bean " + this.getBeanName() + " in Rice Global Resource Loader");
63 }
64
65 return bean;
66 }
67
68 }