Commit 3b3318fa authored by Alex Wenckus's avatar Alex Wenckus Committed by alex

Decoupled http-binding service from file system. No longer dependent on the...

Decoupled http-binding service from file system. No longer dependent on the web.xml in the spank directory. JM-1074

git-svn-id: http://svn.igniterealtime.org/svn/repos/openfire/trunk@8389 b35dd754-fafc-0310-a699-88a17e54d16e
parent 3d55c09b
......@@ -14,8 +14,10 @@ package org.jivesoftware.openfire.http;
import org.mortbay.jetty.Server;
import org.mortbay.jetty.Connector;
import org.mortbay.jetty.Handler;
import org.mortbay.jetty.servlet.ServletHandler;
import org.mortbay.jetty.handler.ContextHandlerCollection;
import org.mortbay.jetty.handler.DefaultHandler;
import org.mortbay.jetty.handler.ContextHandler;
import org.mortbay.jetty.webapp.WebAppContext;
import org.mortbay.jetty.security.SslSocketConnector;
import org.mortbay.jetty.nio.SelectChannelConnector;
......@@ -58,7 +60,7 @@ public final class HttpBindManager {
private CertificateListener certificateListener;
private HttpSessionManager httpSessionManager;
private ContextHandlerCollection contexts;
public static HttpBindManager getInstance() {
......@@ -132,7 +134,8 @@ public final class HttpBindManager {
if (securePort > 0 && CertificateManager.isRSACertificate(SSLConfig.getKeyStore(), "*")) {
if (!CertificateManager.isRSACertificate(SSLConfig.getKeyStore(),
XMPPServer.getInstance().getServerInfo().getName())) {
Log.warn("HTTP binding: Using RSA certificates but they are not valid for the hosted domain");
Log.warn("HTTP binding: Using RSA certificates but they are not valid for " +
"the hosted domain");
}
SslSocketConnector sslConnector = new JiveSslConnector();
......@@ -222,8 +225,7 @@ public final class HttpBindManager {
}
private synchronized void changeHttpBindPorts(int unsecurePort, int securePort)
throws Exception
{
throws Exception {
if (unsecurePort < 0 && securePort < 0) {
throw new IllegalArgumentException("At least one port must be greater than zero.");
}
......@@ -264,15 +266,33 @@ public final class HttpBindManager {
if (httpsConnector != null) {
httpBindServer.addConnector(httpsConnector);
}
createWebAppContext();
httpBindServer.setHandlers(new Handler[] { contexts, new DefaultHandler() });
createBoshHandler(contexts, "/http-bind");
loadStaticDirectory(contexts);
httpBindServer.setHandlers(new Handler[]{contexts, new DefaultHandler()});
}
private WebAppContext createWebAppContext() {
WebAppContext context = new WebAppContext(contexts, JiveGlobals.getHomeDirectory() +
File.separator + "resources" + File.separator + "spank", "/");
context.setWelcomeFiles(new String[]{"index.html"});
return context;
private void createBoshHandler(ContextHandlerCollection contexts, String boshPath) {
ServletHandler handler = new ServletHandler();
handler.addServletWithMapping(HttpBindServlet.class, "/");
ContextHandler boshContextHandler = new ContextHandler(contexts, boshPath);
boshContextHandler.setHandler(handler);
}
private void loadStaticDirectory(ContextHandlerCollection contexts) {
File spankDirectory = new File(JiveGlobals.getHomeDirectory() + File.separator
+ "resources" + File.separator + "spank");
if (spankDirectory.exists()) {
if (spankDirectory.canRead()) {
WebAppContext context = new WebAppContext(contexts, spankDirectory.getPath(), "/");
context.setWelcomeFiles(new String[]{"index.html"});
}
else {
Log.warn("Openfire cannot read the directory: " + spankDirectory);
}
}
}
public ContextHandlerCollection getContexts() {
......@@ -348,7 +368,7 @@ public final class HttpBindManager {
}
private synchronized void restartServer() {
if(httpBindServer != null) {
if (httpBindServer != null) {
try {
httpBindServer.stop();
}
......@@ -428,7 +448,7 @@ public final class HttpBindManager {
}
public void certificateDeleted(KeyStore keyStore, String alias) {
restartServer();
restartServer();
}
public void certificateSigned(KeyStore keyStore, String alias,
......
......@@ -4,36 +4,4 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<servlet>
<servlet-name>HttpBindServlet</servlet-name>
<servlet-class>org.jivesoftware.openfire.http.HttpBindServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>HttpBindServlet</servlet-name>
<url-pattern>/http-bind/</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>JavaScriptServlet</servlet-name>
<servlet-class>org.jivesoftware.openfire.http.ResourceServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>JavaScriptServlet</servlet-name>
<url-pattern>/scripts/</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>FlashCrossDomain</servlet-name>
<servlet-class>org.jivesoftware.openfire.http.FlashCrossDomainServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>FlashCrossDomain</servlet-name>
<url-pattern>/crossdomain.xml</url-pattern>
</servlet-mapping>
</web-app>
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