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