camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From krass...@apache.org
Subject svn commit: r880672 [1/3] - in /camel/trunk: components/ components/camel-gae/ components/camel-gae/src/ components/camel-gae/src/main/ components/camel-gae/src/main/java/ components/camel-gae/src/main/java/org/ components/camel-gae/src/main/java/org/a...
Date Mon, 16 Nov 2009 08:46:50 GMT
Author: krasserm
Date: Mon Nov 16 08:45:58 2009
New Revision: 880672

URL: http://svn.apache.org/viewvc?rev=880672&view=rev
Log:
Initial work on Camel components for Google App Engine

Added:
    camel/trunk/components/camel-gae/   (with props)
    camel/trunk/components/camel-gae/pom.xml   (with props)
    camel/trunk/components/camel-gae/src/
    camel/trunk/components/camel-gae/src/main/
    camel/trunk/components/camel-gae/src/main/java/
    camel/trunk/components/camel-gae/src/main/java/org/
    camel/trunk/components/camel-gae/src/main/java/org/apache/
    camel/trunk/components/camel-gae/src/main/java/org/apache/camel/
    camel/trunk/components/camel-gae/src/main/java/org/apache/camel/component/
    camel/trunk/components/camel-gae/src/main/java/org/apache/camel/component/gae/
    camel/trunk/components/camel-gae/src/main/java/org/apache/camel/component/gae/bind/
    camel/trunk/components/camel-gae/src/main/java/org/apache/camel/component/gae/bind/HttpBindingInvocationHandler.java   (with props)
    camel/trunk/components/camel-gae/src/main/java/org/apache/camel/component/gae/bind/InboundBinding.java   (with props)
    camel/trunk/components/camel-gae/src/main/java/org/apache/camel/component/gae/bind/InboundBindingSupport.java   (with props)
    camel/trunk/components/camel-gae/src/main/java/org/apache/camel/component/gae/bind/OutboundBinding.java   (with props)
    camel/trunk/components/camel-gae/src/main/java/org/apache/camel/component/gae/bind/OutboundBindingSupport.java   (with props)
    camel/trunk/components/camel-gae/src/main/java/org/apache/camel/component/gae/context/
    camel/trunk/components/camel-gae/src/main/java/org/apache/camel/component/gae/context/GaeDefaultCamelContext.java   (with props)
    camel/trunk/components/camel-gae/src/main/java/org/apache/camel/component/gae/context/GaeSpringCamelContext.java   (with props)
    camel/trunk/components/camel-gae/src/main/java/org/apache/camel/component/gae/http/
    camel/trunk/components/camel-gae/src/main/java/org/apache/camel/component/gae/http/GHttpBinding.java   (with props)
    camel/trunk/components/camel-gae/src/main/java/org/apache/camel/component/gae/http/GHttpComponent.java   (with props)
    camel/trunk/components/camel-gae/src/main/java/org/apache/camel/component/gae/http/GHttpEndpoint.java   (with props)
    camel/trunk/components/camel-gae/src/main/java/org/apache/camel/component/gae/http/GHttpException.java   (with props)
    camel/trunk/components/camel-gae/src/main/java/org/apache/camel/component/gae/http/GHttpProducer.java   (with props)
    camel/trunk/components/camel-gae/src/main/java/org/apache/camel/component/gae/mail/
    camel/trunk/components/camel-gae/src/main/java/org/apache/camel/component/gae/mail/GMailBinding.java   (with props)
    camel/trunk/components/camel-gae/src/main/java/org/apache/camel/component/gae/mail/GMailComponent.java   (with props)
    camel/trunk/components/camel-gae/src/main/java/org/apache/camel/component/gae/mail/GMailEndpoint.java   (with props)
    camel/trunk/components/camel-gae/src/main/java/org/apache/camel/component/gae/mail/GMailProducer.java   (with props)
    camel/trunk/components/camel-gae/src/main/java/org/apache/camel/component/gae/task/
    camel/trunk/components/camel-gae/src/main/java/org/apache/camel/component/gae/task/GTaskBinding.java   (with props)
    camel/trunk/components/camel-gae/src/main/java/org/apache/camel/component/gae/task/GTaskComponent.java   (with props)
    camel/trunk/components/camel-gae/src/main/java/org/apache/camel/component/gae/task/GTaskEndpoint.java   (with props)
    camel/trunk/components/camel-gae/src/main/java/org/apache/camel/component/gae/task/GTaskEndpointInfo.java   (with props)
    camel/trunk/components/camel-gae/src/main/java/org/apache/camel/component/gae/task/GTaskProducer.java   (with props)
    camel/trunk/components/camel-gae/src/main/resources/
    camel/trunk/components/camel-gae/src/main/resources/META-INF/
    camel/trunk/components/camel-gae/src/main/resources/META-INF/services/
    camel/trunk/components/camel-gae/src/main/resources/META-INF/services/org/
    camel/trunk/components/camel-gae/src/main/resources/META-INF/services/org/apache/
    camel/trunk/components/camel-gae/src/main/resources/META-INF/services/org/apache/camel/
    camel/trunk/components/camel-gae/src/main/resources/META-INF/services/org/apache/camel/component/
    camel/trunk/components/camel-gae/src/main/resources/META-INF/services/org/apache/camel/component/ghttp
    camel/trunk/components/camel-gae/src/main/resources/META-INF/services/org/apache/camel/component/ghttps
    camel/trunk/components/camel-gae/src/main/resources/META-INF/services/org/apache/camel/component/gmail
    camel/trunk/components/camel-gae/src/main/resources/META-INF/services/org/apache/camel/component/gtask
    camel/trunk/components/camel-gae/src/test/
    camel/trunk/components/camel-gae/src/test/java/
    camel/trunk/components/camel-gae/src/test/java/com/
    camel/trunk/components/camel-gae/src/test/java/com/google/
    camel/trunk/components/camel-gae/src/test/java/com/google/appengine/
    camel/trunk/components/camel-gae/src/test/java/com/google/appengine/api/
    camel/trunk/components/camel-gae/src/test/java/com/google/appengine/api/labs/
    camel/trunk/components/camel-gae/src/test/java/com/google/appengine/api/labs/taskqueue/
    camel/trunk/components/camel-gae/src/test/java/com/google/appengine/api/labs/taskqueue/TaskOptionsAccessor.java   (with props)
    camel/trunk/components/camel-gae/src/test/java/com/google/appengine/api/urlfetch/
    camel/trunk/components/camel-gae/src/test/java/com/google/appengine/api/urlfetch/MockHttpResponse.java   (with props)
    camel/trunk/components/camel-gae/src/test/java/org/
    camel/trunk/components/camel-gae/src/test/java/org/apache/
    camel/trunk/components/camel-gae/src/test/java/org/apache/camel/
    camel/trunk/components/camel-gae/src/test/java/org/apache/camel/component/
    camel/trunk/components/camel-gae/src/test/java/org/apache/camel/component/gae/
    camel/trunk/components/camel-gae/src/test/java/org/apache/camel/component/gae/http/
    camel/trunk/components/camel-gae/src/test/java/org/apache/camel/component/gae/http/GHttpBindingTest.java   (with props)
    camel/trunk/components/camel-gae/src/test/java/org/apache/camel/component/gae/http/GHttpCombinedRouteBuilder.java   (with props)
    camel/trunk/components/camel-gae/src/test/java/org/apache/camel/component/gae/http/GHttpCombinedRouteBuilderTest.java   (with props)
    camel/trunk/components/camel-gae/src/test/java/org/apache/camel/component/gae/http/GHttpEndpointTest.java   (with props)
    camel/trunk/components/camel-gae/src/test/java/org/apache/camel/component/gae/http/GHttpInboundRouteBuilder.java   (with props)
    camel/trunk/components/camel-gae/src/test/java/org/apache/camel/component/gae/http/GHttpInboundRouteBuilderTest.java   (with props)
    camel/trunk/components/camel-gae/src/test/java/org/apache/camel/component/gae/http/GHttpOutboundRouteBuilder.java   (with props)
    camel/trunk/components/camel-gae/src/test/java/org/apache/camel/component/gae/http/GHttpOutboundRouteBuilderTest.java   (with props)
    camel/trunk/components/camel-gae/src/test/java/org/apache/camel/component/gae/http/GHttpTestUtils.java   (with props)
    camel/trunk/components/camel-gae/src/test/java/org/apache/camel/component/gae/http/MockUrlFetchService.java   (with props)
    camel/trunk/components/camel-gae/src/test/java/org/apache/camel/component/gae/mail/
    camel/trunk/components/camel-gae/src/test/java/org/apache/camel/component/gae/mail/GMailBindingTest.java   (with props)
    camel/trunk/components/camel-gae/src/test/java/org/apache/camel/component/gae/mail/GMailEndpointTest.java   (with props)
    camel/trunk/components/camel-gae/src/test/java/org/apache/camel/component/gae/mail/GMailOutboundRouteBuilder.java   (with props)
    camel/trunk/components/camel-gae/src/test/java/org/apache/camel/component/gae/mail/GMailOutboundRouteBuilderTest.java   (with props)
    camel/trunk/components/camel-gae/src/test/java/org/apache/camel/component/gae/mail/GMailTestUtils.java   (with props)
    camel/trunk/components/camel-gae/src/test/java/org/apache/camel/component/gae/mail/MockMailService.java   (with props)
    camel/trunk/components/camel-gae/src/test/java/org/apache/camel/component/gae/support/
    camel/trunk/components/camel-gae/src/test/java/org/apache/camel/component/gae/support/ServletTestSupport.java   (with props)
    camel/trunk/components/camel-gae/src/test/java/org/apache/camel/component/gae/task/
    camel/trunk/components/camel-gae/src/test/java/org/apache/camel/component/gae/task/GTaskBindingTest.java   (with props)
    camel/trunk/components/camel-gae/src/test/java/org/apache/camel/component/gae/task/GTaskCombinedRouteBuilder.java   (with props)
    camel/trunk/components/camel-gae/src/test/java/org/apache/camel/component/gae/task/GTaskCombinedRouteBuilderTest.java   (with props)
    camel/trunk/components/camel-gae/src/test/java/org/apache/camel/component/gae/task/GTaskEndpointTest.java   (with props)
    camel/trunk/components/camel-gae/src/test/java/org/apache/camel/component/gae/task/GTaskTestUtils.java   (with props)
    camel/trunk/components/camel-gae/src/test/java/org/apache/camel/component/gae/task/MockQueue.java   (with props)
    camel/trunk/components/camel-gae/src/test/resources/
    camel/trunk/components/camel-gae/src/test/resources/org/
    camel/trunk/components/camel-gae/src/test/resources/org/apache/
    camel/trunk/components/camel-gae/src/test/resources/org/apache/camel/
    camel/trunk/components/camel-gae/src/test/resources/org/apache/camel/component/
    camel/trunk/components/camel-gae/src/test/resources/org/apache/camel/component/gae/
    camel/trunk/components/camel-gae/src/test/resources/org/apache/camel/component/gae/http/
    camel/trunk/components/camel-gae/src/test/resources/org/apache/camel/component/gae/http/context-combined.xml   (with props)
    camel/trunk/components/camel-gae/src/test/resources/org/apache/camel/component/gae/http/context-inbound.xml   (with props)
    camel/trunk/components/camel-gae/src/test/resources/org/apache/camel/component/gae/http/context-outbound.xml   (with props)
    camel/trunk/components/camel-gae/src/test/resources/org/apache/camel/component/gae/http/web-combined.xml   (with props)
    camel/trunk/components/camel-gae/src/test/resources/org/apache/camel/component/gae/http/web-inbound.xml   (with props)
    camel/trunk/components/camel-gae/src/test/resources/org/apache/camel/component/gae/mail/
    camel/trunk/components/camel-gae/src/test/resources/org/apache/camel/component/gae/mail/context-outbound.xml   (with props)
    camel/trunk/components/camel-gae/src/test/resources/org/apache/camel/component/gae/task/
    camel/trunk/components/camel-gae/src/test/resources/org/apache/camel/component/gae/task/context-combined.xml   (with props)
    camel/trunk/components/camel-gae/src/test/resources/org/apache/camel/component/gae/task/web-combined.xml   (with props)
