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 | 0 | 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 | 0 | super(CoreResourceLoader.NAME, serviceLocator); |
45 | 0 | this.registry = registry; |
46 | 0 | } |
47 | |
|
48 | |
|
49 | |
|
50 | |
|
51 | |
public Object getService(QName serviceName) { |
52 | 0 | if (isRemoteService(serviceName)) { |
53 | 0 | return null; |
54 | |
} |
55 | 0 | Object service = super.getService(serviceName); |
56 | 0 | if (service == null && getRegistry() != null) { |
57 | 0 | service = getRegistry().getService(serviceName); |
58 | |
} |
59 | 0 | return service; |
60 | |
} |
61 | |
|
62 | |
|
63 | |
|
64 | |
@Override |
65 | |
public Object getObject(ObjectDefinition objectDefinition) { |
66 | 0 | Object object = super.getObject(objectDefinition); |
67 | 0 | if (object == null && getRegistry() != null) { |
68 | 0 | object = getRegistry().getObject(objectDefinition); |
69 | |
} |
70 | 0 | return object; |
71 | |
} |
72 | |
|
73 | |
@Override |
74 | |
protected boolean shouldWrapService(QName serviceName, Object service) { |
75 | |
|
76 | 0 | if (serviceName.getLocalPart().equals("transactionTemplate")) { |
77 | 0 | return false; |
78 | |
} |
79 | 0 | return super.shouldWrapService(serviceName, service); |
80 | |
} |
81 | |
|
82 | |
|
83 | |
|
84 | |
@Override |
85 | |
public void stop() throws Exception { |
86 | 0 | if (getRegistry() != null) { |
87 | 0 | registry.stop(); |
88 | |
} |
89 | 0 | super.stop(); |
90 | 0 | } |
91 | |
|
92 | |
|
93 | |
|
94 | |
|
95 | |
|
96 | |
|
97 | |
protected boolean isRemoteService(QName serviceName) { |
98 | 0 | return (useRemoteEmailServices() && |
99 | |
serviceName.getLocalPart().equals(KEWServiceLocator.IMMEDIATE_EMAIL_REMINDER_SERVICE)); |
100 | |
} |
101 | |
|
102 | |
protected boolean useRemoteEmailServices() { |
103 | 0 | String useRemoteEmailServicesValue = ConfigContext.getCurrentContextConfig().getProperty(KEWConstants.USE_REMOTE_EMAIL_SERVICES); |
104 | 0 | if (!StringUtils.isBlank(useRemoteEmailServicesValue)) { |
105 | 0 | return new Boolean(useRemoteEmailServicesValue.trim()); |
106 | |
} |
107 | 0 | return false; |
108 | |
} |
109 | |
|
110 | |
public PluginRegistry getRegistry() { |
111 | 0 | return registry; |
112 | |
} |
113 | |
|
114 | |
} |