Return-Path: Delivered-To: apmail-activemq-commits-archive@www.apache.org Received: (qmail 308 invoked from network); 22 Mar 2007 14:24:15 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 22 Mar 2007 14:24:15 -0000 Received: (qmail 92022 invoked by uid 500); 22 Mar 2007 14:24:11 -0000 Delivered-To: apmail-activemq-commits-archive@activemq.apache.org Received: (qmail 91965 invoked by uid 500); 22 Mar 2007 14:24:10 -0000 Mailing-List: contact commits-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@activemq.apache.org Delivered-To: mailing list commits@activemq.apache.org Received: (qmail 91753 invoked by uid 99); 22 Mar 2007 14:24:09 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 22 Mar 2007 07:24:09 -0700 X-ASF-Spam-Status: No, hits=-99.5 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 22 Mar 2007 07:23:58 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id 159591A9838; Thu, 22 Mar 2007 07:23:38 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: commits@activemq.apache.org From: jstrachan@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20070322142338.159591A9838@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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 @@ + + + + + + + 4.0.0 + + + org.apache.camel + camel-parent + 1.0-SNAPSHOT + + + camel-http + Camel :: HTTP + Camel HTTP support + + + + + org.apache.camel + camel-core + 1.0-SNAPSHOT + + + + commons-logging + commons-logging + + + + org.apache.geronimo.specs + geronimo-servlet_2.4_spec + + + + org.mortbay.jetty + jetty + true + + + + junit + junit + test + + + + 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 { + + private HttpBinding binding; + + protected HttpEndpoint(String uri, CamelContext camelContext) { + super(uri, camelContext); + } + + public void onExchange(HttpExchange exchange) { + Processor 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 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 @@ camel-core + camel-http camel-jms camel-jbi camel-mina