Modified:
    camel/trunk/components/camel-servlet/pom.xml
    camel/trunk/components/camel-servlet/src/main/java/org/apache/camel/component/servlet/ServletComponent.java
    camel/trunk/components/pom.xml
    camel/trunk/parent/pom.xml

Propchange: camel/trunk/components/camel-gae/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Mon Nov 16 08:45:58 2009
@@ -0,0 +1,8 @@
+.checkstyle
+.pmd
+eclipse-classes
+target
+.classpath
+.project
+.settings
+*.i??

Added: camel/trunk/components/camel-gae/pom.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-gae/pom.xml?rev=880672&view=auto
==============================================================================
--- camel/trunk/components/camel-gae/pom.xml (added)
+++ camel/trunk/components/camel-gae/pom.xml Mon Nov 16 08:45:58 2009
@@ -0,0 +1,91 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+  <modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <groupId>org.apache.camel</groupId>
+    <artifactId>camel-parent</artifactId>
+    <version>2.1-SNAPSHOT</version>
+  </parent>
+
+  <artifactId>camel-gae</artifactId>
+  <packaging>bundle</packaging>
+  <name>Camel :: GAE</name>
+  <description>Camel GAE support</description>
+
+  <properties>
+	<camel.osgi.export.pkg>org.apache.camel.component.gae.*</camel.osgi.export.pkg>
+    <appengine-sdk-version>1.2.6</appengine-sdk-version>
+  </properties>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.camel</groupId>
+      <artifactId>camel-servlet</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>com.google.appengine</groupId>
+      <artifactId>appengine-api-1.0-sdk</artifactId>
+      <version>${appengine-sdk-version}</version>
+    </dependency>
+    <dependency>
+      <groupId>com.google.appengine</groupId>
+      <artifactId>appengine-api-labs</artifactId>
+      <version>${appengine-sdk-version}</version>
+    </dependency>
+
+    <!-- testing -->
+    <dependency>
+      <groupId>org.apache.camel</groupId>
+      <artifactId>camel-test</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.springframework</groupId>
+      <artifactId>spring-test</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>httpunit</groupId>
+      <artifactId>httpunit</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+
+  <repositories>
+    <repository>
+      <id>openehealth.releases</id>
+      <name>Camel Maven Repository</name>
+      <url>http://svn.apache.org/repos/asf/camel/m2-repo</url>
+      <releases>
+        <enabled>true</enabled>
+      </releases>
+      <snapshots>
+        <enabled>false</enabled>
+      </snapshots>
+    </repository>
+  </repositories>
+    
+</project>

Propchange: camel/trunk/components/camel-gae/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: camel/trunk/components/camel-gae/src/main/java/org/apache/camel/component/gae/bind/HttpBindingInvocationHandler.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-gae/src/main/java/org/apache/camel/component/gae/bind/HttpBindingInvocationHandler.java?rev=880672&view=auto
==============================================================================
--- camel/trunk/components/camel-gae/src/main/java/org/apache/camel/component/gae/bind/HttpBindingInvocationHandler.java (added)
+++ camel/trunk/components/camel-gae/src/main/java/org/apache/camel/component/gae/bind/HttpBindingInvocationHandler.java Mon Nov 16 08:45:58 2009
@@ -0,0 +1,55 @@
+/**
+ * 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.gae.bind;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+
+import org.apache.camel.Endpoint;
+import org.apache.camel.component.http.HttpBinding;
+import org.apache.camel.component.http.HttpMessage;
+
+/**
+ * Post-processes {@link HttpBinding} invocations by delegating to an
+ * endpoint's {@link InboundBinding}.
+ */
+public class HttpBindingInvocationHandler<E extends Endpoint, S, T> implements InvocationHandler {
+
+    private E endpoint;
+    private HttpBinding httpBinding;
+    private InboundBinding<E, S, T> inboundBinding; 
+    
+    public HttpBindingInvocationHandler(E endpoint, HttpBinding httpBinding, InboundBinding<E, S, T> inboundBinding) {
+        this.endpoint = endpoint;
+        this.httpBinding = httpBinding;
+        this.inboundBinding = inboundBinding;
+    }
+    
+    @SuppressWarnings("unchecked")
+    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
+        Object result = method.invoke(httpBinding, args); // updates args
+        if (method.getName().equals("readRequest") && (args.length == 2)) {
+            HttpMessage message = (HttpMessage)args[1];
+            // prepare exchange for further inbound binding operations
+            message.getExchange().setIn(message);
+            // delegate further binding operations to inbound binding
+            inboundBinding.readRequest(endpoint, message.getExchange(), (S)args[0]);
+        } 
+        return result;
+    }
+    
+}

Propchange: camel/trunk/components/camel-gae/src/main/java/org/apache/camel/component/gae/bind/HttpBindingInvocationHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: camel/trunk/components/camel-gae/src/main/java/org/apache/camel/component/gae/bind/InboundBinding.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-gae/src/main/java/org/apache/camel/component/gae/bind/InboundBinding.java?rev=880672&view=auto
==============================================================================
--- camel/trunk/components/camel-gae/src/main/java/org/apache/camel/component/gae/bind/InboundBinding.java (added)
+++ camel/trunk/components/camel-gae/src/main/java/org/apache/camel/component/gae/bind/InboundBinding.java Mon Nov 16 08:45:58 2009
@@ -0,0 +1,59 @@
+/**
+ * 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.gae.bind;
+
+import org.apache.camel.Consumer;
+import org.apache.camel.Endpoint;
+import org.apache.camel.Exchange;
+
+/**
+ * Represents the binding of request and response types to an {@link Exchange}.
+ * The request and response types are defined via the type parameters
+ * <code>S</code> and <code>T</code>, respectively. The InboundBinding is used
+ * by {@link Consumer} implementations or their clients to translate between
+ * protocol-specific or services-specific messages and {@link Exchange} objects.
+ * 
+ * @param S
+ *            request type.
+ * @param T
+ *            response type.
+ * @param E
+ *            endpoint type.
+ */
+public interface InboundBinding<E extends Endpoint, S, T> {
+
+    /**
+     * Populates an {@link Exchange} from request data and endpoint configuration data.
+     * 
+     * @param endpoint endpoint providing binding-relevant information. 
+     * @param exchange exchange to be populated or created (if <code>null</code>) from request data.
+     * @param request request to read data from.
+     * @return the populated exchange.
+     */
+    Exchange readRequest(E endpoint, Exchange exchange, S request) throws Exception;
+    
+    /**
+     * Creates or populates a response object from {@link Exchange} and endpoint configuration data.
+     * 
+     * @param endpoint endpoint providing binding-relevant information. 
+     * @param exchange exchange to read data from.
+     * @param response to be populated or created (if <code>null</code>) from exchange data.
+     * @return the populated response.
+     */
+    T writeResponse(E endpoint, Exchange exchange, T response) throws Exception;
+    
+}

Propchange: camel/trunk/components/camel-gae/src/main/java/org/apache/camel/component/gae/bind/InboundBinding.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: camel/trunk/components/camel-gae/src/main/java/org/apache/camel/component/gae/bind/InboundBindingSupport.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-gae/src/main/java/org/apache/camel/component/gae/bind/InboundBindingSupport.java?rev=880672&view=auto
==============================================================================
--- camel/trunk/components/camel-gae/src/main/java/org/apache/camel/component/gae/bind/InboundBindingSupport.java (added)
+++ camel/trunk/components/camel-gae/src/main/java/org/apache/camel/component/gae/bind/InboundBindingSupport.java Mon Nov 16 08:45:58 2009
@@ -0,0 +1,34 @@
+/**
+ * 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.gae.bind;
+
+import org.apache.camel.Consumer;
+import org.apache.camel.Endpoint;
+
+/**
+ * Implemented by {@link Endpoint}s that provide an {@link InboundBinding} to
+ * {@link Consumer}s.
+ * 
+ * @see InboundBinding
+ */
+public interface InboundBindingSupport<E extends Endpoint, S, T> {
+
+    InboundBinding<E, S, T> getInboundBinding();
+    
+    void setInboundBinding(InboundBinding<E, S, T> inboundBinding);
+    
+}

Propchange: camel/trunk/components/camel-gae/src/main/java/org/apache/camel/component/gae/bind/InboundBindingSupport.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: camel/trunk/components/camel-gae/src/main/java/org/apache/camel/component/gae/bind/OutboundBinding.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-gae/src/main/java/org/apache/camel/component/gae/bind/OutboundBinding.java?rev=880672&view=auto
==============================================================================
--- camel/trunk/components/camel-gae/src/main/java/org/apache/camel/component/gae/bind/OutboundBinding.java (added)
+++ camel/trunk/components/camel-gae/src/main/java/org/apache/camel/component/gae/bind/OutboundBinding.java Mon Nov 16 08:45:58 2009
@@ -0,0 +1,59 @@
+/**
+ * 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.gae.bind;
+
+import org.apache.camel.Endpoint;
+import org.apache.camel.Exchange;
+import org.apache.camel.Producer;
+
+/**
+ * Represents the binding of request and response types to an {@link Exchange}.
+ * The request and response types are defined via the type parameters
+ * <code>S</code> and <code>T</code>, respectively. The OutboundBinding is used
+ * by {@link Producer} implementations to translate between {@link Exchange}
+ * objects and protocol-specific or services-specific messages.
+ * 
+ * @param S
+ *            request type.
+ * @param T
+ *            response type.
+ * @param E
+ *            endpoint type.
+ */
+public interface OutboundBinding<E extends Endpoint, S, T> {
+
+    /**
+     * Creates or populates a request object from {@link Exchange} and endpoint configuration data.
+     * 
+     * @param endpoint endpoint providing binding-relevant information. 
+     * @param exchange exchange to read data from.
+     * @param request request to be populated or created (if <code>null</code>) from exchange data.
+     * @return the populated response.
+     */
+    S writeRequest(E endpoint, Exchange exchange, S request) throws Exception;
+    
+    /**
+     * Populates an {@link Exchange} from response data and endpoint configuration data.
+     * 
+     * @param endpoint endpoint providing binding-relevant information. 
+     * @param exchange exchange to be populated or created (if <code>null</code>) from response data.
+     * @param response response to read data from.
+     * @return the populated exchange.
+     */
+    Exchange readResponse(E endpoint, Exchange exchange, T response) throws Exception;
+    
+}

Propchange: camel/trunk/components/camel-gae/src/main/java/org/apache/camel/component/gae/bind/OutboundBinding.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: camel/trunk/components/camel-gae/src/main/java/org/apache/camel/component/gae/bind/OutboundBindingSupport.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-gae/src/main/java/org/apache/camel/component/gae/bind/OutboundBindingSupport.java?rev=880672&view=auto
==============================================================================
--- camel/trunk/components/camel-gae/src/main/java/org/apache/camel/component/gae/bind/OutboundBindingSupport.java (added)
+++ camel/trunk/components/camel-gae/src/main/java/org/apache/camel/component/gae/bind/OutboundBindingSupport.java Mon Nov 16 08:45:58 2009
@@ -0,0 +1,34 @@
+/**
+ * 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.gae.bind;
+
+import org.apache.camel.Endpoint;
+import org.apache.camel.Producer;
+
+/**
+ * Implemented by {@link Endpoint}s that provide an {@link OutboundBinding} to
+ * {@link Producer}s.
+ * 
+ * @see InboundBinding
+ */
+public interface OutboundBindingSupport<E extends Endpoint, S, T> {
+
+    OutboundBinding<E, S, T> getOutboundBinding();
+
+    void setOutboundBinding(OutboundBinding<E, S, T> outboundBinding);
+    
+}

Propchange: camel/trunk/components/camel-gae/src/main/java/org/apache/camel/component/gae/bind/OutboundBindingSupport.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: camel/trunk/components/camel-gae/src/main/java/org/apache/camel/component/gae/context/GaeDefaultCamelContext.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-gae/src/main/java/org/apache/camel/component/gae/context/GaeDefaultCamelContext.java?rev=880672&view=auto
==============================================================================
--- camel/trunk/components/camel-gae/src/main/java/org/apache/camel/component/gae/context/GaeDefaultCamelContext.java (added)
+++ camel/trunk/components/camel-gae/src/main/java/org/apache/camel/component/gae/context/GaeDefaultCamelContext.java Mon Nov 16 08:45:58 2009
@@ -0,0 +1,29 @@
+/**
+ * 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.gae.context;
+
+import org.apache.camel.impl.DefaultCamelContext;
+
+public class GaeDefaultCamelContext extends DefaultCamelContext {
+
+    @Override
+    protected void doStart() throws Exception {
+        disableJMX(); // JMX not allowed on GAE
+        super.doStart();
+    }
+
+}

Propchange: camel/trunk/components/camel-gae/src/main/java/org/apache/camel/component/gae/context/GaeDefaultCamelContext.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: camel/trunk/components/camel-gae/src/main/java/org/apache/camel/component/gae/context/GaeSpringCamelContext.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-gae/src/main/java/org/apache/camel/component/gae/context/GaeSpringCamelContext.java?rev=880672&view=auto
==============================================================================
--- camel/trunk/components/camel-gae/src/main/java/org/apache/camel/component/gae/context/GaeSpringCamelContext.java (added)
+++ camel/trunk/components/camel-gae/src/main/java/org/apache/camel/component/gae/context/GaeSpringCamelContext.java Mon Nov 16 08:45:58 2009
@@ -0,0 +1,42 @@
+/**
+ * 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.gae.context;
+
+import java.util.List;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.spring.SpringCamelContext;
+
+public class GaeSpringCamelContext extends SpringCamelContext {
+
+    @Override
+    protected void doStart() throws Exception {
+        disableJMX(); // JMX not allowed on GAE
+        super.doStart();
+    }
+
+    public void setRouteBuilders(List<RouteBuilder> routeBuilders) throws Exception {
+        for (RouteBuilder routebuilder : routeBuilders) {
+            addRoutes(routebuilder);
+        }
+    }
+
+    public void setRouteBuilder(RouteBuilder routeBuilder) throws Exception {
+        addRoutes(routeBuilder);
+    }
+    
+}

Propchange: camel/trunk/components/camel-gae/src/main/java/org/apache/camel/component/gae/context/GaeSpringCamelContext.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: camel/trunk/components/camel-gae/src/main/java/org/apache/camel/component/gae/http/GHttpBinding.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-gae/src/main/java/org/apache/camel/component/gae/http/GHttpBinding.java?rev=880672&view=auto
==============================================================================
--- camel/trunk/components/camel-gae/src/main/java/org/apache/camel/component/gae/http/GHttpBinding.java (added)
+++ camel/trunk/components/camel-gae/src/main/java/org/apache/camel/component/gae/http/GHttpBinding.java Mon Nov 16 08:45:58 2009
@@ -0,0 +1,204 @@
+/**
+ * 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.gae.http;
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.zip.GZIPInputStream;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import com.google.appengine.api.urlfetch.HTTPHeader;
+import com.google.appengine.api.urlfetch.HTTPMethod;
+import com.google.appengine.api.urlfetch.HTTPRequest;
+import com.google.appengine.api.urlfetch.HTTPResponse;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Message;
+import org.apache.camel.component.gae.bind.InboundBinding;
+import org.apache.camel.component.gae.bind.OutboundBinding;
+import org.apache.camel.spi.HeaderFilterStrategy;
+import org.apache.camel.util.UnsafeUriCharactersEncoder;
+
+import static org.apache.camel.component.gae.http.GHttpEndpoint.getEndpointUrl;
+import static org.apache.camel.component.http.helper.GZIPHelper.isGzip;
+
+/**
+ * Binds the {@link HTTPRequest}/{@link HTTPResponse} pair of the URL fetch
+ * service to a Camel {@link Exchange}.
+ */
+public class GHttpBinding implements 
+    OutboundBinding <GHttpEndpoint, HTTPRequest, HTTPResponse>, 
+    InboundBinding  <GHttpEndpoint, HttpServletRequest, HttpServletResponse> { 
+    
+    // ----------------------------------------------------------------
+    //  Outbound binding
+    // ----------------------------------------------------------------
+    
+    /**
+     * Reads data from <code>response</code> and writes it to the out-message of
+     * the <code>exchange</code>.
+     * 
+     * @param endpoint
+     * @param exchange
+     * @param response
+     * @return the original <code>exchange</code> instance populated with
+     *         response data.
+     * @throws GHttpException
+     *             if the response code is >= 400 and
+     *             {@link GHttpEndpoint#isThrowExceptionOnFailure()} returns
+     *             <code>true</code>.
+     */
+    public Exchange readResponse(GHttpEndpoint endpoint, Exchange exchange, HTTPResponse response) throws Exception {
+        int responseCode = response.getResponseCode();
+        readResponseHeaders(endpoint, exchange, response);
+        readResponseBody(endpoint, exchange, response);
+        if (responseCode >= 400 && endpoint.isThrowExceptionOnFailure()) {
+            throw new GHttpException(responseCode, 
+                exchange.getOut().getBody(InputStream.class), 
+                exchange.getOut().getHeaders());
+        }
+        return exchange;
+    }
+
+    /**
+     * Reads data from <code>exchange</code> and writes it to a newly created
+     * {@link HTTPRequest} instance. The <code>request</code> parameter is
+     * ignored.
+     * 
+     * @param endpoint
+     * @param exchange
+     * @param request
+     *            ignored.
+     * @return a newly created {@link HTTPRequest} instance containing data from
+     *         <code>exchange</code>.
+     */
+    public HTTPRequest writeRequest(GHttpEndpoint endpoint, Exchange exchange, HTTPRequest request) throws Exception {
+        HTTPRequest answer = new HTTPRequest(
+                getRequestUrl(endpoint, exchange), 
+                getRequestMethod(endpoint, exchange));
+        writeRequestHeaders(endpoint, exchange, answer);
+        writeRequestBody(endpoint, exchange, answer);
+        return answer;
+    }
+    
+    // ----------------------------------------------------------------
+    //  Inbound binding
+    // ----------------------------------------------------------------
+    
+    public Exchange readRequest(GHttpEndpoint endpoint, Exchange exchange, HttpServletRequest request) {
+        readRequestHeaders(endpoint, exchange, request);
+        return exchange;
+    }
+
+    /**
+     * @throws UnsupportedOperationException.
+     */
+    public HttpServletResponse writeResponse(GHttpEndpoint endpoint, Exchange exchange, HttpServletResponse response) {
+        throw new UnsupportedOperationException("gtask responses not supported");
+    }
+
+    // ----------------------------------------------------------------
+    //  Customization points
+    // ----------------------------------------------------------------
+    
+    protected void readResponseHeaders(GHttpEndpoint endpoint, Exchange exchange, HTTPResponse response) {
+        HeaderFilterStrategy strategy = endpoint.getHeaderFilterStrategy();
+        
+        Message in = exchange.getIn();
+        Message out = exchange.getOut();
+        
+        out.setHeaders(in.getHeaders());
+        out.setHeader(Exchange.HTTP_RESPONSE_CODE, response.getResponseCode());
+        
+        String contentType = getResponseHeader("Content-Type", response);
+        if (contentType != null) {
+            out.setHeader(Exchange.CONTENT_TYPE, contentType);
+        }
+        
+        for (HTTPHeader header : response.getHeaders()) {
+            String name = header.getName();
+            String value = header.getValue();
+            if (strategy != null && !strategy.applyFilterToExternalHeaders(name, value, exchange)) {
+                out.setHeader(name, value);
+            }
+        }
+    }
+    
+    protected void readRequestHeaders(GHttpEndpoint endpoint, Exchange exchange, HttpServletRequest request) {
+        // EXPERIMENTAL // TODO: resolve gzip encoding issues
+        exchange.getIn().removeHeader("Accept-Encoding");
+        exchange.getIn().removeHeader("Content-Encoding");
+    }
+    
+    protected void writeRequestHeaders(GHttpEndpoint endpoint, Exchange exchange, HTTPRequest request) {
+        HeaderFilterStrategy strategy = endpoint.getHeaderFilterStrategy();
+        for (String headerName : exchange.getIn().getHeaders().keySet()) {
+            String headerValue = exchange.getIn().getHeader(headerName, String.class);
+            if (strategy != null && !strategy.applyFilterToCamelHeaders(headerName, headerValue, exchange)) {
+                request.addHeader(new HTTPHeader(headerName, headerValue));
+            }
+        }
+    }
+    
+    protected void readResponseBody(GHttpEndpoint endpoint, Exchange exchange, HTTPResponse response) throws Exception {
+        byte[] content = response.getContent();
+        if (content != null) {
+            InputStream stream = new ByteArrayInputStream(content);
+            if (isGzip(getResponseHeader("Content-Encoding", response))) {
+                stream = new GZIPInputStream(stream);
+            }
+            exchange.getOut().setBody(stream);
+        }
+    }
+    
+    protected void writeRequestBody(GHttpEndpoint endpoint, Exchange exchange, HTTPRequest request) {
+        request.setPayload(exchange.getIn().getBody(byte[].class));
+    }
+    
+    protected URL getRequestUrl(GHttpEndpoint endpoint, Exchange exchange) throws Exception {
+        String uri = exchange.getIn().getHeader(Exchange.HTTP_URI, String.class);
+        String query = exchange.getIn().getHeader(Exchange.HTTP_QUERY, String.class);
+        if (uri != null && !endpoint.isBridgeEndpoint()) {
+            return getEndpointUrl(UnsafeUriCharactersEncoder.encode(uri), query);
+        }
+        return getEndpointUrl(endpoint.getEndpointUri(), query);
+    }
+    
+    protected HTTPMethod getRequestMethod(GHttpEndpoint endpoint, Exchange exchange) {
+        String method = (String)exchange.getIn().getHeader(Exchange.HTTP_METHOD);
+        if (method != null) {
+            return HTTPMethod.valueOf(method);
+        } else if (exchange.getIn().getBody() != null) {
+            return HTTPMethod.POST;
+        } else {
+            return HTTPMethod.GET;
+        }
+    }
+    
+    protected String getResponseHeader(String name, HTTPResponse response) {
+        for (HTTPHeader header : response.getHeaders()) {
+            if (header.getName().equalsIgnoreCase(name)) {
+                return header.getValue();
+            }
+        }
+        return null;
+    }
+
+}

