src/core/net/sf/basedb/util/extensions/Extension.java

Code
Comments
Other
Rev Date Author Line
4158 22 Feb 08 nicklas 1 /**
4158 22 Feb 08 nicklas 2   $Id$
4158 22 Feb 08 nicklas 3
4158 22 Feb 08 nicklas 4   Copyright (C) Authors contributing to this file.
4158 22 Feb 08 nicklas 5
4158 22 Feb 08 nicklas 6   This file is part of BASE - BioArray Software Environment.
4158 22 Feb 08 nicklas 7   Available at http://base.thep.lu.se/
4158 22 Feb 08 nicklas 8
4158 22 Feb 08 nicklas 9   BASE is free software; you can redistribute it and/or
4158 22 Feb 08 nicklas 10   modify it under the terms of the GNU General Public License
4479 05 Sep 08 jari 11   as published by the Free Software Foundation; either version 3
4158 22 Feb 08 nicklas 12   of the License, or (at your option) any later version.
4158 22 Feb 08 nicklas 13
4158 22 Feb 08 nicklas 14   BASE is distributed in the hope that it will be useful,
4158 22 Feb 08 nicklas 15   but WITHOUT ANY WARRANTY; without even the implied warranty of
4158 22 Feb 08 nicklas 16   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
4158 22 Feb 08 nicklas 17   GNU General Public License for more details.
4158 22 Feb 08 nicklas 18
4158 22 Feb 08 nicklas 19   You should have received a copy of the GNU General Public License
4515 11 Sep 08 jari 20   along with BASE. If not, see <http://www.gnu.org/licenses/>.
4158 22 Feb 08 nicklas 21 */
4158 22 Feb 08 nicklas 22 package net.sf.basedb.util.extensions;
4158 22 Feb 08 nicklas 23
4163 28 Feb 08 nicklas 24 import net.sf.basedb.core.plugin.About;
4170 07 Mar 08 nicklas 25 import net.sf.basedb.util.extensions.xml.XmlLoader;
4163 28 Feb 08 nicklas 26
4158 22 Feb 08 nicklas 27 /**
4158 22 Feb 08 nicklas 28   Represents a concrete implementation of an extension to an
4158 22 Feb 08 nicklas 29   extension point. Each extension must have a unique ID. We recommend 
4158 22 Feb 08 nicklas 30   that ID:s are generated in the same way as Java package names.
4158 22 Feb 08 nicklas 31   An extension defines an {@link ActionFactory} which is a factory class
4158 22 Feb 08 nicklas 32   that knows how to create actions. The actions should be of the same
4158 22 Feb 08 nicklas 33   class (or a subclass) as specified by the 
4158 22 Feb 08 nicklas 34   {@link ExtensionPoint#getActionClass()} method of the extension point that
4158 22 Feb 08 nicklas 35   the extension is extending.
4158 22 Feb 08 nicklas 36   <p>
4158 22 Feb 08 nicklas 37   If the extension point allows it, the extension may also provide a
4158 22 Feb 08 nicklas 38   {@link RendererFactory}. See {@link ExtensionPoint#allowRendererOverride()}.
4158 22 Feb 08 nicklas 39
4163 28 Feb 08 nicklas 40   <p>
4163 28 Feb 08 nicklas 41   Extensions can, for example, be created:
4163 28 Feb 08 nicklas 42   <ul>
4170 07 Mar 08 nicklas 43   <li>Programmatically, using an {@link ExtensionBean} object.
4163 28 Feb 08 nicklas 44   <li>Loaded from extension definition XML files using a {@link XmlLoader}.
4170 07 Mar 08 nicklas 45   <li>Or, in any other way by providing a custom implementation of this interface.
4163 28 Feb 08 nicklas 46   </ul>
4163 28 Feb 08 nicklas 47   
4163 28 Feb 08 nicklas 48   <p>
4163 28 Feb 08 nicklas 49   Before an extension can be used it must be registered with 
7703 11 Apr 19 nicklas 50   {@link Registry#registerExtension(Extension, ClassLoader)}. The extension point that
4163 28 Feb 08 nicklas 51   the extension extends must of course already be registered in the same
4163 28 Feb 08 nicklas 52   registry.
4163 28 Feb 08 nicklas 53   
4158 22 Feb 08 nicklas 54   @author nicklas
4158 22 Feb 08 nicklas 55   @version 2.7
4158 22 Feb 08 nicklas 56   @base.modified $Date$
4158 22 Feb 08 nicklas 57 */
4158 22 Feb 08 nicklas 58 public interface Extension<A extends Action>
4158 22 Feb 08 nicklas 59 {
4158 22 Feb 08 nicklas 60
4158 22 Feb 08 nicklas 61   /**
4158 22 Feb 08 nicklas 62     Get the ID of the extension.
4158 22 Feb 08 nicklas 63     @return A non-null unique identifier value
4158 22 Feb 08 nicklas 64   */
4158 22 Feb 08 nicklas 65   public String getId();
4158 22 Feb 08 nicklas 66
4158 22 Feb 08 nicklas 67   /**
4158 22 Feb 08 nicklas 68     Get the ID of the extension point this extension is extending.
4158 22 Feb 08 nicklas 69     @return A non-null identifier value
4158 22 Feb 08 nicklas 70   */
4158 22 Feb 08 nicklas 71   public String getExtends();
4158 22 Feb 08 nicklas 72   
4158 22 Feb 08 nicklas 73   /**
4170 07 Mar 08 nicklas 74     The extensions in an extension point are by default ordered by their
4163 28 Feb 08 nicklas 75     index value. Extensions with a low value are ordered before
4170 07 Mar 08 nicklas 76     extensions with a high value. The ordering may be overridden by providing
4170 07 Mar 08 nicklas 77     an external {@link ExtensionsFilter} implementation.
4163 28 Feb 08 nicklas 78     @return The index value
4158 22 Feb 08 nicklas 79   */
4163 28 Feb 08 nicklas 80   public float getIndex();
4158 22 Feb 08 nicklas 81   
4158 22 Feb 08 nicklas 82   /**
4163 28 Feb 08 nicklas 83     Get information about the extensions. This is optional, but
4163 28 Feb 08 nicklas 84     we recommend that at least some documentation and contact
4163 28 Feb 08 nicklas 85     information is given.
4163 28 Feb 08 nicklas 86     @return Optional information about the extension
4163 28 Feb 08 nicklas 87   */
4163 28 Feb 08 nicklas 88   public About getAbout();
4163 28 Feb 08 nicklas 89   
4163 28 Feb 08 nicklas 90   /**
4158 22 Feb 08 nicklas 91     Get the factory class for creating actions. The factory must create
4158 22 Feb 08 nicklas 92     objects of the same class or a subclass as the {@link ExtensionPoint#getActionClass()}
4158 22 Feb 08 nicklas 93     method of the extended extension point returns.
4170 07 Mar 08 nicklas 94     @return An action factory (required)
4158 22 Feb 08 nicklas 95   */
4170 07 Mar 08 nicklas 96   public ActionFactory<? extends A> getActionFactory();
4158 22 Feb 08 nicklas 97   
4158 22 Feb 08 nicklas 98   /**
4158 22 Feb 08 nicklas 99     Get an optional factory class for creating renderers for the actions.
4158 22 Feb 08 nicklas 100     This factory will only be used if the extension point allows it.
4158 22 Feb 08 nicklas 101     
4158 22 Feb 08 nicklas 102     @return A renderer factory or null
4158 22 Feb 08 nicklas 103     @see ExtensionPoint#allowRendererOverride()
4158 22 Feb 08 nicklas 104   */
4170 07 Mar 08 nicklas 105   public RendererFactory<? super A> getRendererFactory();
4158 22 Feb 08 nicklas 106   
4158 22 Feb 08 nicklas 107 }