openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmannibu...@apache.org
Subject svn commit: r1765951 - /openwebbeans/microwave/trunk/microwave-core/src/main/java/org/apache/microwave/Microwave.java
Date Fri, 21 Oct 2016 08:43:10 GMT
Author: rmannibucau
Date: Fri Oct 21 08:43:10 2016
New Revision: 1765951

URL: http://svn.apache.org/viewvc?rev=1765951&view=rev
Log:
some cleanup of QuickServerXmlParser

Modified:
    openwebbeans/microwave/trunk/microwave-core/src/main/java/org/apache/microwave/Microwave.java

Modified: openwebbeans/microwave/trunk/microwave-core/src/main/java/org/apache/microwave/Microwave.java
URL: http://svn.apache.org/viewvc/openwebbeans/microwave/trunk/microwave-core/src/main/java/org/apache/microwave/Microwave.java?rev=1765951&r1=1765950&r2=1765951&view=diff
==============================================================================
--- openwebbeans/microwave/trunk/microwave-core/src/main/java/org/apache/microwave/Microwave.java
(original)
+++ openwebbeans/microwave/trunk/microwave-core/src/main/java/org/apache/microwave/Microwave.java
Fri Oct 21 08:43:10 2016
@@ -63,7 +63,6 @@ import org.xml.sax.helpers.DefaultHandle
 
 import javax.xml.parsers.SAXParser;
 import javax.xml.parsers.SAXParserFactory;
-import java.io.ByteArrayInputStream;
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileNotFoundException;
@@ -1417,34 +1416,20 @@ public class Microwave implements AutoCl
         private static final String STOP_KEY = "STOP";
         private static final String HTTP_KEY = "HTTP";
         private static final String SECURED_SUFFIX = "S";
-        private static final String AJP_KEY = "AJP";
         private static final String HOST_KEY = "host";
-        private static final String APP_BASE_KEY = "app-base";
-        private static final String DEFAULT_CONNECTOR_KEY = HTTP_KEY;
-        private static final String KEYSTORE_KEY = "keystoreFile";
-
-        public static final String DEFAULT_HTTP_PORT = "8080";
-        public static final String DEFAULT_HTTPS_PORT = "8443";
-        public static final String DEFAULT_STOP_PORT = "8005";
-        public static final String DEFAULT_AJP_PORT = "8009";
-        public static final String DEFAULT_HOST = "localhost";
-        public static final String DEFAULT_APP_BASE = "webapps";
-        public static final String DEFAULT_KEYSTORE = null;
 
-        private final Map<String, String> values = new TreeMap<String, String>(String.CASE_INSENSITIVE_ORDER);
+        private static final String DEFAULT_HTTP_PORT = "8080";
+        private static final String DEFAULT_HTTPS_PORT = "8443";
+        private static final String DEFAULT_STOP_PORT = "8005";
+        private static final String DEFAULT_HOST = "localhost";
 
-        public QuickServerXmlParser() { // ensure defaults are present
-            this(true);
-        }
+        private final Map<String, String> values = new TreeMap<String, String>(String.CASE_INSENSITIVE_ORDER);
 
-        public QuickServerXmlParser(final boolean useDefaults) {
+        private QuickServerXmlParser(final boolean useDefaults) {
             if (useDefaults) {
                 values.put(STOP_KEY, DEFAULT_STOP_PORT);
                 values.put(HTTP_KEY, DEFAULT_HTTP_PORT);
-                values.put(AJP_KEY, DEFAULT_AJP_PORT);
                 values.put(HOST_KEY, DEFAULT_HOST);
-                values.put(APP_BASE_KEY, DEFAULT_APP_BASE);
-                values.put(KEYSTORE_KEY, DEFAULT_KEYSTORE);
             }
         }
 
@@ -1458,44 +1443,19 @@ public class Microwave implements AutoCl
                 } else {
                     values.put(STOP_KEY, DEFAULT_STOP_PORT);
                 }
-            } else if ("Connector".equalsIgnoreCase(localName)) {
-                String protocol = attributes.getValue("protocol");
-                if (protocol == null) {
-                    protocol = DEFAULT_CONNECTOR_KEY;
-                } else if (protocol.contains("/")) {
-                    protocol = protocol.substring(0, protocol.indexOf("/"));
-                }
-                final String port = attributes.getValue("port");
-                final String ssl = attributes.getValue("secure");
-
-                if (ssl == null || "false".equalsIgnoreCase(ssl)) {
-                    values.put(protocol.toUpperCase(), port);
-                } else {
-                    values.put(protocol.toUpperCase() + SECURED_SUFFIX, port);
-                }
-
-                final String keystore = attributes.getValue("keystoreFile");
-                if (null != keystore) {
-                    values.put(KEYSTORE_KEY, keystore);
-                }
             } else if ("Host".equalsIgnoreCase(localName)) {
                 final String host = attributes.getValue("name");
                 if (host != null) {
                     values.put(HOST_KEY, host);
                 }
-
-                final String appBase = attributes.getValue("appBase");
-                if (appBase != null) {
-                    values.put(APP_BASE_KEY, appBase);
-                }
             }
         }
 
-        public static QuickServerXmlParser parse(final File serverXml) {
+        private static QuickServerXmlParser parse(final File serverXml) {
             return parse(serverXml, true);
         }
 
-        public static QuickServerXmlParser parse(final File serverXml, final boolean defaults)
{
+        private static QuickServerXmlParser parse(final File serverXml, final boolean defaults)
{
             final QuickServerXmlParser handler = new QuickServerXmlParser(defaults);
             try {
                 final SAXParser parser = FACTORY.newSAXParser();
@@ -1506,46 +1466,19 @@ public class Microwave implements AutoCl
             return handler;
         }
 
-        public static QuickServerXmlParser parse(final String serverXmlContents) {
-            final QuickServerXmlParser handler = new QuickServerXmlParser();
-            try {
-                final SAXParser parser = FACTORY.newSAXParser();
-                parser.parse(new ByteArrayInputStream(serverXmlContents.getBytes()), handler);
-            } catch (final Exception e) {
-                // no-op: using defaults
-            }
-            return handler;
-        }
-
         public String http() {
             return value(HTTP_KEY, DEFAULT_HTTP_PORT);
         }
 
-        public String https() { // enough common to be exposed as method
+        private String https() { // enough common to be exposed as method
             return securedValue(HTTP_KEY, DEFAULT_HTTPS_PORT);
         }
 
-        public String ajp() {
-            return value(AJP_KEY, DEFAULT_AJP_PORT);
-        }
-
-        public String stop() {
+        private String stop() {
             return value(STOP_KEY, DEFAULT_STOP_PORT);
         }
 
-        public String appBase() {
-            return value(APP_BASE_KEY, DEFAULT_APP_BASE);
-        }
-
-        public String host() {
-            return value(HOST_KEY, DEFAULT_HOST);
-        }
-
-        public String keystore() {
-            return value(KEYSTORE_KEY, DEFAULT_KEYSTORE);
-        }
-
-        public String value(final String key, final String defaultValue) {
+        private String value(final String key, final String defaultValue) {
             final String val = values.get(key);
             if (val == null) {
                 return defaultValue;
@@ -1553,14 +1486,9 @@ public class Microwave implements AutoCl
             return val;
         }
 
-        public String securedValue(final String key, final String defaultValue) {
+        private String securedValue(final String key, final String defaultValue) {
             return value(key + SECURED_SUFFIX, defaultValue);
         }
-
-        @Override
-        public String toString() {
-            return "QuickServerXmlParser: " + values;
-        }
     }
 
     // there to be able to stack config later on without breaking all methods



Mime
View raw message