Propchange: camel/trunk/components/camel-gae/src/main/java/org/apache/camel/component/gae/http/GHttpBinding.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: camel/trunk/components/camel-gae/src/main/java/org/apache/camel/component/gae/http/GHttpComponent.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-gae/src/main/java/org/apache/camel/component/gae/http/GHttpComponent.java?rev=880672&view=auto
==============================================================================
--- camel/trunk/components/camel-gae/src/main/java/org/apache/camel/component/gae/http/GHttpComponent.java (added)
+++ camel/trunk/components/camel-gae/src/main/java/org/apache/camel/component/gae/http/GHttpComponent.java Mon Nov 16 08:45:58 2009
@@ -0,0 +1,72 @@
+/**
+ * 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.gae.http;
+
+import java.net.URI;
+import java.util.Map;
+
+import com.google.appengine.api.urlfetch.URLFetchService;
+import com.google.appengine.api.urlfetch.URLFetchServiceFactory;
+
+import org.apache.camel.Endpoint;
+import org.apache.camel.component.gae.bind.InboundBinding;
+import org.apache.camel.component.gae.bind.OutboundBinding;
+import org.apache.camel.component.http.HttpClientConfigurer;
+import org.apache.camel.component.servlet.ServletComponent;
+import org.apache.camel.component.servlet.ServletEndpoint;
+import org.apache.commons.httpclient.HttpConnectionManager;
+import org.apache.commons.httpclient.params.HttpClientParams;
+
+/**
+ * The <a href="http://camel.apache.org/todo.html">Google App Engine HTTP
+ * Component</a> supports HTTP-based inbound and outbound communication. Inbound
+ * HTTP communication is realized in terms of the <a
+ * href="http://camel.apache.org/servlet.html"> Servlet Component</a> component.
+ * Outbound HTTP communication uses the URL fetch service of the Google App
+ * Engine.
+ */
+public class GHttpComponent extends ServletComponent {
+
+    @Override
+    @SuppressWarnings("unchecked")
+    protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception {
+        boolean throwException = getAndRemoveParameter(parameters, "throwExceptionOnFailure", Boolean.class, true); 
+        boolean bridgeEndpoint = getAndRemoveParameter(parameters, "bridgeEndpoint", Boolean.class, true); 
+        OutboundBinding outboundBinding = resolveAndRemoveReferenceParameter(
+                parameters, "outboundBindingRef", OutboundBinding.class, new GHttpBinding());
+        InboundBinding inboundBinding = resolveAndRemoveReferenceParameter(
+                parameters, "inboundBindingRef", InboundBinding.class, new GHttpBinding());
+        URLFetchService service = resolveAndRemoveReferenceParameter(
+                parameters, "urlFetchServiceRef", URLFetchService.class, URLFetchServiceFactory.getURLFetchService());
+        GHttpEndpoint endpoint = (GHttpEndpoint)super.createEndpoint(uri, remaining, parameters);
+        endpoint.setThrowExceptionOnFailure(throwException);
+        endpoint.setBridgeEndpoint(bridgeEndpoint);
+        endpoint.setOutboundBinding(outboundBinding);
+        endpoint.setInboundBinding(inboundBinding);
+        endpoint.setUrlFetchService(service);
+        return endpoint;
+    }
+
+    @Override
+    protected ServletEndpoint createServletEndpoint(String endpointUri,
+            ServletComponent component, URI httpUri, HttpClientParams params,
+            HttpConnectionManager httpConnectionManager,
+            HttpClientConfigurer clientConfigurer) throws Exception {
+        return new GHttpEndpoint(endpointUri, component, httpUri, params,
+                httpConnectionManager, clientConfigurer);
+    }
+}

Propchange: camel/trunk/components/camel-gae/src/main/java/org/apache/camel/component/gae/http/GHttpComponent.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: camel/trunk/components/camel-gae/src/main/java/org/apache/camel/component/gae/http/GHttpEndpoint.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-gae/src/main/java/org/apache/camel/component/gae/http/GHttpEndpoint.java?rev=880672&view=auto
==============================================================================
--- camel/trunk/components/camel-gae/src/main/java/org/apache/camel/component/gae/http/GHttpEndpoint.java (added)
+++ camel/trunk/components/camel-gae/src/main/java/org/apache/camel/component/gae/http/GHttpEndpoint.java Mon Nov 16 08:45:58 2009
@@ -0,0 +1,148 @@
+/**
+ * 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.gae.http;
+
+import java.lang.reflect.Proxy;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import com.google.appengine.api.urlfetch.HTTPRequest;
+import com.google.appengine.api.urlfetch.HTTPResponse;
+import com.google.appengine.api.urlfetch.URLFetchService;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Producer;
+import org.apache.camel.component.gae.bind.HttpBindingInvocationHandler;
+import org.apache.camel.component.gae.bind.InboundBinding;
+import org.apache.camel.component.gae.bind.OutboundBinding;
+import org.apache.camel.component.gae.bind.OutboundBindingSupport;
+import org.apache.camel.component.http.HttpBinding;
+import org.apache.camel.component.http.HttpClientConfigurer;
+import org.apache.camel.component.servlet.ServletComponent;
+import org.apache.camel.component.servlet.ServletEndpoint;
+import org.apache.camel.util.URISupport;
+import org.apache.camel.util.UnsafeUriCharactersEncoder;
+import org.apache.commons.httpclient.HttpConnectionManager;
+import org.apache.commons.httpclient.params.HttpClientParams;
+
+/**
+ * Represents a <a href="http://camel.apache.org/todo.html">Google App Engine
+ * HTTP endpoint</a>.
+ */
+public class GHttpEndpoint extends ServletEndpoint implements OutboundBindingSupport<GHttpEndpoint, HTTPRequest, HTTPResponse> {
+
+    public static final String GHTTP_SCHEME = "ghttp";
+    public static final String GHTTPS_SCHEME = "ghttps";
+    
+    public static final String HTTP_SCHEME = "http";
+    public static final String HTTPS_SCHEME = "https";
+    
+    private URLFetchService urlFetchService;
+    
+    private OutboundBinding<GHttpEndpoint, HTTPRequest, HTTPResponse> outboundBinding;
+    private InboundBinding<GHttpEndpoint, HttpServletRequest, HttpServletResponse> inboundBinding;
+    
+    public GHttpEndpoint(String endpointUri, ServletComponent component,
+            URI httpUri, HttpClientParams params,
+            HttpConnectionManager httpConnectionManager,
+            HttpClientConfigurer clientConfigurer) throws URISyntaxException {
+        super(endpointUri, component, httpUri, params, httpConnectionManager, clientConfigurer);
+    }
+
+    /**
+     * Constructs a {@link URL} from an <code>uri</code> and an optional
+     * <code>query</code> string. The encoding strategy follow those of the
+     * Camel HTTP component.
+     * 
+     * @param uri
+     *            must be encoded with
+     *            {@link UnsafeUriCharactersEncoder#encode(String)}.
+     * @param query
+     *            decoded query string. Replaces the query part of
+     *            <code>uri</code> if not <code>null</code>.
+     */
+    @SuppressWarnings("unchecked")
+    static URL getEndpointUrl(String uri, String query) throws Exception {
+        Map<String, Object> parameters = null;
+        URI uriObj = new URI(uri);
+        if (query == null) {
+            parameters = URISupport.parseParameters(uriObj);
+        } else {
+            parameters = URISupport.parseQuery(query);
+        }
+        if (uriObj.getScheme().equals(GHTTPS_SCHEME)) {
+            uriObj = new URI(HTTPS_SCHEME + ":" + uriObj.getRawSchemeSpecificPart());
+        } else { // ghttp or anything else
+            uriObj = new URI(HTTP_SCHEME + ":" + uriObj.getRawSchemeSpecificPart());
+        }
+        return URISupport.createRemainingURI(uriObj, (Map)parameters).toURL();
+    }
+    
+    public URL getEndpointUrl() throws Exception {
+        return getEndpointUrl(getEndpointUri(), null);
+    }
+    
+    public URLFetchService getUrlFetchService() {
+        return urlFetchService;
+    }
+
+    public void setUrlFetchService(URLFetchService urlFetchService) {
+        this.urlFetchService = urlFetchService;
+    }
+
+    public OutboundBinding<GHttpEndpoint, HTTPRequest, HTTPResponse> getOutboundBinding() {
+        return outboundBinding;
+    }
+    
+    public void setOutboundBinding(OutboundBinding<GHttpEndpoint, HTTPRequest, HTTPResponse> outboundBinding) {
+        this.outboundBinding = outboundBinding;
+    }
+    
+    public InboundBinding<GHttpEndpoint, HttpServletRequest, HttpServletResponse> getInboundBinding() {
+        return inboundBinding;
+    }
+
+    public void setInboundBinding(
+            InboundBinding<GHttpEndpoint, HttpServletRequest, HttpServletResponse> inboundBinding) {
+        this.inboundBinding = inboundBinding;
+    }
+
+    /**
+     * Proxies the {@link HttpBinding} returned by {@link super#getBinding()}
+     * with a dynamic proxy. The proxy's invocation handler further delegates to
+     * {@link InboundBinding#readRequest(org.apache.camel.Endpoint, Exchange, Object)}
+     * .
+     * 
+     * @return proxied {@link HttpBinding}.
+     */
+    @Override
+    public HttpBinding getBinding() {
+        return (HttpBinding)Proxy.newProxyInstance(getClass().getClassLoader(), new Class[] {HttpBinding.class}, 
+                new HttpBindingInvocationHandler<GHttpEndpoint, HttpServletRequest, HttpServletResponse>(
+                        this, super.getBinding(), getInboundBinding()));
+    }
+
+    public Producer createProducer() throws Exception {
+        return new GHttpProducer(this);
+    }
+
+}

