camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject svn commit: r731164 - in /activemq/camel/branches/camel-1.x: ./ components/camel-http/src/main/java/org/apache/camel/component/http/ components/camel-jetty/ components/camel-jetty/src/main/java/org/apache/camel/component/jetty/ components/camel-jetty/s...
Date Sun, 04 Jan 2009 04:05:42 GMT
Author: ningjiang
Date: Sat Jan  3 20:05:41 2009
New Revision: 731164

URL: http://svn.apache.org/viewvc?rev=731164&view=rev
Log:
Merged revisions 730936 via svnmerge from 
https://svn.apache.org/repos/asf/activemq/camel/trunk

........
  r730936 | ningjiang | 2009-01-03 16:24:31 +0800 (Sat, 03 Jan 2009) | 1 line
  
  CAMEL-1217  Get the Jetty component's 'httpClient.' options to be set into the indeed apache
http client; also some refactoring of camel-http component
........

Modified:
    activemq/camel/branches/camel-1.x/   (props changed)
    activemq/camel/branches/camel-1.x/components/camel-http/src/main/java/org/apache/camel/component/http/BasicAuthenticationHttpClientConfigurer.java
    activemq/camel/branches/camel-1.x/components/camel-http/src/main/java/org/apache/camel/component/http/HttpComponent.java
    activemq/camel/branches/camel-1.x/components/camel-jetty/pom.xml
    activemq/camel/branches/camel-1.x/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/JettyHttpComponent.java
    activemq/camel/branches/camel-1.x/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/JettyHttpEndpoint.java
    activemq/camel/branches/camel-1.x/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettyHttpClientOptionsTest.java

Propchange: activemq/camel/branches/camel-1.x/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sat Jan  3 20:05:41 2009
@@ -1 +1 @@
-/activemq/camel/trunk:709850,711200,711206,711219-711220,711523,711531,711756,711784,711859,711874,711962,711971,712064,712119,712148,712662,712692,712925,713013,713107,713136,713273,713290,713292,713295,713314,713475,713625,713932,713944,714032,717965,717989,718242,718273,718312-718515,719163-719184,719334,719339,719524,719662,719848,719851,719855,719864,719978-719979,720207,720435-720437,720806,721272,721331,721333-721334,721360,721669,721764,721813,721985,722005,722070,722110,722415,722438,722726,722845,722878,723264,723314,723325-723327,723409,723835,723966,724122,724619,724681,725040,725309-725320,725340,725351,725569-725572,725612,725652-725660,725715,725883,726339,726640-726645,726932,727113,727375,727377,727624,727713,727946,729401,729892,730069,730154,730275,730299,730504-730505,730508,730571,730599,730759,730903,730916,730923,730992,731126
+/activemq/camel/trunk:709850,711200,711206,711219-711220,711523,711531,711756,711784,711859,711874,711962,711971,712064,712119,712148,712662,712692,712925,713013,713107,713136,713273,713290,713292,713295,713314,713475,713625,713932,713944,714032,717965,717989,718242,718273,718312-718515,719163-719184,719334,719339,719524,719662,719848,719851,719855,719864,719978-719979,720207,720435-720437,720806,721272,721331,721333-721334,721360,721669,721764,721813,721985,722005,722070,722110,722415,722438,722726,722845,722878,723264,723314,723325-723327,723409,723835,723966,724122,724619,724681,725040,725309-725320,725340,725351,725569-725572,725612,725652-725660,725715,725883,726339,726640-726645,726932,727113,727375,727377,727624,727713,727946,729401,729892,730069,730154,730275,730299,730504-730505,730508,730571,730599,730759,730903,730916,730923,730936,730992,731126

