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;
30  
31  import org.jcontainer.dna.Configuration;
32  
33  /***
34   * MVC configuration component - it provides the access to common MVC configuration.
35   *
36   * @author <a href="mailto:pablo@caltha.pl">Pawel Potempski</a>
37   * @version $Id: WebConfigurator.java,v 1.9 2005/07/22 17:25:46 pablo Exp $
38   */
39  public class WebConfigurator
40  {
41  	/*** the default encoding. */
42  	public static final String DEFAULT_ENCODING = "UTF-8";
43  
44  	/*** the default content type. */
45  	public static final String DEFAULT_CONTENT_TYPE = "text/html";
46  	
47  	/*** the default view token. */
48  	public static final String DEFAULT_VIEW_TOKEN = "view";
49  	
50  	/*** the default action token. */
51  	public static final String DEFAULT_ACTION_TOKEN = "action";
52  	
53  	/*** the default encoding */
54  	private String defaultEncoding;
55  	
56  	/*** the default content type */
57  	private String defaultContentType;
58  	
59  	/*** the view token */
60  	private String viewToken;
61  	
62  	/*** the action token */
63  	private String actionToken;
64  	
65  	/***
66  	 * Constructor.
67  	 * 
68  	 * @param config the configuration.
69  	 */
70  	public WebConfigurator(Configuration config)
71  	{
72  		defaultEncoding = config.getChild("default_encoding").getValue(DEFAULT_ENCODING);
73  		defaultContentType = config.getChild("default_content_type").getValue(DEFAULT_CONTENT_TYPE);
74  		viewToken = config.getChild("view_token").getValue(DEFAULT_VIEW_TOKEN);
75  		actionToken = config.getChild("action_token").getValue(DEFAULT_ACTION_TOKEN);
76  	}
77      
78  	/***
79  	 * Get the default encoding of MVC created pages.
80  	 * 
81  	 * @return the default encoding.
82  	 */
83  	public String getDefaultEncoding()
84  	{
85  		return defaultEncoding;
86  	}
87  
88  	/***
89  	 * Get the default content type of MVC created pages.
90  	 * 
91  	 * @return the default content type.
92  	 */
93  	public String getDefaultContentType()
94  	{
95  		return defaultContentType;
96  	}
97  	
98  	/***
99  	 * Get the view choice request parameter name.
100 	 * 
101 	 * @return the view parameter name.
102 	 */
103 	public String getViewToken()
104 	{
105 		return viewToken;
106 	}
107 
108 	/***
109 	 * Get the action choice request parameter name.
110 	 * 
111 	 * @return the action parameter name.
112 	 */
113 	public String getActionToken()
114 	{
115 		return actionToken;
116 	}
117 }