📄 globalconfig.java
字号:
/* Copyright (c) 2001 - 2007 TOPP - www.openplans.org. All rights reserved.
* This code is licensed under the GPL 2.0 license, availible at the root
* application directory.
*/
package org.vfny.geoserver.config;
import org.vfny.geoserver.global.Data;
import org.vfny.geoserver.global.GeoServer;
import org.vfny.geoserver.global.dto.ContactDTO;
import org.vfny.geoserver.global.dto.DataDTO;
import org.vfny.geoserver.global.dto.GeoServerDTO;
import java.nio.charset.Charset;
import java.util.logging.Level;
/**
* Global GeoServer Configuration model.
*
* <p>
* GlobalConfig represents the configuration model needed to set up GeoServer
* for use.
* </p>
*
* @author David Zwiers, Refractions Research, Inc.
* @version $Id: GlobalConfig.java 7226 2007-07-10 19:28:46Z saul.farber $
*/
public class GlobalConfig {
public static final String CONFIG_KEY = "Config.Global";
/** Sets the max number of Features returned by GetFeature */
private int maxFeatures = 20000;
/**
* XML Verbosity.
*
* <p>
* Whether newlines and indents should be returned in XML responses.
* </p>
*
* <p>
* This should be called something other than verbose. Verbose should
* control things like printing out "magic" comments that tell people how
* to edit the xml files by hand.
* </p>
* Default is true
*/
private boolean verbose = true;
/**
* Number of decimal places returned in a GetFeature response.
*
* <p>
* Sets the max number of decimal places past the zero returned in a
* GetFeature response. Default is 4.
* </p>
* DZ - should it be moved to FeatureTypeInfo level? JG - no WMS also has a
* getFeature response
*/
private int numDecimals = 8;
/**
* Sets the global character set.
*
* <p>
* This could use some more testing from international users. What it does
* is sets the encoding globally for all postgis database connections (the
* charset tag in FeatureTypeInfo), as well as specifying the encoding in
* the return
* <code>org.vfny.geoserver.config.org.vfny.geoserver.global.xml</code>
* header and mime type.
* </p>
*
* <p>
* The default is UTF-8
* </p>
*
* <p>
* Also be warned that GeoServer does not check if the CharSet is valid
* before attempting to use it, so it will fail miserably if a bad charset
* is used.
* </p>
*/
private Charset charSet;
/**
* The base URL where this servlet will run.
*
* <p>
* If running locally then <code>http://localhost:8080</code> (or whatever
* port you're running on) should work.
* </p>
*
* <p>
* If you are serving to the world then this must be the location where the
* geoserver servlets appear
* </p>
*
* <p>
* JG - can we figure this out at runtime?
* </p>
*/
private String proxyBaseUrl;
/**
* Define a base url for the location of the wfs schemas.
*
* <p>
* By default GeoServer loads and references its own at
* <code>/data/capabilities</code>.
* </p>
*
* <p>
* The standalone Tomcat server needs SchemaBaseUrl defined for validation.
* </p>
*/
private String schemaBaseUrl;
/**
* Defines the Application logging level.
*
* <p>
* Common options are SEVERE, WARNING, INFO, CONFIG, FINER, FINEST, in
* order of Increasing statements logged.
* </p>
*
* <p>
* There may be more then one point of control - the web containers often
* controls logging, the jakarta commons logging system is used by struts,
* these names seem taken from the jdk14 logging framework and GeoServer
* seems to also use log4j.
*
* See http://docs.codehaus.org/display/GEOS/GSIP+13+-+Logging
* for how this is now implemented.
* </p>
*/
private String log4jConfigFile = null;
private boolean suppressStdOutLogging = false;
/** custom log location **/
private String logLocation = null;
private String adminUserName;
private String adminPassword;
/** Whether the exceptions returned to the client should contain full stack traces */
private boolean verboseExceptions;
/** The Server contact person and their contact information. */
private ContactConfig contact = null;
private double jaiMemoryCapacity;
private double jaiMemoryThreshold;
private int jaiTileThreads;
private int jaiTilePriority;
private boolean jaiRecycling;
private boolean imageIOCache;
private boolean jaiJPEGNative;
private boolean jaiPNGNative;
/** tile cache location, full url or relative path */
private String tileCache;
/**
* GlobalConfig constructor.
*
* <p>
* Creates an instance of GlobalConfig and initializes to default settings.
* </p>
*
* @see defaultSettings()
*/
public GlobalConfig() {
maxFeatures = 20000;
verbose = true;
numDecimals = 8;
charSet = Charset.forName("UTF-8");
proxyBaseUrl = null;
schemaBaseUrl = null;
contact = null;
verboseExceptions = true;
logLocation = null;
}
/**
* Instantiates the global config from the geoServer module.
*
* @param geoserver The geoServer module.
*/
public GlobalConfig(GeoServer geoserver) {
this((GeoServerDTO) geoserver.toDTO());
}
/**
* GlobalConfig constructor.
*
* <p>
* Creates a copy of the GeoServerDTO object provided. Charset is not
* cloned, everything else is.
* </p>
*
* @param g
*
* @throws NullPointerException DOCUMENT ME!
*/
public GlobalConfig(GeoServerDTO g) {
if (g == null) {
throw new NullPointerException();
}
maxFeatures = g.getMaxFeatures();
verbose = g.isVerbose();
numDecimals = g.getNumDecimals();
charSet = g.getCharSet();
proxyBaseUrl = g.getProxyBaseUrl();
schemaBaseUrl = g.getSchemaBaseUrl();
adminUserName = g.getAdminUserName();
adminPassword = g.getAdminPassword();
verboseExceptions = g.isVerboseExceptions();
log4jConfigFile = g.getLog4jConfigFile();
suppressStdOutLogging = g.getSuppressStdOutLogging();
logLocation = g.getLogLocation();
jaiMemoryCapacity = g.getJaiMemoryCapacity();
jaiMemoryThreshold = g.getJaiMemoryThreshold();
jaiTileThreads = g.getJaiTileThreads();
jaiTilePriority = g.getJaiTilePriority();
jaiRecycling = g.getJaiRecycling().booleanValue();
imageIOCache = g.getImageIOCache().booleanValue();
jaiJPEGNative = g.getJaiJPEGNative().booleanValue();
jaiPNGNative = g.getJaiPNGNative().booleanValue();
tileCache = g.getTileCache();
if (g.getContact() != null) {
contact = new ContactConfig(g.getContact());
} else {
contact = new ContactConfig();
}
}
/**
* Implement updateDTO.
*
* <p>
* Populates this instance with the GeoServerDTO object provided.
* </p>
*
* @param g A valid GeoServerDTO object to populate this object from
*
* @throws NullPointerException DOCUMENT ME!
*
* @see org.vfny.geoserver.config.DataStructure#updateDTO(java.lang.Object)
*/
public void update(GeoServerDTO g) {
if (g == null) {
throw new NullPointerException("GeoServer Data Transfer Object required");
}
maxFeatures = g.getMaxFeatures();
verbose = g.isVerbose();
numDecimals = g.getNumDecimals();
charSet = g.getCharSet();
schemaBaseUrl = g.getSchemaBaseUrl();
proxyBaseUrl = g.getProxyBaseUrl();
verboseExceptions = g.isVerboseExceptions();
log4jConfigFile = g.getLog4jConfigFile();
suppressStdOutLogging = g.getSuppressStdOutLogging();
logLocation = g.getLogLocation();
jaiMemoryCapacity = g.getJaiMemoryCapacity();
jaiMemoryThreshold = g.getJaiMemoryThreshold();
jaiTileThreads = g.getJaiTileThreads();
jaiTilePriority = g.getJaiTilePriority();
jaiRecycling = g.getJaiRecycling().booleanValue();
imageIOCache = g.getImageIOCache().booleanValue();
jaiJPEGNative = g.getJaiJPEGNative().booleanValue();
jaiPNGNative = g.getJaiPNGNative().booleanValue();
tileCache = g.getTileCache();
if (g.getContact() != null) {
contact = new ContactConfig(g.getContact());
} else {
contact = new ContactConfig();
}
}
/**
* Implement toDTO.
*
* <p>
* Creates a copy of the data in a GeoServerDTO representation
* </p>
*
* @return a copy of the data in a GeoServerDTO representation
*
* @see org.vfny.geoserver.config.DataStructure#toDTO()
*/
public GeoServerDTO toDTO() {
GeoServerDTO g = new GeoServerDTO();
g.setMaxFeatures(maxFeatures);
g.setVerbose(verbose);
g.setAdminPassword(adminPassword);
g.setAdminUserName(adminUserName);
g.setNumDecimals(numDecimals);
g.setCharSet(charSet);
g.setSchemaBaseUrl(schemaBaseUrl);
g.setVerboseExceptions(verboseExceptions);
g.setContact((ContactDTO) contact.toDTO());
g.setLog4jConfigFile(log4jConfigFile);
g.setSuppressStdOutLogging(suppressStdOutLogging);
g.setLogLocation(logLocation);
g.setJaiMemoryCapacity(jaiMemoryCapacity);
g.setJaiMemoryThreshold(jaiMemoryThreshold);
g.setJaiTileThreads(jaiTileThreads);
g.setJaiTilePriority(jaiTilePriority);
g.setJaiRecycling(Boolean.valueOf(jaiRecycling));
g.setImageIOCache(Boolean.valueOf(imageIOCache));
g.setJaiJPEGNative(Boolean.valueOf(jaiJPEGNative));
g.setJaiPNGNative(Boolean.valueOf(jaiPNGNative));
g.setProxyBaseUrl(proxyBaseUrl);
g.setTileCache(tileCache);
return g;
}
/**
* getBaseUrl purpose.
*
* <p>
* Description ...
* </p>
*
* @return
*/
public String getProxyBaseUrl() {
return proxyBaseUrl;
}
/**
* getCharSet purpose.
*
* <p>
* Description ...
* </p>
*
* @return
*/
public Charset getCharSet() {
return charSet;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -