4207 |
04 Apr 08 |
nicklas |
1 |
/** |
4207 |
04 Apr 08 |
nicklas |
$Id$ |
4207 |
04 Apr 08 |
nicklas |
3 |
|
4207 |
04 Apr 08 |
nicklas |
Copyright (C) Authors contributing to this file. |
4207 |
04 Apr 08 |
nicklas |
5 |
|
4207 |
04 Apr 08 |
nicklas |
This file is part of BASE - BioArray Software Environment. |
4207 |
04 Apr 08 |
nicklas |
Available at http://base.thep.lu.se/ |
4207 |
04 Apr 08 |
nicklas |
8 |
|
4207 |
04 Apr 08 |
nicklas |
BASE is free software; you can redistribute it and/or |
4207 |
04 Apr 08 |
nicklas |
modify it under the terms of the GNU General Public License |
4479 |
05 Sep 08 |
jari |
as published by the Free Software Foundation; either version 3 |
4207 |
04 Apr 08 |
nicklas |
of the License, or (at your option) any later version. |
4207 |
04 Apr 08 |
nicklas |
13 |
|
4207 |
04 Apr 08 |
nicklas |
BASE is distributed in the hope that it will be useful, |
4207 |
04 Apr 08 |
nicklas |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
4207 |
04 Apr 08 |
nicklas |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
4207 |
04 Apr 08 |
nicklas |
GNU General Public License for more details. |
4207 |
04 Apr 08 |
nicklas |
18 |
|
4207 |
04 Apr 08 |
nicklas |
You should have received a copy of the GNU General Public License |
4515 |
11 Sep 08 |
jari |
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 |
Keeps contextual information about a single invokation of |
4207 |
04 Apr 08 |
nicklas |
extensions. The {@link Registry#useExtensions(ClientContext, ExtensionsFilter, String...)} |
4207 |
04 Apr 08 |
nicklas |
will create invokation contexts for each enabled extension that |
4207 |
04 Apr 08 |
nicklas |
extends any of the given extension points. |
4207 |
04 Apr 08 |
nicklas |
<p> |
4207 |
04 Apr 08 |
nicklas |
30 |
|
4207 |
04 Apr 08 |
nicklas |
Instances of this class are passed to factory methods, |
4207 |
04 Apr 08 |
nicklas |
for example {@link ActionFactory#getActions(InvokationContext)} |
4207 |
04 Apr 08 |
nicklas |
to make it possible for the factories to know anything about |
4207 |
04 Apr 08 |
nicklas |
the context the extension was invoked in. |
4207 |
04 Apr 08 |
nicklas |
<p> |
4207 |
04 Apr 08 |
nicklas |
36 |
|
4207 |
04 Apr 08 |
nicklas |
Do not confuse the invokation context with the a |
4207 |
04 Apr 08 |
nicklas |
{@link ClientContext} object. The invokation context contains |
4207 |
04 Apr 08 |
nicklas |
the client context (see {@link #getClientContext()} but has also |
4207 |
04 Apr 08 |
nicklas |
a lot more information collected from other parts of the |
4207 |
04 Apr 08 |
nicklas |
extensions system. |
4207 |
04 Apr 08 |
nicklas |
42 |
|
4207 |
04 Apr 08 |
nicklas |
@author nicklas |
4207 |
04 Apr 08 |
nicklas |
@version 2.7 |
4207 |
04 Apr 08 |
nicklas |
@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 |
Get the client context that was passed to the |
4207 |
04 Apr 08 |
nicklas |
{@link Registry#useExtensions(ClientContext, ExtensionsFilter, String...)} |
4207 |
04 Apr 08 |
nicklas |
method. |
4207 |
04 Apr 08 |
nicklas |
@return The client context, or null if the client didn't pass |
4207 |
04 Apr 08 |
nicklas |
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 |
Get information about the extension point. |
4207 |
04 Apr 08 |
nicklas |
@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 |
Get information about the extension. This method may |
5486 |
12 Nov 10 |
nicklas |
return null if there is no current extension, which |
5486 |
12 Nov 10 |
nicklas |
happens when any of the {@link RendererFactory} methods are called |
5486 |
12 Nov 10 |
nicklas |
for a renderer factory attached to an extension point |
5486 |
12 Nov 10 |
nicklas |
and for the {@link ErrorHandlerFactory} methods. |
4207 |
04 Apr 08 |
nicklas |
@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 |
Get the class loader that is used for the given extension |
6030 |
28 Mar 12 |
nicklas |
or extension point. |
6030 |
28 Mar 12 |
nicklas |
@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 |
Get the value of an attribute that has been registered |
4208 |
07 Apr 08 |
nicklas |
for the extension. |
4208 |
07 Apr 08 |
nicklas |
88 |
|
4208 |
07 Apr 08 |
nicklas |
@param name The name of the attribute |
4208 |
07 Apr 08 |
nicklas |
@return The attribute value, or null if no attribute has |
4208 |
07 Apr 08 |
nicklas |
been registered |
4208 |
07 Apr 08 |
nicklas |
@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 |
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 |
Prepare the renderer factory if the extension or extension |
4207 |
04 Apr 08 |
nicklas |
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 |
Get the renderer, if any. This method should always return the |
4207 |
04 Apr 08 |
nicklas |
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 |
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 |
Register an error for the current extension or extension point. |
4618 |
30 Oct 08 |
nicklas |
Registered errors can be retrieved by {@link Registry#getLastExtensionError(String)} |
4618 |
30 Oct 08 |
nicklas |
and {@link Registry#getLastExtensionPointError(String)} |
4618 |
30 Oct 08 |
nicklas |
@param action The action that caused the error |
4618 |
30 Oct 08 |
nicklas |
@param t The error |
4618 |
30 Oct 08 |
nicklas |
@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 |
Clear the registered error for the current extension or extension point. |
4618 |
30 Oct 08 |
nicklas |
@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 |
Get the error handler used in this context. Should never |
5486 |
12 Nov 10 |
nicklas |
be null, since if not the extension point provides one, the |
5486 |
12 Nov 10 |
nicklas |
system should. |
5486 |
12 Nov 10 |
nicklas |
@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 |
} |