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

Code
Comments
Other
Rev Date Author Line
4158 22 Feb 08 nicklas 1 /**
4198 28 Mar 08 nicklas 2   $Id:RendererFactory.java 4187 2008-03-20 11:15:25Z nicklas $
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
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 27   A renderer factory is a factory that can create {@link Renderer}
4158 22 Feb 08 nicklas 28   objects. An extension point may provide a default factory 
4158 22 Feb 08 nicklas 29   ({@link ExtensionPoint#getRendererFactory()}). If allowed by the 
4158 22 Feb 08 nicklas 30   extension point an extension may provide it's own factory
4158 22 Feb 08 nicklas 31   implementation ({@link Extension#getRendererFactory()}.
4158 22 Feb 08 nicklas 32
4170 07 Mar 08 nicklas 33   <p>
4170 07 Mar 08 nicklas 34   Renderer factory implementations must be thread-safe, since a 
4170 07 Mar 08 nicklas 35   single instance of the factory may have to serve multiple requests
4170 07 Mar 08 nicklas 36   at the same time.
4170 07 Mar 08 nicklas 37   
4170 07 Mar 08 nicklas 38   <p>
4170 07 Mar 08 nicklas 39   Note 1! A single factory instance may be used by more than one 
4170 07 Mar 08 nicklas 40   extension/extension point. This is at the control of the client application.
4170 07 Mar 08 nicklas 41   
4170 07 Mar 08 nicklas 42   <p>
4170 07 Mar 08 nicklas 43   Note 2! The BASE web-client uses the {@link XmlLoader} to 
4170 07 Mar 08 nicklas 44   define extensions. The <code>XmlLoader</code> always create a
4170 07 Mar 08 nicklas 45   separate factory instance for each extension/extension point. 
4170 07 Mar 08 nicklas 46   The <code>XmlLoader</code> also requires that the factories has 
4170 07 Mar 08 nicklas 47   a public no-argument constructor.
4170 07 Mar 08 nicklas 48
4158 22 Feb 08 nicklas 49   @author nicklas
4158 22 Feb 08 nicklas 50   @version 2.7
4198 28 Mar 08 nicklas 51   @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 57     This method is called once for each request/use of an
4170 07 Mar 08 nicklas 58     extension and should be used by a factory to initialise the context 
4170 07 Mar 08 nicklas 59     with resources that the actions may need. With the BASE web-client 
4170 07 Mar 08 nicklas 60     this means that it is possible to add scripts or stylesheets that 
4198 28 Mar 08 nicklas 61     is needed by the extension. See 
4198 28 Mar 08 nicklas 62     {@link net.sf.basedb.clients.web.extensions.JspContext}.
4170 07 Mar 08 nicklas 63     
4170 07 Mar 08 nicklas 64     <p>
4198 28 Mar 08 nicklas 65     Note! This method has no return value as opposed to 
4207 04 Apr 08 nicklas 66     {@link ActionFactory#prepareContext(InvokationContext)}. The 
4170 07 Mar 08 nicklas 67     simple reason is that once we get to the point of rendering it
4170 07 Mar 08 nicklas 68     is already known that the extension is enabled.
4170 07 Mar 08 nicklas 69     
4207 04 Apr 08 nicklas 70     @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 75     Get a renderer for a given context. This method may
4158 22 Feb 08 nicklas 76     create a new instance or use an existing instance. If
4158 22 Feb 08 nicklas 77     an existing instance is used, it must be thread-safe, since
4158 22 Feb 08 nicklas 78     multiple threads may use the same renderer.
4158 22 Feb 08 nicklas 79     
4207 04 Apr 08 nicklas 80     @param context The current invokation context
4158 22 Feb 08 nicklas 81     @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 }