aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-application/src
diff options
context:
space:
mode:
authorEvgeny Mandrikov <mandrikov@gmail.com>2012-01-16 12:46:41 +0400
committerEvgeny Mandrikov <mandrikov@gmail.com>2012-01-16 12:53:08 +0400
commit5e5c910205bc245e660062a811bb7b862d28c911 (patch)
treeaff5a3a798472c7f6d1bae8867e5518365a47a85 /sonar-application/src
parentf351e32582397e64039df08265308038a5b6e174 (diff)
downloadsonarqube-5e5c910205bc245e660062a811bb7b862d28c911.tar.gz
sonarqube-5e5c910205bc245e660062a811bb7b862d28c911.zip
SONAR-1263 Add support for AJP13 host
Diffstat (limited to 'sonar-application/src')
-rw-r--r--sonar-application/src/main/assembly/conf/sonar.properties5
-rw-r--r--sonar-application/src/main/java/org/sonar/application/JettyEmbedder.java23
-rw-r--r--sonar-application/src/main/java/org/sonar/application/StartServer.java8
-rw-r--r--sonar-application/src/test/java/org/sonar/application/JettyEmbedderTest.java7
4 files changed, 26 insertions, 17 deletions
diff --git a/sonar-application/src/main/assembly/conf/sonar.properties b/sonar-application/src/main/assembly/conf/sonar.properties
index e6fce16ae21..18601529886 100644
--- a/sonar-application/src/main/assembly/conf/sonar.properties
+++ b/sonar-application/src/main/assembly/conf/sonar.properties
@@ -20,8 +20,9 @@
# Log HTTP requests. Deactivated by default.
#sonar.web.jettyRequestLogs: ../../logs/jetty-yyyy_mm_dd.request.log
-# Apache mod_jk connector. Supported only in standalone mode.
-# Uncomment to activate AJP13 connector.
+# Apache mod_jk connector. Supported only in standalone mode.
+# Uncomment to activate AJP13 connector.
+#sonar.ajp13.host: 0.0.0.0
#sonar.ajp13.port: 8009
diff --git a/sonar-application/src/main/java/org/sonar/application/JettyEmbedder.java b/sonar-application/src/main/java/org/sonar/application/JettyEmbedder.java
index ce11e2c3a86..9660553ec65 100644
--- a/sonar-application/src/main/java/org/sonar/application/JettyEmbedder.java
+++ b/sonar-application/src/main/java/org/sonar/application/JettyEmbedder.java
@@ -40,16 +40,18 @@ import java.util.List;
public class JettyEmbedder {
- private Server server;
- private String host;
- private int port;
- private String contextPath;
- private int ajp13Port = -1;
-
- public JettyEmbedder(String host, int port, String contextPath, int ajp13Port, URL configurationURL) throws Exception {
+ private final Server server;
+ private final String host;
+ private final int port;
+ private final String contextPath;
+ private final String ajp13Host;
+ private final int ajp13Port;
+
+ public JettyEmbedder(String host, int port, String contextPath, String ajp13Host, int ajp13Port, URL configurationURL) throws Exception {
this.host = host.trim();
this.port = port;
this.contextPath = contextPath;
+ this.ajp13Host = ajp13Host;
this.ajp13Port = ajp13Port;
server = new Server();
@@ -61,6 +63,7 @@ public class JettyEmbedder {
System.setProperty("jetty.port", String.valueOf(port));
System.setProperty("jetty.context", contextPath);
if (ajp13Port > 0) {
+ System.setProperty("jetty.ajp13Host", this.ajp13Host);
System.setProperty("jetty.ajp13Port", String.valueOf(ajp13Port));
}
XmlConfiguration configuration = new XmlConfiguration(configurationURL);
@@ -72,7 +75,7 @@ public class JettyEmbedder {
* for tests
*/
JettyEmbedder(String host, int port) throws Exception {
- this(host, port, null, 0, null);
+ this(host, port, null, null, 0, null);
}
public void start() throws Exception {
@@ -122,8 +125,9 @@ public class JettyEmbedder {
connector.setAcceptors(2);
connector.setConfidentialPort(8443);
if (ajp13Port > 0) {
- System.out.println("AJP13 connector is on port " + ajp13Port);
+ System.out.println("AJP13 connector is on " + ajp13Host + ":" + ajp13Port);
Connector ajpConnector = new Ajp13SocketConnector();
+ ajpConnector.setHost(ajp13Host);
ajpConnector.setPort(ajp13Port);
server.addConnector(ajpConnector);
}
@@ -132,7 +136,6 @@ public class JettyEmbedder {
server.setSendServerVersion(false);
server.setSendDateHeader(true);
server.setGracefulShutdown(1000);
-
}
final String getPluginsClasspath(String pluginsPathFromClassloader) throws URISyntaxException, IOException {
diff --git a/sonar-application/src/main/java/org/sonar/application/StartServer.java b/sonar-application/src/main/java/org/sonar/application/StartServer.java
index 41277083409..2d67cc72688 100644
--- a/sonar-application/src/main/java/org/sonar/application/StartServer.java
+++ b/sonar-application/src/main/java/org/sonar/application/StartServer.java
@@ -19,17 +19,18 @@
*/
package org.sonar.application;
+import org.apache.commons.io.FileUtils;
+
import java.io.File;
import java.io.IOException;
import java.net.URISyntaxException;
import java.util.Properties;
-import org.apache.commons.io.FileUtils;
-
public final class StartServer {
private static final String DEFAULT_WEB_HOST = "0.0.0.0";
private static final int DEFAULT_WEB_PORT = 9000;
private static final String DEFAULT_WEB_CONTEXT = "/";
+ private static final String DEFAULT_AJP13_HOST = "0.0.0.0";
private static final int DEFAULT_AJP13_PORT = -1;
private StartServer() {
@@ -43,8 +44,9 @@ public final class StartServer {
String host = configuration.getProperty("sonar.web.host", DEFAULT_WEB_HOST);
int port = Integer.parseInt(configuration.getProperty("sonar.web.port", "" + DEFAULT_WEB_PORT));
String context = configuration.getProperty("sonar.web.context", DEFAULT_WEB_CONTEXT);
+ String ajp13Host = configuration.getProperty("sonar.ajp13.host", DEFAULT_AJP13_HOST);
int ajp13Port = Integer.parseInt(configuration.getProperty("sonar.ajp13.port", "" + DEFAULT_AJP13_PORT));
- JettyEmbedder jetty = new JettyEmbedder(host, port, context, ajp13Port, StartServer.class.getResource("/jetty.xml"));
+ JettyEmbedder jetty = new JettyEmbedder(host, port, context, ajp13Host, ajp13Port, StartServer.class.getResource("/jetty.xml"));
configureRequestLogs(jetty, configuration);
jetty.start();
diff --git a/sonar-application/src/test/java/org/sonar/application/JettyEmbedderTest.java b/sonar-application/src/test/java/org/sonar/application/JettyEmbedderTest.java
index 7744cc73283..91150b888b8 100644
--- a/sonar-application/src/test/java/org/sonar/application/JettyEmbedderTest.java
+++ b/sonar-application/src/test/java/org/sonar/application/JettyEmbedderTest.java
@@ -20,19 +20,22 @@
package org.sonar.application;
import org.apache.commons.lang.StringUtils;
+import org.junit.Test;
+
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
-import org.junit.Test;
public class JettyEmbedderTest {
@Test
public void xmlConfigurationShouldAccessToSomeSystemProperties() throws Exception {
// useful to set the port into the XML file
- new JettyEmbedder("127.0.0.1", 9999, "/", 10000, JettyEmbedderTest.class.getResource("/org/sonar/application/jetty-test.xml"));
+ new JettyEmbedder("127.0.0.1", 9999, "/", "127.0.0.2", 10000,
+ JettyEmbedderTest.class.getResource("/org/sonar/application/jetty-test.xml"));
assertEquals("127.0.0.1", System.getProperty("jetty.host"));
assertEquals("9999", System.getProperty("jetty.port"));
assertEquals("/", System.getProperty("jetty.context"));
+ assertEquals("127.0.0.2", System.getProperty("jetty.ajp13Host"));
assertEquals("10000", System.getProperty("jetty.ajp13Port"));
}