📄 geoserver.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.global;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.Iterator;
import java.util.List;
import java.util.Properties;
import java.util.Set;
import java.util.logging.Level;
import javax.imageio.ImageIO;
import javax.media.jai.JAI;
import javax.media.jai.RecyclingTileFactory;
import javax.servlet.ServletContext;
import org.apache.log4j.Appender;
import org.apache.log4j.LogManager;
import org.apache.log4j.PropertyConfigurator;
import org.geotools.data.DataStoreFactorySpi;
import org.springframework.beans.factory.DisposableBean;
import org.vfny.geoserver.global.dto.ContactDTO;
import org.vfny.geoserver.global.dto.GeoServerDTO;
import org.vfny.geoserver.util.Requests;
import com.sun.media.jai.util.SunTileCache;
/**
* Complete configuration set for the whole server
*
* @author Gabriel Roldan
* @author dzwiers
* @version $Id: GeoServer.java 7746 2007-11-13 15:38:35Z aaime $
*/
public class GeoServer extends GlobalLayerSupertype implements DisposableBean {
/**
* Simple listener interface.
*
* JD: this is a temporary substitute until we have a decent config system.
*/
public interface Listener {
/**
* Callback fired when application state has changed.
*/
void changed();
}
/**
* For finding the instance of this class to use from the web container
*
* <p>
* ServletContext sc = ... GeoServer gs =
* (GeoServer)sc.getAttribute(GeoServer.WEB_CONTAINER_KEY);
* </p>
*/
public static final String WEB_CONTAINER_KEY = "GeoServer";
private String title;
private int maxFeatures = Integer.MAX_VALUE;
private boolean verbose = true;
private int numDecimals = 4;
private Charset charSet = Charset.forName("UTF-8");
private final JAI jaiDef = JAI.getDefaultInstance();
private SunTileCache jaiCache;
private String adminUserName = "admin";
private String adminPassword;
private String schemaBaseUrl;
private String proxyBaseUrl;
private String contactPerson;
private String contactOrganization;
private String contactPosition;
private String addressType;
private String address;
private String addressCity;
private String addressState;
private String addressPostalCode;
private String addressCountry;
private String contactVoice;
private String contactFacsimile;
private String contactEmail;
private String onlineResource;
private double memoryCapacity;
private double memoryThreshold;
private int tileThreads;
private int tilePriority;
private String tileCache;
private Boolean recycling;
private Boolean imageIOCache;
private Boolean JPEGnativeAcc;
private Boolean PNGnativeAcc;
/** Should we throw the stack traces back in responses? */
private boolean verboseExceptions = false;
private String log4jConfigFile;
private boolean suppressStdOutLogging = false;
private String logLocation = null;
private List listeners;
private Config config;
/**
* Default constructor only to facilitate unit testing mock ups; real
* uses shall create an instance through {@link #GeoServer(Config)}.
*/
public GeoServer() {
//do nothing
}
/**
* Creates a GeoServer instance and loads its configuration.
*
* @throws ConfigurationException
*/
public GeoServer(Config config) throws ConfigurationException {
LOGGER.fine("Creating GeoServer");
load(config.getGeoServer());
this.config = config;
listeners = new ArrayList();
}
/**
* Adds a listener to be notified of state change.
*/
public void addListener( Listener listener ) {
listeners.add( listener );
}
/**
* Removes a listener.
*/
public void removeListener( Listener listener ) {
listeners.remove( listener );
}
/**
* Notifies all listeners of a change.
*/
public void fireChange() {
for ( Iterator l = listeners.iterator(); l.hasNext(); ) {
Listener listener = (Listener) l.next();
try {
listener.changed();
}
catch( Throwable t ) {
LOGGER.warning( "listener threw exception, turn logging to FINE to view stack trace" );
LOGGER.log( Level.FINE, t.getLocalizedMessage(), t );
}
}
}
/**
* getAddress purpose.
*
* <p>
* Returns the contact Address.
* </p>
*
* @return String the contact Address.
*/
public String getAddress() {
return notNull(address);
}
/**
* getAddressCity purpose.
*
* <p>
* Returns the contact City.
* </p>
*
* @return String the contact City.
*/
public String getAddressCity() {
return notNull(addressCity);
}
/**
* getAddressCountry purpose.
*
* <p>
* Returns the contact Country.
* </p>
*
* @return String the contact Country.
*/
public String getAddressCountry() {
return notNull(addressCountry);
}
/**
* getAddressPostalCode purpose.
*
* <p>
* Returns the contact PostalCode.
* </p>
*
* @return String the contact PostalCode.
*/
public String getAddressPostalCode() {
return notNull(addressPostalCode);
}
/**
* getAddressState purpose.
*
* <p>
* Returns the contact State.
* </p>
*
* @return String the contact State.
*/
public String getAddressState() {
return notNull(addressState);
}
/**
* getAddressType purpose.
*
* <p>
* Returns the contact Address Type.
* </p>
*
* @return String the contact Address Type.
*/
public String getAddressType() {
return notNull(addressType);
}
/**
* getCharSet purpose.
*
* <p>
* Returns the default charset for this server instance.
* </p>
*
* @return Charset the default charset for this server instance.
*/
public Charset getCharSet() {
if (charSet != null) {
return charSet;
}
return Charset.forName("UTF-8");
}
/**
* getContactEmail purpose.
*
* <p>
* Returns the contact Email.
* </p>
*
* @return String the contact Email.
*/
public String getContactEmail() {
return notNull(contactEmail);
}
/**
* getContactFacsimile purpose.
*
* <p>
* Returns the contact Facsimile.
* </p>
*
* @return String the contact Facsimile.
*/
public String getContactFacsimile() {
return notNull(contactFacsimile);
}
/**
* getContactOrganization purpose.
*
* <p>
* Returns the contact Organization.
* </p>
*
* @return String the contact Organization.
*/
public String getContactOrganization() {
return notNull(contactOrganization);
}
/**
* getContactPerson purpose.
*
* <p>
* Returns the contact Person.
* </p>
*
* @return String the contact Person.
*/
public String getContactPerson() {
return notNull(contactPerson);
}
/**
* getContactPosition purpose.
*
* <p>
* Returns the contact Position.
* </p>
*
* @return String the contact Position.
*/
public String getContactPosition() {
return notNull(contactPosition);
}
/**
* getContactVoice purpose.
*
* <p>
* Returns the contact Phone.
* </p>
*
* @return String the contact Phone.
*/
public String getContactVoice() {
return notNull(contactVoice);
}
/**
* getOnlineResource purpose.
*
* <p>
* Returns the online Resource.
* </p>
*
* @return String the online Resource.
*/
public String getOnlineResource() {
return notNull(onlineResource);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -