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

Code
Comments
Other
Rev Date Author Line
4207 04 Apr 08 nicklas 1 /**
4207 04 Apr 08 nicklas 2   $Id$
4207 04 Apr 08 nicklas 3
4207 04 Apr 08 nicklas 4   Copyright (C) Authors contributing to this file.
4207 04 Apr 08 nicklas 5
4207 04 Apr 08 nicklas 6   This file is part of BASE - BioArray Software Environment.
4207 04 Apr 08 nicklas 7   Available at http://base.thep.lu.se/
4207 04 Apr 08 nicklas 8
4207 04 Apr 08 nicklas 9   BASE is free software; you can redistribute it and/or
4207 04 Apr 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
4207 04 Apr 08 nicklas 12   of the License, or (at your option) any later version.
4207 04 Apr 08 nicklas 13
4207 04 Apr 08 nicklas 14   BASE is distributed in the hope that it will be useful,
4207 04 Apr 08 nicklas 15   but WITHOUT ANY WARRANTY; without even the implied warranty of
4207 04 Apr 08 nicklas 16   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
4207 04 Apr 08 nicklas 17   GNU General Public License for more details.
4207 04 Apr 08 nicklas 18
4207 04 Apr 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/>.
4207 04 Apr 08 nicklas 21 */
4207 04 Apr 08 nicklas 22 package net.sf.basedb.util.extensions;
4207 04 Apr 08 nicklas 23
4207 04 Apr 08 nicklas 24 /**
4207 04 Apr 08 nicklas 25   Keeps contextual information about a single invokation of
4207 04 Apr 08 nicklas 26   extensions. The {@link Registry#useExtensions(ClientContext, ExtensionsFilter, String...)}
4207 04 Apr 08 nicklas 27   will create invokation contexts for each enabled extension that
4207 04 Apr 08 nicklas 28   extends any of the given extension points.
4207 04 Apr 08 nicklas 29   <p>
4207 04 Apr 08 nicklas 30   
4207 04 Apr 08 nicklas 31   Instances of this class are passed to factory methods,
4207 04 Apr 08 nicklas 32   for example {@link ActionFactory#getActions(InvokationContext)}
4207 04 Apr 08 nicklas 33   to make it possible for the factories to know anything about
4207 04 Apr 08 nicklas 34   the context the extension was invoked in.
4207 04 Apr 08 nicklas 35   <p>
4207 04 Apr 08 nicklas 36   
4207 04 Apr 08 nicklas 37   Do not confuse the invokation context with the a 
4207 04 Apr 08 nicklas 38   {@link ClientContext} object. The invokation context contains
4207 04 Apr 08 nicklas 39   the client context (see {@link #getClientContext()} but has also
4207 04 Apr 08 nicklas 40   a lot more information collected from other parts of the 
4207 04 Apr 08 nicklas 41   extensions system.
4207 04 Apr 08 nicklas 42
4207 04 Apr 08 nicklas 43   @author nicklas
4207 04 Apr 08 nicklas 44   @version 2.7
4207 04 Apr 08 nicklas 45   @base.modified $Date$
4207 04 Apr 08 nicklas 46 */
4207 04 Apr 08 nicklas 47 public abstract class InvokationContext<A extends Action>
4207 04 Apr 08 nicklas 48 {
5486 12 Nov 10 nicklas 49
4207 04 Apr 08 nicklas 50   protected InvokationContext()
4207 04 Apr 08 nicklas 51   {}
4207 04 Apr 08 nicklas 52   
4207 04 Apr 08 nicklas 53   /**
4207 04 Apr 08 nicklas 54     Get the client context that was passed to the 
4207 04 Apr 08 nicklas 55     {@link Registry#useExtensions(ClientContext, ExtensionsFilter, String...)}
4207 04 Apr 08 nicklas 56     method.
4207 04 Apr 08 nicklas 57     @return The client context, or null if the client didn't pass
4207 04 Apr 08 nicklas 58       any context object
4207 04 Apr 08 nicklas 59   */
4207 04 Apr 08 nicklas 60   public abstract ClientContext getClientContext();
4207 04 Apr 08 nicklas 61
4207 04 Apr 08 nicklas 62   /**
4207 04 Apr 08 nicklas 63     Get information about the extension point.
4207 04 Apr 08 nicklas 64     @return An extension point object
4207 04 Apr 08 nicklas 65   */
4207 04 Apr 08 nicklas 66   public abstract ExtensionPoint<? super A> getExtensionPoint();
4207 04 Apr 08 nicklas 67   
4207 04 Apr 08 nicklas 68   /**
4207 04 Apr 08 nicklas 69     Get information about the extension. This method may
5486 12 Nov 10 nicklas 70     return null if there is no current extension, which 
5486 12 Nov 10 nicklas 71     happens when any of the {@link RendererFactory} methods are called 
5486 12 Nov 10 nicklas 72     for a renderer factory attached to an extension point
5486 12 Nov 10 nicklas 73     and for the {@link ErrorHandlerFactory} methods.
4207 04 Apr 08 nicklas 74     @return An extension object, or null if there is no current extension
4207 04 Apr 08 nicklas 75   */
4207 04 Apr 08 nicklas 76   public abstract Extension<A> getExtension();
4207 04 Apr 08 nicklas 77   
4208 07 Apr 08 nicklas 78   /**
6030 28 Mar 12 nicklas 79     Get the class loader that is used for the given extension
6030 28 Mar 12 nicklas 80     or extension point.
6030 28 Mar 12 nicklas 81     @since 3.2
6030 28 Mar 12 nicklas 82   */
6030 28 Mar 12 nicklas 83   public abstract ClassLoader getClassLoader();
6030 28 Mar 12 nicklas 84   
6030 28 Mar 12 nicklas 85   /**
4208 07 Apr 08 nicklas 86     Get the value of an attribute that has been registered
4208 07 Apr 08 nicklas 87     for the extension.
4208 07 Apr 08 nicklas 88     
4208 07 Apr 08 nicklas 89     @param name The name of the attribute
4208 07 Apr 08 nicklas 90     @return The attribute value, or null if no attribute has
4208 07 Apr 08 nicklas 91       been registered
4208 07 Apr 08 nicklas 92     @see Registry#getAttribute(String, String)
4208 07 Apr 08 nicklas 93   */
4207 04 Apr 08 nicklas 94   public abstract Object getAttribute(String name);
4207 04 Apr 08 nicklas 95
4207 04 Apr 08 nicklas 96   /**
4207 04 Apr 08 nicklas 97     Get the registry where this invokation originated from.
4207 04 Apr 08 nicklas 98   */
4207 04 Apr 08 nicklas 99   protected abstract Registry getRegistry();
4207 04 Apr 08 nicklas 100   
4207 04 Apr 08 nicklas 101   /**
4207 04 Apr 08 nicklas 102     Prepare the renderer factory if the extension or extension
4207 04 Apr 08 nicklas 103     point has one.
4207 04 Apr 08 nicklas 104   */
4207 04 Apr 08 nicklas 105   protected abstract void prepareRendererFactory();
4207 04 Apr 08 nicklas 106   
4207 04 Apr 08 nicklas 107   /**
4207 04 Apr 08 nicklas 108     Get the renderer, if any. This method should always return the
4207 04 Apr 08 nicklas 109     same rendere instance if called multiple times on the same object. 
4207 04 Apr 08 nicklas 110   */
4207 04 Apr 08 nicklas 111   protected abstract Renderer<? super A> getRenderer();
4207 04 Apr 08 nicklas 112
4207 04 Apr 08 nicklas 113   /**
4207 04 Apr 08 nicklas 114     Get the actions, or null if there is no current extension.
4207 04 Apr 08 nicklas 115   */
4207 04 Apr 08 nicklas 116   protected abstract A[] getActions();
4207 04 Apr 08 nicklas 117   
4618 30 Oct 08 nicklas 118   /**
4618 30 Oct 08 nicklas 119     Register an error for the current extension or extension point. 
4618 30 Oct 08 nicklas 120     Registered errors can be retrieved by {@link Registry#getLastExtensionError(String)}
4618 30 Oct 08 nicklas 121     and {@link Registry#getLastExtensionPointError(String)}
4618 30 Oct 08 nicklas 122     @param action The action that caused the error
4618 30 Oct 08 nicklas 123     @param t The error
4618 30 Oct 08 nicklas 124     @since 2.9
4618 30 Oct 08 nicklas 125   */
4618 30 Oct 08 nicklas 126   protected abstract void setError(A action, Throwable t);
4618 30 Oct 08 nicklas 127   
4618 30 Oct 08 nicklas 128   /**
4618 30 Oct 08 nicklas 129     Clear the registered error for the current extension or extension point.
4618 30 Oct 08 nicklas 130     @since 2.9
4618 30 Oct 08 nicklas 131   */
4618 30 Oct 08 nicklas 132   protected abstract void clearError();
4618 30 Oct 08 nicklas 133   
5486 12 Nov 10 nicklas 134   /**
5486 12 Nov 10 nicklas 135     Get the error handler used in this context. Should never
5486 12 Nov 10 nicklas 136     be null, since if not the extension point provides one, the
5486 12 Nov 10 nicklas 137     system should.
5486 12 Nov 10 nicklas 138     @since 2.17
5486 12 Nov 10 nicklas 139   */
5486 12 Nov 10 nicklas 140   protected abstract ErrorHandler<? super A> getErrorHandler();
5486 12 Nov 10 nicklas 141   
4207 04 Apr 08 nicklas 142 }