camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chir...@apache.org
Subject svn commit: r571197 - in /activemq/camel/trunk: ./ camel-core/src/main/java/org/apache/camel/util/ components/camel-http/src/main/java/org/apache/camel/component/http/ components/camel-jetty/ components/camel-jetty/src/main/java/org/apache/camel/compon...
Date Thu, 30 Aug 2007 14:57:06 GMT
Author: chirino
Date: Thu Aug 30 07:57:05 2007
New Revision: 571197

URL: http://svn.apache.org/viewvc?rev=571197&view=rev
Log:
Support async completion of inbound HTTP requests by leveraging Jetty's Continuation Feature
Support using the Jetty Client API to produce to an HTTP endpoint.

https://issues.apache.org/activemq/browse/CAMEL-130
https://issues.apache.org/activemq/browse/CAMEL-131


Modified:
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/util/IntrospectionSupport.java
    activemq/camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/HttpEndpoint.java
    activemq/camel/trunk/components/camel-jetty/pom.xml
    activemq/camel/trunk/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/JettyHttpComponent.java
    activemq/camel/trunk/pom.xml

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/util/IntrospectionSupport.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/util/IntrospectionSupport.java?rev=571197&r1=571196&r2=571197&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/util/IntrospectionSupport.java
(original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/util/IntrospectionSupport.java
Thu Aug 30 07:57:05 2007
@@ -18,7 +18,9 @@
 
 import java.beans.PropertyEditor;
 import java.beans.PropertyEditorManager;
+import java.io.IOException;
 import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.lang.reflect.Modifier;
 import java.net.URI;
@@ -86,6 +88,19 @@
         return rc;
     }
 
+    public static Object getProperty(Object target, String prop) throws SecurityException,
NoSuchMethodException, IllegalArgumentException, IllegalAccessException, InvocationTargetException
{
+        if (target == null) {
+            throw new IllegalArgumentException("target was null.");
+        }
+        if (prop == null) {
+            throw new IllegalArgumentException("prop was null.");
+        }
+        prop = prop.substring(0, 1).toUpperCase() + prop.substring(1);
+
+        Class clazz = target.getClass();
+        Method method = clazz.getMethod("get" + prop, new Class[] {});
+        return method.invoke(target, new Object[] {});
+    }
     public static boolean setProperties(Object target, Map props, String optionPrefix) {
         boolean rc = false;
         if (target == null) {

Modified: activemq/camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/HttpEndpoint.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/HttpEndpoint.java?rev=571197&r1=571196&r2=571197&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/HttpEndpoint.java
(original)
+++ activemq/camel/trunk/components/camel-http/src/main/java/org/apache/camel/component/http/HttpEndpoint.java
Thu Aug 30 07:57:05 2007
@@ -24,6 +24,7 @@
 
 import org.apache.camel.Consumer;
 import org.apache.camel.Processor;
+import org.apache.camel.Producer;
 import org.apache.camel.impl.DefaultEndpoint;
 
 /**
@@ -44,7 +45,7 @@
         this.httpUri = httpURI;
     }
 
-    public HttpProducer createProducer() throws Exception {
+    public Producer<HttpExchange> createProducer() throws Exception {
         return new HttpProducer(this);
     }
 
@@ -100,5 +101,9 @@
 
     public String getProtocol() {
         return httpUri.getScheme();
+    }
+
+    public URI getHttpUri() {
+        return httpUri;
     }
 }

Modified: activemq/camel/trunk/components/camel-jetty/pom.xml
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-jetty/pom.xml?rev=571197&r1=571196&r2=571197&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-jetty/pom.xml (original)
+++ activemq/camel/trunk/components/camel-jetty/pom.xml Thu Aug 30 07:57:05 2007
@@ -49,7 +49,10 @@
     <dependency>
       <groupId>org.mortbay.jetty</groupId>
       <artifactId>jetty</artifactId>
-      <optional>false</optional>
+    </dependency>
+    <dependency>
+      <groupId>org.mortbay.jetty</groupId>
+      <artifactId>jetty-client</artifactId>
     </dependency>
 
     <!-- testing -->

Modified: activemq/camel/trunk/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/JettyHttpComponent.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/JettyHttpComponent.java?rev=571197&r1=571196&r2=571197&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/JettyHttpComponent.java
(original)
+++ activemq/camel/trunk/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/JettyHttpComponent.java
Thu Aug 30 07:57:05 2007
@@ -27,11 +27,10 @@
 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.HttpProducer;
-import org.apache.camel.util.URISupport;
 
 import org.mortbay.jetty.Connector;
 import org.mortbay.jetty.Server;
+import org.mortbay.jetty.client.HttpClient;
 import org.mortbay.jetty.nio.SelectChannelConnector;
 import org.mortbay.jetty.security.SslSocketConnector;
 import org.mortbay.jetty.servlet.Context;
@@ -66,17 +65,19 @@
     private CamelServlet camelServlet;
     private Server server;
     private final HashMap<String, ConnectorRef> connectors = new HashMap<String,
ConnectorRef>();
+    private HttpClient httpClient;
 
     @Override
     protected Endpoint<HttpExchange> createEndpoint(String uri, String remaining, Map
parameters) throws Exception {
-        return new HttpEndpoint(uri, this, new URI(remaining)) {
+        URI httpURL = uri.startsWith("jetty:") ? new URI(remaining) : new URI(uri);
+        return new HttpEndpoint(uri, this, httpURL) {
             @Override
-            public HttpProducer createProducer() throws Exception {
-                throw new RuntimeCamelException("Not implemented.  You can only consume from
a jetty endpoint.");
+            public JettyHttpProducer createProducer() throws Exception {
+                return new JettyHttpProducer(this);
             }
         };
     }
-    
+
     /**
      * Connects the URL specified on the endpoint to the specified processor.
      * 
@@ -155,7 +156,7 @@
     // -------------------------------------------------------------------------
 
     protected Server createServer() throws Exception {
-        camelServlet = new CamelServlet();
+        camelServlet = new CamelContinuationServlet();
 
         Server server = new Server();
         Context context = new Context(Context.NO_SECURITY | Context.NO_SESSIONS);
@@ -180,6 +181,31 @@
         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/trunk/pom.xml
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/pom.xml?rev=571197&r1=571196&r2=571197&view=diff
==============================================================================
--- activemq/camel/trunk/pom.xml (original)
+++ activemq/camel/trunk/pom.xml Thu Aug 30 07:57:05 2007
@@ -37,7 +37,7 @@
     <camel-version>1.1-SNAPSHOT</camel-version>
     <compiler.fork>false</compiler.fork>
     <cxf-version>2.0.1-incubator</cxf-version>
-    <jetty-version>6.1.4</jetty-version>
+    <jetty-version>6.1.5</jetty-version>
     <m1-repo-url>scpexe://minotaur.apache.org/www/people.apache.org/repo/m1-snapshot-repository</m1-repo-url>
     <openjpa-version>0.9.6-incubating</openjpa-version>
     <release-repo-url>scpexe://people.apache.org/www/people.apache.org/repo/m2-ibiblio-rsync-repository
@@ -540,6 +540,11 @@
       <dependency>
         <groupId>org.mortbay.jetty</groupId>
         <artifactId>jetty</artifactId>
+        <version>${jetty-version}</version>
+      </dependency>
+      <dependency>
+        <groupId>org.mortbay.jetty</groupId>
+        <artifactId>jetty-client</artifactId>
         <version>${jetty-version}</version>
       </dependency>
 



Mime
View raw message