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