Fixes according to review. #2

Merged
merged 3 commits into from Oct 7, 2011
View
2 base/pom.xml
@@ -8,9 +8,7 @@
<version>2.0-SNAPSHOT</version>
</parent>
- <groupId>org.cloudname</groupId>
<artifactId>base</artifactId>
- <version>2.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>Cloudname Base</name>
View
3 base/src/META-INF/MANIFEST.MF
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Class-Path:
+
View
25 base/src/main/java/org/cloudname/con/HttpConsole.java
@@ -2,10 +2,10 @@
import java.net.InetSocketAddress;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.HashMap;
import java.util.Set;
import java.util.concurrent.Executors;
-import java.util.Collections;
import org.cloudname.con.netty.HttpConsolePipelineFactory;
import org.cloudname.con.widget.HttpWidget;
@@ -27,6 +27,8 @@
*
*/
public class HttpConsole {
+ public static final int HTTPCONSOLE_DEFAULT_PORT = 4601;
+
private int port;
private Channel channel;
private ServerBootstrap bootstrap;
@@ -43,7 +45,7 @@ private HttpConsole(int port) {
}
/**
- * TODO(paulrene): write javadoc.
+ * Create a new HttpConsole instance which listens to {@code port}.
*/
public static HttpConsole create(int port) {
return new HttpConsole(port);
@@ -74,7 +76,14 @@ public HttpConsole start() {
}
/**
- * TODO(paulrene): write javadoc.
+ * Add a new HttpWidget to the given path and initialize it
+ *
+ * @param widget Widget to add to the path
+ * @param path The path to add the Widget to. You may use the wildcard at the end of the path, eg. "/hello/*"
+ * @throws NullPointerException Will be thrown if widget or path is null.
+ * @throws IllegalArgumentException Will be thrown if you try to add a Widget to the root path
+ * @throws IllegalStateException Will be thrown if you try to add a Widget to a path that is already taken
+ *
*/
public HttpConsole addWidget(HttpWidget widget, String path) {
if (null == path) {
@@ -105,7 +114,11 @@ public HttpConsole addWidget(HttpWidget widget, String path) {
/**
- * TODO(paulrene): write javadoc.
+ *
+ * Unbinds the connector and releases resources.
+ *
+ * This will also invoke destroy() on all registered Widgets
+ *
*/
public void shutdown() {
if (null == channel) {
@@ -130,6 +143,10 @@ public int getPort() {
return port;
}
+
+ /**
+ * @return The registered paths
+ */
public Set<String> getWidgetPaths() {
return Collections.unmodifiableSet(pathToWidgetMap.keySet());
}
View
3 base/src/main/java/org/cloudname/con/netty/HttpConsolePipelineFactory.java
@@ -26,6 +26,9 @@ public HttpConsolePipelineFactory(HttpConsole console) {
this.console = console;
}
+ /* (non-Javadoc)
+ * @see org.jboss.netty.channel.ChannelPipelineFactory#getPipeline()
+ */
public ChannelPipeline getPipeline() throws Exception {
// Create a default pipeline implementation.
ChannelPipeline pipeline = Channels.pipeline();
View
2 base/src/main/java/org/cloudname/con/widget/HttpWidget.java
@@ -10,8 +10,6 @@
*
* Provides an interface to be implemented by Widgets wishing to handle HTTP requests
*
- *
- *
* @author paulrene
*
*/
View
2 cn/pom.xml
@@ -8,9 +8,7 @@
<version>2.0-SNAPSHOT</version>
</parent>
- <groupId>org.cloudname</groupId>
<artifactId>cn</artifactId>
- <version>2.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>Cloudname Library</name>
View
3 cn/src/META-INF/MANIFEST.MF
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Class-Path:
+
View
2 log/pom.xml
@@ -8,9 +8,7 @@
<version>2.0-SNAPSHOT</version>
</parent>
- <groupId>org.cloudname</groupId>
<artifactId>log</artifactId>
- <version>2.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>Cloudname Log</name>
View
3 log/src/META-INF/MANIFEST.MF
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Class-Path:
+
View
100 pom.xml
@@ -5,7 +5,7 @@
<groupId>org.cloudname</groupId>
<artifactId>cloudname-parent</artifactId>
<version>2.0-SNAPSHOT</version>
- <packaging>pom</packaging>
+ <packaging>pom</packaging>
<name>Cloudname Parent</name>
<url>http://org.cloudname/</url>
@@ -55,22 +55,22 @@
<plugins>
<!-- Use Java 6 -->
<plugin>
- <artifactId>maven-compiler-plugin</artifactId>
- <version>2.3.2</version>
- <configuration>
- <source>1.6</source>
- <target>1.6</target>
- </configuration>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>2.3.2</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
</plugin>
-
+
<!-- Output test errors to console -->
<plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-plugin</artifactId>
- <version>2.7.2</version>
- <configuration>
- <useFile>false</useFile>
- </configuration>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>2.7.2</version>
+ <configuration>
+ <useFile>false</useFile>
+ </configuration>
</plugin>
</plugins>
@@ -81,50 +81,50 @@
<!-- Internal dependencies -->
<dependency>
- <groupId>org.cloudname</groupId>
- <artifactId>cn</artifactId>
- <version>${cn.cn.version}</version>
+ <groupId>org.cloudname</groupId>
+ <artifactId>cn</artifactId>
+ <version>${cn.cn.version}</version>
</dependency>
<dependency>
- <groupId>org.cloudname</groupId>
- <artifactId>testtools</artifactId>
- <version>${cn.testtools.version}</version>
+ <groupId>org.cloudname</groupId>
+ <artifactId>testtools</artifactId>
+ <version>${cn.testtools.version}</version>
</dependency>
<dependency>
- <groupId>org.cloudname</groupId>
- <artifactId>log</artifactId>
- <version>${cn.log.version}</version>
+ <groupId>org.cloudname</groupId>
+ <artifactId>log</artifactId>
+ <version>${cn.log.version}</version>
</dependency>
<!-- Netty -->
<dependency>
- <groupId>org.jboss.netty</groupId>
- <artifactId>netty</artifactId>
- <version>${cn.netty.version}</version>
+ <groupId>org.jboss.netty</groupId>
+ <artifactId>netty</artifactId>
+ <version>${cn.netty.version}</version>
</dependency>
<!-- JoptSimple command line argument parser -->
<dependency>
- <groupId>net.sf.jopt-simple</groupId>
- <artifactId>jopt-simple</artifactId>
- <version>3.2</version>
+ <groupId>net.sf.jopt-simple</groupId>
+ <artifactId>jopt-simple</artifactId>
+ <version>3.2</version>
</dependency>
<!-- Google Protocol Buffers -->
<dependency>
- <groupId>com.google.protobuf</groupId>
- <artifactId>protobuf-java</artifactId>
- <version>${cn.protobuf.version}</version>
+ <groupId>com.google.protobuf</groupId>
+ <artifactId>protobuf-java</artifactId>
+ <version>${cn.protobuf.version}</version>
</dependency>
-
+
<!-- ZooKeeper -->
<dependency>
- <groupId>org.apache.zookeeper</groupId>
- <artifactId>zookeeper</artifactId>
- <version>${cn.zookeeper.version}</version>
- <exclusions>
+ <groupId>org.apache.zookeeper</groupId>
+ <artifactId>zookeeper</artifactId>
+ <version>${cn.zookeeper.version}</version>
+ <exclusions>
<exclusion>
<groupId>com.sun.jmx</groupId>
<artifactId>jmxri</artifactId>
@@ -139,26 +139,26 @@
</exclusion>
</exclusions>
</dependency>
-
+
<!-- Jackson JSON library -->
<dependency>
- <groupId>org.codehaus.jackson</groupId>
- <artifactId>jackson-core-asl</artifactId>
- <version>${cn.jackson.version}</version>
+ <groupId>org.codehaus.jackson</groupId>
+ <artifactId>jackson-core-asl</artifactId>
+ <version>${cn.jackson.version}</version>
</dependency>
-
+
<dependency>
- <groupId>org.codehaus.jackson</groupId>
- <artifactId>jackson-mapper-asl</artifactId>
- <version>${cn.jackson.version}</version>
+ <groupId>org.codehaus.jackson</groupId>
+ <artifactId>jackson-mapper-asl</artifactId>
+ <version>${cn.jackson.version}</version>
</dependency>
-
+
<!-- Junit -->
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>${cn.junit.version}</version>
- <scope>test</scope>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>${cn.junit.version}</version>
+ <scope>test</scope>
</dependency>
</dependencies>
</dependencyManagement>
View
2 testtools/pom.xml
@@ -8,9 +8,7 @@
<version>2.0-SNAPSHOT</version>
</parent>
- <groupId>org.cloudname</groupId>
<artifactId>testtools</artifactId>
- <version>2.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>Cloudname Test Tools</name>
View
3 testtools/src/META-INF/MANIFEST.MF
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Class-Path:
+
View
2 timber/pom.xml
@@ -8,9 +8,7 @@
<version>2.0-SNAPSHOT</version>
</parent>
- <groupId>org.cloudname</groupId>
<artifactId>timber</artifactId>
- <version>2.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>Cloudname Timber</name>