comparison artifact-database/src/main/java/de/intevation/artifactdatabase/rest/Standalone.java @ 88:69c84cf7c5d7

Added javadoc to the REST package of the artifact database (complete). artifacts/trunk@840 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Fri, 26 Mar 2010 15:05:11 +0000
parents 48d1a9a082c2
children e27cf9c84eb8
comparison
equal deleted inserted replaced
87:0f48188a6e02 88:69c84cf7c5d7
6 6
7 import de.intevation.artifacts.ArtifactDatabase; 7 import de.intevation.artifacts.ArtifactDatabase;
8 8
9 import de.intevation.artifactdatabase.Config; 9 import de.intevation.artifactdatabase.Config;
10 10
11 import de.intevation.artifactdatabase.rest.RestApp;
12
13 import org.apache.log4j.Logger; 11 import org.apache.log4j.Logger;
14 12
15 /** 13 /**
14 * Starts an HTTP server bound to a RestApp.
15 * The server (binding interface and port) is configure via the
16 * global configuration.
17 *
16 * @author <a href="mailto:sascha.teichmann@intevation">Sascha L. Teichmann</a> 18 * @author <a href="mailto:sascha.teichmann@intevation">Sascha L. Teichmann</a>
17 */ 19 */
18 public class Standalone 20 public class Standalone
19 { 21 {
20 private static Logger logger = Logger.getLogger(Standalone.class); 22 private static Logger logger = Logger.getLogger(Standalone.class);
21 23
24 /**
25 * XPath to figure out the port where to listen from the
26 * global configuration.
27 */
22 public static final String REST_PORT = 28 public static final String REST_PORT =
23 "/artifact-database/rest-server/port/text()"; 29 "/artifact-database/rest-server/port/text()";
24 30
31 /**
32 * XPath to figure out from global configuration
33 * which network interface to use to bind the HTTP server.
34 */
25 public static final String LISTEN_INTERFACE = 35 public static final String LISTEN_INTERFACE =
26 "/artifact-database/rest-server/listen/text()"; 36 "/artifact-database/rest-server/listen/text()";
27 37
38 /**
39 * The default port of the HTTP server: 8181
40 */
28 public static final int DEFAULT_PORT = 8181; 41 public static final int DEFAULT_PORT = 8181;
29 42
43 /**
44 * Builds a RestApp wrapped around the given artifact database,
45 * and bind this application to HTTP server. The HTTP server
46 * is configured by the global configuration. If no port is
47 * given by the configuration the default port is used. If
48 * no interface is given the HTTP server is reachable from
49 * all interfaces.
50 * @param db The artifact database to be exposed via the
51 * REST application.
52 */
30 public static void startAsServer(ArtifactDatabase db) { 53 public static void startAsServer(ArtifactDatabase db) {
31 String portString = Config.getStringXPath(REST_PORT); 54 String portString = Config.getStringXPath(REST_PORT);
32 String listenString = Config.getStringXPath(LISTEN_INTERFACE); 55 String listenString = Config.getStringXPath(LISTEN_INTERFACE);
33 56
34 int port = DEFAULT_PORT; 57 int port = DEFAULT_PORT;
69 catch (Exception e) { 92 catch (Exception e) {
70 logger.error(e.getLocalizedMessage(), e); 93 logger.error(e.getLocalizedMessage(), e);
71 } 94 }
72 } 95 }
73 } 96 }
74 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8: 97 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org