Propchange: activemq/camel/branches/camel-1.x/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: activemq/camel/branches/camel-1.x/components/camel-http/src/main/java/org/apache/camel/component/http/BasicAuthenticationHttpClientConfigurer.java
URL: http://svn.apache.org/viewvc/activemq/camel/branches/camel-1.x/components/camel-http/src/main/java/org/apache/camel/component/http/BasicAuthenticationHttpClientConfigurer.java?rev=731164&r1=731163&r2=731164&view=diff
==============================================================================
--- activemq/camel/branches/camel-1.x/components/camel-http/src/main/java/org/apache/camel/component/http/BasicAuthenticationHttpClientConfigurer.java
(original)
+++ activemq/camel/branches/camel-1.x/components/camel-http/src/main/java/org/apache/camel/component/http/BasicAuthenticationHttpClientConfigurer.java
Sat Jan  3 20:05:41 2009
@@ -1,3 +1,19 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
 package org.apache.camel.component.http;
 
 import org.apache.commons.httpclient.Credentials;

Modified: activemq/camel/branches/camel-1.x/components/camel-http/src/main/java/org/apache/camel/component/http/HttpComponent.java
URL: http://svn.apache.org/viewvc/activemq/camel/branches/camel-1.x/components/camel-http/src/main/java/org/apache/camel/component/http/HttpComponent.java?rev=731164&r1=731163&r2=731164&view=diff
==============================================================================
--- activemq/camel/branches/camel-1.x/components/camel-http/src/main/java/org/apache/camel/component/http/HttpComponent.java
(original)
+++ activemq/camel/branches/camel-1.x/components/camel-http/src/main/java/org/apache/camel/component/http/HttpComponent.java
Sat Jan  3 20:05:41 2009
@@ -65,14 +65,15 @@
     public void disconnect(HttpConsumer consumer) throws Exception {
     }
 
