01: package org.geoserver;
02:
03: import java.util.logging.Logger;
04:
05: import javax.imageio.spi.ImageReaderSpi;
06: import javax.servlet.ServletContextEvent;
07: import javax.servlet.ServletContextListener;
08:
09: import org.geotools.factory.Hints;
10: import org.geotools.resources.image.ImageUtilities;
11: import org.geotools.util.logging.Logging;
12:
13: /**
14: * Listens for GeoServer startup and tries to configure axis order, logging
15: * redirection, and a few other things that really need to be set up before
16: * anything else starts up
17: */
18: public class GeoserverInitStartupListener implements
19: ServletContextListener {
20: private static final Logger LOGGER = Logging
21: .getLogger("org.geoserver.logging");
22:
23: public void contextDestroyed(ServletContextEvent sce) {
24: }
25:
26: public void contextInitialized(ServletContextEvent sce) {
27: // if the server admin did not set it up otherwise, force X/Y axis
28: // ordering
29: // This one is a good place because we need to initialize this property
30: // before any other opeation can trigger the initialization of the CRS
31: // subsystem
32: if (System.getProperty("org.geotools.referencing.forceXY") == null) {
33: // Hints.putSystemDefault(Hints.FORCE_LONGITUDE_FIRST_AXIS_ORDER,
34: // Boolean.TRUE);
35: System.setProperty("org.geotools.referencing.forceXY",
36: "true");
37: }
38: if (Boolean.TRUE
39: .equals(Hints
40: .getSystemDefault(Hints.FORCE_LONGITUDE_FIRST_AXIS_ORDER))) {
41: Hints.putSystemDefault(Hints.FORCE_AXIS_ORDER_HONORING,
42: "http");
43: }
44:
45: // HACK: java.util.prefs are awful. See
46: // http://www.allaboutbalance.com/disableprefs. When the site comes
47: // back up we should implement their better way of fixing the problem.
48: System.setProperty("java.util.prefs.syncInterval", "5000000");
49:
50: // HACK: under JDK 1.4.2 the native java image i/o stuff is failing
51: // in all containers besides Tomcat. If running under jdk 1.4.2 we
52: // disable the native codecs, unless the user forced the setting already
53: if (System.getProperty("java.version").startsWith("1.4")
54: && (System
55: .getProperty("com.sun.media.imageio.disableCodecLib") == null)) {
56: LOGGER
57: .warning("Disabling mediaLib acceleration since this is a "
58: + "java 1.4 VM.\n If you want to force its enabling, " //
59: + "set -Dcom.sun.media.imageio.disableCodecLib=true "
60: + "in your virtual machine");
61: System.setProperty("com.sun.media.imageio.disableCodecLib",
62: "true");
63: } else {
64: // in any case, the native png reader is worse than the pure java ones, so
65: // let's disable it (the native png writer is on the other side faster)...
66: ImageUtilities.allowNativeCodec("png", false, false);
67: }
68: }
69:
70: }
|