activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jstrac...@apache.org
Subject svn commit: r521286 - in /activemq/camel/trunk: ./ camel-http/ camel-http/src/ camel-http/src/main/ camel-http/src/main/java/ camel-http/src/main/java/org/ camel-http/src/main/java/org/apache/ camel-http/src/main/java/org/apache/camel/ camel-http/src/m...
Date Thu, 22 Mar 2007 14:23:37 GMT
Author: jstrachan
Date: Thu Mar 22 07:23:34 2007
New Revision: 521286

URL: http://svn.apache.org/viewvc?view=rev&rev=521286
Log:
a very rough cut of a http component for camel

Added:
    activemq/camel/trunk/camel-http/
    activemq/camel/trunk/camel-http/pom.xml   (with props)
    activemq/camel/trunk/camel-http/src/
    activemq/camel/trunk/camel-http/src/main/
    activemq/camel/trunk/camel-http/src/main/java/
    activemq/camel/trunk/camel-http/src/main/java/org/
    activemq/camel/trunk/camel-http/src/main/java/org/apache/
    activemq/camel/trunk/camel-http/src/main/java/org/apache/camel/
    activemq/camel/trunk/camel-http/src/main/java/org/apache/camel/component/
    activemq/camel/trunk/camel-http/src/main/java/org/apache/camel/component/http/
    activemq/camel/trunk/camel-http/src/main/java/org/apache/camel/component/http/CamelServlet.java
  (with props)
    activemq/camel/trunk/camel-http/src/main/java/org/apache/camel/component/http/HttpBinding.java
  (with props)
    activemq/camel/trunk/camel-http/src/main/java/org/apache/camel/component/http/HttpEndpoint.java
  (with props)
    activemq/camel/trunk/camel-http/src/main/java/org/apache/camel/component/http/HttpExchange.java
  (with props)
    activemq/camel/trunk/camel-http/src/main/java/org/apache/camel/component/http/HttpMessage.java
  (with props)
    activemq/camel/trunk/camel-http/src/main/resources/
    activemq/camel/trunk/camel-http/src/main/resources/META-INF/
    activemq/camel/trunk/camel-http/src/main/resources/META-INF/services/
    activemq/camel/trunk/camel-http/src/main/resources/META-INF/services/org/
    activemq/camel/trunk/camel-http/src/main/resources/META-INF/services/org/apache/
    activemq/camel/trunk/camel-http/src/main/resources/META-INF/services/org/apache/camel/
    activemq/camel/trunk/camel-http/src/main/resources/META-INF/services/org/apache/camel/EndpointResolver/
    activemq/camel/trunk/camel-http/src/main/resources/META-INF/services/org/apache/camel/EndpointResolver/http
    activemq/camel/trunk/camel-http/src/test/
    activemq/camel/trunk/camel-http/src/test/java/
    activemq/camel/trunk/camel-http/src/test/java/org/
    activemq/camel/trunk/camel-http/src/test/java/org/apache/
    activemq/camel/trunk/camel-http/src/test/java/org/apache/camel/
    activemq/camel/trunk/camel-http/src/test/java/org/apache/camel/component/
    activemq/camel/trunk/camel-http/src/test/java/org/apache/camel/component/http/
    activemq/camel/trunk/camel-http/src/test/resources/
Modified:
    activemq/camel/trunk/pom.xml

Added: activemq/camel/trunk/camel-http/pom.xml
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-http/pom.xml?view=auto&rev=521286
==============================================================================
--- activemq/camel/trunk/camel-http/pom.xml (added)
+++ activemq/camel/trunk/camel-http/pom.xml Thu Mar 22 07:23:34 2007
@@ -0,0 +1,66 @@
+<?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 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0">
+
+  <modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <groupId>org.apache.camel</groupId>
+    <artifactId>camel-parent</artifactId>
+    <version>1.0-SNAPSHOT</version>
+  </parent>
+
+  <artifactId>camel-http</artifactId>
+  <name>Camel :: HTTP</name>
+  <description>Camel HTTP support</description>
+
+  <dependencies>
+
+    <dependency>
+      <groupId>org.apache.camel</groupId>
+      <artifactId>camel-core</artifactId>
+      <version>1.0-SNAPSHOT</version>
+    </dependency>
+
+    <dependency>
+      <groupId>commons-logging</groupId>
+      <artifactId>commons-logging</artifactId>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.geronimo.specs</groupId>
+      <artifactId>geronimo-servlet_2.4_spec</artifactId>
+    </dependency>
+
+    <dependency>
+      <groupId>org.mortbay.jetty</groupId>
+      <artifactId>jetty</artifactId>
+      <optional>true</optional>
+    </dependency>
+
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+
+</project>

