001 // $HeadURL: svn+ssh://rbezema@svn.wald.intevation.org/deegree/base/tags/2.1/src/org/deegree/enterprise/DeegreeParams.java $ 002 /*---------------- FILE HEADER ------------------------------------------ 003 004 This file is part of deegree. 005 Copyright (C) 2001-2006 by: 006 EXSE, Department of Geography, University of Bonn 007 http://www.giub.uni-bonn.de/deegree/ 008 lat/lon GmbH 009 http://www.lat-lon.de 010 011 This library is free software; you can redistribute it and/or 012 modify it under the terms of the GNU Lesser General Public 013 License as published by the Free Software Foundation; either 014 version 2.1 of the License, or (at your option) any later version. 015 016 This library is distributed in the hope that it will be useful, 017 but WITHOUT ANY WARRANTY; without even the implied warranty of 018 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 019 Lesser General Public License for more details. 020 021 You should have received a copy of the GNU Lesser General Public 022 License along with this library; if not, write to the Free Software 023 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 024 025 Contact: 026 027 Andreas Poth 028 lat/lon GmbH 029 Aennchenstr. 19 030 53115 Bonn 031 Germany 032 E-Mail: poth@lat-lon.de 033 034 Prof. Dr. Klaus Greve 035 Department of Geography 036 University of Bonn 037 Meckenheimer Allee 166 038 53115 Bonn 039 Germany 040 E-Mail: greve@giub.uni-bonn.de 041 042 043 ---------------------------------------------------------------------------*/ 044 package org.deegree.enterprise; 045 046 import java.io.Serializable; 047 import java.nio.charset.Charset; 048 049 import org.deegree.model.metadata.iso19115.OnlineResource; 050 import org.deegree.ogcwebservices.wms.InvalidFormatException; 051 052 /** 053 * Base class for the <code>deegreeParams</code> section of configurations for 054 * all deegree web service types. The <code>deegreeParams</code> section 055 * contains deegree specific parameters that are not part of the OGC CSW 056 * capabilities specification. The concrete web service implementations (WMS, 057 * WFS CWS, ...) derive this class and add their specific configuration 058 * parameters. 059 * <p> 060 * The common <code>deegreeParams</code> elements are: <table border="1"> 061 * <tr> 062 * <th>Name</th> 063 * <th>Mandatory</th> 064 * <th>Function</th> 065 * </tr> 066 * <tr> 067 * <td>DefaultOnlineResource</td> 068 * <td align="center">X</td> 069 * <td>The DefaultOnlineResource will be used whenever a required 070 * OnlineResource is not defined.</td> 071 * </tr> 072 * <tr> 073 * <td>CacheSize</td> 074 * <td align="center">-</td> 075 * <td>Amount of Memory to use for caching, default = 100 (MB).</td> 076 * </tr> 077 * <tr> 078 * <td>RequestTimeLimit</td> 079 * <td align="center">-</td> 080 * <td>Maximum amount of time that is allowed for the execution of a request, 081 * defaults to 2 minutes.</td> 082 * </tr> 083 * <tr> 084 * <td>Encoding</td> 085 * <td align="center">-</td> 086 * <td>String encoding, default is UTF-8.</td> 087 * </tr> 088 * </table> 089 * 090 * @author <a href="mailto:poth@lat-lon.de">Andreas Poth </a> 091 * @author <a href="mailto:mschneider@lat-lon.de">Markus Schneider </a> 092 * @author last edited by: $Author: bezema $ 093 * 094 * @version 2.0, $Revision: 6259 $, $Date: 2007-03-20 10:15:15 +0100 (Di, 20 Mär 2007) $ 095 * 096 * @since 2.0 097 */ 098 099 public abstract class DeegreeParams implements Serializable { 100 101 private OnlineResource defaultOnlineResource = null; 102 private int cacheSize = 100; 103 private int requestTimeLimit = 0; 104 private Charset characterSet= null; 105 106 /** 107 * Creates a new instance of DeegreeParams with characterSet set to UTF-8. 108 * 109 * @param defaultOnlineResource 110 * @param cacheSize 111 * @param requestTimeLimit in milliseconds 112 */ 113 public DeegreeParams(OnlineResource defaultOnlineResource, 114 int cacheSize, int requestTimeLimit) { 115 this.defaultOnlineResource = defaultOnlineResource; 116 this.cacheSize = cacheSize; 117 this.requestTimeLimit = requestTimeLimit; 118 if( Charset.isSupported("UTF-8") ){//UTF-8 mus be supported 119 this.characterSet = Charset.forName("UTF-8"); 120 } 121 } 122 123 /** 124 * Creates a new instance of DeegreeParams. 125 * 126 * @param defaultOnlineResource 127 * @param cacheSize 128 * @param requestTimeLimit 129 * @param characterSet 130 */ 131 public DeegreeParams(OnlineResource defaultOnlineResource, 132 int cacheSize, int requestTimeLimit, String characterSet) { 133 this.defaultOnlineResource = defaultOnlineResource; 134 this.cacheSize = cacheSize; 135 this.requestTimeLimit = requestTimeLimit; 136 if( Charset.isSupported(characterSet) ){ 137 this.characterSet = Charset.forName(characterSet); 138 } 139 else if( Charset.isSupported("UTF-8") ){//UTF-8 mus be supported 140 this.characterSet = Charset.forName("UTF-8"); 141 } 142 } 143 144 /** 145 * Returns the CacheSize. 146 * 147 * @return the size 148 */ 149 public int getCacheSize() { 150 return cacheSize; 151 } 152 153 /** 154 * Sets the CacheSize. 155 * 156 * @param cacheSize 157 */ 158 public void setCacheSize(int cacheSize) { 159 this.cacheSize = cacheSize; 160 } 161 162 /** 163 * Returns the defaultOnlineResource. 164 * 165 * @return the URL 166 */ 167 public OnlineResource getDefaultOnlineResource() { 168 return defaultOnlineResource; 169 } 170 171 /** 172 * Sets the defaultOnlineResource. 173 * 174 * @param defaultOnlineResource 175 */ 176 public void setDefaultOnlineResource(OnlineResource defaultOnlineResource) { 177 this.defaultOnlineResource = defaultOnlineResource; 178 } 179 180 /** 181 * @return the requestTimeLimit, in milliseconds. 182 */ 183 public int getRequestTimeLimit() { 184 return requestTimeLimit; 185 } 186 187 /** 188 * Sets the requestTimeLimit. 189 * 190 * @param requestTimeLimit 191 192 */ 193 public void setRequestTimeLimit(int requestTimeLimit) { 194 this.requestTimeLimit = requestTimeLimit; 195 } 196 197 /** 198 * Returns the characterSet. 199 * 200 * @return the charset 201 * 202 */ 203 public String getCharacterSet() { 204 return characterSet.displayName(); 205 } 206 207 /** 208 * @return the Charset requested by the deegreeparams. 209 */ 210 public Charset getCharset(){ 211 return characterSet; 212 } 213 214 /** 215 * Sets the characterSet. 216 * 217 * @param characterSet 218 * @throws InvalidFormatException 219 * 220 */ 221 public void setCharacterSet(String characterSet) throws InvalidFormatException { 222 if( Charset.isSupported(characterSet) ){ 223 this.characterSet = Charset.forName(characterSet); 224 } 225 else { 226 throw new InvalidFormatException("DeegreeParams: The given charset is not supported by the jvm" ); 227 } 228 } 229 230 } 231 /******************************************************************************* 232 * Changes to this class. What the people have been up to: $Log: 233 * DeegreeParams.java,v $ Revision 1.1 2004/06/23 11:55:40 mschneider Changed 234 * hierarchy in org.deegree.ogcwebservices.getcapabilities: - 235 * OGCCommonCapabilities are derived for Capabilities according to the OGCCommon 236 * Implementation Specification 0.2 - OGCStandardCapabilities are derived for 237 * Capabilities prior to the OGCCommon Implementation Specification 0.2 238 * 239 * Revision 1.3 2004/06/11 08:47:30 ap no message 240 * 241 * Revision 1.2 2004/05/25 07:19:13 ap no message 242 * 243 * Revision 1.1 2004/05/24 06:46:47 ap no message 244 * 245 * 246 ******************************************************************************/