4158 |
22 Feb 08 |
nicklas |
1 |
/** |
4198 |
28 Mar 08 |
nicklas |
$Id:RendererFactory.java 4187 2008-03-20 11:15:25Z nicklas $ |
4158 |
22 Feb 08 |
nicklas |
3 |
|
4158 |
22 Feb 08 |
nicklas |
Copyright (C) Authors contributing to this file. |
4158 |
22 Feb 08 |
nicklas |
5 |
|
4158 |
22 Feb 08 |
nicklas |
This file is part of BASE - BioArray Software Environment. |
4158 |
22 Feb 08 |
nicklas |
Available at http://base.thep.lu.se/ |
4158 |
22 Feb 08 |
nicklas |
8 |
|
4158 |
22 Feb 08 |
nicklas |
BASE is free software; you can redistribute it and/or |
4158 |
22 Feb 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 |
4158 |
22 Feb 08 |
nicklas |
of the License, or (at your option) any later version. |
4158 |
22 Feb 08 |
nicklas |
13 |
|
4158 |
22 Feb 08 |
nicklas |
BASE is distributed in the hope that it will be useful, |
4158 |
22 Feb 08 |
nicklas |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
4158 |
22 Feb 08 |
nicklas |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
4158 |
22 Feb 08 |
nicklas |
GNU General Public License for more details. |
4158 |
22 Feb 08 |
nicklas |
18 |
|
4158 |
22 Feb 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/>. |
4158 |
22 Feb 08 |
nicklas |
21 |
*/ |
4158 |
22 Feb 08 |
nicklas |
22 |
package net.sf.basedb.util.extensions; |
4158 |
22 Feb 08 |
nicklas |
23 |
|
4170 |
07 Mar 08 |
nicklas |
24 |
import net.sf.basedb.util.extensions.xml.XmlLoader; |
4170 |
07 Mar 08 |
nicklas |
25 |
|
4158 |
22 Feb 08 |
nicklas |
26 |
/** |
4158 |
22 Feb 08 |
nicklas |
A renderer factory is a factory that can create {@link Renderer} |
4158 |
22 Feb 08 |
nicklas |
objects. An extension point may provide a default factory |
4158 |
22 Feb 08 |
nicklas |
({@link ExtensionPoint#getRendererFactory()}). If allowed by the |
4158 |
22 Feb 08 |
nicklas |
extension point an extension may provide it's own factory |
4158 |
22 Feb 08 |
nicklas |
implementation ({@link Extension#getRendererFactory()}. |
4158 |
22 Feb 08 |
nicklas |
32 |
|
4170 |
07 Mar 08 |
nicklas |
<p> |
4170 |
07 Mar 08 |
nicklas |
Renderer factory implementations must be thread-safe, since a |
4170 |
07 Mar 08 |
nicklas |
single instance of the factory may have to serve multiple requests |
4170 |
07 Mar 08 |
nicklas |
at the same time. |
4170 |
07 Mar 08 |
nicklas |
37 |
|
4170 |
07 Mar 08 |
nicklas |
<p> |
4170 |
07 Mar 08 |
nicklas |
Note 1! A single factory instance may be used by more than one |
4170 |
07 Mar 08 |
nicklas |
extension/extension point. This is at the control of the client application. |
4170 |
07 Mar 08 |
nicklas |
41 |
|
4170 |
07 Mar 08 |
nicklas |
<p> |
4170 |
07 Mar 08 |
nicklas |
Note 2! The BASE web-client uses the {@link XmlLoader} to |
4170 |
07 Mar 08 |
nicklas |
define extensions. The <code>XmlLoader</code> always create a |
4170 |
07 Mar 08 |
nicklas |
separate factory instance for each extension/extension point. |
4170 |
07 Mar 08 |
nicklas |
The <code>XmlLoader</code> also requires that the factories has |
4170 |
07 Mar 08 |
nicklas |
a public no-argument constructor. |
4170 |
07 Mar 08 |
nicklas |
48 |
|
4158 |
22 Feb 08 |
nicklas |
@author nicklas |
4158 |
22 Feb 08 |
nicklas |
@version 2.7 |
4198 |
28 Mar 08 |
nicklas |
@base.modified $Date:2008-03-20 12:15:25 +0100 (Thu, 20 Mar 2008) $ |
4158 |
22 Feb 08 |
nicklas |
52 |
*/ |
4158 |
22 Feb 08 |
nicklas |
53 |
public interface RendererFactory<A extends Action> |
4158 |
22 Feb 08 |
nicklas |
54 |
{ |
4158 |
22 Feb 08 |
nicklas |
55 |
|
4158 |
22 Feb 08 |
nicklas |
56 |
/** |
4170 |
07 Mar 08 |
nicklas |
This method is called once for each request/use of an |
4170 |
07 Mar 08 |
nicklas |
extension and should be used by a factory to initialise the context |
4170 |
07 Mar 08 |
nicklas |
with resources that the actions may need. With the BASE web-client |
4170 |
07 Mar 08 |
nicklas |
this means that it is possible to add scripts or stylesheets that |
4198 |
28 Mar 08 |
nicklas |
is needed by the extension. See |
4198 |
28 Mar 08 |
nicklas |
{@link net.sf.basedb.clients.web.extensions.JspContext}. |
4170 |
07 Mar 08 |
nicklas |
63 |
|
4170 |
07 Mar 08 |
nicklas |
<p> |
4198 |
28 Mar 08 |
nicklas |
Note! This method has no return value as opposed to |
4207 |
04 Apr 08 |
nicklas |
{@link ActionFactory#prepareContext(InvokationContext)}. The |
4170 |
07 Mar 08 |
nicklas |
simple reason is that once we get to the point of rendering it |
4170 |
07 Mar 08 |
nicklas |
is already known that the extension is enabled. |
4170 |
07 Mar 08 |
nicklas |
69 |
|
4207 |
04 Apr 08 |
nicklas |
@param context The current invokation context |
4170 |
07 Mar 08 |
nicklas |
71 |
*/ |
4207 |
04 Apr 08 |
nicklas |
72 |
public void prepareContext(InvokationContext<? extends A> context); |
4170 |
07 Mar 08 |
nicklas |
73 |
|
4170 |
07 Mar 08 |
nicklas |
74 |
/** |
4158 |
22 Feb 08 |
nicklas |
Get a renderer for a given context. This method may |
4158 |
22 Feb 08 |
nicklas |
create a new instance or use an existing instance. If |
4158 |
22 Feb 08 |
nicklas |
an existing instance is used, it must be thread-safe, since |
4158 |
22 Feb 08 |
nicklas |
multiple threads may use the same renderer. |
4158 |
22 Feb 08 |
nicklas |
79 |
|
4207 |
04 Apr 08 |
nicklas |
@param context The current invokation context |
4158 |
22 Feb 08 |
nicklas |
@return A renderer instance |
4158 |
22 Feb 08 |
nicklas |
82 |
*/ |
4207 |
04 Apr 08 |
nicklas |
83 |
public Renderer<? super A> getRenderer(InvokationContext<? extends A> context); |
4158 |
22 Feb 08 |
nicklas |
84 |
|
4158 |
22 Feb 08 |
nicklas |
85 |
} |