aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Becker2013-09-18 10:58:34 (EDT)
committerThomas Becker2013-09-18 11:55:23 (EDT)
commit36efbb9869ca922fb2be6207859130cdccfb908c (patch)
treec7db46963fbfe33846c7bd6fd647ea862890bdea
parentb4a8871b62957f5d804ee1fd64de0bd25b8188e3 (diff)
downloadorg.eclipse.jetty.project-36efbb9869ca922fb2be6207859130cdccfb908c.zip
org.eclipse.jetty.project-36efbb9869ca922fb2be6207859130cdccfb908c.tar.gz
org.eclipse.jetty.project-36efbb9869ca922fb2be6207859130cdccfb908c.tar.bz2
416453 Add comments to embedded FileServer example
-rw-r--r--examples/embedded/src/main/java/org/eclipse/jetty/embedded/FileServer.java12
1 files changed, 11 insertions, 1 deletions
diff --git a/examples/embedded/src/main/java/org/eclipse/jetty/embedded/FileServer.java b/examples/embedded/src/main/java/org/eclipse/jetty/embedded/FileServer.java
index 15d947a..f47b666 100644
--- a/examples/embedded/src/main/java/org/eclipse/jetty/embedded/FileServer.java
+++ b/examples/embedded/src/main/java/org/eclipse/jetty/embedded/FileServer.java
@@ -32,17 +32,27 @@ public class FileServer
{
public static void main(String[] args) throws Exception
{
+ // Create a basic Jetty server object that will listen on port 8080. Note that if you set this to port 0
+ // then a randomly available port will be assigned that you can either look in the logs for the port,
+ // or programmatically obtain it for use in test cases.
Server server = new Server(8080);
+ // Create the ResourceHandler. It is the object that will actually handle the request for a given file. It is
+ // a Jetty Handler object so it is suitable for chaining with other handlers as you will see in other examples.
ResourceHandler resource_handler = new ResourceHandler();
+ // Configure the ResourceHandler. Setting the resource base indicates where the files should be served out of.
+ // In this example it is the current directory but it can be configured to anything that the jvm has access to.
resource_handler.setDirectoriesListed(true);
resource_handler.setWelcomeFiles(new String[]{ "index.html" });
resource_handler.setResourceBase(".");
-
+
+ // Add the ResourceHandler to the server.
HandlerList handlers = new HandlerList();
handlers.setHandlers(new Handler[] { resource_handler, new DefaultHandler() });
server.setHandler(handlers);
+ //Start things up! By using the server.join() the server thread will join with the current thread.
+ // See "http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/Thread.html#join()" for more details.
server.start();
server.join();
}