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.config.ConfigContext;
23 import org.kuali.rice.core.reflect.ObjectDefinition;
24 import org.kuali.rice.core.resourceloader.BaseWrappingResourceLoader;
25 import org.kuali.rice.core.resourceloader.ServiceLocator;
26 import org.kuali.rice.kew.plugin.PluginRegistry;
27 import org.kuali.rice.kew.service.KEWServiceLocator;
28 import org.kuali.rice.kew.util.KEWConstants;
29
30
31
32
33
34
35
36 public class CoreResourceLoader extends BaseWrappingResourceLoader {
37
38 private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger
39 .getLogger(CoreResourceLoader.class);
40
41 public static final QName NAME = new QName(ConfigContext.getCurrentContextConfig().getServiceNamespace(), "KEW_SPRING+PLUGIN_REGISTRY_CONTAINER_RESOURCE_LOADER");
42
43 private final PluginRegistry registry;
44
45 public CoreResourceLoader(ServiceLocator serviceLocator, PluginRegistry registry) {
46 super(CoreResourceLoader.NAME, serviceLocator);
47 this.registry = registry;
48 }
49
50
51
52
53 public Object getService(QName serviceName) {
54 if (isRemoteService(serviceName)) {
55 return null;
56 }
57 Object service = super.getService(serviceName);
58 if (service == null && getRegistry() != null) {
59 service = getRegistry().getService(serviceName);
60 }
61 return service;
62 }
63
64
65
66 @Override
67 public Object getObject(ObjectDefinition objectDefinition) {
68 Object object = super.getObject(objectDefinition);
69 if (object == null && getRegistry() != null) {
70 object = getRegistry().getObject(objectDefinition);
71 }
72 return object;
73 }
74
75 @Override
76 protected boolean shouldWrapService(QName serviceName, Object service) {
77
78 if (serviceName.getLocalPart().equals("transactionTemplate")) {
79 return false;
80 }
81 return super.shouldWrapService(serviceName, service);
82 }
83
84
85
86 @Override
87 public void stop() throws Exception {
88 if (getRegistry() != null) {
89 registry.stop();
90 }
91 super.stop();
92 }
93
94
95
96
97
98
99 protected boolean isRemoteService(QName serviceName) {
100 return (useRemoteEmailServices() &&
101 serviceName.getLocalPart().equals(KEWServiceLocator.IMMEDIATE_EMAIL_REMINDER_SERVICE));
102 }
103
104 protected boolean useRemoteEmailServices() {
105 String useRemoteEmailServicesValue = ConfigContext.getCurrentContextConfig().getProperty(KEWConstants.USE_REMOTE_EMAIL_SERVICES);
106 if (!StringUtils.isBlank(useRemoteEmailServicesValue)) {
107 return new Boolean(useRemoteEmailServicesValue.trim());
108 }
109 return false;
110 }
111
112 public PluginRegistry getRegistry() {
113 return registry;
114 }
115
116 }