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