Propchange: camel/trunk/components/camel-gae/src/main/java/org/apache/camel/component/gae/http/GHttpEndpoint.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: camel/trunk/components/camel-gae/src/main/java/org/apache/camel/component/gae/http/GHttpException.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-gae/src/main/java/org/apache/camel/component/gae/http/GHttpException.java?rev=880672&view=auto
==============================================================================
--- camel/trunk/components/camel-gae/src/main/java/org/apache/camel/component/gae/http/GHttpException.java (added)
+++ camel/trunk/components/camel-gae/src/main/java/org/apache/camel/component/gae/http/GHttpException.java Mon Nov 16 08:45:58 2009
@@ -0,0 +1,53 @@
+/**
+ * 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.gae.http;
+
+import java.io.InputStream;
+import java.util.Map;
+
+import org.apache.camel.CamelException;
+
+/**
+ * Thrown to indicate a response code >=400.
+ */
+public class GHttpException extends CamelException {
+
+    private static final long serialVersionUID = -190965884678800954L;
+
+    private final int responseCode;
+    private final InputStream responseBody;
+    private final Map<String, Object> responseHeaders;
+    
+    public GHttpException(int responseCode, InputStream responseBody, Map<String, Object> responseHeaders) {
+        this.responseCode = responseCode;
+        this.responseBody = responseBody;
+        this.responseHeaders = responseHeaders;
+    }
+
+    public int getResponseCode() {
+        return responseCode;
+    }
+
+    public InputStream getResponseBody() {
+        return responseBody;
+    }
+
+    public Map<String, Object> getResponseHeaders() {
+        return responseHeaders;
+    }  
+    
+}

Propchange: camel/trunk/components/camel-gae/src/main/java/org/apache/camel/component/gae/http/GHttpException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: camel/trunk/components/camel-gae/src/main/java/org/apache/camel/component/gae/http/GHttpProducer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-gae/src/main/java/org/apache/camel/component/gae/http/GHttpProducer.java?rev=880672&view=auto
==============================================================================
--- camel/trunk/components/camel-gae/src/main/java/org/apache/camel/component/gae/http/GHttpProducer.java (added)
+++ camel/trunk/components/camel-gae/src/main/java/org/apache/camel/component/gae/http/GHttpProducer.java Mon Nov 16 08:45:58 2009
@@ -0,0 +1,64 @@
+/**
+ * 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.gae.http;
+
+import com.google.appengine.api.urlfetch.HTTPRequest;
+import com.google.appengine.api.urlfetch.HTTPResponse;
+import com.google.appengine.api.urlfetch.URLFetchService;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.component.gae.bind.OutboundBinding;
+import org.apache.camel.impl.DefaultProducer;
+
+public class GHttpProducer extends DefaultProducer {
+
+    public GHttpProducer(GHttpEndpoint endpoint) {
+        super(endpoint);
+    }
+    
+    @Override
+    public GHttpEndpoint getEndpoint() {
+        return (GHttpEndpoint)super.getEndpoint();
+    }
+    
+    public OutboundBinding<GHttpEndpoint, HTTPRequest, HTTPResponse> getOutboundBinding() {
+        return getEndpoint().getOutboundBinding();
+    }
+    
+    public URLFetchService getUrlFetchService() {
+        return getEndpoint().getUrlFetchService();
+    }
+
+    /**
+     * Invokes the URL fetch service.
+     * 
+     * @param exchange
+     *            contains the request data in the in-message. The result is
+     *            written to the out-message.
+     * @throws GHttpException
+     *             if the response code is >= 400 and
+     *             {@link GHttpEndpoint#isThrowExceptionOnFailure()} returns
+     *             <code>true</code>.
+     * @see GHttpBinding
+     */
+    public void process(Exchange exchange) throws Exception {
+        HTTPRequest request = getOutboundBinding().writeRequest(getEndpoint(), exchange, null);
+        HTTPResponse response = getUrlFetchService().fetch(request);
+        getOutboundBinding().readResponse(getEndpoint(), exchange, response);
+    }
+
+}

Propchange: camel/trunk/components/camel-gae/src/main/java/org/apache/camel/component/gae/http/GHttpProducer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: camel/trunk/components/camel-gae/src/main/java/org/apache/camel/component/gae/mail/GMailBinding.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-gae/src/main/java/org/apache/camel/component/gae/mail/GMailBinding.java?rev=880672&view=auto
==============================================================================
--- camel/trunk/components/camel-gae/src/main/java/org/apache/camel/component/gae/mail/GMailBinding.java (added)
+++ camel/trunk/components/camel-gae/src/main/java/org/apache/camel/component/gae/mail/GMailBinding.java Mon Nov 16 08:45:58 2009
@@ -0,0 +1,98 @@
+/**
+ * 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.gae.mail;
+
+import com.google.appengine.api.mail.MailService.Message;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.component.gae.bind.OutboundBinding;
+
+/**
+ * Binds the {@link Message} of the mail service to a Camel {@link Exchange}.
+ */
+public class GMailBinding implements OutboundBinding<GMailEndpoint, Message, Void> {
+
+    /**
+     * Camel header for setting the mail message subject.
+     */
+    public static final String GMAIL_SUBJECT = "org.apache.camel.component.gae.mail.Subject";
+    
+    /**
+     * Camel header for setting the mail message recipient (list).
+     */
+    public static final String GMAIL_TO = "org.apache.camel.component.gae.mail.To";
+    
+    /**
+     * Reads data from <code>exchange</code> and writes it to a newly created
+     * {@link Message} instance. The <code>request</code> parameter is
+     * ignored.
+     * 
+     * @param endpoint
+     * @param exchange
+     * @param request
+     *            ignored.
+     * @return a newly created {@link Message} instance containing data from
+     *         <code>exchange</code>.
+     */
+    public Message writeRequest(GMailEndpoint endpoint, Exchange exchange, Message request) {
+        Message message = new Message();
+        writeFrom(endpoint, exchange, message);
+        writeTo(endpoint, exchange, message);
+        writeSubject(endpoint, exchange, message);
+        writeBody(endpoint, exchange, message);
+        writeAttachments(endpoint, exchange, message);
+        return message;
+    }
+
+    /**
+     * @throws UnsupportedOperationException.
+     */
+    public Exchange readResponse(GMailEndpoint endpoint, Exchange exchange, Void response) {
+        throw new UnsupportedOperationException("gmail responses not supported");
+    }
+
+    protected void writeFrom(GMailEndpoint endpoint, Exchange exchange, Message request) {
+        request.setSender(endpoint.getSender());
+    }
+    
+    protected void writeTo(GMailEndpoint endpoint, Exchange exchange, Message request) {
+        // TODO: support comma-separated list of receivers
+        String to = (String)exchange.getIn().getHeader(GMAIL_TO);
+        if (to == null) {
+            to = endpoint.getTo();
+        }
+        request.setTo(to);
+    }
+    
+    protected void writeSubject(GMailEndpoint endpoint, Exchange exchange, Message request) {
+        String subject = (String)exchange.getIn().getHeader(GMAIL_SUBJECT);
+        if (subject == null) {
+            subject = endpoint.getSubject();
+        }
+        request.setSubject(subject);
+    }
+    
+    protected void writeBody(GMailEndpoint endpoint, Exchange exchange, Message request) {
+        // TODO: allow message header or endpoint uri to configure character encoding
+        request.setTextBody(exchange.getIn().getBody(String.class));
+    }
+    
+    protected void writeAttachments(GMailEndpoint endpoint, Exchange exchange, Message request) {
+        // TODO: support attachments
+    }
+    
+}