Propchange: activemq/camel/trunk/camel-http/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: activemq/camel/trunk/camel-http/pom.xml
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: activemq/camel/trunk/camel-http/pom.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: activemq/camel/trunk/camel-http/src/main/java/org/apache/camel/component/http/CamelServlet.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-http/src/main/java/org/apache/camel/component/http/CamelServlet.java?view=auto&rev=521286
==============================================================================
--- activemq/camel/trunk/camel-http/src/main/java/org/apache/camel/component/http/CamelServlet.java
(added)
+++ activemq/camel/trunk/camel-http/src/main/java/org/apache/camel/component/http/CamelServlet.java
Thu Mar 22 07:23:34 2007
@@ -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.http;
+
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.ServletException;
+import java.io.IOException;
+
+/**
+ * @version $Revision$
+ */
+public class CamelServlet extends HttpServlet {
+    private HttpEndpoint endpoint;
+
+    public CamelServlet() {
+    }
+
+    public CamelServlet(HttpEndpoint endpoint) {
+        this.endpoint = endpoint;
+    }
+
+    @Override
+    protected void service(HttpServletRequest request, HttpServletResponse response) throws
ServletException, IOException {
+        HttpEndpoint endpoint = resolveEndpoint(request, response);
+        if (endpoint == null) {
+            throw new ServletException("No endpoint found for request: " + request.getRequestURI());
+        }
+
+        HttpExchange exchange = endpoint.createExchange(request, response);
+        endpoint.onExchange(exchange);
+
+        // now lets output to the response
+        endpoint.getBinding().writeResponse(exchange);
+    }
+
+    protected HttpEndpoint resolveEndpoint(HttpServletRequest request, HttpServletResponse
response) {
+        return endpoint;
+    }
+}

Propchange: activemq/camel/trunk/camel-http/src/main/java/org/apache/camel/component/http/CamelServlet.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: activemq/camel/trunk/camel-http/src/main/java/org/apache/camel/component/http/CamelServlet.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: activemq/camel/trunk/camel-http/src/main/java/org/apache/camel/component/http/CamelServlet.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: activemq/camel/trunk/camel-http/src/main/java/org/apache/camel/component/http/HttpBinding.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-http/src/main/java/org/apache/camel/component/http/HttpBinding.java?view=auto&rev=521286
==============================================================================
--- activemq/camel/trunk/camel-http/src/main/java/org/apache/camel/component/http/HttpBinding.java
(added)
+++ activemq/camel/trunk/camel-http/src/main/java/org/apache/camel/component/http/HttpBinding.java
Thu Mar 22 07:23:34 2007
@@ -0,0 +1,31 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.http;
+
+/**
+ * @version $Revision$
+ */
+public class HttpBinding {
+
+    /**
+     * Writes the  exchange to the servlet response
+     */
+    public void writeResponse(HttpExchange exchange) {
+        /** TODO */
+    }
+}

Propchange: activemq/camel/trunk/camel-http/src/main/java/org/apache/camel/component/http/HttpBinding.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: activemq/camel/trunk/camel-http/src/main/java/org/apache/camel/component/http/HttpBinding.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: activemq/camel/trunk/camel-http/src/main/java/org/apache/camel/component/http/HttpBinding.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: activemq/camel/trunk/camel-http/src/main/java/org/apache/camel/component/http/HttpEndpoint.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-http/src/main/java/org/apache/camel/component/http/HttpEndpoint.java?view=auto&rev=521286
==============================================================================
--- activemq/camel/trunk/camel-http/src/main/java/org/apache/camel/component/http/HttpEndpoint.java
(added)
+++ activemq/camel/trunk/camel-http/src/main/java/org/apache/camel/component/http/HttpEndpoint.java
Thu Mar 22 07:23:34 2007
@@ -0,0 +1,70 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.http;
+
+import org.apache.camel.impl.DefaultEndpoint;
+import org.apache.camel.Processor;
+import org.apache.camel.CamelContext;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ * Represents a HTTP based Endpoint
+ *
+ * @version $Revision$
+ */
+public class HttpEndpoint extends DefaultEndpoint<HttpExchange> {
+
+    private HttpBinding binding;
+
+    protected HttpEndpoint(String uri, CamelContext camelContext) {
+        super(uri, camelContext);
+    }
+
+    public void onExchange(HttpExchange exchange) {
+        Processor<HttpExchange> processor = getInboundProcessor();
+        if (processor != null) {
+            // lets route straight to our processor
+            processor.onExchange(exchange);
+        }
+        else {
+            // we need an external HTTP client such as commons-httpclient
+            // TODO
+        }
+    }
+
+    public HttpExchange createExchange() {
+        return new HttpExchange(getContext());
+    }
+
+    public HttpExchange createExchange(HttpServletRequest request, HttpServletResponse response)
{
+        return new HttpExchange(getContext(), request, response);
+    }
+
+    public HttpBinding getBinding() {
+        if (binding == null) {
+            binding = new HttpBinding();
+        }
+        return binding;
+    }
+
+    public void setBinding(HttpBinding binding) {
+        this.binding = binding;
+    }
+}

