1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.kuali.rice.kew.resourceloader;
18
19 import javax.xml.namespace.QName;
20
21 import org.apache.commons.lang.StringUtils;
22 import org.kuali.rice.core.api.config.CoreConfigHelper;
23 import org.kuali.rice.core.api.config.property.ConfigContext;
24 import org.kuali.rice.core.api.reflect.ObjectDefinition;
25 import org.kuali.rice.core.api.resourceloader.ServiceLocator;
26 import org.kuali.rice.core.impl.resourceloader.BaseWrappingResourceLoader;
27 import org.kuali.rice.kew.plugin.PluginRegistry;
28 import org.kuali.rice.kew.service.KEWServiceLocator;
29 import org.kuali.rice.kew.util.KEWConstants;
30
31
32
33
34
35
36
37 public class CoreResourceLoader extends BaseWrappingResourceLoader {
38
39 public static final QName NAME = new QName(CoreConfigHelper.getApplicationId(), "KEW_SPRING+PLUGIN_REGISTRY_CONTAINER_RESOURCE_LOADER");
40
41 private final PluginRegistry registry;
42
43 public CoreResourceLoader(ServiceLocator serviceLocator, PluginRegistry registry) {
44 super(CoreResourceLoader.NAME, serviceLocator);
45 this.registry = registry;
46 }
47
48
49
50
51 public Object getService(QName serviceName) {
52 if (isRemoteService(serviceName)) {
53 return null;
54 }
55 Object service = super.getService(serviceName);
56 if (service == null && getRegistry() != null) {
57 service = getRegistry().getService(serviceName);
58 }
59 return service;
60 }
61
62
63
64 @Override
65 public Object getObject(ObjectDefinition objectDefinition) {
66 Object object = super.getObject(objectDefinition);
67 if (object == null && getRegistry() != null) {
68 object = getRegistry().getObject(objectDefinition);
69 }
70 return object;
71 }
72
73 @Override
74 protected boolean shouldWrapService(QName serviceName, Object service) {
75
76 if (serviceName.getLocalPart().equals("transactionTemplate")) {
77 return false;
78 }
79 return super.shouldWrapService(serviceName, service);
80 }
81
82
83
84 @Override
85 public void stop() throws Exception {
86 if (getRegistry() != null) {
87 registry.stop();
88 }
89 super.stop();
90 }
91
92
93
94
95
96
97 protected boolean isRemoteService(QName serviceName) {
98 return (useRemoteEmailServices() &&
99 serviceName.getLocalPart().equals(KEWServiceLocator.IMMEDIATE_EMAIL_REMINDER_SERVICE));
100 }
101
102 protected boolean useRemoteEmailServices() {
103 String useRemoteEmailServicesValue = ConfigContext.getCurrentContextConfig().getProperty(KEWConstants.USE_REMOTE_EMAIL_SERVICES);
104 if (!StringUtils.isBlank(useRemoteEmailServicesValue)) {
105 return new Boolean(useRemoteEmailServicesValue.trim());
106 }
107 return false;
108 }
109
110 public PluginRegistry getRegistry() {
111 return registry;
112 }
113
114 }