Propchange: camel/trunk/components/camel-gae/src/main/java/org/apache/camel/component/gae/mail/GMailBinding.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: camel/trunk/components/camel-gae/src/main/java/org/apache/camel/component/gae/mail/GMailComponent.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-gae/src/main/java/org/apache/camel/component/gae/mail/GMailComponent.java?rev=880672&view=auto
==============================================================================
--- camel/trunk/components/camel-gae/src/main/java/org/apache/camel/component/gae/mail/GMailComponent.java (added)
+++ camel/trunk/components/camel-gae/src/main/java/org/apache/camel/component/gae/mail/GMailComponent.java Mon Nov 16 08:45:58 2009
@@ -0,0 +1,48 @@
+/**
+ * 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.gae.mail;
+
+import java.util.Map;
+
+import com.google.appengine.api.mail.MailService;
+import com.google.appengine.api.mail.MailServiceFactory;
+
+import org.apache.camel.Endpoint;
+import org.apache.camel.component.gae.bind.OutboundBinding;
+import org.apache.camel.impl.DefaultComponent;
+
+/**
+ * The <a href="http://camel.apache.org/todo.html">Google App Engine Mail
+ * Component</a> supports outbound mail communication. It makes use of the mail
+ * service provided by Google App Engine.
+ */
+public class GMailComponent extends DefaultComponent {
+
+    @Override
+    @SuppressWarnings("unchecked")
+    protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception {
+        OutboundBinding binding = resolveAndRemoveReferenceParameter(
+                parameters, "outboundBindingRef", OutboundBinding.class, new GMailBinding());
+        MailService service = resolveAndRemoveReferenceParameter(
+                parameters, "mailServiceRef", MailService.class, MailServiceFactory.getMailService());
+        GMailEndpoint endpoint = new GMailEndpoint(uri, remaining);
+        endpoint.setOutboundBinding(binding);
+        endpoint.setMailService(service);
+        return endpoint;
+    }
+
+}

Propchange: camel/trunk/components/camel-gae/src/main/java/org/apache/camel/component/gae/mail/GMailComponent.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: camel/trunk/components/camel-gae/src/main/java/org/apache/camel/component/gae/mail/GMailEndpoint.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-gae/src/main/java/org/apache/camel/component/gae/mail/GMailEndpoint.java?rev=880672&view=auto
==============================================================================
--- camel/trunk/components/camel-gae/src/main/java/org/apache/camel/component/gae/mail/GMailEndpoint.java (added)
+++ camel/trunk/components/camel-gae/src/main/java/org/apache/camel/component/gae/mail/GMailEndpoint.java Mon Nov 16 08:45:58 2009
@@ -0,0 +1,97 @@
+/**
+ * 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.gae.mail;
+
+import com.google.appengine.api.mail.MailService;
+import com.google.appengine.api.mail.MailService.Message;
+
+import org.apache.camel.Consumer;
+import org.apache.camel.Processor;
+import org.apache.camel.Producer;
+import org.apache.camel.component.gae.bind.OutboundBinding;
+import org.apache.camel.component.gae.bind.OutboundBindingSupport;
+import org.apache.camel.impl.DefaultEndpoint;
+
+/**
+ * Represents a <a href="http://camel.apache.org/todo.html">Google App Engine Mail endpoint</a>.
+ */
+public class GMailEndpoint extends DefaultEndpoint implements OutboundBindingSupport<GMailEndpoint, Message, Void> {
+
+    private OutboundBinding<GMailEndpoint, Message, Void> outboundBinding;
+    
+    private MailService mailService;
+    
+    private String sender;
+    
+    private String subject;
+    
+    private String to;
+    
+    public GMailEndpoint(String endpointUri, String sender) {
+        super(endpointUri);
+        this.sender = sender;
+    }
+    
+    public OutboundBinding<GMailEndpoint, Message, Void> getOutboundBinding() {
+        return outboundBinding;
+    }
+
+    public void setOutboundBinding(OutboundBinding<GMailEndpoint, Message, Void> outboundBinding) {
+        this.outboundBinding = outboundBinding;
+    }
+    
+    public String getSender() {
+        return sender;
+    }
+    
+    public MailService getMailService() {
+        return mailService;
+    }
+
+    public void setMailService(MailService mailService) {
+        this.mailService = mailService;
+    }
+
+    public String getSubject() {
+        return subject;
+    }
+
+    public void setSubject(String subject) {
+        this.subject = subject;
+    }
+
+    public String getTo() {
+        return to;
+    }
+
+    public void setTo(String to) {
+        this.to = to;
+    }
+
+    public Consumer createConsumer(Processor processor) throws Exception {
+        throw new UnsupportedOperationException("consumption from gmail endpoint not supported");
+    }
+
+    public Producer createProducer() throws Exception {
+        return new GMailProducer(this);
+    }
+
+    public boolean isSingleton() {
+        return true;
+    }
+
+}

Propchange: camel/trunk/components/camel-gae/src/main/java/org/apache/camel/component/gae/mail/GMailEndpoint.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: camel/trunk/components/camel-gae/src/main/java/org/apache/camel/component/gae/mail/GMailProducer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-gae/src/main/java/org/apache/camel/component/gae/mail/GMailProducer.java?rev=880672&view=auto
==============================================================================
--- camel/trunk/components/camel-gae/src/main/java/org/apache/camel/component/gae/mail/GMailProducer.java (added)
+++ camel/trunk/components/camel-gae/src/main/java/org/apache/camel/component/gae/mail/GMailProducer.java Mon Nov 16 08:45:58 2009
@@ -0,0 +1,56 @@
+/**
+ * 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.gae.mail;
+
+import com.google.appengine.api.mail.MailService;
+import com.google.appengine.api.mail.MailService.Message;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.component.gae.bind.OutboundBinding;
+import org.apache.camel.impl.DefaultProducer;
+
+public class GMailProducer extends DefaultProducer {
+
+    public GMailProducer(GMailEndpoint endpoint) {
+        super(endpoint);
+    }
+
+    @Override
+    public GMailEndpoint getEndpoint() {
+        return (GMailEndpoint)super.getEndpoint();
+    }
+    
+    public OutboundBinding<GMailEndpoint, Message, Void> getOutboundBinding() {
+        return getEndpoint().getOutboundBinding();
+    }
+    
+    public MailService getMailService() {
+        return getEndpoint().getMailService();
+    }
+
+    /**
+     * Invokes the mail service.
+     * 
+     * @param exchange
+     *            contains the mail data in the in-message.
+     * @see GMailBinding
+     */
+    public void process(Exchange exchange) throws Exception {
+        getMailService().send(getOutboundBinding().writeRequest(getEndpoint(), exchange, null));
+    }
+
+}

