From eb6c8d5a12b342a361712f5362636baabc497e46 Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Wed, 5 Aug 2009 01:05:19 +0000 Subject: [PATCH] XmlConfiguration example git-svn-id: svn+ssh://dev.eclipse.org/svnroot/rt/org.eclipse.jetty/jetty/trunk@635 7e9141cc-0065-0410-87d8-b60c137991c4 --- .../eclipse/jetty/embedded/FileServer.java | 5 ++- .../eclipse/jetty/embedded/FileServerXml.java | 25 +++++++++++++ .../src/main/resources/fileserver.xml | 35 +++++++++++++++++++ 3 files changed, 64 insertions(+), 1 deletion(-) create mode 100644 example-jetty-embedded/src/main/java/org/eclipse/jetty/embedded/FileServerXml.java create mode 100644 example-jetty-embedded/src/main/resources/fileserver.xml diff --git a/example-jetty-embedded/src/main/java/org/eclipse/jetty/embedded/FileServer.java b/example-jetty-embedded/src/main/java/org/eclipse/jetty/embedded/FileServer.java index 520a3bfc44a..8410801fff9 100644 --- a/example-jetty-embedded/src/main/java/org/eclipse/jetty/embedded/FileServer.java +++ b/example-jetty-embedded/src/main/java/org/eclipse/jetty/embedded/FileServer.java @@ -21,10 +21,13 @@ import org.eclipse.jetty.server.handler.ResourceHandler; import org.eclipse.jetty.util.log.Log; /* ------------------------------------------------------------ */ -/** +/** Simple Jetty FileServer. + * This is a simple example of Jetty configured as a FileServer. + * * File server Usage - java org.eclipse.jetty.server.example.FileServer [ port [ * docroot ]] * + * @see FileServerXml for the equivalent example done in XML configuration. * @author gregw * */ diff --git a/example-jetty-embedded/src/main/java/org/eclipse/jetty/embedded/FileServerXml.java b/example-jetty-embedded/src/main/java/org/eclipse/jetty/embedded/FileServerXml.java new file mode 100644 index 00000000000..d9bf0a34468 --- /dev/null +++ b/example-jetty-embedded/src/main/java/org/eclipse/jetty/embedded/FileServerXml.java @@ -0,0 +1,25 @@ +package org.eclipse.jetty.embedded; + +import org.eclipse.jetty.server.Server; +import org.eclipse.jetty.util.resource.Resource; +import org.eclipse.jetty.xml.XmlConfiguration; + + +/* ------------------------------------------------------------ */ +/** A Jetty FileServer. + * This server is identical to {@link FileServer}, except that it + * is configured via an {@link XmlConfiguration} config file that + * does the identical work. + * @see http://dev.eclipse.org/svnroot/rt/org.eclipse.jetty/jetty/trunk/example-jetty-embedded/src/main/resources/fileserver.xml + */ +public class FileServerXml +{ + public static void main(String[] args) throws Exception + { + Resource fileserver_xml = Resource.newSystemResource("fileserver.xml"); + XmlConfiguration configuration = new XmlConfiguration(fileserver_xml.getInputStream()); + Server server = (Server)configuration.configure(); + server.start(); + server.join(); + } +} diff --git a/example-jetty-embedded/src/main/resources/fileserver.xml b/example-jetty-embedded/src/main/resources/fileserver.xml new file mode 100644 index 00000000000..9354f79cbdf --- /dev/null +++ b/example-jetty-embedded/src/main/resources/fileserver.xml @@ -0,0 +1,35 @@ + + + + + + + + + 8080 + + + + + + + + + + + true + + index.html + + . + + + + + + + + + + + \ No newline at end of file