Add HelloWorld Servlet

Change-Id: I1574df9a34f49e55a994481c4a52ee5f778b7c2c
diff --git a/BUCK b/BUCK
index e09f161..6c98ff5 100644
--- a/BUCK
+++ b/BUCK
@@ -3,6 +3,7 @@
   srcs = glob(['src/main/java/**/*.java']),
   resources = glob(['src/main/resources/**/*']),
   manifest_entries = [
-    'Gerrit-SshModule: com.googlesource.gerrit.plugins.cookbook.SshModule'
+    'Gerrit-HttpModule: com.googlesource.gerrit.plugins.cookbook.HttpModule',
+    'Gerrit-SshModule: com.googlesource.gerrit.plugins.cookbook.SshModule',
   ]
 )
diff --git a/pom.xml b/pom.xml
index e6f444a..c4732c1 100644
--- a/pom.xml
+++ b/pom.xml
@@ -37,6 +37,7 @@
         <configuration>
           <archive>
             <manifestEntries>
+              <Gerrit-HttpModule>com.googlesource.gerrit.plugins.cookbook.HttpModule</Gerrit-HttpModule>
               <Gerrit-SshModule>com.googlesource.gerrit.plugins.cookbook.SshModule</Gerrit-SshModule>
 
               <Implementation-Vendor>Gerrit Code Review</Implementation-Vendor>
diff --git a/src/main/java/com/googlesource/gerrit/plugins/cookbook/HelloWorldServlet.java b/src/main/java/com/googlesource/gerrit/plugins/cookbook/HelloWorldServlet.java
new file mode 100644
index 0000000..c8823bf
--- /dev/null
+++ b/src/main/java/com/googlesource/gerrit/plugins/cookbook/HelloWorldServlet.java
@@ -0,0 +1,44 @@
+// Copyright (C) 2013 The Android Open Source Project
+//
+// 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.googlesource.gerrit.plugins.cookbook;
+
+import java.io.IOException;
+import java.io.Writer;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import com.google.inject.Singleton;
+
+@Singleton
+class HelloWorldServlet extends HttpServlet {
+  private static final long serialVersionUID = 1L;
+
+  @Override
+  protected void doGet(final HttpServletRequest req,
+      final HttpServletResponse rsp) throws IOException, ServletException {
+    rsp.setContentType("text/html");
+    rsp.setCharacterEncoding("UTF-8");
+    final Writer out = rsp.getWriter();
+    out.write("<html>");
+    out.write("<body>");
+    out.write("<h2>Hello world!</h2>");
+    out.write("</body>");
+    out.write("</html>");
+    out.close();
+  }
+}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/cookbook/HttpModule.java b/src/main/java/com/googlesource/gerrit/plugins/cookbook/HttpModule.java
new file mode 100644
index 0000000..ab85671
--- /dev/null
+++ b/src/main/java/com/googlesource/gerrit/plugins/cookbook/HttpModule.java
@@ -0,0 +1,24 @@
+// Copyright (C) 2013 The Android Open Source Project
+//
+// 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.googlesource.gerrit.plugins.cookbook;
+
+import com.google.gerrit.httpd.plugins.HttpPluginModule;
+
+public class HttpModule extends HttpPluginModule {
+  @Override
+  protected void configureServlets() {
+    serve("/say-hello/*").with(HelloWorldServlet.class);
+  }
+}
diff --git a/src/main/resources/Documentation/servlet-hello.md b/src/main/resources/Documentation/servlet-hello.md
new file mode 100644
index 0000000..e4902bf
--- /dev/null
+++ b/src/main/resources/Documentation/servlet-hello.md
@@ -0,0 +1,27 @@
+cookbook-plugin hello
+=====================
+
+NAME
+----
+say-hello - Print our "Hello world" message
+
+SYNOPSIS
+--------
+>     http://<host>:<port>/cookbook-plugin/say-hello/
+
+DESCRIPTION
+-----------
+Prints "Hello world!".
+
+ACCESS
+------
+Any user.
+
+SEE ALSO
+--------
+
+* [Plugin Development](../../../Documentation/dev-plugins.html)
+
+GERRIT
+------
+Part of [Gerrit Code Review](../../../Documentation/index.html)