You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by dk...@apache.org on 2014/08/05 19:53:40 UTC
[1/4] git commit: Start the process of issolating Jetty 8 and 9
differences.
Repository: cxf
Updated Branches:
refs/heads/master bea22d764 -> 88adfaf2a
Start the process of issolating Jetty 8 and 9 differences.
Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/b67537db
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/b67537db
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/b67537db
Branch: refs/heads/master
Commit: b67537dbace0896073b55b375b8ccdc4cce83365
Parents: bea22d7
Author: Daniel Kulp <dk...@apache.org>
Authored: Tue Aug 5 12:21:13 2014 -0400
Committer: Daniel Kulp <dk...@apache.org>
Committed: Tue Aug 5 12:21:39 2014 -0400
----------------------------------------------------------------------
parent/pom.xml | 6 +-
rt/transports/http-jetty/pom.xml | 5 +
.../http_jetty/JettyHTTPServerEngine.java | 111 ++++++++++++-------
3 files changed, 80 insertions(+), 42 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cxf/blob/b67537db/parent/pom.xml
----------------------------------------------------------------------
diff --git a/parent/pom.xml b/parent/pom.xml
index e010fbf..833b409 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -114,8 +114,10 @@
<cxf.joda.time.version>2.2</cxf.joda.time.version>
<cxf.jdom.version>1.0</cxf.jdom.version>
<cxf.jettison.version>1.3.5</cxf.jettison.version>
- <cxf.jetty.version>8.1.15.v20140411</cxf.jetty.version>
- <cxf.jetty.osgi.version>[7.6,8.2)</cxf.jetty.osgi.version>
+ <cxf.jetty8.version>8.1.15.v20140411</cxf.jetty8.version>
+ <cxf.jetty9.version>9.2.2.v20140723</cxf.jetty9.version>
+ <cxf.jetty.version>${cxf.jetty8.version}</cxf.jetty.version>
+ <cxf.jetty.osgi.version>[8.1,10)</cxf.jetty.osgi.version>
<cxf.jibx.version>1.2.5</cxf.jibx.version>
<cxf.junit.version>4.11</cxf.junit.version>
<cxf.maven.core.version>2.2.1</cxf.maven.core.version>
http://git-wip-us.apache.org/repos/asf/cxf/blob/b67537db/rt/transports/http-jetty/pom.xml
----------------------------------------------------------------------
diff --git a/rt/transports/http-jetty/pom.xml b/rt/transports/http-jetty/pom.xml
index f659c1e..0e3d1b1 100644
--- a/rt/transports/http-jetty/pom.xml
+++ b/rt/transports/http-jetty/pom.xml
@@ -99,6 +99,11 @@
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
+ <artifactId>jetty-continuation</artifactId>
+ <version>${cxf.jetty.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-jmx</artifactId>
<version>${cxf.jetty.version}</version>
<optional>true</optional>
http://git-wip-us.apache.org/repos/asf/cxf/blob/b67537db/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngine.java
----------------------------------------------------------------------
diff --git a/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngine.java b/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngine.java
index c490c7c..c89209a 100644
--- a/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngine.java
+++ b/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngine.java
@@ -19,6 +19,7 @@
package org.apache.cxf.transport.http_jetty;
+import java.io.Closeable;
import java.io.IOException;
import java.net.URL;
import java.security.GeneralSecurityException;
@@ -329,20 +330,15 @@ public class JettyHTTPServerEngine
server.setSendServerVersion(getSendServerVersion());
if (mBeanContainer != null) {
- server.getContainer().addEventListener(mBeanContainer);
+ getContainer(server).addEventListener(mBeanContainer);
}
if (connector == null) {
connector = connectorFactory.createConnector(getHost(), getPort());
if (LOG.isLoggable(Level.FINER)) {
- LOG.finer("connector.host: "
- + connector.getHost() == null
- ? "null"
- : "\"" + connector.getHost() + "\"");
- LOG.finer("connector.port: " + connector.getPort());
+ logConnector(connector);
}
}
-
server.addConnector(connector);
/*
* The server may have no handler, it might have a collection handler,
@@ -477,20 +473,40 @@ public class JettyHTTPServerEngine
++servantCount;
}
+ private static Container getContainer(Object server) {
+ if (server instanceof Container) {
+ return (Container)server;
+ }
+ try {
+ return (Container)server.getClass().getMethod("getContainer").invoke(server);
+ } catch (RuntimeException t) {
+ throw t;
+ } catch (Throwable t) {
+ throw new RuntimeException(t);
+ }
+ }
+
+ private static void logConnector(Connector connector) {
+ try {
+ String h = (String)connector.getClass().getMethod("getHost").invoke(connector);
+ int port = (Integer)connector.getClass().getMethod("getPort").invoke(connector);
+ LOG.finer("connector.host: "
+ + h == null
+ ? "null"
+ : "\"" + h + "\"");
+ LOG.finer("connector.port: " + port);
+ } catch (Throwable t) {
+ //ignore
+ }
+ }
+
protected void setupThreadPool() {
- AbstractConnector aconn = (AbstractConnector) connector;
if (isSetThreadingParameters()) {
- ThreadPool pool = aconn.getThreadPool();
- if (pool == null) {
- pool = aconn.getServer().getThreadPool();
- }
- if (pool == null) {
- pool = new QueuedThreadPool();
- aconn.getServer().setThreadPool(pool);
- aconn.setThreadPool(pool);
- }
+
+ QueuedThreadPool pl = getThreadPool();
//threads for the acceptors and selectors are taken from
//the pool so we need to have room for those
+ AbstractConnector aconn = (AbstractConnector) connector;
int acc = aconn.getAcceptors() * 2;
if (getThreadingParameters().isSetMaxThreads()
&& getThreadingParameters().getMaxThreads() <= acc) {
@@ -500,32 +516,30 @@ public class JettyHTTPServerEngine
getThreadingParameters().getMaxThreads(),
acc));
}
- if (pool instanceof QueuedThreadPool) {
- QueuedThreadPool pl = (QueuedThreadPool)pool;
- if (getThreadingParameters().isSetMinThreads()) {
- pl.setMinThreads(getThreadingParameters().getMinThreads());
- }
- if (getThreadingParameters().isSetMaxThreads()) {
- pl.setMaxThreads(getThreadingParameters().getMaxThreads());
- }
- } else {
- try {
- if (getThreadingParameters().isSetMinThreads()) {
- pool.getClass().getMethod("setMinThreads", Integer.TYPE)
- .invoke(pool, getThreadingParameters().getMinThreads());
- }
- if (getThreadingParameters().isSetMaxThreads()) {
- pool.getClass().getMethod("setMaxThreads", Integer.TYPE)
- .invoke(pool, getThreadingParameters().getMaxThreads());
- }
- } catch (Throwable t) {
- //ignore - this won't happen for Jetty 7.1 - 7.2 and 7.3 and newer
- //will be instanceof QueuedThreadPool above
- }
+ if (getThreadingParameters().isSetMinThreads()) {
+ pl.setMinThreads(getThreadingParameters().getMinThreads());
+ }
+ if (getThreadingParameters().isSetMaxThreads()) {
+ pl.setMaxThreads(getThreadingParameters().getMaxThreads());
}
}
}
+ private QueuedThreadPool getThreadPool() {
+ QueuedThreadPool pool = (QueuedThreadPool)server.getThreadPool();
+ if (pool == null) {
+ pool = new QueuedThreadPool();
+ try {
+ server.getClass().getMethod("setThreadPool", ThreadPool.class).invoke(server, pool);
+ } catch (RuntimeException t) {
+ throw t;
+ } catch (Throwable t) {
+ throw new RuntimeException(t);
+ }
+ }
+ return pool;
+ }
+
private void setReuseAddress(Connector conn) throws IOException {
if (conn instanceof AbstractConnector) {
((AbstractConnector)conn).setReuseAddress(isReuseAddress());
@@ -664,6 +678,19 @@ public class JettyHTTPServerEngine
return createConnector(null, porto);
}
public AbstractConnector createConnector(String hosto, int porto) {
+ /*
+ HttpConfiguration httpConfig = new HttpConfiguration();
+ httpConfig.setSendServerVersion(getSendServerVersion());
+ HttpConnectionFactory httpFactory = new HttpConnectionFactory(httpConfig);
+ ServerConnector httpConnector = new ServerConnector(server, httpFactory);
+ httpConnector.setPort(porto);
+ httpConnector.setHost(hosto);
+ if (getMaxIdleTime() > 0) {
+ httpConnector.setIdleTimeout(getMaxIdleTime());
+ }
+ return httpConnector;
+ */
+
// now we just use the SelectChannelConnector as the default connector
SelectChannelConnector result =
new SelectChannelConnector();
@@ -724,7 +751,11 @@ public class JettyHTTPServerEngine
if (server != null) {
try {
connector.stop();
- connector.close();
+ if (connector instanceof Closeable) {
+ ((Closeable)connector).close();
+ } else {
+ connector.getClass().getMethod("close").invoke(connector);
+ }
} finally {
server.stop();
server.destroy();
[4/4] git commit: JettyHTTPDestination works with both Jetty 8 and
Jetty 9
Posted by dk...@apache.org.
JettyHTTPDestination works with both Jetty 8 and Jetty 9
Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/88adfaf2
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/88adfaf2
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/88adfaf2
Branch: refs/heads/master
Commit: 88adfaf2ad97b4968b0dc47194b29c717b138d7a
Parents: 944eb0b
Author: Daniel Kulp <dk...@apache.org>
Authored: Tue Aug 5 13:12:08 2014 -0400
Committer: Daniel Kulp <dk...@apache.org>
Committed: Tue Aug 5 13:12:08 2014 -0400
----------------------------------------------------------------------
.../http_jetty/JettyHTTPDestination.java | 53 +++++++++++++++-----
1 file changed, 41 insertions(+), 12 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cxf/blob/88adfaf2/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPDestination.java
----------------------------------------------------------------------
diff --git a/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPDestination.java b/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPDestination.java
index 3907b26..eef3492 100644
--- a/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPDestination.java
+++ b/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPDestination.java
@@ -23,6 +23,7 @@ import java.io.FilterOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
+import java.lang.reflect.InvocationTargetException;
import java.net.MalformedURLException;
import java.net.URL;
import java.security.GeneralSecurityException;
@@ -51,8 +52,7 @@ import org.apache.cxf.transport.http.DestinationRegistry;
import org.apache.cxf.transport.http_jetty.continuations.JettyContinuationProvider;
import org.apache.cxf.transport.https.CertConstraintsJaxBUtils;
import org.apache.cxf.transports.http.configuration.HTTPServerPolicy;
-import org.eclipse.jetty.server.AbstractHttpConnection;
-import org.eclipse.jetty.server.AbstractHttpConnection.Output;
+import org.eclipse.jetty.server.HttpOutput;
import org.eclipse.jetty.server.Request;
@@ -261,8 +261,8 @@ public class JettyHTTPDestination extends AbstractHTTPDestination {
private OutputStream wrapOutput(OutputStream out) {
try {
- if (out instanceof Output) {
- out = new JettyOutputStream((Output)out);
+ if (out instanceof HttpOutput) {
+ out = new JettyOutputStream((HttpOutput)out);
}
} catch (Throwable t) {
//ignore
@@ -272,20 +272,36 @@ public class JettyHTTPDestination extends AbstractHTTPDestination {
static class JettyOutputStream extends FilterOutputStream implements CopyingOutputStream {
- final Output out;
+ final HttpOutput out;
boolean written;
- public JettyOutputStream(Output o) {
+ public JettyOutputStream(HttpOutput o) {
super(o);
out = o;
}
+ private boolean sendContent(Class<?> type, InputStream c) throws IOException {
+ try {
+ out.getClass().getMethod("sendContent", type).invoke(out, c);
+ } catch (InvocationTargetException ioe) {
+ if (ioe.getTargetException() instanceof IOException) {
+ throw (IOException)ioe.getTargetException();
+ }
+ return false;
+ } catch (Exception e) {
+ return false;
+ }
+ return true;
+ }
@Override
public int copyFrom(InputStream in) throws IOException {
if (written) {
return IOUtils.copy(in, out);
}
CountingInputStream c = new CountingInputStream(in);
- out.sendContent(c);
+ if (!sendContent(InputStream.class, c)
+ && !sendContent(Object.class, c)) {
+ IOUtils.copy(c, out);
+ }
return c.getCount();
}
public void write(int b) throws IOException {
@@ -356,11 +372,24 @@ public class JettyHTTPDestination extends AbstractHTTPDestination {
}
}
- private AbstractHttpConnection getCurrentConnection() {
- return AbstractHttpConnection.getCurrentConnection();
- }
private Request getCurrentRequest() {
- AbstractHttpConnection con = getCurrentConnection();
- return con.getRequest();
+ try {
+ //Jetty 8
+ Object con = ClassLoaderUtils.loadClass("org.eclipse.jetty.server.AbstractHttpConnection",
+ getClass()).getMethod("getCurrentConnection").invoke(null);
+ return (Request)con.getClass().getMethod("getRequest").invoke(con);
+ } catch (Throwable t) {
+ //
+ }
+ try {
+ //Jetty 9
+ Object con = ClassLoaderUtils.loadClass("org.eclipse.jetty.server.HttpConnection",
+ getClass()).getMethod("getCurrentConnection").invoke(null);
+ Object channel = con.getClass().getMethod("getHttpChannel").invoke(con);
+ return (Request)channel.getClass().getMethod("getRequest").invoke(channel);
+ } catch (Throwable t) {
+ //
+ }
+ return null;
}
}
[3/4] git commit: Remove some reflection code that's not needed by
dropping support for Jetty 7
Posted by dk...@apache.org.
Remove some reflection code that's not needed by dropping support for Jetty 7
Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/944eb0ba
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/944eb0ba
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/944eb0ba
Branch: refs/heads/master
Commit: 944eb0ba1043bd4daf9cf087b66bc9cab10b8ff2
Parents: 13dfe0f
Author: Daniel Kulp <dk...@apache.org>
Authored: Tue Aug 5 12:39:35 2014 -0400
Committer: Daniel Kulp <dk...@apache.org>
Committed: Tue Aug 5 12:39:35 2014 -0400
----------------------------------------------------------------------
.../http_jetty/JettyHTTPDestination.java | 69 ++------------------
1 file changed, 6 insertions(+), 63 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cxf/blob/944eb0ba/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPDestination.java
----------------------------------------------------------------------
diff --git a/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPDestination.java b/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPDestination.java
index 703b552..3907b26 100644
--- a/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPDestination.java
+++ b/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPDestination.java
@@ -38,7 +38,6 @@ import org.apache.cxf.BusFactory;
import org.apache.cxf.common.classloader.ClassLoaderUtils;
import org.apache.cxf.common.classloader.ClassLoaderUtils.ClassLoaderHolder;
import org.apache.cxf.common.logging.LogUtils;
-import org.apache.cxf.common.util.ReflectionUtil;
import org.apache.cxf.configuration.jsse.TLSServerParameters;
import org.apache.cxf.configuration.security.CertificateConstraintsType;
import org.apache.cxf.continuations.ContinuationProvider;
@@ -52,11 +51,9 @@ import org.apache.cxf.transport.http.DestinationRegistry;
import org.apache.cxf.transport.http_jetty.continuations.JettyContinuationProvider;
import org.apache.cxf.transport.https.CertConstraintsJaxBUtils;
import org.apache.cxf.transports.http.configuration.HTTPServerPolicy;
-import org.eclipse.jetty.http.Generator;
-import org.eclipse.jetty.io.AbstractConnection;
+import org.eclipse.jetty.server.AbstractHttpConnection;
import org.eclipse.jetty.server.AbstractHttpConnection.Output;
import org.eclipse.jetty.server.Request;
-import org.springframework.util.ClassUtils;
public class JettyHTTPDestination extends AbstractHTTPDestination {
@@ -208,24 +205,7 @@ public class JettyHTTPDestination extends AbstractHTTPDestination {
HttpServletResponse resp) throws IOException {
doService(servletContext, req, resp);
}
-
- static AbstractConnection getConnectionForRequest(Request r) {
- try {
- return (AbstractConnection)r.getClass().getMethod("getConnection").invoke(r);
- } catch (Exception ex) {
- return null;
- }
- }
-
- private void setHeadFalse(AbstractConnection con) {
- try {
- Generator gen = (Generator)con.getClass().getMethod("getGenerator").invoke(con);
- gen.setHead(false);
- } catch (Exception ex) {
- //ignore - can continue
- }
- }
-
+
protected void doService(ServletContext context,
HttpServletRequest req,
HttpServletResponse resp) throws IOException {
@@ -235,14 +215,6 @@ public class JettyHTTPDestination extends AbstractHTTPDestination {
Request baseRequest = (req instanceof Request)
? (Request)req : getCurrentRequest();
- if (!"HEAD".equals(req.getMethod())) {
- //bug in Jetty with persistent connections that if a HEAD is
- //sent, a _head flag is never reset
- AbstractConnection c = getConnectionForRequest(baseRequest);
- if (c != null) {
- setHeadFalse(c);
- }
- }
HTTPServerPolicy sp = getServer();
if (sp.isSetRedirectURL()) {
resp.sendRedirect(sp.getRedirectURL());
@@ -384,40 +356,11 @@ public class JettyHTTPDestination extends AbstractHTTPDestination {
}
}
- private AbstractConnection getCurrentConnection() {
- // AbstractHttpConnection on Jetty 7.6, HttpConnection on Jetty <=7.5
- Class<?> cls = null;
- try {
- cls = ClassUtils.forName("org.eclipse.jetty.server.AbstractHttpConnection",
- AbstractConnection.class.getClassLoader());
- } catch (Exception e) {
- //ignore
- }
- if (cls == null) {
- try {
- cls = ClassUtils.forName("org.eclipse.jetty.server.HttpConnection",
- AbstractConnection.class.getClassLoader());
- } catch (Exception e) {
- //ignore
- }
- }
-
- try {
- return (AbstractConnection)ReflectionUtil
- .setAccessible(cls.getMethod("getCurrentConnection")).invoke(null);
- } catch (Exception e) {
- //ignore
- }
- return null;
+ private AbstractHttpConnection getCurrentConnection() {
+ return AbstractHttpConnection.getCurrentConnection();
}
private Request getCurrentRequest() {
- AbstractConnection con = getCurrentConnection();
- try {
- return (Request)ReflectionUtil
- .setAccessible(con.getClass().getMethod("getRequest")).invoke(con);
- } catch (Exception e) {
- //ignore
- }
- return null;
+ AbstractHttpConnection con = getCurrentConnection();
+ return con.getRequest();
}
}
[2/4] git commit: Change how maxIdle and reuseAddress is handled to
make Jetty8/9 easier
Posted by dk...@apache.org.
Change how maxIdle and reuseAddress is handled to make Jetty8/9 easier
Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/13dfe0f9
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/13dfe0f9
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/13dfe0f9
Branch: refs/heads/master
Commit: 13dfe0f9fcaa0aee4c603072436d85861a0ab734
Parents: b67537d
Author: Daniel Kulp <dk...@apache.org>
Authored: Tue Aug 5 12:31:01 2014 -0400
Committer: Daniel Kulp <dk...@apache.org>
Committed: Tue Aug 5 12:31:01 2014 -0400
----------------------------------------------------------------------
.../http_jetty/JettyConnectorFactory.java | 10 ++-----
.../http_jetty/JettyHTTPServerEngine.java | 28 +++++++-------------
.../https_jetty/JettySslConnectorFactory.java | 24 +++++------------
3 files changed, 17 insertions(+), 45 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cxf/blob/13dfe0f9/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyConnectorFactory.java
----------------------------------------------------------------------
diff --git a/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyConnectorFactory.java b/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyConnectorFactory.java
index 4020902..c5273b3 100644
--- a/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyConnectorFactory.java
+++ b/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyConnectorFactory.java
@@ -28,16 +28,10 @@ public interface JettyConnectorFactory {
/**
* Create a Listener.
- *
- * @param port the listen port
- */
- AbstractConnector createConnector(int port);
-
- /**
- * Create a Listener.
+ * @param jettyHTTPServerEngine
*
* @param host the host to bind to. IP address or hostname is allowed. null to bind to all hosts.
* @param port the listen port
*/
- AbstractConnector createConnector(String host, int port);
+ AbstractConnector createConnector(JettyHTTPServerEngine jettyHTTPServerEngine, String host, int port);
}
http://git-wip-us.apache.org/repos/asf/cxf/blob/13dfe0f9/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngine.java
----------------------------------------------------------------------
diff --git a/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngine.java b/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngine.java
index c89209a..03540a5 100644
--- a/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngine.java
+++ b/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngine.java
@@ -334,7 +334,7 @@ public class JettyHTTPServerEngine
}
if (connector == null) {
- connector = connectorFactory.createConnector(getHost(), getPort());
+ connector = connectorFactory.createConnector(this, getHost(), getPort());
if (LOG.isLoggable(Level.FINER)) {
logConnector(connector);
}
@@ -408,7 +408,6 @@ public class JettyHTTPServerEngine
}
try {
- setReuseAddress(connector);
setupThreadPool();
server.start();
} catch (Exception e) {
@@ -540,14 +539,6 @@ public class JettyHTTPServerEngine
return pool;
}
- private void setReuseAddress(Connector conn) throws IOException {
- if (conn instanceof AbstractConnector) {
- ((AbstractConnector)conn).setReuseAddress(isReuseAddress());
- } else {
- LOG.log(Level.INFO, "UNKNOWN_CONNECTOR_MSG", new Object[] {conn});
- }
- }
-
/**
* Remove a previously registered servant.
*
@@ -674,10 +665,7 @@ public class JettyHTTPServerEngine
*/
protected JettyConnectorFactory getHTTPConnectorFactory() {
return new JettyConnectorFactory() {
- public AbstractConnector createConnector(int porto) {
- return createConnector(null, porto);
- }
- public AbstractConnector createConnector(String hosto, int porto) {
+ public AbstractConnector createConnector(JettyHTTPServerEngine engine, String hosto, int porto) {
/*
HttpConfiguration httpConfig = new HttpConfiguration();
httpConfig.setSendServerVersion(getSendServerVersion());
@@ -685,9 +673,10 @@ public class JettyHTTPServerEngine
ServerConnector httpConnector = new ServerConnector(server, httpFactory);
httpConnector.setPort(porto);
httpConnector.setHost(hosto);
- if (getMaxIdleTime() > 0) {
- httpConnector.setIdleTimeout(getMaxIdleTime());
+ if (engine.getMaxIdleTime() > 0) {
+ httpConnector.setIdleTimeout(engine.getMaxIdleTime());
}
+ httpConnector.setReuseAddress(engine.isReuseAddress());
return httpConnector;
*/
@@ -703,9 +692,10 @@ public class JettyHTTPServerEngine
result.setHost(hosto);
}
result.setPort(porto);
- if (getMaxIdleTime() > 0) {
- result.setMaxIdleTime(getMaxIdleTime());
+ if (engine.getMaxIdleTime() > 0) {
+ result.setMaxIdleTime(engine.getMaxIdleTime());
}
+ result.setReuseAddress(engine.isReuseAddress());
return result;
}
};
@@ -717,7 +707,7 @@ public class JettyHTTPServerEngine
protected JettyConnectorFactory getHTTPSConnectorFactory(
TLSServerParameters tlsParams
) {
- return new JettySslConnectorFactory(tlsParams, getMaxIdleTime());
+ return new JettySslConnectorFactory(tlsParams);
}
/**
http://git-wip-us.apache.org/repos/asf/cxf/blob/13dfe0f9/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/https_jetty/JettySslConnectorFactory.java
----------------------------------------------------------------------
diff --git a/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/https_jetty/JettySslConnectorFactory.java b/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/https_jetty/JettySslConnectorFactory.java
index 2b6c5d2..da1fbc5 100644
--- a/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/https_jetty/JettySslConnectorFactory.java
+++ b/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/https_jetty/JettySslConnectorFactory.java
@@ -21,6 +21,7 @@ package org.apache.cxf.transport.https_jetty;
import org.apache.cxf.configuration.jsse.TLSServerParameters;
import org.apache.cxf.transport.http_jetty.JettyConnectorFactory;
+import org.apache.cxf.transport.http_jetty.JettyHTTPServerEngine;
import org.eclipse.jetty.server.AbstractConnector;
/**
@@ -29,25 +30,11 @@ import org.eclipse.jetty.server.AbstractConnector;
*/
public final class JettySslConnectorFactory implements JettyConnectorFactory {
- TLSServerParameters tlsServerParameters;
- int maxIdleTime;
+ final TLSServerParameters tlsServerParameters;
public JettySslConnectorFactory(TLSServerParameters params) {
tlsServerParameters = params;
}
-
- public JettySslConnectorFactory(TLSServerParameters params, int maxIdle) {
- this(params);
- this.maxIdleTime = maxIdle;
- }
- /**
- * Create a Listener.
- *
- * @param port the listen port
- */
- public AbstractConnector createConnector(int port) {
- return createConnector(null, port);
- }
/**
* Create a Listener.
@@ -55,7 +42,7 @@ public final class JettySslConnectorFactory implements JettyConnectorFactory {
* @param host the host to bind to. IP address or hostname is allowed. null to bind to all hosts.
* @param port the listen port
*/
- public AbstractConnector createConnector(String host, int port) {
+ public AbstractConnector createConnector(JettyHTTPServerEngine engine, String host, int port) {
assert tlsServerParameters != null;
CXFJettySslSocketConnector secureConnector =
@@ -64,9 +51,10 @@ public final class JettySslConnectorFactory implements JettyConnectorFactory {
secureConnector.setHost(host);
}
secureConnector.setPort(port);
- if (maxIdleTime > 0) {
- secureConnector.setMaxIdleTime(maxIdleTime);
+ if (engine.getMaxIdleTime() > 0) {
+ secureConnector.setMaxIdleTime(engine.getMaxIdleTime());
}
+ secureConnector.setReuseAddress(engine.isReuseAddress());
decorateCXFJettySslSocketConnector(secureConnector);
return secureConnector;
}