Mercurial > dive4elements > framework
annotate artifact-database/src/main/java/de/intevation/artifactdatabase/rest/Standalone.java @ 318:2ed77f7e1bab
Swapped SQL parameter indices when fetching collection name.
artifacts/trunk@2455 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Tue, 02 Aug 2011 14:13:20 +0000 |
parents | d52947ce8629 |
children |
rev | line source |
---|---|
100
933bbc9fc11f
Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
93
diff
changeset
|
1 /* |
933bbc9fc11f
Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
93
diff
changeset
|
2 * Copyright (c) 2010 by Intevation GmbH |
933bbc9fc11f
Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
93
diff
changeset
|
3 * |
933bbc9fc11f
Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
93
diff
changeset
|
4 * This program is free software under the LGPL (>=v2.1) |
933bbc9fc11f
Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
93
diff
changeset
|
5 * Read the file LGPL.txt coming with the software for details |
933bbc9fc11f
Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
93
diff
changeset
|
6 * or visit http://www.gnu.org/licenses/ if it does not exist. |
933bbc9fc11f
Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
93
diff
changeset
|
7 */ |
933bbc9fc11f
Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
93
diff
changeset
|
8 |
19
1259d192e3c3
* New configuration based on config directory
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
9 package de.intevation.artifactdatabase.rest; |
1259d192e3c3
* New configuration based on config directory
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
10 |
263
c0fb96f88ad1
Make used HTTP server exchangeable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
262
diff
changeset
|
11 import de.intevation.artifacts.common.utils.XMLUtils; |
93
e27cf9c84eb8
Unified imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
88
diff
changeset
|
12 |
e27cf9c84eb8
Unified imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
88
diff
changeset
|
13 import de.intevation.artifacts.ArtifactDatabase; |
e27cf9c84eb8
Unified imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
88
diff
changeset
|
14 |
e27cf9c84eb8
Unified imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
88
diff
changeset
|
15 import org.apache.log4j.Logger; |
e27cf9c84eb8
Unified imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
88
diff
changeset
|
16 |
19
1259d192e3c3
* New configuration based on config directory
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
17 import org.restlet.Component; |
101
7fc0650f194c
Upgraded the Restlet version to 2.0.4 (current stable).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
100
diff
changeset
|
18 import org.restlet.Server; |
19
1259d192e3c3
* New configuration based on config directory
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
19 |
1259d192e3c3
* New configuration based on config directory
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
20 import org.restlet.data.Protocol; |
1259d192e3c3
* New configuration based on config directory
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
21 |
263
c0fb96f88ad1
Make used HTTP server exchangeable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
262
diff
changeset
|
22 import org.w3c.dom.Document; |
c0fb96f88ad1
Make used HTTP server exchangeable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
262
diff
changeset
|
23 |
24
d5dc2900392f
* Added callback parameter to Artifact.setup()
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
20
diff
changeset
|
24 /** |
88
69c84cf7c5d7
Added javadoc to the REST package of the artifact database (complete).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
77
diff
changeset
|
25 * Starts an HTTP server bound to a RestApp. |
69c84cf7c5d7
Added javadoc to the REST package of the artifact database (complete).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
77
diff
changeset
|
26 * The server (binding interface and port) is configure via the |
69c84cf7c5d7
Added javadoc to the REST package of the artifact database (complete).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
77
diff
changeset
|
27 * global configuration. |
69c84cf7c5d7
Added javadoc to the REST package of the artifact database (complete).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
77
diff
changeset
|
28 * |
77
48d1a9a082c2
Bring @author javadoc tags in form '@author <a href="john.doe@example.com">John Doe</a>'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
47
diff
changeset
|
29 * @author <a href="mailto:sascha.teichmann@intevation">Sascha L. Teichmann</a> |
24
d5dc2900392f
* Added callback parameter to Artifact.setup()
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
20
diff
changeset
|
30 */ |
19
1259d192e3c3
* New configuration based on config directory
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
31 public class Standalone |
263
c0fb96f88ad1
Make used HTTP server exchangeable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
262
diff
changeset
|
32 implements HTTPServer |
19
1259d192e3c3
* New configuration based on config directory
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
33 { |
1259d192e3c3
* New configuration based on config directory
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
34 private static Logger logger = Logger.getLogger(Standalone.class); |
1259d192e3c3
* New configuration based on config directory
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
35 |
88
69c84cf7c5d7
Added javadoc to the REST package of the artifact database (complete).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
77
diff
changeset
|
36 /** |
69c84cf7c5d7
Added javadoc to the REST package of the artifact database (complete).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
77
diff
changeset
|
37 * XPath to figure out the port where to listen from the |
69c84cf7c5d7
Added javadoc to the REST package of the artifact database (complete).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
77
diff
changeset
|
38 * global configuration. |
69c84cf7c5d7
Added javadoc to the REST package of the artifact database (complete).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
77
diff
changeset
|
39 */ |
19
1259d192e3c3
* New configuration based on config directory
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
40 public static final String REST_PORT = |
1259d192e3c3
* New configuration based on config directory
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
41 "/artifact-database/rest-server/port/text()"; |
1259d192e3c3
* New configuration based on config directory
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
42 |
88
69c84cf7c5d7
Added javadoc to the REST package of the artifact database (complete).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
77
diff
changeset
|
43 /** |
69c84cf7c5d7
Added javadoc to the REST package of the artifact database (complete).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
77
diff
changeset
|
44 * XPath to figure out from global configuration |
69c84cf7c5d7
Added javadoc to the REST package of the artifact database (complete).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
77
diff
changeset
|
45 * which network interface to use to bind the HTTP server. |
69c84cf7c5d7
Added javadoc to the REST package of the artifact database (complete).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
77
diff
changeset
|
46 */ |
44
86d2a843e588
Allow REST server to bind to configurable interface.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
24
diff
changeset
|
47 public static final String LISTEN_INTERFACE = |
86d2a843e588
Allow REST server to bind to configurable interface.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
24
diff
changeset
|
48 "/artifact-database/rest-server/listen/text()"; |
86d2a843e588
Allow REST server to bind to configurable interface.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
24
diff
changeset
|
49 |
88
69c84cf7c5d7
Added javadoc to the REST package of the artifact database (complete).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
77
diff
changeset
|
50 /** |
69c84cf7c5d7
Added javadoc to the REST package of the artifact database (complete).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
77
diff
changeset
|
51 * The default port of the HTTP server: 8181 |
69c84cf7c5d7
Added javadoc to the REST package of the artifact database (complete).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
77
diff
changeset
|
52 */ |
19
1259d192e3c3
* New configuration based on config directory
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
53 public static final int DEFAULT_PORT = 8181; |
1259d192e3c3
* New configuration based on config directory
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
54 |
262
5cab846eb2a3
flys/issue65: Set number of max. restlet threads to 1024 and make it configurable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
207
diff
changeset
|
55 public static final String MAX_THREADS = |
5cab846eb2a3
flys/issue65: Set number of max. restlet threads to 1024 and make it configurable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
207
diff
changeset
|
56 "/artifact-database/rest-server/max-threads/text()"; |
5cab846eb2a3
flys/issue65: Set number of max. restlet threads to 1024 and make it configurable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
207
diff
changeset
|
57 |
5cab846eb2a3
flys/issue65: Set number of max. restlet threads to 1024 and make it configurable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
207
diff
changeset
|
58 public static final String MAX_THREADS_DEFAULT = |
5cab846eb2a3
flys/issue65: Set number of max. restlet threads to 1024 and make it configurable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
207
diff
changeset
|
59 "1024"; |
5cab846eb2a3
flys/issue65: Set number of max. restlet threads to 1024 and make it configurable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
207
diff
changeset
|
60 |
263
c0fb96f88ad1
Make used HTTP server exchangeable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
262
diff
changeset
|
61 protected int port; |
19
1259d192e3c3
* New configuration based on config directory
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
62 |
263
c0fb96f88ad1
Make used HTTP server exchangeable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
262
diff
changeset
|
63 protected String listen; |
c0fb96f88ad1
Make used HTTP server exchangeable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
262
diff
changeset
|
64 |
c0fb96f88ad1
Make used HTTP server exchangeable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
262
diff
changeset
|
65 protected String maxThreads; |
c0fb96f88ad1
Make used HTTP server exchangeable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
262
diff
changeset
|
66 |
c0fb96f88ad1
Make used HTTP server exchangeable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
262
diff
changeset
|
67 public Standalone() { |
c0fb96f88ad1
Make used HTTP server exchangeable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
262
diff
changeset
|
68 } |
c0fb96f88ad1
Make used HTTP server exchangeable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
262
diff
changeset
|
69 |
264
fa0d9acea897
flys/issue65: Added Jetty HTTP server as a replacement option to foster better scalability. Needs testing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
263
diff
changeset
|
70 @Override |
263
c0fb96f88ad1
Make used HTTP server exchangeable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
262
diff
changeset
|
71 public void setup(Document document) { |
c0fb96f88ad1
Make used HTTP server exchangeable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
262
diff
changeset
|
72 String portString = XMLUtils.xpathString(document, REST_PORT, null); |
c0fb96f88ad1
Make used HTTP server exchangeable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
262
diff
changeset
|
73 |
c0fb96f88ad1
Make used HTTP server exchangeable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
262
diff
changeset
|
74 port = DEFAULT_PORT; |
19
1259d192e3c3
* New configuration based on config directory
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
75 |
1259d192e3c3
* New configuration based on config directory
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
76 if (portString != null) { |
1259d192e3c3
* New configuration based on config directory
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
77 try { |
1259d192e3c3
* New configuration based on config directory
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
78 port = Integer.parseInt(portString); |
1259d192e3c3
* New configuration based on config directory
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
79 if (port < 0) { |
1259d192e3c3
* New configuration based on config directory
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
80 throw new NumberFormatException(); |
1259d192e3c3
* New configuration based on config directory
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
81 } |
1259d192e3c3
* New configuration based on config directory
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
82 } |
1259d192e3c3
* New configuration based on config directory
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
83 catch (NumberFormatException nfe) { |
1259d192e3c3
* New configuration based on config directory
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
84 logger.error("rest port is not a positive integer value.", nfe); |
1259d192e3c3
* New configuration based on config directory
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
85 return; |
1259d192e3c3
* New configuration based on config directory
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
86 } |
1259d192e3c3
* New configuration based on config directory
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
87 } |
1259d192e3c3
* New configuration based on config directory
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
88 |
263
c0fb96f88ad1
Make used HTTP server exchangeable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
262
diff
changeset
|
89 listen = XMLUtils.xpathString(document, LISTEN_INTERFACE, null); |
c0fb96f88ad1
Make used HTTP server exchangeable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
262
diff
changeset
|
90 maxThreads = XMLUtils.xpathString(document, MAX_THREADS, null); |
c0fb96f88ad1
Make used HTTP server exchangeable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
262
diff
changeset
|
91 } |
c0fb96f88ad1
Make used HTTP server exchangeable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
262
diff
changeset
|
92 |
264
fa0d9acea897
flys/issue65: Added Jetty HTTP server as a replacement option to foster better scalability. Needs testing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
263
diff
changeset
|
93 protected Server createServer() { |
265
d52947ce8629
XMLUtils.xpathString() returns empty string not null.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
264
diff
changeset
|
94 return listen != null && listen.length() > 0 |
264
fa0d9acea897
flys/issue65: Added Jetty HTTP server as a replacement option to foster better scalability. Needs testing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
263
diff
changeset
|
95 ? new Server(Protocol.HTTP, listen, port) |
fa0d9acea897
flys/issue65: Added Jetty HTTP server as a replacement option to foster better scalability. Needs testing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
263
diff
changeset
|
96 : new Server(Protocol.HTTP, port); |
fa0d9acea897
flys/issue65: Added Jetty HTTP server as a replacement option to foster better scalability. Needs testing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
263
diff
changeset
|
97 } |
fa0d9acea897
flys/issue65: Added Jetty HTTP server as a replacement option to foster better scalability. Needs testing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
263
diff
changeset
|
98 |
fa0d9acea897
flys/issue65: Added Jetty HTTP server as a replacement option to foster better scalability. Needs testing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
263
diff
changeset
|
99 protected void logServerStart() { |
fa0d9acea897
flys/issue65: Added Jetty HTTP server as a replacement option to foster better scalability. Needs testing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
263
diff
changeset
|
100 logger.info("Starting " + getClass().getName() + " HTTP server on " |
fa0d9acea897
flys/issue65: Added Jetty HTTP server as a replacement option to foster better scalability. Needs testing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
263
diff
changeset
|
101 + (listen != null ? listen : "*") |
fa0d9acea897
flys/issue65: Added Jetty HTTP server as a replacement option to foster better scalability. Needs testing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
263
diff
changeset
|
102 + ":" + port); |
fa0d9acea897
flys/issue65: Added Jetty HTTP server as a replacement option to foster better scalability. Needs testing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
263
diff
changeset
|
103 } |
fa0d9acea897
flys/issue65: Added Jetty HTTP server as a replacement option to foster better scalability. Needs testing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
263
diff
changeset
|
104 |
263
c0fb96f88ad1
Make used HTTP server exchangeable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
262
diff
changeset
|
105 /** |
c0fb96f88ad1
Make used HTTP server exchangeable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
262
diff
changeset
|
106 * Builds a RestApp wrapped around the given artifact database, |
c0fb96f88ad1
Make used HTTP server exchangeable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
262
diff
changeset
|
107 * and bind this application to HTTP server. The HTTP server |
c0fb96f88ad1
Make used HTTP server exchangeable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
262
diff
changeset
|
108 * is configured by the global configuration. If no port is |
c0fb96f88ad1
Make used HTTP server exchangeable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
262
diff
changeset
|
109 * given by the configuration the default port is used. If |
c0fb96f88ad1
Make used HTTP server exchangeable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
262
diff
changeset
|
110 * no interface is given the HTTP server is reachable from |
c0fb96f88ad1
Make used HTTP server exchangeable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
262
diff
changeset
|
111 * all interfaces. |
c0fb96f88ad1
Make used HTTP server exchangeable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
262
diff
changeset
|
112 * @param db The artifact database to be exposed via the |
c0fb96f88ad1
Make used HTTP server exchangeable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
262
diff
changeset
|
113 * REST application. |
c0fb96f88ad1
Make used HTTP server exchangeable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
262
diff
changeset
|
114 */ |
264
fa0d9acea897
flys/issue65: Added Jetty HTTP server as a replacement option to foster better scalability. Needs testing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
263
diff
changeset
|
115 @Override |
263
c0fb96f88ad1
Make used HTTP server exchangeable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
262
diff
changeset
|
116 public void startAsServer(ArtifactDatabase db) { |
c0fb96f88ad1
Make used HTTP server exchangeable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
262
diff
changeset
|
117 |
19
1259d192e3c3
* New configuration based on config directory
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
118 RestApp app = new RestApp(db); |
1259d192e3c3
* New configuration based on config directory
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
119 |
1259d192e3c3
* New configuration based on config directory
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
120 Component component = new Component(); |
1259d192e3c3
* New configuration based on config directory
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
121 |
264
fa0d9acea897
flys/issue65: Added Jetty HTTP server as a replacement option to foster better scalability. Needs testing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
263
diff
changeset
|
122 Server server = createServer(); |
19
1259d192e3c3
* New configuration based on config directory
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
123 |
101
7fc0650f194c
Upgraded the Restlet version to 2.0.4 (current stable).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
100
diff
changeset
|
124 component.getServers().add(server); |
7fc0650f194c
Upgraded the Restlet version to 2.0.4 (current stable).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
100
diff
changeset
|
125 |
262
5cab846eb2a3
flys/issue65: Set number of max. restlet threads to 1024 and make it configurable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
207
diff
changeset
|
126 server.getContext().getParameters().add( |
265
d52947ce8629
XMLUtils.xpathString() returns empty string not null.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
264
diff
changeset
|
127 "maxThreads", maxThreads != null && maxThreads.length() > 0 |
262
5cab846eb2a3
flys/issue65: Set number of max. restlet threads to 1024 and make it configurable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
207
diff
changeset
|
128 ? maxThreads |
5cab846eb2a3
flys/issue65: Set number of max. restlet threads to 1024 and make it configurable.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
207
diff
changeset
|
129 : MAX_THREADS_DEFAULT); |
101
7fc0650f194c
Upgraded the Restlet version to 2.0.4 (current stable).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
100
diff
changeset
|
130 |
19
1259d192e3c3
* New configuration based on config directory
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
131 component.getDefaultHost().attach(app); |
1259d192e3c3
* New configuration based on config directory
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
132 |
264
fa0d9acea897
flys/issue65: Added Jetty HTTP server as a replacement option to foster better scalability. Needs testing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
263
diff
changeset
|
133 logServerStart(); |
20
ff666592c1c3
Added factory listing '/factories' to web app.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
19
diff
changeset
|
134 |
19
1259d192e3c3
* New configuration based on config directory
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
135 try { |
1259d192e3c3
* New configuration based on config directory
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
136 component.start(); |
1259d192e3c3
* New configuration based on config directory
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
137 } |
1259d192e3c3
* New configuration based on config directory
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
138 catch (Exception e) { |
1259d192e3c3
* New configuration based on config directory
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
139 logger.error(e.getLocalizedMessage(), e); |
1259d192e3c3
* New configuration based on config directory
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
140 } |
1259d192e3c3
* New configuration based on config directory
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
141 } |
1259d192e3c3
* New configuration based on config directory
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
142 } |
93
e27cf9c84eb8
Unified imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
88
diff
changeset
|
143 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |