KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > portal > common > plugin > AbstractPluginContainer


1 /*****************************************
2  * *
3  * JBoss Portal: The OpenSource Portal *
4  * *
5  * Distributable under LGPL license. *
6  * See terms of license at gnu.org. *
7  * *
8  *****************************************/

9 package org.jboss.portal.common.plugin;
10
11 import java.util.HashMap JavaDoc;
12 import java.util.Map JavaDoc;
13 import java.util.Set JavaDoc;
14
15 /**
16  * @author <a HREF="mailto:julien@jboss.org">Julien Viet</a>
17  * @version $Revision: 1.2 $
18  */

19 public class AbstractPluginContainer implements PluginContainer
20 {
21
22    protected Map JavaDoc plugins;
23
24    public AbstractPluginContainer(Map JavaDoc plugins)
25    {
26       this.plugins = plugins;
27    }
28
29    public AbstractPluginContainer()
30    {
31       this(new HashMap JavaDoc());
32    }
33
34    public synchronized void addPlugin(String JavaDoc key, Plugin plugin)
35    {
36       Map JavaDoc copy = new HashMap JavaDoc(plugins);
37       copy.put(key, plugin);
38       plugins = copy;
39    }
40
41    public synchronized void removePlugin(String JavaDoc key)
42    {
43       Map JavaDoc copy = new HashMap JavaDoc(plugins);
44       copy.remove(key);
45       plugins = copy;
46    }
47
48    public Plugin getPlugin(String JavaDoc key)
49    {
50       return (Plugin)plugins.get(key);
51    }
52
53    public Set JavaDoc getPluginKeySet()
54    {
55       return plugins.keySet();
56    }
57 }
58
Popular Tags