You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ni...@apache.org on 2009/07/08 07:42:21 UTC
svn commit: r792041 - in /camel/branches/camel-1.x: ./
components/camel-jetty/src/main/java/org/apache/camel/component/jetty/
components/camel-jetty/src/test/java/org/apache/camel/component/jetty/
etc/eclipse/
Author: ningjiang
Date: Wed Jul 8 05:42:20 2009
New Revision: 792041
URL: http://svn.apache.org/viewvc?rev=792041&view=rev
Log:
Merged revisions 792038 via svnmerge from
https://svn.apache.org/repos/asf/camel/trunk
........
r792038 | ningjiang | 2009-07-08 13:13:14 +0800 (Wed, 08 Jul 2009) | 1 line
CAMEL-1809 Share the Jetty connector across the camel contexts
........
Modified:
camel/branches/camel-1.x/ (props changed)
camel/branches/camel-1.x/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/JettyHttpComponent.java
camel/branches/camel-1.x/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettyHttpEndpointDisconnectTest.java
camel/branches/camel-1.x/etc/eclipse/Camel.importorder (props changed)
camel/branches/camel-1.x/etc/eclipse/CamelCodeFormatter.xml (props changed)
Propchange: camel/branches/camel-1.x/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Jul 8 05:42:20 2009
@@ -1 +1 @@
-/camel/trunk:736980,739733,739904,740251,740295,740306,740596,740663,741848,742231,742705,742739,742854,742856,742898,742906,743613,743762,743773,743920,743959-743960,744123,745105,745367,745541,745751,745826,745978,746269,746872,746895,746962,747258,747678-747704,748392,748436,748821,749563-749564,749574,749628-749629,749936,749956,750017,750334,750396,750761,750796,752068,752117,752418,752751-752755,752764-752773,752956,753087,753101,753175,755136,755487,756313,756348,756870,756939,757636,757693,757743,757865,758539,758563,758600,758617,758692,758990,759362,759453,759887,759931,760003,760890,760909,760937,761194,761536,761583,761607,762047,762633,762650,762935,763095,763484,763551,765154,765686,765729,765743,765824,766016,766289,766584,766588,766590,766602,766673,767403,767824,768342,769239,769346,769368,769434,770172,770906,771303,773193,773446,773781,774192,774383,774658-774659,776198,776289,776504,776975,778102,778689-778701,779121,779143,779489,781314-781349,781775,781
923,781974,781993,782557,782594,782681,782886,782918-782923,783204,783248,783363,783639,783704,785564,785584,785599,787206,787581,787598,787605,787928,788393,789121,789703,790560,790936,791379,791476,791767
+/camel/trunk:736980,739733,739904,740251,740295,740306,740596,740663,741848,742231,742705,742739,742854,742856,742898,742906,743613,743762,743773,743920,743959-743960,744123,745105,745367,745541,745751,745826,745978,746269,746872,746895,746962,747258,747678-747704,748392,748436,748821,749563-749564,749574,749628-749629,749936,749956,750017,750334,750396,750761,750796,752068,752117,752418,752751-752755,752764-752773,752956,753087,753101,753175,755136,755487,756313,756348,756870,756939,757636,757693,757743,757865,758539,758563,758600,758617,758692,758990,759362,759453,759887,759931,760003,760890,760909,760937,761194,761536,761583,761607,762047,762633,762650,762935,763095,763484,763551,765154,765686,765729,765743,765824,766016,766289,766584,766588,766590,766602,766673,767403,767824,768342,769239,769346,769368,769434,770172,770906,771303,773193,773446,773781,774192,774383,774658-774659,776198,776289,776504,776975,778102,778689-778701,779121,779143,779489,781314-781349,781775,781
923,781974,781993,782557,782594,782681,782886,782918-782923,783204,783248,783363,783639,783704,785564,785584,785599,787206,787581,787598,787605,787928,788393,789121,789703,790560,790936,791379,791476,791767,792038
Propchange: camel/branches/camel-1.x/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.
Modified: camel/branches/camel-1.x/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/JettyHttpComponent.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-1.x/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/JettyHttpComponent.java?rev=792041&r1=792040&r2=792041&view=diff
==============================================================================
--- camel/branches/camel-1.x/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/JettyHttpComponent.java (original)
+++ camel/branches/camel-1.x/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/JettyHttpComponent.java Wed Jul 8 05:42:20 2009
@@ -49,13 +49,25 @@
* @version $Revision$
*/
public class JettyHttpComponent extends HttpComponent {
+
+ protected static final HashMap<String, ConnectorRef> CONNECTORS = new HashMap<String, ConnectorRef>();
+
+ private static final transient Log LOG = LogFactory.getLog(JettyHttpComponent.class);
+ private static final String JETTY_SSL_KEYSTORE = "jetty.ssl.keystore";
+
+ protected String sslKeyPassword;
+ protected String sslPassword;
+ protected String sslKeystore;
+ protected SslSocketConnector sslSocketConnector;
class ConnectorRef {
+ Server server;
Connector connector;
CamelServlet servlet;
int refCount;
- public ConnectorRef(Connector connector, CamelServlet servlet) {
+ public ConnectorRef(Server server, Connector connector, CamelServlet servlet) {
+ this.server = server;
this.connector = connector;
this.servlet = servlet;
increment();
@@ -70,14 +82,11 @@
}
}
- private static final transient Log LOG = LogFactory.getLog(JettyHttpComponent.class);
- protected Server server;
- protected final HashMap<String, ConnectorRef> connectors = new HashMap<String, ConnectorRef>();
- protected String sslKeyPassword;
- protected String sslPassword;
- protected String sslKeystore;
- protected SslSocketConnector sslSocketConnector;
+ /*static {
+ // create the Server static object;
+
+ }*/
@Override
protected Endpoint<HttpExchange> createEndpoint(String uri, String remaining, Map parameters) throws Exception {
@@ -111,8 +120,8 @@
JettyHttpEndpoint endpoint = (JettyHttpEndpoint)consumer.getEndpoint();
String connectorKey = getConnectorKey(endpoint);
- synchronized (connectors) {
- ConnectorRef connectorRef = connectors.get(connectorKey);
+ synchronized (CONNECTORS) {
+ ConnectorRef connectorRef = CONNECTORS.get(connectorKey);
if (connectorRef == null) {
Connector connector;
if ("https".equals(endpoint.getProtocol())) {
@@ -125,27 +134,28 @@
if ("localhost".equalsIgnoreCase(endpoint.getHttpUri().getHost())) {
LOG.warn("You use localhost interface! It means that no external connections will be available. Don't you want to use 0.0.0.0 instead (all network interfaces)?");
}
- getServer().addConnector(connector);
+ Server server = createServer();
+ server.addConnector(connector);
- connectorRef = new ConnectorRef(connector, createServletForConnector(connector, endpoint.getHandlers()));
+ connectorRef = new ConnectorRef(server, connector, createServletForConnector(server, connector, endpoint.getHandlers()));
connector.start();
- connectors.put(connectorKey, connectorRef);
+ CONNECTORS.put(connectorKey, connectorRef);
} else {
// ref track the connector
connectorRef.increment();
}
// check the session support
- if (endpoint.isSessionSupport()) {
- enableSessionSupport();
+ if (endpoint.isSessionSupport()) {
+ enableSessionSupport(connectorRef.server);
}
connectorRef.servlet.connect(consumer);
}
}
- private void enableSessionSupport() throws Exception {
- Context context = (Context)getServer().getChildHandlerByClass(Context.class);
+ private void enableSessionSupport(Server server) throws Exception {
+ Context context = (Context)server.getChildHandlerByClass(Context.class);
if (context.getSessionHandler() == null) {
SessionHandler sessionHandler = new SessionHandler();
context.setSessionHandler(sessionHandler);
@@ -168,14 +178,15 @@
HttpEndpoint endpoint = consumer.getEndpoint();
String connectorKey = getConnectorKey(endpoint);
- synchronized (connectors) {
- ConnectorRef connectorRef = connectors.get(connectorKey);
+ synchronized (CONNECTORS) {
+ ConnectorRef connectorRef = CONNECTORS.get(connectorKey);
if (connectorRef != null) {
connectorRef.servlet.disconnect(consumer);
if (connectorRef.decrement() == 0) {
- getServer().removeConnector(connectorRef.connector);
+ connectorRef.server.removeConnector(connectorRef.connector);
connectorRef.connector.stop();
- connectors.remove(connectorKey);
+ connectorRef.server.stop();
+ CONNECTORS.remove(connectorKey);
}
}
}
@@ -187,18 +198,7 @@
// Properties
// -------------------------------------------------------------------------
-
- public Server getServer() throws Exception {
- if (server == null) {
- server = createServer();
- }
- return server;
- }
-
- public void setServer(Server server) {
- this.server = server;
- }
-
+
public String getSslKeyPassword() {
return sslKeyPassword;
}
@@ -241,9 +241,9 @@
sslSocketConnector = connector;
}
- protected CamelServlet createServletForConnector(Connector connector, String handlerNames) throws Exception {
+
+ protected CamelServlet createServletForConnector(Server server, Connector connector, String handlerNames) throws Exception {
CamelServlet camelServlet = new CamelContinuationServlet();
-
Context context = new Context(server, "/", Context.NO_SECURITY | Context.NO_SESSIONS);
context.setConnectorNames(new String[] {connector.getName()});
@@ -267,30 +267,14 @@
// Implementation methods
// -------------------------------------------------------------------------
-
protected Server createServer() throws Exception {
Server server = new Server();
ContextHandlerCollection collection = new ContextHandlerCollection();
collection.setServer(server);
server.addHandler(collection);
server.start();
-
return server;
}
-
- @Override
- protected void doStop() throws Exception {
- for (ConnectorRef connectorRef : connectors.values()) {
- connectorRef.connector.stop();
- }
- connectors.clear();
-
- if (server != null) {
- server.stop();
- }
-
- super.doStop();
- }
private Handler getHandler(String handlerName) {
Handler handler = null;
Modified: camel/branches/camel-1.x/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettyHttpEndpointDisconnectTest.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-1.x/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettyHttpEndpointDisconnectTest.java?rev=792041&r1=792040&r2=792041&view=diff
==============================================================================
--- camel/branches/camel-1.x/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettyHttpEndpointDisconnectTest.java (original)
+++ camel/branches/camel-1.x/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettyHttpEndpointDisconnectTest.java Wed Jul 8 05:42:20 2009
@@ -30,7 +30,7 @@
context.stop();
JettyHttpComponent component = (JettyHttpComponent) context.getComponent("jetty");
- assertEquals("Connector should have been removed", 0, component.connectors.size());
+ assertEquals("Connector should have been removed", 0, component.CONNECTORS.size());
}
protected RouteBuilder createRouteBuilder() throws Exception {
Propchange: camel/branches/camel-1.x/etc/eclipse/Camel.importorder
('svn:mergeinfo' removed)
Propchange: camel/branches/camel-1.x/etc/eclipse/CamelCodeFormatter.xml
('svn:mergeinfo' removed)