Mercurial > dive4elements > framework
comparison artifact-database/src/main/java/de/intevation/artifactdatabase/rest/Standalone.java @ 44:86d2a843e588
Allow REST server to bind to configurable interface.
artifacts/trunk@151 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Tue, 29 Sep 2009 10:25:53 +0000 |
parents | d5dc2900392f |
children | f2648672c9c4 |
comparison
equal
deleted
inserted
replaced
43:b8516aa3d8a1 | 44:86d2a843e588 |
---|---|
20 private static Logger logger = Logger.getLogger(Standalone.class); | 20 private static Logger logger = Logger.getLogger(Standalone.class); |
21 | 21 |
22 public static final String REST_PORT = | 22 public static final String REST_PORT = |
23 "/artifact-database/rest-server/port/text()"; | 23 "/artifact-database/rest-server/port/text()"; |
24 | 24 |
25 public static final String LISTEN_INTERFACE = | |
26 "/artifact-database/rest-server/listen/text()"; | |
27 | |
25 public static final int DEFAULT_PORT = 8181; | 28 public static final int DEFAULT_PORT = 8181; |
26 | 29 |
27 public static void startAsServer(ArtifactDatabase db) { | 30 public static void startAsServer(ArtifactDatabase db) { |
28 String portString = Config.getStringXPath(REST_PORT); | 31 String portString = Config.getStringXPath(REST_PORT); |
32 String listenString = Config.getStringXPath(LISTEN_INTERFACE); | |
29 | 33 |
30 int port = DEFAULT_PORT; | 34 int port = DEFAULT_PORT; |
31 | 35 |
32 if (portString != null) { | 36 if (portString != null) { |
33 try { | 37 try { |
44 | 48 |
45 RestApp app = new RestApp(db); | 49 RestApp app = new RestApp(db); |
46 | 50 |
47 Component component = new Component(); | 51 Component component = new Component(); |
48 | 52 |
49 component.getServers().add(Protocol.HTTP, port); | 53 if (listenString != null) { |
54 component.getServers().add(Protocol.HTTP, listenString, port); | |
55 } | |
56 else { | |
57 component.getServers().add(Protocol.HTTP, port); | |
58 } | |
50 | 59 |
51 component.getDefaultHost().attach(app); | 60 component.getDefaultHost().attach(app); |
52 | 61 |
53 logger.info("Starting rest HTTP server on port " + port); | 62 logger.info("Starting rest HTTP server on port " + port); |
54 | 63 |