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