Propchange: camel/trunk/components/camel-gae/src/main/java/org/apache/camel/component/gae/mail/GMailProducer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: camel/trunk/components/camel-gae/src/main/java/org/apache/camel/component/gae/task/GTaskBinding.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-gae/src/main/java/org/apache/camel/component/gae/task/GTaskBinding.java?rev=880672&view=auto
==============================================================================
--- camel/trunk/components/camel-gae/src/main/java/org/apache/camel/component/gae/task/GTaskBinding.java (added)
+++ camel/trunk/components/camel-gae/src/main/java/org/apache/camel/component/gae/task/GTaskBinding.java Mon Nov 16 08:45:58 2009
@@ -0,0 +1,167 @@
+/**
+ * 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.gae.task;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import com.google.appengine.api.labs.taskqueue.TaskOptions;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Message;
+import org.apache.camel.component.gae.bind.InboundBinding;
+import org.apache.camel.component.gae.bind.OutboundBinding;
+import org.apache.camel.component.http.DefaultHttpBinding;
+import org.apache.camel.component.http.HttpMessage;
+import org.apache.camel.spi.HeaderFilterStrategy;
+
+/**
+ * Binds the {@link TaskOptions} of the task queueing service to a Camel
+ * {@link Exchange} for outbound communication. For inbound communication a
+ * {@link HttpMessage} is bound to {@link Exchange}.
+ */
+public class GTaskBinding implements 
+    OutboundBinding <GTaskEndpoint, TaskOptions, Void>,
+    InboundBinding  <GTaskEndpoint, HttpServletRequest, HttpServletResponse> { 
+
+    /**
+     * Camel header name corresponding to <code>X-AppEngine-QueueName</code>
+     * header created by task queueing service.
+     */
+    public static final String GTASK_QUEUE_NAME = "org.apache.camel.component.gae.task.QueueName";
+
+    /**
+     * Camel header name corresponding to <code>X-AppEngine-TaskName</code>
+     * header created by task queueing service.
+     */
+    public static final String GTASK_TASK_NAME = "org.apache.camel.component.gae.task.TaskName";
+    
+    /**
+     * Camel header name corresponding to <code>X-AppEngine-TaskRetryCount</code>
+     * header created by task queueing service.
+     */
+    public static final String GTASK_RETRY_COUNT = "org.apache.camel.component.gae.task.RetryCount";
+
+    static final String GAE_QUEUE_NAME = "X-AppEngine-QueueName";
+    static final String GAE_TASK_NAME = "X-AppEngine-TaskName";
+    static final String GAE_RETRY_COUNT = "X-AppEngine-TaskRetryCount";
+    
+    // ----------------------------------------------------------------
+    //  Outbound binding
+    // ----------------------------------------------------------------
+    
+    /**
+     * Reads data from <code>exchange</code> and writes it to a newly created
+     * {@link TaskOptions} instance. The <code>request</code> parameter is
+     * ignored.
+     * 
+     * @param endpoint
+     * @param exchange
+     * @param request
+     *            ignored.
+     * @return a newly created {@link TaskOptions} instance containing data from
+     *         <code>exchange</code>.
+     */
+    public TaskOptions writeRequest(GTaskEndpoint endpoint, Exchange exchange, TaskOptions request) {
+        TaskOptions answer = TaskOptions.Builder.url(getWorkerRoot(endpoint) + endpoint.getPath());
+        writeRequestHeaders(endpoint, exchange, answer);
+        writeRequestBody(endpoint, exchange, answer);
+        // TODO: consider TaskOptions method (POST, GET, ...)
+        return answer;
+    }
+    
+    /**
+     * @throws UnsupportedOperationException.
+     */
+    public Exchange readResponse(GTaskEndpoint endpoint, Exchange exchange, Void response) {
+        throw new UnsupportedOperationException("gtask responses not supported");
+    }
+
+    // ----------------------------------------------------------------
+    //  Inbound binding
+    // ----------------------------------------------------------------
+    
+    /**
+     * Replaces the task service-specific headers (<code>X-AppEngine-*</code>)
+     * with Camel-specific headers.
+     * 
+     * @see GTaskBinding#GTASK_QUEUE_NAME
+     * @see GTaskBinding#GTASK_TASK_NAME
+     * @see GTaskBinding#GTASK_RETRY_COUNT
+     * @see DefaultHttpBinding#readRequest(HttpServletRequest, HttpMessage)
+     */
+    public Exchange readRequest(GTaskEndpoint endpoint, Exchange exchange, HttpServletRequest request) {
+        readRequestHeaders(endpoint, exchange, request);
+        return exchange;
+    }
+
+    /**
+     * @throws UnsupportedOperationException.
+     */
+    public HttpServletResponse writeResponse(GTaskEndpoint endpoint, Exchange exchange, HttpServletResponse response) {
+        throw new UnsupportedOperationException("gtask responses not supported");
+    }
+
+    // ----------------------------------------------------------------
+    //  Customization points
+    // ----------------------------------------------------------------
+    
+    protected void writeRequestHeaders(GTaskEndpoint endpoint, Exchange exchange, TaskOptions request) {
+        HeaderFilterStrategy strategy = endpoint.getHeaderFilterStrategy();
+        for (String headerName : exchange.getIn().getHeaders().keySet()) {
+            String headerValue = exchange.getIn().getHeader(headerName, String.class);
+            if (strategy != null && !strategy.applyFilterToCamelHeaders(headerName, headerValue, exchange)) {
+                request.header(headerName, headerValue);
+            }
+        }
+    }
+
+    protected void readRequestHeaders(GTaskEndpoint endpoint, Exchange exchange, HttpServletRequest request) {
+        Message message = exchange.getIn();
+        String key = GAE_QUEUE_NAME;
+        Object val = message.getHeader(key);
+        if (val != null) {
+            message.getHeaders().put(GTASK_QUEUE_NAME, val);
+            message.getHeaders().remove(key);
+        }
+        key = GAE_TASK_NAME;
+        val = message.getHeader(key);
+        if (val != null) {
+            message.getHeaders().put(GTASK_TASK_NAME, val);
+            message.getHeaders().remove(key);
+        }
+        key = GAE_RETRY_COUNT;
+        val = message.getHeader(key);
+        if (val != null) {
+            message.getHeaders().put(GTASK_RETRY_COUNT, Integer.parseInt(val.toString()));
+            message.getHeaders().remove(key);
+        }
+        // EXPERIMENTAL // TODO: resolve gzip encoding issues
+        exchange.getIn().removeHeader("Accept-Encoding");
+        exchange.getIn().removeHeader("Content-Encoding");
+    }
+    
+    protected void writeRequestBody(GTaskEndpoint endpoint, Exchange exchange, TaskOptions request) {
+        // TODO: allow message header or endpoint uri to configure character encoding and content type
+        request.payload(exchange.getIn().getBody(byte[].class), "application/octet-stream");
+    }
+    
+    protected String getWorkerRoot(GTaskEndpoint endpoint) {
+        return "/" + endpoint.getWorkerRoot();
+    }
+
+}

Propchange: camel/trunk/components/camel-gae/src/main/java/org/apache/camel/component/gae/task/GTaskBinding.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: camel/trunk/components/camel-gae/src/main/java/org/apache/camel/component/gae/task/GTaskComponent.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-gae/src/main/java/org/apache/camel/component/gae/task/GTaskComponent.java?rev=880672&view=auto
==============================================================================
--- camel/trunk/components/camel-gae/src/main/java/org/apache/camel/component/gae/task/GTaskComponent.java (added)
+++ camel/trunk/components/camel-gae/src/main/java/org/apache/camel/component/gae/task/GTaskComponent.java Mon Nov 16 08:45:58 2009
@@ -0,0 +1,76 @@
+/**
+ * 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.gae.task;
+
+import java.net.URI;
+import java.util.Map;
+
+import com.google.appengine.api.labs.taskqueue.Queue;
+import com.google.appengine.api.labs.taskqueue.QueueFactory;
+
+import org.apache.camel.Endpoint;
+import org.apache.camel.component.gae.bind.InboundBinding;
+import org.apache.camel.component.gae.bind.OutboundBinding;
+import org.apache.camel.component.http.HttpClientConfigurer;
+import org.apache.camel.component.servlet.ServletComponent;
+import org.apache.camel.component.servlet.ServletEndpoint;
+import org.apache.commons.httpclient.HttpConnectionManager;
+import org.apache.commons.httpclient.params.HttpClientParams;
+
+/**
+ * The <a href="http://camel.apache.org/todo.html">Google App Engine Task
+ * Queueing Component</a> supports asynchronous message processing. Outbound
+ * communication uses the task queueing service of the Google App Engine.
+ * Inbound communication is realized in terms of the <a
+ * href="http://camel.apache.org/servlet.html"> Servlet Component</a> component
+ * for installing a web hook.
+ */
+public class GTaskComponent extends ServletComponent {
+
+    @Override
+    @SuppressWarnings("unchecked")
+    protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception {
+        String workerRoot = getAndRemoveParameter(
+                parameters, "workerRoot", String.class, "worker");
+        OutboundBinding outboundBinding = resolveAndRemoveReferenceParameter(
+                parameters, "outboundBindingRef", OutboundBinding.class, new GTaskBinding());
+        InboundBinding inboundBinding = resolveAndRemoveReferenceParameter(
+                parameters, "inboundBindingRef", InboundBinding.class, new GTaskBinding());
+        Queue queue = resolveAndRemoveReferenceParameter(
+                parameters, "queueRef", Queue.class, QueueFactory.getQueue(remaining));
+        GTaskEndpointInfo info = new GTaskEndpointInfo(uri, remaining);
+        GTaskEndpoint endpoint = (GTaskEndpoint)super.createEndpoint(
+            info.getCanonicalUri(),
+            info.getCanonicalUriPath(),
+            parameters);
+        endpoint.setWorkerRoot(workerRoot);
+        endpoint.setOutboundBinding(outboundBinding);
+        endpoint.setInboundBinding(inboundBinding);
+        endpoint.setQueue(queue);        
+        return endpoint;
+    }
+
+    @Override
+    protected ServletEndpoint createServletEndpoint(String endpointUri,
+            ServletComponent component, URI httpUri, HttpClientParams params,
+            HttpConnectionManager httpConnectionManager,
+            HttpClientConfigurer clientConfigurer) throws Exception {
+        return new GTaskEndpoint(endpointUri, component, httpUri, params,
+                httpConnectionManager, clientConfigurer);
+    }
+
+}

Propchange: camel/trunk/components/camel-gae/src/main/java/org/apache/camel/component/gae/task/GTaskComponent.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message