01: /***************************************************************
02: * This file is part of the [fleXive](R) project.
03: *
04: * Copyright (c) 1999-2007
05: * UCS - unique computing solutions gmbh (http://www.ucs.at)
06: * All rights reserved
07: *
08: * The [fleXive](R) project is free software; you can redistribute
09: * it and/or modify it under the terms of the GNU General Public
10: * License as published by the Free Software Foundation;
11: * either version 2 of the License, or (at your option) any
12: * later version.
13: *
14: * The GNU General Public License can be found at
15: * http://www.gnu.org/copyleft/gpl.html.
16: * A copy is found in the textfile GPL.txt and important notices to the
17: * license from the author are found in LICENSE.txt distributed with
18: * these libraries.
19: *
20: * This library is distributed in the hope that it will be useful,
21: * but WITHOUT ANY WARRANTY; without even the implied warranty of
22: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23: * GNU General Public License for more details.
24: *
25: * For further information about UCS - unique computing solutions gmbh,
26: * please see the company website: http://www.ucs.at
27: *
28: * For further information about [fleXive](R), please see the
29: * project website: http://www.flexive.org
30: *
31: *
32: * This copyright notice MUST APPEAR in all copies of the file!
33: ***************************************************************/package com.flexive.faces.plugin;
34:
35: /**
36: * <p>
37: * An extension point where plugins can be registered. An extension point specifies
38: * a specific subinterface of {@link PluginExecutor}. Plugins registered with this extension
39: * point then use the PluginExecutor's methods to modify the application's behaviour.
40: * </p>
41: * <p>
42: * This class must be subclassed to bind its type parameters but is usually used anonymously
43: * (similar to a ThreadLocal variable), e.g.
44: * </p>
45: * <pre>
46: * public static final ExtensionPoint<MyPluginExecutorInterface> EXTENSION =
47: * <b>new ExtensionPoint<MyPluginExecutorInterface>("myExtensionName") { }</b>;
48: * </pre>
49: * <p><i>Note: it should be possible to use ExtensionPoint directly through a generic
50: * instantiation (i.e. {@code new ExtensionPoint<MyExecutor>()}), however this requires a
51: * more powerful type resolver than the plugin registry's simple implementation. JDK7
52: * will have this.</i></p>
53: *
54: * @author Daniel Lichtenberger (daniel.lichtenberger@flexive.com), UCS - unique computing solutions gmbh (http://www.ucs.at)
55: * @version $Rev: 1 $
56: */
57: public abstract class ExtensionPoint<PEX extends PluginExecutor> {
58: private final String name;
59:
60: /**
61: * Create a new extension point. The name is the unique identifier of the
62: * extension point.
63: *
64: * @param name the extension point name. Used to identify an extension point, must
65: * be unique for the application.
66: */
67: public ExtensionPoint(String name) {
68: this .name = name;
69: }
70:
71: /**
72: * Returns the unique name of this extension point.
73: *
74: * @return the unique name of this extension point.
75: */
76: public String getName() {
77: return name;
78: }
79:
80: @Override
81: public boolean equals(Object o) {
82: if (this == o)
83: return true;
84: if (o == null || !(o instanceof ExtensionPoint))
85: return false;
86: return name.equals(((ExtensionPoint) o).name);
87: }
88:
89: @Override
90: public int hashCode() {
91: return name.hashCode();
92: }
93: }
|