Commit 12786892 authored by Alex Wenckus's avatar Alex Wenckus Committed by alex

Wasn't working as the Handlers were trampling eachother, we may want to either...

Wasn't working as the Handlers were trampling eachother, we may want to either create a special handler or manually modify the handlers as we are doing now.

git-svn-id: http://svn.igniterealtime.org/svn/repos/wildfire/branches@5752 b35dd754-fafc-0310-a699-88a17e54d16e
parent 080fa60a
...@@ -15,7 +15,9 @@ import org.jivesoftware.util.Log; ...@@ -15,7 +15,9 @@ import org.jivesoftware.util.Log;
import org.jivesoftware.wildfire.net.SSLConfig; import org.jivesoftware.wildfire.net.SSLConfig;
import org.mortbay.jetty.Connector; import org.mortbay.jetty.Connector;
import org.mortbay.jetty.Server; import org.mortbay.jetty.Server;
import org.mortbay.jetty.Handler; import org.mortbay.jetty.servlet.Context;
import org.mortbay.jetty.servlet.ServletHolder;
import org.mortbay.jetty.servlet.ServletHandler;
import org.mortbay.jetty.nio.SelectChannelConnector; import org.mortbay.jetty.nio.SelectChannelConnector;
import org.mortbay.jetty.security.SslSocketConnector; import org.mortbay.jetty.security.SslSocketConnector;
...@@ -41,6 +43,7 @@ public class HttpServerManager { ...@@ -41,6 +43,7 @@ public class HttpServerManager {
public static final String HTTP_BIND_PORT = "httpbind.port.plain"; public static final String HTTP_BIND_PORT = "httpbind.port.plain";
public static final String HTTP_BIND_SECURE_PORT = "httpbind.port.secure"; public static final String HTTP_BIND_SECURE_PORT = "httpbind.port.secure";
private String httpBindPath;
public static HttpServerManager getInstance() { public static HttpServerManager getInstance() {
return instance; return instance;
...@@ -50,21 +53,22 @@ public class HttpServerManager { ...@@ -50,21 +53,22 @@ public class HttpServerManager {
private int securePort; private int securePort;
private Server adminServer; private Server adminServer;
private Server httpBindServer; private Server httpBindServer;
private Handler adminConsoleContext; private Context adminConsoleContext;
private Handler httpBindContext; private ServletHolder httpBindContext;
private HttpServerManager() { private HttpServerManager() {
} }
public void setAdminConsoleContext(Handler context) { public void setAdminConsoleContext(Context context) {
this.adminConsoleContext = context; this.adminConsoleContext = context;
} }
public void setHttpBindContext(Handler context) { public void setHttpBindContext(ServletHolder context, String httpBindPath) {
this.httpBindContext = context; this.httpBindContext = context;
this.httpBindPath = httpBindPath;
} }
private void createHttpBindServer(Handler context) { private void createHttpBindServer() {
port = JiveGlobals.getIntProperty(HTTP_BIND_PORT, 9090); port = JiveGlobals.getIntProperty(HTTP_BIND_PORT, 9090);
securePort = JiveGlobals.getIntProperty(HTTP_BIND_SECURE_PORT, 9091); securePort = JiveGlobals.getIntProperty(HTTP_BIND_SECURE_PORT, 9091);
...@@ -77,10 +81,9 @@ public class HttpServerManager { ...@@ -77,10 +81,9 @@ public class HttpServerManager {
for (Connector connector : connectors) { for (Connector connector : connectors) {
httpBindServer.addConnector(connector); httpBindServer.addConnector(connector);
} }
httpBindServer.addHandler(context);
} }
private void createAdminConsoleServer(Handler context) { private void createAdminConsoleServer() {
int port = JiveGlobals.getXMLProperty(ADMIN_CONSOLE_PORT, 9090); int port = JiveGlobals.getXMLProperty(ADMIN_CONSOLE_PORT, 9090);
int securePort = JiveGlobals.getXMLProperty(ADMIN_CONOSLE_SECURE_PORT, 9091); int securePort = JiveGlobals.getXMLProperty(ADMIN_CONOSLE_SECURE_PORT, 9091);
boolean loadConnectors = true; boolean loadConnectors = true;
...@@ -95,7 +98,6 @@ public class HttpServerManager { ...@@ -95,7 +98,6 @@ public class HttpServerManager {
" ports."); " ports.");
httpBindServer = null; httpBindServer = null;
httpBindServer = new Server(); httpBindServer = new Server();
httpBindServer.addHandler(httpBindContext);
adminServer = httpBindServer; adminServer = httpBindServer;
} }
else { else {
...@@ -117,16 +119,18 @@ public class HttpServerManager { ...@@ -117,16 +119,18 @@ public class HttpServerManager {
adminServer.addConnector(connector); adminServer.addConnector(connector);
} }
} }
adminServer.addHandler(context);
} }
public void startup() { public void startup() {
if(httpBindContext != null) { if(httpBindContext != null) {
createHttpBindServer(httpBindContext); createHttpBindServer();
} }
if(adminConsoleContext != null) { if(adminConsoleContext != null) {
createAdminConsoleServer(adminConsoleContext); createAdminConsoleServer();
} }
addContexts();
if(httpBindServer != null) { if(httpBindServer != null) {
try { try {
httpBindServer.start(); httpBindServer.start();
...@@ -145,6 +149,23 @@ public class HttpServerManager { ...@@ -145,6 +149,23 @@ public class HttpServerManager {
} }
} }
private void addContexts() {
if(httpBindServer == adminServer && httpBindServer != null) {
adminConsoleContext.addServlet(httpBindContext, httpBindPath);
adminServer.addHandler(adminConsoleContext);
return;
}
if(httpBindServer != null) {
ServletHandler servletHandler = new ServletHandler();
servletHandler.addServletWithMapping(httpBindContext, httpBindPath);
httpBindServer.addHandler(servletHandler);
}
if(adminServer != null) {
adminServer.addHandler(adminConsoleContext);
// TODO remove the http bind servlet
}
}
public void shutdown() { public void shutdown() {
if(httpBindServer != null) { if(httpBindServer != null) {
try { try {
......
...@@ -291,15 +291,11 @@ public class ConnectionManagerImpl extends BasicModule implements ConnectionMana ...@@ -291,15 +291,11 @@ public class ConnectionManagerImpl extends BasicModule implements ConnectionMana
} }
private void startHTTPBindListeners() { private void startHTTPBindListeners() {
serverManager.setHttpBindContext(createServletHandler()); serverManager.setHttpBindContext(createServletHandler(), "/http-bind/");
} }
private Handler createServletHandler() { private ServletHolder createServletHandler() {
ServletHolder servletHolder = new ServletHolder( return new ServletHolder(new HttpBindServlet(new HttpSessionManager()));
new HttpBindServlet(new HttpSessionManager()));
ServletHandler servletHandler = new ServletHandler();
servletHandler.addServletWithMapping(servletHolder, "/http-bind/");
return servletHandler;
} }
public void initialize(XMPPServer server) { public void initialize(XMPPServer server) {
......
<%--
- $Revision: 3268 $
- $Date: 2006-01-09 18:42:09 -0800 (Mon, 09 Jan 2006) $
-
- Copyright (C) 2004 Jive Software. All rights reserved.
-
- This software is published under the terms of the GNU Public License (GPL),
- a copy of which is included in this distribution.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head><title>Simple jsp page</title></head>
<body>Place your content here</body>
</html>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment