Revision: 4001
Author: [email protected]
Date: Tue Mar 2 16:34:56 2010
Log: Zero argument ancillary servlet ctor for playground integration
http://codereview.appspot.com/224102
[email protected]
http://code.google.com/p/google-caja/source/detail?r=4001
Added:
/trunk/src/com/google/caja/ancillary/servlet/MainServlet.java
Modified:
/trunk/src/com/google/caja/ancillary/servlet/CajaWebToolsServlet.java
/trunk/src/com/google/caja/ancillary/servlet/Main.java
/trunk/web.xml
=======================================
--- /dev/null
+++ /trunk/src/com/google/caja/ancillary/servlet/MainServlet.java Tue Mar
2 16:34:56 2010
@@ -0,0 +1,40 @@
+// Copyright (C) 2010 Google Inc.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package com.google.caja.ancillary.servlet;
+
+import java.net.URI;
+import java.security.SecureRandom;
+
+/**
+ * A CajaWebToolsServlet that is wired to the outside world and has a
+ * convenient zero argument ctor.
+ *
+ * @author [email protected]
+ */
+public final class MainServlet extends CajaWebToolsServlet {
+
+ private static String makeCacheId() {
+ return Integer.toString(new SecureRandom().nextInt(1 << 30), 36);
+ }
+
+ private static URI makeUserAgentDbUri() {
+ return URI.create(System.getProperty(
+ "caja.webservice.useragentDb",
+ UserAgentDb.BROWSERSCOPE_WEB_SERVICE.toString()));
+ }
+
+ /** Zero argument ctor for Jetty. */
+ public MainServlet() { super(makeCacheId(), makeUserAgentDbUri()); }
+}
=======================================
--- /trunk/src/com/google/caja/ancillary/servlet/CajaWebToolsServlet.java
Tue Jan 19 16:43:06 2010
+++ /trunk/src/com/google/caja/ancillary/servlet/CajaWebToolsServlet.java
Tue Mar 2 16:34:56 2010
@@ -87,7 +87,7 @@
try {
String query = req.getQueryString();
URI indexUri = new URI(
- null, null, "/" + Verb.INDEX.relRequestPath, query, null);
+ null, null, Verb.INDEX.relRequestPath, query, null);
resp.sendRedirect(indexUri.toString());
} catch (URISyntaxException ex) {
ex.printStackTrace();
=======================================
--- /trunk/src/com/google/caja/ancillary/servlet/Main.java Tue Mar 2
16:07:39 2010
+++ /trunk/src/com/google/caja/ancillary/servlet/Main.java Tue Mar 2
16:34:56 2010
@@ -15,8 +15,6 @@
package com.google.caja.ancillary.servlet;
import java.io.IOException;
-import java.net.URI;
-import java.security.SecureRandom;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -28,20 +26,7 @@
*
* @author [email protected]
*/
-public final class Main extends CajaWebToolsServlet {
-
- private static String makeCacheId() {
- return Integer.toString(new SecureRandom().nextInt(1 << 30), 36);
- }
-
- private static URI makeUserAgentDbUri() {
- return URI.create(System.getProperty(
- "caja.webservice.useragentDb",
- UserAgentDb.BROWSERSCOPE_WEB_SERVICE.toString()));
- }
-
- /** Zero argument ctor for Jetty. */
- public Main() { super(makeCacheId(), makeUserAgentDbUri()); }
+public final class Main {
/** Starts a server on port 8080. */
public static void main(String[] args) throws Exception {
@@ -53,7 +38,7 @@
throw new Exception("What are these command line parameters for?");
}
Server server = new Server(port);
- final Main servlet = new Main();
+ final MainServlet servlet = new MainServlet();
server.setHandler(new AbstractHandler() {
public void handle(
String tgt, HttpServletRequest req, HttpServletResponse resp,
=======================================
--- /trunk/web.xml Tue Mar 2 16:07:39 2010
+++ /trunk/web.xml Tue Mar 2 16:34:56 2010
@@ -19,7 +19,7 @@
</servlet>
<servlet>
<servlet-name>ToolsServlet</servlet-name>
- <servlet-class>com.google.caja.ancillary.servlet.Main</servlet-class>
+
<servlet-class>com.google.caja.ancillary.servlet.MainServlet</servlet-class>
</servlet>
<servlet-mapping>