1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
package org.kuali.rice.kew.plugin; |
18 | |
|
19 | |
import java.io.FileNotFoundException; |
20 | |
import java.io.IOException; |
21 | |
|
22 | |
import javax.xml.namespace.QName; |
23 | |
|
24 | |
import org.kuali.rice.core.config.ConfigContext; |
25 | |
import org.kuali.rice.core.resourceloader.ResourceLoader; |
26 | |
import org.kuali.rice.kew.exception.InvalidXmlException; |
27 | |
|
28 | |
|
29 | |
|
30 | |
|
31 | |
|
32 | |
|
33 | |
|
34 | |
|
35 | |
|
36 | |
|
37 | |
|
38 | |
|
39 | |
public class ClassLoaderPluginLoader implements PluginLoader { |
40 | |
|
41 | |
private String pluginConfigPath; |
42 | |
private ClassLoader classLoader; |
43 | |
|
44 | 0 | public ClassLoaderPluginLoader(ClassLoader classLoader) { |
45 | 0 | this.classLoader = classLoader; |
46 | 0 | } |
47 | |
|
48 | |
public String getPluginName() { |
49 | 0 | return ResourceLoader.EMBEDDED_PLUGIN; |
50 | |
} |
51 | |
|
52 | |
public Plugin load() throws Exception { |
53 | |
|
54 | 0 | QName name = new QName(ConfigContext.getCurrentContextConfig().getServiceNamespace(), ResourceLoader.EMBEDDED_PLUGIN); |
55 | 0 | Plugin plugin = new Plugin(name, loadPluginConfig(pluginConfigPath), classLoader); |
56 | 0 | plugin.bindThread(); |
57 | |
try { |
58 | 0 | PluginUtils.installResourceLoader(plugin); |
59 | 0 | PluginUtils.installPluginListeners(plugin); |
60 | 0 | } finally { |
61 | 0 | plugin.unbindThread(); |
62 | 0 | } |
63 | 0 | return plugin; |
64 | |
} |
65 | |
|
66 | |
public void setPluginConfigPath(String pluginConfigPath) { |
67 | 0 | this.pluginConfigPath = pluginConfigPath; |
68 | 0 | } |
69 | |
|
70 | |
public boolean isRemoved() { |
71 | 0 | return false; |
72 | |
} |
73 | |
|
74 | |
public boolean isModified() { |
75 | 0 | return false; |
76 | |
} |
77 | |
|
78 | |
private PluginConfig loadPluginConfig(String pluginConfigPath) { |
79 | 0 | PluginConfigParser parser = new PluginConfigParser(); |
80 | |
try { |
81 | 0 | PluginConfig pluginConfig = parser.parse(classLoader.getResource(pluginConfigPath), ConfigContext.getCurrentContextConfig()); |
82 | 0 | pluginConfig.parseConfig(); |
83 | 0 | return pluginConfig; |
84 | 0 | } catch (FileNotFoundException e) { |
85 | 0 | throw new PluginException("Could not locate the plugin config file at path " + pluginConfigPath, e); |
86 | 0 | } catch (IOException ioe) { |
87 | 0 | throw new PluginException("Could not read the plugin config file", ioe); |
88 | 0 | } catch (InvalidXmlException ixe) { |
89 | 0 | throw new PluginException("Could not parse the plugin config file", ixe); |
90 | |
} |
91 | |
} |
92 | |
|
93 | |
} |