-    @Override
-    protected Endpoint<HttpExchange> createEndpoint(String uri, String remaining, Map
parameters)
-        throws Exception {
-
-        // http client can be configured from URI options
-        HttpClientParams params = new HttpClientParams();
-        IntrospectionSupport.setProperties(params, parameters, "httpClient.");
-
+    /** 
+     * Setting http binding and http client configurer according to the parameters
+     * Also setting the BasicAuthenticationHttpClientConfigurer if the username 
+     * and password option are not null.
+     * 
+     * @param parameters the map of parameters 
+     * 
+     */
+    protected void configureParameters(Map parameters) {
         // lookup http binding in registry if provided
         String ref = getAndRemoveParameter(parameters, "httpBindingRef", String.class);
         if (ref != null) {
@@ -91,6 +92,17 @@
         if (ref != null) {
             httpClientConfigurer = CamelContextHelper.mandatoryLookup(getCamelContext(),
ref, HttpClientConfigurer.class);
         }
+    }
+    
+    @Override
+    protected Endpoint createEndpoint(String uri, String remaining, Map parameters)
+        throws Exception {
+
+        // http client can be configured from URI options
+        HttpClientParams params = new HttpClientParams();
+        IntrospectionSupport.setProperties(params, parameters, "httpClient.");        
+        
+        configureParameters(parameters);
 
         // restructure uri to be based on the parameters left as we dont want to include
the Camel internal options
         URI httpUri = URISupport.createRemainingURI(new URI(uri), parameters);

Modified: activemq/camel/branches/camel-1.x/components/camel-jetty/pom.xml
URL: http://svn.apache.org/viewvc/activemq/camel/branches/camel-1.x/components/camel-jetty/pom.xml?rev=731164&r1=731163&r2=731164&view=diff
==============================================================================
--- activemq/camel/branches/camel-1.x/components/camel-jetty/pom.xml (original)
+++ activemq/camel/branches/camel-1.x/components/camel-jetty/pom.xml Sat Jan  3 20:05:41 2009
@@ -51,11 +51,7 @@
       <groupId>org.mortbay.jetty</groupId>
       <artifactId>jetty</artifactId>
     </dependency>
-    <dependency>
-      <groupId>org.mortbay.jetty</groupId>
-      <artifactId>jetty-client</artifactId>
-    </dependency>
-
+    
     <!-- testing -->
     <dependency>
       <groupId>org.apache.camel</groupId>

Modified: activemq/camel/branches/camel-1.x/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/JettyHttpComponent.java
URL: http://svn.apache.org/viewvc/activemq/camel/branches/camel-1.x/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/JettyHttpComponent.java?rev=731164&r1=731163&r2=731164&view=diff
==============================================================================
--- activemq/camel/branches/camel-1.x/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/JettyHttpComponent.java
(original)
+++ activemq/camel/branches/camel-1.x/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/JettyHttpComponent.java
Sat Jan  3 20:05:41 2009
@@ -22,7 +22,6 @@
 
 import org.apache.camel.Endpoint;
 import org.apache.camel.component.http.CamelServlet;
-import org.apache.camel.component.http.HttpBinding;
 import org.apache.camel.component.http.HttpComponent;
 import org.apache.camel.component.http.HttpConsumer;
 import org.apache.camel.component.http.HttpEndpoint;
@@ -30,11 +29,11 @@
 import org.apache.camel.util.CamelContextHelper;
 import org.apache.camel.util.IntrospectionSupport;
 import org.apache.camel.util.URISupport;
+import org.apache.commons.httpclient.params.HttpClientParams;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.mortbay.jetty.Connector;
 import org.mortbay.jetty.Server;
-import org.mortbay.jetty.client.HttpClient;
 import org.mortbay.jetty.handler.ContextHandlerCollection;
 import org.mortbay.jetty.nio.SelectChannelConnector;
 import org.mortbay.jetty.security.SslSocketConnector;
@@ -75,8 +74,7 @@
     private static final transient Log LOG = LogFactory.getLog(JettyHttpComponent.class);
     
     protected Server server;
-    protected HashMap<String, ConnectorRef> connectors = new HashMap<String, ConnectorRef>();
-    protected HttpClient httpClient;
+    protected HashMap<String, ConnectorRef> connectors = new HashMap<String, ConnectorRef>();
   
     protected String sslKeyPassword;
     protected String sslPassword;
     protected String sslKeystore;
@@ -86,23 +84,16 @@
     protected Endpoint<HttpExchange> createEndpoint(String uri, String remaining, Map
parameters) throws Exception {
         uri = uri.startsWith("jetty:") ? remaining : uri;
 
-        // http client can be configured from URI options
-        if (httpClient == null) {
-            httpClient = createHttpClient();
-        }
-        IntrospectionSupport.setProperties(httpClient, parameters, "httpClient.");
-
-        // lookup http binding in registry if provided
-        String ref = getAndRemoveParameter(parameters, "httpBindingRef", String.class);
-        if (ref != null) {
-            httpBinding = CamelContextHelper.mandatoryLookup(getCamelContext(), ref, HttpBinding.class);
-        }
+        HttpClientParams params = new HttpClientParams();
+        IntrospectionSupport.setProperties(params, parameters, "httpClient.");   
+
+        configureParameters(parameters);
 
         // restructure uri to be based on the parameters left as we dont want to include
the Camel internal options
         URI httpUri = URISupport.createRemainingURI(new URI(uri), parameters);
         uri = httpUri.toString();
 
-        JettyHttpEndpoint result = new JettyHttpEndpoint(this, uri, httpUri, getHttpConnectionManager());
+        JettyHttpEndpoint result = new JettyHttpEndpoint(this, uri, httpUri, params, getHttpConnectionManager(),
httpClientConfigurer);
         if (httpBinding != null) {
             result.setBinding(httpBinding);
         }
@@ -286,31 +277,8 @@
         if (server != null) {
             server.stop();
         }
-        httpClient.stop();
+        
         super.doStop();
     }
-
-    @Override
-    protected void doStart() throws Exception {
-        super.doStart();
-        if (httpClient == null) {
-            httpClient = createHttpClient();
-        }
-        httpClient.start();
-    }
-
-    protected HttpClient createHttpClient() throws Exception {
-        HttpClient httpClient = new HttpClient();
-        httpClient.setConnectorType(HttpClient.CONNECTOR_SELECT_CHANNEL);
-        httpClient.setMaxConnectionsPerAddress(2);
-        return httpClient;
-    }
-
-    public HttpClient getHttpClient() {
-        return httpClient;
-    }
-
-    public void setHttpClient(HttpClient httpClient) {
-        this.httpClient = httpClient;
-    }
+   
 }

Modified: activemq/camel/branches/camel-1.x/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/JettyHttpEndpoint.java
URL: http://svn.apache.org/viewvc/activemq/camel/branches/camel-1.x/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/JettyHttpEndpoint.java?rev=731164&r1=731163&r2=731164&view=diff
==============================================================================
--- activemq/camel/branches/camel-1.x/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/JettyHttpEndpoint.java
(original)
+++ activemq/camel/branches/camel-1.x/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/JettyHttpEndpoint.java
Sat Jan  3 20:05:41 2009
@@ -23,11 +23,13 @@
 import org.apache.camel.PollingConsumer;
 import org.apache.camel.Processor;
 import org.apache.camel.Producer;
+import org.apache.camel.component.http.HttpClientConfigurer;
 import org.apache.camel.component.http.HttpConsumer;
 import org.apache.camel.component.http.HttpEndpoint;
 import org.apache.camel.component.http.HttpExchange;
 import org.apache.camel.component.http.HttpPollingConsumer;
 import org.apache.commons.httpclient.HttpConnectionManager;
+import org.apache.commons.httpclient.params.HttpClientParams;
 
 /**
  * @version $Revision$
@@ -36,8 +38,9 @@
     private JettyHttpComponent component;
     private boolean sessionSupport;
 
-    public JettyHttpEndpoint(JettyHttpComponent component, String uri, URI httpURL, HttpConnectionManager
httpConnectionManager) throws URISyntaxException {
-        super(uri, component, httpURL, httpConnectionManager);
+    public JettyHttpEndpoint(JettyHttpComponent component, String uri, URI httpURL, HttpClientParams
clientParams,
+                             HttpConnectionManager httpConnectionManager, HttpClientConfigurer
clientConfigurer) throws URISyntaxException {
+        super(uri, component, httpURL, clientParams, httpConnectionManager, clientConfigurer);
         this.component = component;
     }
 

Modified: activemq/camel/branches/camel-1.x/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettyHttpClientOptionsTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/branches/camel-1.x/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettyHttpClientOptionsTest.java?rev=731164&r1=731163&r2=731164&view=diff
==============================================================================
--- activemq/camel/branches/camel-1.x/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettyHttpClientOptionsTest.java
(original)
+++ activemq/camel/branches/camel-1.x/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettyHttpClientOptionsTest.java
Sat Jan  3 20:05:41 2009
@@ -17,7 +17,9 @@
 package org.apache.camel.component.jetty;
 
 import org.apache.camel.ContextTestSupport;
+import org.apache.camel.Endpoint;
 import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.http.HttpProducer;
 
 /**
  * Unit test for http client options.
@@ -26,9 +28,10 @@
 
     public void testCustomHttpBinding() throws Exception {
         // assert jetty was configured with our timeout
-        JettyHttpComponent jetty = context.getComponent("jetty", JettyHttpComponent.class);
-        assertNotNull(jetty);
-        assertEquals(5555, jetty.getHttpClient().getIdleTimeout());
+        JettyHttpEndpoint jettyEndpoint = (JettyHttpEndpoint) context.getEndpoint("jetty:http://localhost:8080/myapp/myservice?httpClient.soTimeout=5555");
+        assertNotNull("Jetty endpoint should not be null ", jettyEndpoint);
+        HttpProducer producer = (HttpProducer)jettyEndpoint.createProducer();
+        assertEquals("Get the wrong http client parameter", 5555, producer.getHttpClient().getParams().getSoTimeout());
 
         // send and receive
         Object out = template.requestBody("http://localhost:8080/myapp/myservice", "Hello
World");
@@ -40,7 +43,7 @@
         return new RouteBuilder() {
             @Override
             public void configure() throws Exception {
-                from("jetty:http://localhost:8080/myapp/myservice?httpClient.idleTimeout=5555").transform().constant("Bye
World");
+                from("jetty:http://localhost:8080/myapp/myservice?httpClient.soTimeout=5555").transform().constant("Bye
World");
             }
         };
     }



Mime
View raw message