JAL-4023 use %g for distances (scientific notation for very small or large values)
[jalview.git] / utils / JettyExamplesDir.java
1 /*******************************************************************************
2  * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3  * Copyright (C) $$Year-Rel$$ The Jalview Authors
4  * 
5  * This file is part of Jalview.
6  * 
7  * Jalview is free software: you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License 
9  * as published by the Free Software Foundation, either version 3
10  * of the License, or (at your option) any later version.
11  *  
12  * Jalview is distributed in the hope that it will be useful, but 
13  * WITHOUT ANY WARRANTY; without even the implied warranty 
14  * of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
15  * PURPOSE.  See the GNU General Public License for more details.
16  * 
17  * You should have received a copy of the GNU General Public License
18  * along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
19  * The Jalview Authors are detailed in the 'AUTHORS' file.
20  ******************************************************************************/
21 //
22 //========================================================================
23 //Copyright (c) 1995-2015 Mort Bay Consulting Pty. Ltd.
24 //------------------------------------------------------------------------
25 //All rights reserved. This program and the accompanying materials
26 //are made available under the terms of the Eclipse Public License v1.0
27 //and Apache License v2.0 which accompanies this distribution.
28 //
29 //  The Eclipse Public License is available at
30 //  http://www.eclipse.org/legal/epl-v10.html
31 //
32 //  The Apache License v2.0 is available at
33 //  http://www.opensource.org/licenses/apache2.0.php
34 //
35 //You may elect to redistribute this code under either of these licenses.
36 //========================================================================
37 //
38
39 import org.eclipse.jetty.server.Handler;
40 import org.eclipse.jetty.server.Server;
41 import org.eclipse.jetty.server.handler.DefaultHandler;
42 import org.eclipse.jetty.server.handler.HandlerList;
43 import org.eclipse.jetty.server.handler.ResourceHandler;
44
45 public class JettyExamplesDir
46 {
47
48   /**
49    * Simple Jetty FileServer. This is a simple example of Jetty configured as a
50    * FileServer.
51    */
52
53   public static void main(String[] args) throws Exception
54   {
55     // Create a basic Jetty server object that will listen on port 8080. Note
56     // that if you set this to port 0
57     // then a randomly available port will be assigned that you can either look
58     // in the logs for the port,
59     // or programmatically obtain it for use in test cases.
60     Server server = new Server(8080);
61
62     // Create the ResourceHandler. It is the object that will actually handle
63     // the request for a given file. It is
64     // a Jetty Handler object so it is suitable for chaining with other handlers
65     // as you will see in other examples.
66     ResourceHandler resource_handler = new ResourceHandler();
67     // Configure the ResourceHandler. Setting the resource base indicates where
68     // the files should be served out of.
69     // In this example it is the current directory but it can be configured to
70     // anything that the jvm has access to.
71     resource_handler.setDirectoriesListed(true);
72     resource_handler.setWelcomeFiles(new String[] { "applets.html" });
73     resource_handler.setResourceBase(".");
74
75     // Add the ResourceHandler to the server.
76     // GzipHandler gzip = new GzipHandler();
77     // server.setHandler(gzip);
78     HandlerList handlers = new HandlerList();
79     handlers.setHandlers(new Handler[] { resource_handler,
80         new DefaultHandler() });
81     server.setHandler(handlers);
82
83     // Start things up! By using the server.join() the server thread will join
84     // with the current thread.
85     // See
86     // "http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/Thread.html#join()"
87     // for more details.
88     server.start();
89     server.join();
90   }
91 }