diff options
Diffstat (limited to 'same/src/main/java/com/orbekk/same/http')
4 files changed, 27 insertions, 3 deletions
diff --git a/same/src/main/java/com/orbekk/same/http/JettyServerContainer.java b/same/src/main/java/com/orbekk/same/http/JettyServerContainer.java index 34db226..c15d94d 100644 --- a/same/src/main/java/com/orbekk/same/http/JettyServerContainer.java +++ b/same/src/main/java/com/orbekk/same/http/JettyServerContainer.java @@ -7,7 +7,7 @@ import org.eclipse.jetty.servlet.ServletContextHandler; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class JettyServerContainer { +public class JettyServerContainer implements ServerContainer { Logger logger = LoggerFactory.getLogger(getClass()); Server server; int port; diff --git a/same/src/main/java/com/orbekk/same/http/ServerContainer.java b/same/src/main/java/com/orbekk/same/http/ServerContainer.java new file mode 100644 index 0000000..6f87910 --- /dev/null +++ b/same/src/main/java/com/orbekk/same/http/ServerContainer.java @@ -0,0 +1,8 @@ +package com.orbekk.same.http; + +public interface ServerContainer { + public abstract int getPort(); + public abstract void start() throws Exception; + public abstract void stop() throws Exception; + public abstract void join() throws Exception; +}
\ No newline at end of file diff --git a/same/src/main/java/com/orbekk/same/http/TjwsServerBuilder.java b/same/src/main/java/com/orbekk/same/http/TjwsServerBuilder.java index c0aed5a..7a07dbd 100644 --- a/same/src/main/java/com/orbekk/same/http/TjwsServerBuilder.java +++ b/same/src/main/java/com/orbekk/same/http/TjwsServerBuilder.java @@ -29,7 +29,7 @@ public class TjwsServerBuilder { return withServlet(new RpcServlet(server), pathSpec); } - public TjwsServerContainer build() { + public ServerContainer build() { TjwsServerContainer server = TjwsServerContainer.create(port); for (int i = 0; i < servletPaths.size(); i++) { String path = servletPaths.get(i); diff --git a/same/src/main/java/com/orbekk/same/http/TjwsServerContainer.java b/same/src/main/java/com/orbekk/same/http/TjwsServerContainer.java index a38cfac..ec2f2a2 100644 --- a/same/src/main/java/com/orbekk/same/http/TjwsServerContainer.java +++ b/same/src/main/java/com/orbekk/same/http/TjwsServerContainer.java @@ -7,7 +7,7 @@ import org.slf4j.LoggerFactory; import Acme.Serve.Serve; -public class TjwsServerContainer { +public class TjwsServerContainer implements ServerContainer { private static class MyServer extends Serve { public void join() { try { @@ -31,18 +31,34 @@ public class TjwsServerContainer { this.server = server; } + /* (non-Javadoc) + * @see com.orbekk.same.http.ServerContainer#getPort() + */ + @Override public int getPort() { return (Integer)this.server.getAttribute(Serve.ARG_PORT); } + /* (non-Javadoc) + * @see com.orbekk.same.http.ServerContainer#start() + */ + @Override public void start() { server.runInBackground(); } + /* (non-Javadoc) + * @see com.orbekk.same.http.ServerContainer#stop() + */ + @Override public void stop() { server.stopBackground(); } + /* (non-Javadoc) + * @see com.orbekk.same.http.ServerContainer#join() + */ + @Override public void join() { server.join(); } |