KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > dspace > core > SelfNamedPlugin


1 /*
2  * SelfNamedPlugin.java
3  *
4  * Version: $Revision: 1.1 $
5  *
6  * Date: $Date: 2005/10/13 01:11:51 $
7  *
8  * Copyright (c) 2002-2005, Hewlett-Packard Company and Massachusetts
9  * Institute of Technology. All rights reserved.
10  *
11  * Redistribution and use in source and binary forms, with or without
12  * modification, are permitted provided that the following conditions are
13  * met:
14  *
15  * - Redistributions of source code must retain the above copyright
16  * notice, this list of conditions and the following disclaimer.
17  *
18  * - Redistributions in binary form must reproduce the above copyright
19  * notice, this list of conditions and the following disclaimer in the
20  * documentation and/or other materials provided with the distribution.
21  *
22  * - Neither the name of the Hewlett-Packard Company nor the name of the
23  * Massachusetts Institute of Technology nor the names of their
24  * contributors may be used to endorse or promote products derived from
25  * this software without specific prior written permission.
26  *
27  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
28  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
29  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
30  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
31  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
32  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
33  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
34  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
35  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
36  * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
37  * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
38  * DAMAGE.
39  */

40 package org.dspace.core;
41
42 /**
43  * Simple lightweight "framework" for managing plugins.
44  * <p>
45  * This is a superclass of all classes which are managed as self-named
46  * plugins. They must extend <code>SelfNamedPlugin</code> or its
47  * subclass.
48  * <p>
49  * Unfortunately, this has to be an <code>abstract class</code> because
50  * an <code>interface</code> may not have static methods. The
51  * <code>pluginAliases</code> method is static so it can be invoked
52  * without creating an instance, and thus let the aliases live in the
53  * class itself so there is no need for name mapping in a separate
54  * configuration file.
55  * <p>
56  * See the documentation in the
57  * <code>PluginManager</code> class for more details.
58  *
59  * @author Larry Stone
60  * @version $Revision: 1.1 $
61  * @see PluginManager
62  */

63 public abstract class SelfNamedPlugin
64 {
65     // the specific alias used to find the class that created this instance.
66
private String JavaDoc myName = null;
67
68     /**
69      * Get the names of this plugin implementation.
70      * Returns all names to which this plugin answers.
71      * <p>
72      * A name should be a short generic name illustrative of the
73      * service, e.g. <code>"PDF"</code>, <code>"JPEG"</code>, <code>"GIF"</code>
74      * for media filters.
75      * <p>
76      * Each name must be unique among all the plugins implementing any
77      * given interface, but it can be the same as a name of
78      * a plugin for a different interface. For example, two classes
79      * may each have a <code>"default"</code> name if they do not
80      * implement any of the same interfaces.
81      *
82      * @return array of names of this plugin
83      */

84     public static String JavaDoc[] getPluginNames()
85     {
86         return null;
87     }
88
89     /**
90      * Get an instance's particular name.
91      * Returns the name by which the class was chosen when
92      * this instance was created. Only works for instances created
93      * by <code>PluginManager</code>, or if someone remembers to call <code>setPluginName.</code>
94      * <p>
95      * Useful when the implementation class wants to be configured differently
96      * when it is invoked under different names.
97      *
98      * @return name or null if not available.
99      */

100     public String JavaDoc getPluginInstanceName()
101     {
102         return myName;
103     }
104
105     /**
106      * Set the name under which this plugin was instantiated.
107      * Not to be invoked by application code, it is
108      * called automatically by <code>PluginManager.getNamedPlugin()</code>
109      * when the plugin is instantiated.
110      *
111      * @param name -- name used to select this class.
112      */

113     protected void setPluginInstanceName(String JavaDoc name)
114     {
115         myName = name;
116     }
117 }
118
Popular Tags