View Javadoc

1   // 
2   //Copyright (c) 2003, Caltha - Gajda, Krzewski, Mach, Potempski Sp.J. 
3   //All rights reserved. 
4   //   
5   //Redistribution and use in source and binary forms, with or without modification,  
6   //are permitted provided that the following conditions are met: 
7   //   
8   //* Redistributions of source code must retain the above copyright notice,  
9   //this list of conditions and the following disclaimer. 
10  //* Redistributions in binary form must reproduce the above copyright notice,  
11  //this list of conditions and the following disclaimer in the documentation  
12  //and/or other materials provided with the distribution. 
13  //* Neither the name of the Caltha - Gajda, Krzewski, Mach, Potempski Sp.J.  
14  //nor the names of its contributors may be used to endorse or promote products  
15  //derived from this software without specific prior written permission. 
16  // 
17  //THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"  
18  //AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED  
19  //WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
20  //IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,  
21  //INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,  
22  //BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 
23  //OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,  
24  //WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)  
25  //ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE  
26  //POSSIBILITY OF SUCH DAMAGE. 
27  //
28  
29  package org.objectledge.web.mvc.tools;
30  
31  import org.jcontainer.dna.Configuration;
32  import org.jcontainer.dna.ConfigurationException;
33  import org.objectledge.context.Context;
34  import org.objectledge.parameters.RequestParameters;
35  import org.objectledge.pipeline.ProcessingException;
36  import org.objectledge.web.HttpContext;
37  import org.objectledge.web.WebConfigurator;
38  import org.objectledge.web.mvc.MVCContext;
39  
40  /**
41   * Context tool factory component to build the link tool.
42   * 
43   * @author <a href="mailto:pablo@caltha.pl">Pawel Potempski</a>
44   * @version $Id: LinkToolFactoryImpl.java,v 1.3 2005/03/31 10:05:57 pablo Exp $
45   */
46  public class LinkToolFactoryImpl implements LinkToolFactory
47  {
48  	/*** the context. */
49  	protected Context context;
50  	
51  	/*** configuration component. */
52  	protected WebConfigurator webConfigurator;
53      
54      /*** link tool configuration. */
55      protected LinkTool.Configuration linkToolConfiguration;
56      	
57  	/***
58  	 * Component constructor.
59  	 *
60  	 * @param config the config.
61  	 * @param context the context.
62  	 * @param webConfigurator the web configurator component.
63       * @throws ConfigurationException if the configuraiton is invalid.
64   	 */
65  	public LinkToolFactoryImpl(Configuration config, Context context, 
66          WebConfigurator webConfigurator)
67          throws ConfigurationException
68  	{
69  		this.context = context;
70  		this.webConfigurator = webConfigurator;
71          this.linkToolConfiguration = new LinkTool.Configuration(config, webConfigurator);
72  	}
73  	
74      /***
75  	 * {@inheritDoc}
76  	 */
77  	public Object getTool()
78          throws ProcessingException
79  	{
80          HttpContext httpContext = HttpContext.getHttpContext(context);
81          MVCContext mvcContext = MVCContext.getMVCContext(context);
82          RequestParameters requestParameters = RequestParameters.getRequestParameters(context);
83  		return new LinkTool(httpContext, mvcContext, requestParameters, linkToolConfiguration);
84  	}
85  	
86  	/***
87  	 * {@inheritDoc}
88  	 */
89  	public void recycleTool(Object tool)
90          throws ProcessingException
91  	{
92          // these simple objects do not need recycling
93  	}
94  
95  	/***
96  	 * {@inheritDoc}
97  	 */
98  	public String getKey()
99  	{
100 		return "link";
101 	}    
102 }