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