Propchange: activemq/camel/trunk/camel-http/src/main/java/org/apache/camel/component/http/HttpEndpoint.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: activemq/camel/trunk/camel-http/src/main/java/org/apache/camel/component/http/HttpEndpoint.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: activemq/camel/trunk/camel-http/src/main/java/org/apache/camel/component/http/HttpEndpoint.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: activemq/camel/trunk/camel-http/src/main/java/org/apache/camel/component/http/HttpExchange.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-http/src/main/java/org/apache/camel/component/http/HttpExchange.java?view=auto&rev=521286
==============================================================================
--- activemq/camel/trunk/camel-http/src/main/java/org/apache/camel/component/http/HttpExchange.java
(added)
+++ activemq/camel/trunk/camel-http/src/main/java/org/apache/camel/component/http/HttpExchange.java
Thu Mar 22 07:23:34 2007
@@ -0,0 +1,63 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.http;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.impl.DefaultExchange;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ * Represents a HTTP exchange
+ *
+ * @version $Revision$
+ */
+public class HttpExchange extends DefaultExchange {
+    private HttpServletRequest request;
+    private HttpServletResponse response;
+
+    public HttpExchange(CamelContext context) {
+        super(context);
+    }
+
+    public HttpExchange(CamelContext context, HttpServletRequest request, HttpServletResponse
response) {
+        super(context);
+        this.request = request;
+        this.response = response;
+        setIn(new HttpMessage(request));
+    }
+
+    /**
+     * Returns the underlying Servlet request for inbound HTTP requests
+     *
+     * @return the underlying Servlet request for inbound HTTP requests
+     */
+    public HttpServletRequest getRequest() {
+        return request;
+    }
+
+    /**
+     * Returns the underlying Servlet response for inbound HTTP requests
+     *
+     * @return the underlying Servlet response for inbound HTTP requests
+     */
+    public HttpServletResponse getResponse() {
+        return response;
+    }
+}

Propchange: activemq/camel/trunk/camel-http/src/main/java/org/apache/camel/component/http/HttpExchange.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: activemq/camel/trunk/camel-http/src/main/java/org/apache/camel/component/http/HttpExchange.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: activemq/camel/trunk/camel-http/src/main/java/org/apache/camel/component/http/HttpExchange.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: activemq/camel/trunk/camel-http/src/main/java/org/apache/camel/component/http/HttpMessage.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-http/src/main/java/org/apache/camel/component/http/HttpMessage.java?view=auto&rev=521286
==============================================================================
--- activemq/camel/trunk/camel-http/src/main/java/org/apache/camel/component/http/HttpMessage.java
(added)
+++ activemq/camel/trunk/camel-http/src/main/java/org/apache/camel/component/http/HttpMessage.java
Thu Mar 22 07:23:34 2007
@@ -0,0 +1,47 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.http;
+
+import org.apache.camel.impl.DefaultMessage;
+
+import javax.servlet.http.HttpServletRequest;
+import java.util.Map;
+
+/**
+ * @version $Revision$
+ */
+public class HttpMessage extends DefaultMessage {
+    private HttpServletRequest request;
+
+    public HttpMessage() {
+    }
+
+    public HttpMessage(HttpServletRequest request) {
+        this.request = request;
+    }
+
+    @Override
+    protected Object createBody() {
+        return super.createBody();    /** TODO */
+    }
+
+    @Override
+    protected Map<String, Object> createHeaders() {
+        return super.createHeaders();    /** TODO */
+    }
+}

Propchange: activemq/camel/trunk/camel-http/src/main/java/org/apache/camel/component/http/HttpMessage.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: activemq/camel/trunk/camel-http/src/main/java/org/apache/camel/component/http/HttpMessage.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: activemq/camel/trunk/camel-http/src/main/java/org/apache/camel/component/http/HttpMessage.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: activemq/camel/trunk/camel-http/src/main/resources/META-INF/services/org/apache/camel/EndpointResolver/http
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-http/src/main/resources/META-INF/services/org/apache/camel/EndpointResolver/http?view=auto&rev=521286
==============================================================================
--- activemq/camel/trunk/camel-http/src/main/resources/META-INF/services/org/apache/camel/EndpointResolver/http
(added)
+++ activemq/camel/trunk/camel-http/src/main/resources/META-INF/services/org/apache/camel/EndpointResolver/http
Thu Mar 22 07:23:34 2007
@@ -0,0 +1 @@
+class=org.apache.camel.component.http.HttpEndpointResolver

Modified: activemq/camel/trunk/pom.xml
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/pom.xml?view=diff&rev=521286&r1=521285&r2=521286
==============================================================================
--- activemq/camel/trunk/pom.xml (original)
+++ activemq/camel/trunk/pom.xml Thu Mar 22 07:23:34 2007
@@ -108,6 +108,7 @@
 
   <modules>
     <module>camel-core</module>
+    <module>camel-http</module>
     <module>camel-jms</module>
     <module>camel-jbi</module>
     <module>camel-mina</module>



Mime
View raw message