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.util.ArrayList; |
20 | |
import java.util.Collections; |
21 | |
import java.util.List; |
22 | |
|
23 | |
import javax.xml.namespace.QName; |
24 | |
|
25 | |
import org.kuali.rice.core.api.config.CoreConfigHelper; |
26 | |
import org.kuali.rice.core.api.resourceloader.ResourceLoader; |
27 | |
import org.kuali.rice.core.api.resourceloader.ResourceLoaderContainer; |
28 | |
|
29 | |
|
30 | |
|
31 | |
|
32 | |
|
33 | |
|
34 | |
|
35 | |
|
36 | |
|
37 | |
|
38 | |
|
39 | |
public abstract class BasePluginRegistry extends ResourceLoaderContainer implements PluginRegistry { |
40 | |
|
41 | 0 | private List<PluginEnvironment> pluginEnvironments = Collections.synchronizedList(new ArrayList<PluginEnvironment>()); |
42 | |
|
43 | |
public BasePluginRegistry() { |
44 | 0 | super(new QName(CoreConfigHelper.getApplicationId(), ResourceLoader.PLUGIN_REGISTRY_LOADER_NAME)); |
45 | 0 | } |
46 | |
|
47 | |
public BasePluginRegistry(QName name) { |
48 | 0 | super(name); |
49 | 0 | } |
50 | |
|
51 | |
public PluginEnvironment getPluginEnvironment(String pluginName) { |
52 | 0 | for (PluginEnvironment environment : pluginEnvironments) { |
53 | 0 | if (environment.getPluginName().equals(pluginName)) { |
54 | 0 | return environment; |
55 | |
} |
56 | |
} |
57 | 0 | return null; |
58 | |
} |
59 | |
|
60 | |
public void addPluginEnvironment(PluginEnvironment pluginEnvironment) { |
61 | |
|
62 | 0 | if (pluginEnvironment.getPlugin() != null && !containsResourceLoader(pluginEnvironment.getPlugin())) { |
63 | 0 | addResourceLoader(pluginEnvironment.getPlugin()); |
64 | |
} |
65 | 0 | pluginEnvironments.add(pluginEnvironment); |
66 | 0 | } |
67 | |
|
68 | |
public PluginEnvironment removePluginEnvironment(String pluginName) { |
69 | 0 | PluginEnvironment environment = getPluginEnvironment(pluginName); |
70 | 0 | if (environment == null) { |
71 | 0 | return null; |
72 | |
} |
73 | 0 | if (environment.getPlugin() != null) { |
74 | 0 | super.removeResourceLoader(environment.getPlugin().getName()); |
75 | |
} |
76 | 0 | if (!pluginEnvironments.remove(environment)) { |
77 | 0 | return null; |
78 | |
} |
79 | 0 | return environment; |
80 | |
} |
81 | |
|
82 | |
public Plugin getPlugin(QName pluginName) { |
83 | 0 | return (Plugin)getResourceLoader(pluginName); |
84 | |
} |
85 | |
|
86 | |
public List<QName> getPluginNames() { |
87 | 0 | return super.getResourceLoaderNames(); |
88 | |
} |
89 | |
|
90 | |
public List<PluginEnvironment> getPluginEnvironments() { |
91 | 0 | return Collections.unmodifiableList(pluginEnvironments); |
92 | |
} |
93 | |
} |