1 /*
2 Copyright (C) 2000 - 2007 Grid Systems, S.A.
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License, version 2, as
6 published by the Free Software Foundation.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12
13 You should have received a copy of the GNU General Public License
14 along with this program; if not, write to the Free Software
15 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 */
17 package com.gridsystems.innergrid.kernel.plugin;
18
19 import java.util.LinkedHashMap;
20
21 /**
22 * Map implementation in which keys can be "typed" by adding a suffix.
23 *
24 * @author Rodrigo Ruiz
25 * @version 1.0
26 */
27 public class PluginMap extends LinkedHashMap<String, Plugin> {
28 /**
29 * Default Serial Version UID.
30 */
31 private static final long serialVersionUID = 123452345346L;
32
33 /**
34 * Default constructor.
35 */
36 public PluginMap() {
37 super();
38 }
39
40 /**
41 * Gets a plugin item from the map by its name.
42 * <p>
43 * If the specified name includes a type suffix, it performs a direct search. If a
44 * type suffix is not provided, it will first search for a local version, and if not
45 * found, it will try to find a proxy version.
46 *
47 * @param name The plugin name
48 * @return The plugin instance
49 */
50 public Plugin getPlugin(String name) {
51 return (Plugin)super.get(name);
52 }
53
54 /**
55 * Adds a plugin to the map.
56 *
57 * @param plugin The plugin to add
58 */
59 public void addPlugin(Plugin plugin) {
60 if (plugin != null) {
61 super.put(plugin.getName(), plugin);
62 }
63 }
64
65 /**
66 * Removes a plugin from the map.
67 *
68 * @param plugin The plugin to remove
69 */
70 public void removePlugin(Plugin plugin) {
71 if (plugin != null) {
72 super.remove(plugin.getName());
73 }
74 }
75 }