You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by gn...@apache.org on 2007/09/12 09:29:22 UTC
svn commit: r574819 [1/2] - in /activemq/camel/trunk/components: ./
camel-jhc/ camel-jhc/src/ camel-jhc/src/main/ camel-jhc/src/main/java/
camel-jhc/src/main/java/org/ camel-jhc/src/main/java/org/apache/
camel-jhc/src/main/java/org/apache/camel/ camel-...
Author: gnodet
Date: Wed Sep 12 00:29:20 2007
New Revision: 574819
URL: http://svn.apache.org/viewvc?rev=574819&view=rev
Log:
CAMEL-146: Asynchronous HTTP component
Added:
activemq/camel/trunk/components/camel-jhc/
activemq/camel/trunk/components/camel-jhc/pom.xml
activemq/camel/trunk/components/camel-jhc/src/
activemq/camel/trunk/components/camel-jhc/src/main/
activemq/camel/trunk/components/camel-jhc/src/main/java/
activemq/camel/trunk/components/camel-jhc/src/main/java/org/
activemq/camel/trunk/components/camel-jhc/src/main/java/org/apache/
activemq/camel/trunk/components/camel-jhc/src/main/java/org/apache/camel/
activemq/camel/trunk/components/camel-jhc/src/main/java/org/apache/camel/component/
activemq/camel/trunk/components/camel-jhc/src/main/java/org/apache/camel/component/jhc/
activemq/camel/trunk/components/camel-jhc/src/main/java/org/apache/camel/component/jhc/AsyncBufferingHttpServiceHandler.java
activemq/camel/trunk/components/camel-jhc/src/main/java/org/apache/camel/component/jhc/BufferingHttpServiceHandler.java
activemq/camel/trunk/components/camel-jhc/src/main/java/org/apache/camel/component/jhc/DefaultListeningIOReactor.java
activemq/camel/trunk/components/camel-jhc/src/main/java/org/apache/camel/component/jhc/JhcComponent.java
activemq/camel/trunk/components/camel-jhc/src/main/java/org/apache/camel/component/jhc/JhcConsumer.java
activemq/camel/trunk/components/camel-jhc/src/main/java/org/apache/camel/component/jhc/JhcConverter.java
activemq/camel/trunk/components/camel-jhc/src/main/java/org/apache/camel/component/jhc/JhcEndpoint.java
activemq/camel/trunk/components/camel-jhc/src/main/java/org/apache/camel/component/jhc/JhcExchange.java
activemq/camel/trunk/components/camel-jhc/src/main/java/org/apache/camel/component/jhc/JhcMessage.java
activemq/camel/trunk/components/camel-jhc/src/main/java/org/apache/camel/component/jhc/JhcProducer.java
activemq/camel/trunk/components/camel-jhc/src/main/resources/
activemq/camel/trunk/components/camel-jhc/src/main/resources/META-INF/
activemq/camel/trunk/components/camel-jhc/src/main/resources/META-INF/LICENSE.txt (with props)
activemq/camel/trunk/components/camel-jhc/src/main/resources/META-INF/NOTICE.txt
activemq/camel/trunk/components/camel-jhc/src/main/resources/META-INF/services/
activemq/camel/trunk/components/camel-jhc/src/main/resources/META-INF/services/org/
activemq/camel/trunk/components/camel-jhc/src/main/resources/META-INF/services/org/apache/
activemq/camel/trunk/components/camel-jhc/src/main/resources/META-INF/services/org/apache/camel/
activemq/camel/trunk/components/camel-jhc/src/main/resources/META-INF/services/org/apache/camel/TypeConverter
activemq/camel/trunk/components/camel-jhc/src/main/resources/META-INF/services/org/apache/camel/component/
activemq/camel/trunk/components/camel-jhc/src/main/resources/META-INF/services/org/apache/camel/component/jhc
activemq/camel/trunk/components/camel-jhc/src/test/
activemq/camel/trunk/components/camel-jhc/src/test/java/
activemq/camel/trunk/components/camel-jhc/src/test/java/org/
activemq/camel/trunk/components/camel-jhc/src/test/java/org/apache/
activemq/camel/trunk/components/camel-jhc/src/test/java/org/apache/camel/
activemq/camel/trunk/components/camel-jhc/src/test/java/org/apache/camel/component/
activemq/camel/trunk/components/camel-jhc/src/test/java/org/apache/camel/component/jhc/
activemq/camel/trunk/components/camel-jhc/src/test/java/org/apache/camel/component/jhc/HttpTest.java
activemq/camel/trunk/components/camel-jhc/src/test/resources/
activemq/camel/trunk/components/camel-jhc/src/test/resources/log4j.properties
Modified:
activemq/camel/trunk/components/pom.xml
Added: activemq/camel/trunk/components/camel-jhc/pom.xml
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-jhc/pom.xml?rev=574819&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-jhc/pom.xml (added)
+++ activemq/camel/trunk/components/camel-jhc/pom.xml Wed Sep 12 00:29:20 2007
@@ -0,0 +1,79 @@
+<?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.1-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>camel-jhc</artifactId>
+ <name>Camel :: Jakarta Http Components</name>
+ <description>Camel Jakarta Http Components support</description>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpcore</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpcore-nio</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpcore-niossl</artifactId>
+ </dependency>
+
+ <!-- testing -->
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-core</artifactId>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <version>1.0.4</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+</project>
Added: activemq/camel/trunk/components/camel-jhc/src/main/java/org/apache/camel/component/jhc/AsyncBufferingHttpServiceHandler.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-jhc/src/main/java/org/apache/camel/component/jhc/AsyncBufferingHttpServiceHandler.java?rev=574819&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-jhc/src/main/java/org/apache/camel/component/jhc/AsyncBufferingHttpServiceHandler.java (added)
+++ activemq/camel/trunk/components/camel-jhc/src/main/java/org/apache/camel/component/jhc/AsyncBufferingHttpServiceHandler.java Wed Sep 12 00:29:20 2007
@@ -0,0 +1,126 @@
+package org.apache.camel.component.jhc;
+
+import org.apache.http.*;
+import org.apache.http.impl.DefaultHttpResponseFactory;
+import org.apache.http.impl.DefaultConnectionReuseStrategy;
+import org.apache.http.nio.util.ByteBufferAllocator;
+import org.apache.http.nio.NHttpServerConnection;
+import org.apache.http.params.HttpParams;
+import org.apache.http.params.HttpParamsLinker;
+import org.apache.http.protocol.*;
+
+import java.io.IOException;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: gnodet
+ * Date: Sep 11, 2007
+ * Time: 6:57:34 PM
+ * To change this template use File | Settings | File Templates.
+ */
+public abstract class AsyncBufferingHttpServiceHandler extends BufferingHttpServiceHandler {
+
+ public interface AsyncHandler {
+
+ void sendResponse(HttpResponse response) throws IOException, HttpException;
+
+ }
+
+ public AsyncBufferingHttpServiceHandler(final HttpParams params) {
+ super(createDefaultProcessor(),
+ new DefaultHttpResponseFactory(),
+ new DefaultConnectionReuseStrategy(),
+ params);
+ }
+
+ public AsyncBufferingHttpServiceHandler(final HttpProcessor httpProcessor,
+ final HttpResponseFactory responseFactory,
+ final ConnectionReuseStrategy connStrategy,
+ final HttpParams params) {
+ super(httpProcessor, responseFactory, connStrategy, params);
+ }
+
+ public AsyncBufferingHttpServiceHandler(final HttpProcessor httpProcessor,
+ final HttpResponseFactory responseFactory,
+ final ConnectionReuseStrategy connStrategy,
+ final ByteBufferAllocator allocator,
+ final HttpParams params) {
+ super(httpProcessor, responseFactory, connStrategy, allocator, params);
+ }
+
+ protected static HttpProcessor createDefaultProcessor() {
+ BasicHttpProcessor httpproc = new BasicHttpProcessor();
+ httpproc.addInterceptor(new ResponseDate());
+ httpproc.addInterceptor(new ResponseServer());
+ httpproc.addInterceptor(new ResponseContent());
+ httpproc.addInterceptor(new ResponseConnControl());
+ return httpproc;
+ }
+
+ protected void processRequest(
+ final NHttpServerConnection conn,
+ final HttpRequest request) throws IOException, HttpException {
+
+ HttpContext context = conn.getContext();
+ HttpVersion ver = request.getRequestLine().getHttpVersion();
+
+ if (!ver.lessEquals(HttpVersion.HTTP_1_1)) {
+ // Downgrade protocol version if greater than HTTP/1.1
+ ver = HttpVersion.HTTP_1_1;
+ }
+
+
+ context.setAttribute(HttpExecutionContext.HTTP_REQUEST, request);
+ context.setAttribute(HttpExecutionContext.HTTP_CONNECTION, conn);
+
+ try {
+
+ this.httpProcessor.process(request, context);
+
+ HttpRequestHandler handler = null;
+ if (this.handlerResolver != null) {
+ String requestURI = request.getRequestLine().getUri();
+ handler = this.handlerResolver.lookup(requestURI);
+ }
+ if (handler != null) {
+ HttpResponse response = this.responseFactory.newHttpResponse(
+ ver,
+ HttpStatus.SC_OK,
+ conn.getContext());
+ HttpParamsLinker.link(response, this.params);
+ context.setAttribute(HttpExecutionContext.HTTP_RESPONSE, response);
+ handler.handle(request, response, context);
+ sendResponse(conn, response);
+ } else {
+ asyncProcessRequest(request, context, new AsyncHandler() {
+ public void sendResponse(HttpResponse response) throws IOException, HttpException {
+ try {
+ AsyncBufferingHttpServiceHandler.this.sendResponse(conn, response);
+ } catch (HttpException ex) {
+ response = AsyncBufferingHttpServiceHandler.this.responseFactory.newHttpResponse(
+ HttpVersion.HTTP_1_0,
+ HttpStatus.SC_INTERNAL_SERVER_ERROR,
+ conn.getContext());
+ HttpParamsLinker.link(response, AsyncBufferingHttpServiceHandler.this.params);
+ AsyncBufferingHttpServiceHandler.this.handleException(ex, response);
+ AsyncBufferingHttpServiceHandler.this.sendResponse(conn, response);
+ }
+ }
+ });
+ }
+
+ } catch (HttpException ex) {
+ HttpResponse response = this.responseFactory.newHttpResponse(
+ HttpVersion.HTTP_1_0,
+ HttpStatus.SC_INTERNAL_SERVER_ERROR,
+ context);
+ HttpParamsLinker.link(response, this.params);
+ handleException(ex, response);
+ sendResponse(conn, response);
+ }
+
+ }
+
+ protected abstract void asyncProcessRequest(HttpRequest requet, HttpContext context, AsyncHandler handler);
+
+}
Added: activemq/camel/trunk/components/camel-jhc/src/main/java/org/apache/camel/component/jhc/BufferingHttpServiceHandler.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-jhc/src/main/java/org/apache/camel/component/jhc/BufferingHttpServiceHandler.java?rev=574819&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-jhc/src/main/java/org/apache/camel/component/jhc/BufferingHttpServiceHandler.java (added)
+++ activemq/camel/trunk/components/camel-jhc/src/main/java/org/apache/camel/component/jhc/BufferingHttpServiceHandler.java Wed Sep 12 00:29:20 2007
@@ -0,0 +1,451 @@
+/*
+ * $HeadURL: https://svn.apache.org/repos/asf/jakarta/httpcomponents/httpcore/tags/4.0-alpha5/module-nio/src/main/java/org/apache/http/nio/protocol/BufferingHttpServiceHandler.java $
+ * $Revision: 547966 $
+ * $Date: 2007-06-16 21:26:21 +0200 (Sat, 16 Jun 2007) $
+ *
+ * ====================================================================
+ * 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.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ */
+
+package org.apache.camel.component.jhc;
+
+import org.apache.http.*;
+import org.apache.http.entity.ByteArrayEntity;
+import org.apache.http.nio.ContentDecoder;
+import org.apache.http.nio.ContentEncoder;
+import org.apache.http.nio.NHttpServerConnection;
+import org.apache.http.nio.NHttpServiceHandler;
+import org.apache.http.nio.entity.ContentBufferEntity;
+import org.apache.http.nio.entity.ContentOutputStream;
+import org.apache.http.nio.protocol.NHttpServiceHandlerBase;
+import org.apache.http.nio.util.*;
+import org.apache.http.params.HttpParams;
+import org.apache.http.params.HttpParamsLinker;
+import org.apache.http.protocol.*;
+import org.apache.http.util.EncodingUtils;
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+/**
+ * HTTP service handler implementation that buffers the content of HTTP messages
+ * entirely in memory and processes HTTP requests on the main I/O thread.
+ *
+ * <p>This service handler should be used only when dealing with HTTP messages
+ * that are known to be limited in length</p>
+ *
+ * @author <a href="mailto:oleg at ural.ru">Oleg Kalnichevski</a>
+ *
+ */
+public class BufferingHttpServiceHandler extends NHttpServiceHandlerBase
+ implements NHttpServiceHandler {
+
+ public BufferingHttpServiceHandler(
+ final HttpProcessor httpProcessor,
+ final HttpResponseFactory responseFactory,
+ final ConnectionReuseStrategy connStrategy,
+ final ByteBufferAllocator allocator,
+ final HttpParams params) {
+ super(httpProcessor, responseFactory, connStrategy, allocator, params);
+ }
+
+ public BufferingHttpServiceHandler(
+ final HttpProcessor httpProcessor,
+ final HttpResponseFactory responseFactory,
+ final ConnectionReuseStrategy connStrategy,
+ final HttpParams params) {
+ this(httpProcessor, responseFactory, connStrategy,
+ new HeapByteBufferAllocator(), params);
+ }
+
+ public void connected(final NHttpServerConnection conn) {
+ HttpContext context = conn.getContext();
+
+ ServerConnState connState = new ServerConnState(allocator);
+ context.setAttribute(CONN_STATE, connState);
+
+ if (this.eventListener != null) {
+ this.eventListener.connectionOpen(conn);
+ }
+ }
+
+ public void requestReceived(final NHttpServerConnection conn) {
+ HttpContext context = conn.getContext();
+
+ HttpRequest request = conn.getHttpRequest();
+ HttpParamsLinker.link(request, this.params);
+
+ ServerConnState connState = (ServerConnState) context.getAttribute(CONN_STATE);
+
+ // Update connection state
+ connState.resetInput();
+ connState.setRequest(request);
+ connState.setInputState(ServerConnState.REQUEST_RECEIVED);
+
+ HttpVersion ver = request.getRequestLine().getHttpVersion();
+ if (!ver.lessEquals(HttpVersion.HTTP_1_1)) {
+ // Downgrade protocol version if greater than HTTP/1.1
+ ver = HttpVersion.HTTP_1_1;
+ }
+
+ HttpResponse response;
+
+ try {
+
+ if (request instanceof HttpEntityEnclosingRequest) {
+ if (((HttpEntityEnclosingRequest) request).expectContinue()) {
+ response = this.responseFactory.newHttpResponse(
+ ver, HttpStatus.SC_CONTINUE, context);
+ HttpParamsLinker.link(response, this.params);
+
+ if (this.expectationVerifier != null) {
+ try {
+ this.expectationVerifier.verify(request, response, context);
+ } catch (HttpException ex) {
+ response = this.responseFactory.newHttpResponse(
+ HttpVersion.HTTP_1_0,
+ HttpStatus.SC_INTERNAL_SERVER_ERROR,
+ context);
+ HttpParamsLinker.link(response, this.params);
+ handleException(ex, response);
+ }
+ }
+
+ if (response.getStatusLine().getStatusCode() < 200) {
+ // Send 1xx response indicating the server expections
+ // have been met
+ conn.submitResponse(response);
+ } else {
+ // The request does not meet the server expections
+ conn.resetInput();
+ connState.resetInput();
+ sendResponse(conn, response);
+ }
+ }
+ // Request content is expected.
+ // Wait until the request content is fully received
+ } else {
+ // No request content is expected.
+ // Process request right away
+ conn.suspendInput();
+ processRequest(conn, request);
+ }
+
+ } catch (IOException ex) {
+ shutdownConnection(conn, ex);
+ if (this.eventListener != null) {
+ this.eventListener.fatalIOException(ex, conn);
+ }
+ } catch (HttpException ex) {
+ closeConnection(conn, ex);
+ if (this.eventListener != null) {
+ this.eventListener.fatalProtocolException(ex, conn);
+ }
+ }
+
+ }
+
+ public void closed(final NHttpServerConnection conn) {
+ if (this.eventListener != null) {
+ this.eventListener.connectionClosed(conn);
+ }
+ }
+
+ public void exception(final NHttpServerConnection conn, final HttpException httpex) {
+ HttpContext context = conn.getContext();
+ try {
+ HttpResponse response = this.responseFactory.newHttpResponse(
+ HttpVersion.HTTP_1_0, HttpStatus.SC_INTERNAL_SERVER_ERROR, context);
+ HttpParamsLinker.link(response, this.params);
+ handleException(httpex, response);
+ response.setEntity(null);
+ sendResponse(conn, response);
+
+ } catch (IOException ex) {
+ shutdownConnection(conn, ex);
+ if (this.eventListener != null) {
+ this.eventListener.fatalIOException(ex, conn);
+ }
+ } catch (HttpException ex) {
+ closeConnection(conn, ex);
+ if (this.eventListener != null) {
+ this.eventListener.fatalProtocolException(ex, conn);
+ }
+ }
+ }
+
+ public void inputReady(final NHttpServerConnection conn, final ContentDecoder decoder) {
+ HttpContext context = conn.getContext();
+ HttpRequest request = conn.getHttpRequest();
+
+ ServerConnState connState = (ServerConnState) context.getAttribute(CONN_STATE);
+ ContentInputBuffer buffer = connState.getInbuffer();
+
+ // Update connection state
+ connState.setInputState(ServerConnState.REQUEST_BODY_STREAM);
+
+ try {
+ buffer.consumeContent(decoder);
+ if (decoder.isCompleted()) {
+ // Request entity has been fully received
+ connState.setInputState(ServerConnState.REQUEST_BODY_DONE);
+
+ // Create a wrapper entity instead of the original one
+ HttpEntityEnclosingRequest entityReq = (HttpEntityEnclosingRequest) request;
+ if (entityReq.getEntity() != null) {
+ entityReq.setEntity(new ContentBufferEntity(
+ entityReq.getEntity(),
+ connState.getInbuffer()));
+ }
+ conn.suspendInput();
+ processRequest(conn, request);
+ }
+
+ } catch (IOException ex) {
+ shutdownConnection(conn, ex);
+ if (this.eventListener != null) {
+ this.eventListener.fatalIOException(ex, conn);
+ }
+ } catch (HttpException ex) {
+ closeConnection(conn, ex);
+ if (this.eventListener != null) {
+ this.eventListener.fatalProtocolException(ex, conn);
+ }
+ }
+ }
+
+ public void responseReady(final NHttpServerConnection conn) {
+ }
+
+ public void outputReady(final NHttpServerConnection conn, final ContentEncoder encoder) {
+
+ HttpContext context = conn.getContext();
+ HttpResponse response = conn.getHttpResponse();
+
+ ServerConnState connState = (ServerConnState) context.getAttribute(CONN_STATE);
+ ContentOutputBuffer buffer = connState.getOutbuffer();
+
+ // Update connection state
+ connState.setOutputState(ServerConnState.RESPONSE_BODY_STREAM);
+
+ try {
+
+ buffer.produceContent(encoder);
+ if (encoder.isCompleted()) {
+ connState.setOutputState(ServerConnState.RESPONSE_BODY_DONE);
+ connState.resetOutput();
+ if (!this.connStrategy.keepAlive(response, context)) {
+ conn.close();
+ } else {
+ conn.requestInput();
+ }
+ }
+
+ } catch (IOException ex) {
+ shutdownConnection(conn, ex);
+ if (this.eventListener != null) {
+ this.eventListener.fatalIOException(ex, conn);
+ }
+ }
+ }
+
+ protected void handleException(final HttpException ex, final HttpResponse response) {
+ int code = HttpStatus.SC_INTERNAL_SERVER_ERROR;
+ if (ex instanceof MethodNotSupportedException) {
+ code = HttpStatus.SC_NOT_IMPLEMENTED;
+ } else if (ex instanceof UnsupportedHttpVersionException) {
+ code = HttpStatus.SC_HTTP_VERSION_NOT_SUPPORTED;
+ } else if (ex instanceof ProtocolException) {
+ code = HttpStatus.SC_BAD_REQUEST;
+ }
+ response.setStatusCode(code);
+
+ byte[] msg = EncodingUtils.getAsciiBytes(ex.getMessage());
+ ByteArrayEntity entity = new ByteArrayEntity(msg);
+ entity.setContentType("text/plain; charset=US-ASCII");
+ response.setEntity(entity);
+ }
+
+ protected void processRequest(
+ final NHttpServerConnection conn,
+ final HttpRequest request) throws IOException, HttpException {
+
+ HttpContext context = conn.getContext();
+ HttpVersion ver = request.getRequestLine().getHttpVersion();
+
+ if (!ver.lessEquals(HttpVersion.HTTP_1_1)) {
+ // Downgrade protocol version if greater than HTTP/1.1
+ ver = HttpVersion.HTTP_1_1;
+ }
+
+ HttpResponse response = this.responseFactory.newHttpResponse(
+ ver,
+ HttpStatus.SC_OK,
+ conn.getContext());
+ HttpParamsLinker.link(response, this.params);
+
+ context.setAttribute(HttpExecutionContext.HTTP_REQUEST, request);
+ context.setAttribute(HttpExecutionContext.HTTP_CONNECTION, conn);
+ context.setAttribute(HttpExecutionContext.HTTP_RESPONSE, response);
+
+ try {
+
+ this.httpProcessor.process(request, context);
+
+ HttpRequestHandler handler = null;
+ if (this.handlerResolver != null) {
+ String requestURI = request.getRequestLine().getUri();
+ handler = this.handlerResolver.lookup(requestURI);
+ }
+ if (handler != null) {
+ handler.handle(request, response, context);
+ } else {
+ response.setStatusCode(HttpStatus.SC_NOT_IMPLEMENTED);
+ }
+
+ } catch (HttpException ex) {
+ response = this.responseFactory.newHttpResponse(HttpVersion.HTTP_1_0,
+ HttpStatus.SC_INTERNAL_SERVER_ERROR, context);
+ HttpParamsLinker.link(response, this.params);
+ handleException(ex, response);
+ }
+
+ sendResponse(conn, response);
+ }
+
+ protected void sendResponse(
+ final NHttpServerConnection conn,
+ final HttpResponse response) throws IOException, HttpException {
+
+ HttpContext context = conn.getContext();
+
+ ServerConnState connState = (ServerConnState) context.getAttribute(CONN_STATE);
+ ContentOutputBuffer buffer = connState.getOutbuffer();
+
+ this.httpProcessor.process(response, context);
+
+ if (!canResponseHaveBody(connState.getRequest(), response)) {
+ response.setEntity(null);
+ }
+
+ conn.submitResponse(response);
+
+ // Update connection state
+ connState.setOutputState(ServerConnState.RESPONSE_SENT);
+
+ HttpEntity entity = response.getEntity();
+ if (entity != null) {
+ OutputStream outstream = new ContentOutputStream(buffer);
+ entity.writeTo(outstream);
+ outstream.flush();
+ outstream.close();
+ } else {
+ connState.resetOutput();
+ if (!this.connStrategy.keepAlive(response, context)) {
+ conn.close();
+ } else {
+ conn.requestInput();
+ }
+ }
+ }
+
+ static class ServerConnState {
+
+ public static final int READY = 0;
+ public static final int REQUEST_RECEIVED = 1;
+ public static final int REQUEST_BODY_STREAM = 2;
+ public static final int REQUEST_BODY_DONE = 4;
+ public static final int RESPONSE_SENT = 8;
+ public static final int RESPONSE_BODY_STREAM = 16;
+ public static final int RESPONSE_BODY_DONE = 32;
+
+ private SimpleInputBuffer inbuffer;
+ private ContentOutputBuffer outbuffer;
+
+ private int inputState;
+ private int outputState;
+
+ private HttpRequest request;
+ private final ByteBufferAllocator allocator;
+
+ public ServerConnState(final ByteBufferAllocator allocator) {
+ super();
+ this.inputState = READY;
+ this.outputState = READY;
+ this.allocator = allocator;
+ }
+
+ public ContentInputBuffer getInbuffer() {
+ if (this.inbuffer == null) {
+ this.inbuffer = new SimpleInputBuffer(2048, allocator);
+ }
+ return this.inbuffer;
+ }
+
+ public ContentOutputBuffer getOutbuffer() {
+ if (this.outbuffer == null) {
+ this.outbuffer = new SimpleOutputBuffer(2048, allocator);
+ }
+ return this.outbuffer;
+ }
+
+ public int getInputState() {
+ return this.inputState;
+ }
+
+ public void setInputState(int inputState) {
+ this.inputState = inputState;
+ }
+
+ public int getOutputState() {
+ return this.outputState;
+ }
+
+ public void setOutputState(int outputState) {
+ this.outputState = outputState;
+ }
+
+ public HttpRequest getRequest() {
+ return this.request;
+ }
+
+ public void setRequest(final HttpRequest request) {
+ this.request = request;
+ }
+
+ public void resetInput() {
+ this.inbuffer = null;
+ this.request = null;
+ this.inputState = READY;
+ }
+
+ public void resetOutput() {
+ this.outbuffer = null;
+ this.outputState = READY;
+ }
+
+ }
+
+}
Added: activemq/camel/trunk/components/camel-jhc/src/main/java/org/apache/camel/component/jhc/DefaultListeningIOReactor.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-jhc/src/main/java/org/apache/camel/component/jhc/DefaultListeningIOReactor.java?rev=574819&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-jhc/src/main/java/org/apache/camel/component/jhc/DefaultListeningIOReactor.java (added)
+++ activemq/camel/trunk/components/camel-jhc/src/main/java/org/apache/camel/component/jhc/DefaultListeningIOReactor.java Wed Sep 12 00:29:20 2007
@@ -0,0 +1,208 @@
+/*
+ * $HeadURL$
+ * $Revision$
+ * $Date$
+ *
+ * ====================================================================
+ * 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.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ */
+
+package org.apache.camel.component.jhc;
+
+import org.apache.http.impl.nio.reactor.AbstractMultiworkerIOReactor;
+import org.apache.http.impl.nio.reactor.ChannelEntry;
+import org.apache.http.nio.params.HttpNIOParams;
+import org.apache.http.nio.reactor.IOEventDispatch;
+import org.apache.http.nio.reactor.IOReactorException;
+import org.apache.http.nio.reactor.IOReactorExceptionHandler;
+import org.apache.http.nio.reactor.ListeningIOReactor;
+import org.apache.http.params.HttpConnectionParams;
+import org.apache.http.params.HttpParams;
+import org.apache.http.util.concurrent.ThreadFactory;
+
+import java.io.IOException;
+import java.io.InterruptedIOException;
+import java.net.Socket;
+import java.net.SocketAddress;
+import java.nio.channels.*;
+import java.util.Iterator;
+import java.util.Set;
+
+/**
+ * Trunk version of DefaultListenerIOReactor.
+ * Should be removed when upgrading to httpcore > alpha5
+ */
+public class DefaultListeningIOReactor extends AbstractMultiworkerIOReactor
+ implements ListeningIOReactor {
+
+ private volatile boolean closed = false;
+
+ private final HttpParams params;
+ private final Selector selector;
+
+ private IOReactorExceptionHandler exceptionHandler;
+
+ public DefaultListeningIOReactor(
+ int workerCount,
+ final ThreadFactory threadFactory,
+ final HttpParams params) throws IOReactorException {
+ super(HttpNIOParams.getSelectInterval(params), workerCount, threadFactory);
+ this.params = params;
+ try {
+ this.selector = Selector.open();
+ } catch (IOException ex) {
+ throw new IOReactorException("Failure opening selector", ex);
+ }
+ }
+
+ public DefaultListeningIOReactor(
+ int workerCount,
+ final HttpParams params) throws IOReactorException {
+ this(workerCount, null, params);
+ }
+
+ public void setExceptionHandler(final IOReactorExceptionHandler exceptionHandler) {
+ this.exceptionHandler = exceptionHandler;
+ }
+
+ public void execute(final IOEventDispatch eventDispatch)
+ throws InterruptedIOException, IOReactorException {
+ if (eventDispatch == null) {
+ throw new IllegalArgumentException("Event dispatcher may not be null");
+ }
+ startWorkers(eventDispatch);
+ for (;;) {
+
+ int readyCount;
+ try {
+ readyCount = this.selector.select(getSelectTimeout());
+ } catch (InterruptedIOException ex) {
+ throw ex;
+ } catch (IOException ex) {
+ throw new IOReactorException("Unexpected selector failure", ex);
+ }
+
+ if (this.closed) {
+ break;
+ }
+ if (readyCount > 0) {
+ processEvents(this.selector.selectedKeys());
+ }
+ verifyWorkers();
+ }
+ }
+
+ private void processEvents(final Set selectedKeys)
+ throws IOReactorException {
+ for (Iterator it = selectedKeys.iterator(); it.hasNext(); ) {
+
+ SelectionKey key = (SelectionKey) it.next();
+ processEvent(key);
+
+ }
+ selectedKeys.clear();
+ }
+
+ private void processEvent(final SelectionKey key)
+ throws IOReactorException {
+ try {
+
+ if (key.isAcceptable()) {
+
+ ServerSocketChannel serverChannel = (ServerSocketChannel) key.channel();
+ SocketChannel socketChannel = null;
+ try {
+ socketChannel = serverChannel.accept();
+ } catch (IOException ex) {
+ if (this.exceptionHandler == null || !this.exceptionHandler.handle(ex)) {
+ throw new IOReactorException("Failure accepting connection", ex);
+ }
+ }
+
+ if (socketChannel != null) {
+ try {
+ prepareSocket(socketChannel.socket());
+ } catch (IOException ex) {
+ if (this.exceptionHandler == null || !this.exceptionHandler.handle(ex)) {
+ throw new IOReactorException("Failure initalizing socket", ex);
+ }
+ }
+ ChannelEntry entry = new ChannelEntry(socketChannel);
+ addChannel(entry);
+ }
+ }
+
+ } catch (CancelledKeyException ex) {
+ key.attach(null);
+ }
+ }
+
+ protected void prepareSocket(final Socket socket) throws IOException {
+ socket.setTcpNoDelay(HttpConnectionParams.getTcpNoDelay(this.params));
+ socket.setSoTimeout(HttpConnectionParams.getSoTimeout(this.params));
+ int linger = HttpConnectionParams.getLinger(this.params);
+ if (linger >= 0) {
+ socket.setSoLinger(linger > 0, linger);
+ }
+ }
+
+ public SocketAddress listen(
+ final SocketAddress address) throws IOException {
+ if (this.closed) {
+ throw new IllegalStateException("I/O reactor has been shut down");
+ }
+ ServerSocketChannel serverChannel = ServerSocketChannel.open();
+ serverChannel.configureBlocking(false);
+ serverChannel.socket().bind(address);
+ SelectionKey key = serverChannel.register(this.selector, SelectionKey.OP_ACCEPT);
+ key.attach(null);
+ return serverChannel.socket().getLocalSocketAddress();
+ }
+
+ public void shutdown() throws IOException {
+ if (this.closed) {
+ return;
+ }
+ this.closed = true;
+
+ // Close out all channels
+ Set keys = this.selector.keys();
+ for (Iterator it = keys.iterator(); it.hasNext(); ) {
+ try {
+ SelectionKey key = (SelectionKey) it.next();
+ Channel channel = key.channel();
+ if (channel != null) {
+ channel.close();
+ }
+ } catch (IOException ignore) {
+ }
+ }
+ // Stop dispatching I/O events
+ this.selector.close();
+ // Stop the workers
+ stopWorkers(500);
+ }
+
+}
Added: activemq/camel/trunk/components/camel-jhc/src/main/java/org/apache/camel/component/jhc/JhcComponent.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-jhc/src/main/java/org/apache/camel/component/jhc/JhcComponent.java?rev=574819&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-jhc/src/main/java/org/apache/camel/component/jhc/JhcComponent.java (added)
+++ activemq/camel/trunk/components/camel-jhc/src/main/java/org/apache/camel/component/jhc/JhcComponent.java Wed Sep 12 00:29:20 2007
@@ -0,0 +1,82 @@
+/**
+ * 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.jhc;
+
+import org.apache.camel.Endpoint;
+import org.apache.camel.Exchange;
+import org.apache.camel.AsyncCallback;
+import org.apache.camel.Message;
+import org.apache.camel.impl.DefaultComponent;
+import org.apache.http.params.BasicHttpParams;
+import org.apache.http.params.HttpParams;
+import org.apache.http.params.HttpConnectionParams;
+import org.apache.http.params.HttpProtocolParams;
+import org.apache.http.nio.reactor.ConnectingIOReactor;
+import org.apache.http.nio.reactor.IOEventDispatch;
+import org.apache.http.nio.reactor.SessionRequestCallback;
+import org.apache.http.nio.reactor.SessionRequest;
+import org.apache.http.nio.protocol.BufferingHttpClientHandler;
+import org.apache.http.nio.protocol.HttpRequestExecutionHandler;
+import org.apache.http.nio.protocol.EventListener;
+import org.apache.http.nio.NHttpConnection;
+import org.apache.http.util.concurrent.ThreadFactory;
+import org.apache.http.impl.nio.reactor.DefaultConnectingIOReactor;
+import org.apache.http.impl.nio.DefaultClientIOEventDispatch;
+import org.apache.http.impl.DefaultConnectionReuseStrategy;
+import org.apache.http.protocol.*;
+import org.apache.http.*;
+import org.apache.http.entity.ByteArrayEntity;
+import org.apache.http.message.BasicHttpRequest;
+import org.apache.http.message.BasicHttpEntityEnclosingRequest;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.net.URI;
+import java.util.Map;
+import java.util.Iterator;
+import java.io.InterruptedIOException;
+import java.io.IOException;
+
+public class JhcComponent extends DefaultComponent<JhcExchange> {
+
+ private static Log LOG = LogFactory.getLog(JhcComponent.class);
+
+ private HttpParams params;
+
+ public JhcComponent() {
+ params = new BasicHttpParams(null)
+ .setIntParameter(HttpConnectionParams.SO_TIMEOUT, 5000)
+ .setIntParameter(HttpConnectionParams.CONNECTION_TIMEOUT, 10000)
+ .setIntParameter(HttpConnectionParams.SOCKET_BUFFER_SIZE, 8 * 1024)
+ .setBooleanParameter(HttpConnectionParams.STALE_CONNECTION_CHECK, false)
+ .setBooleanParameter(HttpConnectionParams.TCP_NODELAY, true)
+ .setParameter(HttpProtocolParams.USER_AGENT, "Camel-JhcComponent/1.1");
+ }
+
+ public HttpParams getParams() {
+ return params;
+ }
+
+ public void setParams(HttpParams params) {
+ this.params = params;
+ }
+
+ protected Endpoint<JhcExchange> createEndpoint(String uri, String remaining, Map parameters) throws Exception {
+ return new JhcEndpoint(uri, this, new URI(uri.substring(uri.indexOf(':') + 1)));
+ }
+
+}
\ No newline at end of file
Added: activemq/camel/trunk/components/camel-jhc/src/main/java/org/apache/camel/component/jhc/JhcConsumer.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-jhc/src/main/java/org/apache/camel/component/jhc/JhcConsumer.java?rev=574819&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-jhc/src/main/java/org/apache/camel/component/jhc/JhcConsumer.java (added)
+++ activemq/camel/trunk/components/camel-jhc/src/main/java/org/apache/camel/component/jhc/JhcConsumer.java Wed Sep 12 00:29:20 2007
@@ -0,0 +1,172 @@
+package org.apache.camel.component.jhc;
+
+import org.apache.camel.AsyncCallback;
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.impl.DefaultConsumer;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.http.*;
+import org.apache.http.entity.ByteArrayEntity;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.impl.DefaultConnectionReuseStrategy;
+import org.apache.http.impl.DefaultHttpResponseFactory;
+import org.apache.http.impl.nio.DefaultServerIOEventDispatch;
+import org.apache.http.impl.nio.reactor.SSLServerIOEventDispatch;
+import org.apache.http.nio.*;
+import org.apache.http.nio.entity.ContentOutputStream;
+import org.apache.http.nio.util.ContentOutputBuffer;
+import org.apache.http.nio.protocol.EventListener;
+import org.apache.http.nio.reactor.IOEventDispatch;
+import org.apache.http.nio.reactor.ListeningIOReactor;
+import org.apache.http.params.HttpParams;
+import org.apache.http.protocol.*;
+import org.apache.http.util.EncodingUtils;
+import org.apache.http.util.concurrent.ThreadFactory;
+
+import javax.net.ssl.SSLContext;
+import java.io.IOException;
+import java.io.InterruptedIOException;
+import java.io.UnsupportedEncodingException;
+import java.io.OutputStream;
+import java.net.InetSocketAddress;
+import java.net.SocketAddress;
+import java.nio.ByteBuffer;
+import java.nio.channels.ReadableByteChannel;
+import java.nio.channels.ServerSocketChannel;
+import java.nio.channels.SelectionKey;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: gnodet
+ * Date: Sep 7, 2007
+ * Time: 8:15:54 PM
+ * To change this template use File | Settings | File Templates.
+ */
+public class JhcConsumer extends DefaultConsumer<JhcExchange> {
+
+ private static Log LOG = LogFactory.getLog(JhcConsumer.class);
+
+ private int nbThreads = 2;
+ private ListeningIOReactor ioReactor;
+ private ThreadFactory threadFactory;
+ private Thread runner;
+
+ public JhcConsumer(JhcEndpoint endpoint, Processor processor) {
+ super(endpoint, processor);
+ }
+
+ public JhcEndpoint getEndpoint() {
+ return (JhcEndpoint) super.getEndpoint();
+ }
+
+ protected void doStart() throws Exception {
+ super.doStart();
+ final SocketAddress addr = new InetSocketAddress(getEndpoint().getPort());
+ HttpParams params = getEndpoint().getParams();
+ ioReactor = new DefaultListeningIOReactor(nbThreads, threadFactory, params);
+
+ final IOEventDispatch ioEventDispatch;
+ if ("https".equals(getEndpoint().getProtocol())) {
+ SSLContext sslContext = null; // TODO
+ ioEventDispatch = new SSLServerIOEventDispatch(new MyHandler(params), sslContext, params);
+ } else {
+ ioEventDispatch = new DefaultServerIOEventDispatch(new MyHandler(params), params);
+ }
+ runner = new Thread() {
+ public void run() {
+ try {
+ ioReactor.listen(addr);
+ ioReactor.execute(ioEventDispatch);
+ } catch (InterruptedIOException ex) {
+ LOG.info("Interrupted");
+ } catch (IOException e) {
+ LOG.warn("I/O error: " + e.getMessage());
+ }
+ LOG.debug("Shutdown");
+ }
+ };
+ runner.start();
+ }
+
+ protected void doStop() throws Exception {
+ LOG.debug("Stopping");
+ ioReactor.shutdown();
+ LOG.debug("Waiting runner");
+ runner.join();
+ LOG.debug("Stopped");
+ super.doStop();
+ }
+
+ class MyHttpRequestHandler implements HttpRequestHandler {
+
+ public void handle(HttpRequest httpRequest, HttpResponse httpResponse, HttpContext httpContext) throws HttpException, IOException {
+ LOG.debug("handle");
+ }
+ }
+
+ static class EventLogger implements EventListener {
+
+ public void connectionOpen(final NHttpConnection conn) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Connection open: " + conn);
+ }
+ }
+
+ public void connectionTimeout(final NHttpConnection conn) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Connection timed out: " + conn);
+ }
+ }
+
+ public void connectionClosed(final NHttpConnection conn) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Connection closed: " + conn);
+ }
+ }
+
+ public void fatalIOException(final IOException ex, final NHttpConnection conn) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("I/O error: " + ex.getMessage());
+ }
+ }
+
+ public void fatalProtocolException(final HttpException ex, final NHttpConnection conn) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("HTTP error: " + ex.getMessage());
+ }
+ }
+
+ }
+
+
+ class MyHandler extends AsyncBufferingHttpServiceHandler {
+ public MyHandler(HttpParams params) {
+ super(params);
+ }
+ protected void asyncProcessRequest(final HttpRequest request, final HttpContext context, final AsyncBufferingHttpServiceHandler.AsyncHandler handler) {
+ final Exchange exchange = getEndpoint().createExchange();
+ exchange.getIn().setHeader("http.uri", request.getRequestLine().getUri());
+ if (request instanceof HttpEntityEnclosingRequest) {
+ exchange.getIn().setBody(((HttpEntityEnclosingRequest) request).getEntity());
+ }
+ getAsyncProcessor().process(exchange, new AsyncCallback() {
+ public void done(boolean doneSynchronously) {
+ LOG.debug("handleExchange");
+ // create the default response to this request
+ HttpVersion httpVersion = request.getRequestLine().getHttpVersion();
+ HttpResponse response = responseFactory.newHttpResponse(httpVersion, HttpStatus.SC_OK, context);
+ HttpEntity entity = exchange.getOut().getBody(HttpEntity.class);
+ response.setEntity(entity);
+ response.setParams(getEndpoint().getParams());
+ try {
+ handler.sendResponse(response);
+ } catch (Exception e) {
+ LOG.info(e);
+ }
+ }
+ });
+ }
+ }
+
+}
Added: activemq/camel/trunk/components/camel-jhc/src/main/java/org/apache/camel/component/jhc/JhcConverter.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-jhc/src/main/java/org/apache/camel/component/jhc/JhcConverter.java?rev=574819&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-jhc/src/main/java/org/apache/camel/component/jhc/JhcConverter.java (added)
+++ activemq/camel/trunk/components/camel-jhc/src/main/java/org/apache/camel/component/jhc/JhcConverter.java Wed Sep 12 00:29:20 2007
@@ -0,0 +1,50 @@
+package org.apache.camel.component.jhc;
+
+import org.apache.camel.Converter;
+import org.apache.http.HttpEntity;
+import org.apache.http.entity.InputStreamEntity;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.util.EntityUtils;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.UnsupportedEncodingException;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: gnodet
+ * Date: Sep 10, 2007
+ * Time: 8:26:44 AM
+ * To change this template use File | Settings | File Templates.
+ */
+@Converter
+public final class JhcConverter {
+
+ private JhcConverter() {
+ }
+
+ @Converter
+ public static InputStream toInputStream(HttpEntity entity) throws IOException {
+ return entity.getContent();
+ }
+
+ @Converter
+ public static byte[] toByteArray(HttpEntity entity) throws IOException {
+ return EntityUtils.toByteArray(entity);
+ }
+
+ @Converter
+ public static String toString(HttpEntity entity) throws IOException {
+ return EntityUtils.toString(entity);
+ }
+
+ @Converter
+ public static HttpEntity toEntity(InputStream is) {
+ return new InputStreamEntity(is, -1);
+ }
+
+ @Converter
+ public static HttpEntity toEntity(String str) throws UnsupportedEncodingException {
+ return new StringEntity(str);
+ }
+}
Added: activemq/camel/trunk/components/camel-jhc/src/main/java/org/apache/camel/component/jhc/JhcEndpoint.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-jhc/src/main/java/org/apache/camel/component/jhc/JhcEndpoint.java?rev=574819&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-jhc/src/main/java/org/apache/camel/component/jhc/JhcEndpoint.java (added)
+++ activemq/camel/trunk/components/camel-jhc/src/main/java/org/apache/camel/component/jhc/JhcEndpoint.java Wed Sep 12 00:29:20 2007
@@ -0,0 +1,81 @@
+package org.apache.camel.component.jhc;
+
+import org.apache.camel.Consumer;
+import org.apache.camel.Processor;
+import org.apache.camel.Producer;
+import org.apache.camel.impl.DefaultEndpoint;
+import org.apache.http.params.HttpConnectionParams;
+import org.apache.http.params.HttpParams;
+import org.apache.http.params.BasicHttpParams;
+
+import java.net.URI;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: gnodet
+ * Date: Sep 7, 2007
+ * Time: 8:06:42 PM
+ * To change this template use File | Settings | File Templates.
+ */
+public class JhcEndpoint extends DefaultEndpoint<JhcExchange> {
+
+ private HttpParams params;
+ private URI httpUri;
+
+ public JhcEndpoint(String endpointUri, JhcComponent component, URI httpUri) {
+ super(endpointUri, component);
+ params = new BasicHttpParams(component.getParams());
+ this.httpUri = httpUri;
+ }
+
+ public HttpParams getParams() {
+ return params;
+ }
+
+ public void setParams(HttpParams params) {
+ this.params = params;
+ }
+
+ public URI getHttpUri() {
+ return httpUri;
+ }
+
+ public void setHttpUri(URI httpUri) {
+ this.httpUri = httpUri;
+ }
+
+ public String getProtocol() {
+ return httpUri.getScheme();
+ }
+
+ public String getHost() {
+ return httpUri.getHost();
+ }
+
+ public int getPort() {
+ if (httpUri.getPort() == -1) {
+ if ("https".equals(getProtocol())) {
+ return 443;
+ } else {
+ return 80;
+ }
+ }
+ return httpUri.getPort();
+ }
+
+ public String getPath() {
+ return httpUri.getPath();
+ }
+
+ public boolean isSingleton() {
+ return true;
+ }
+
+ public Producer<JhcExchange> createProducer() throws Exception {
+ return new JhcProducer(this);
+ }
+
+ public Consumer<JhcExchange> createConsumer(Processor processor) throws Exception {
+ return new JhcConsumer(this, processor);
+ }
+}
Added: activemq/camel/trunk/components/camel-jhc/src/main/java/org/apache/camel/component/jhc/JhcExchange.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-jhc/src/main/java/org/apache/camel/component/jhc/JhcExchange.java?rev=574819&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-jhc/src/main/java/org/apache/camel/component/jhc/JhcExchange.java (added)
+++ activemq/camel/trunk/components/camel-jhc/src/main/java/org/apache/camel/component/jhc/JhcExchange.java Wed Sep 12 00:29:20 2007
@@ -0,0 +1,35 @@
+/**
+ * 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.jhc;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.ExchangePattern;
+import org.apache.camel.impl.DefaultExchange;
+import org.apache.http.HttpRequest;
+import org.apache.http.HttpResponse;
+
+public class JhcExchange extends DefaultExchange {
+
+ public JhcExchange(CamelContext context) {
+ super(context);
+ }
+
+ public JhcExchange(CamelContext context, ExchangePattern pattern) {
+ super(context, pattern);
+ }
+
+}
\ No newline at end of file
Added: activemq/camel/trunk/components/camel-jhc/src/main/java/org/apache/camel/component/jhc/JhcMessage.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-jhc/src/main/java/org/apache/camel/component/jhc/JhcMessage.java?rev=574819&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-jhc/src/main/java/org/apache/camel/component/jhc/JhcMessage.java (added)
+++ activemq/camel/trunk/components/camel-jhc/src/main/java/org/apache/camel/component/jhc/JhcMessage.java Wed Sep 12 00:29:20 2007
@@ -0,0 +1,23 @@
+/**
+ * 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.jhc;
+
+import org.apache.camel.impl.DefaultMessage;
+
+public class JhcMessage extends DefaultMessage {
+
+}
\ No newline at end of file
Added: activemq/camel/trunk/components/camel-jhc/src/main/java/org/apache/camel/component/jhc/JhcProducer.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-jhc/src/main/java/org/apache/camel/component/jhc/JhcProducer.java?rev=574819&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-jhc/src/main/java/org/apache/camel/component/jhc/JhcProducer.java (added)
+++ activemq/camel/trunk/components/camel-jhc/src/main/java/org/apache/camel/component/jhc/JhcProducer.java Wed Sep 12 00:29:20 2007
@@ -0,0 +1,265 @@
+package org.apache.camel.component.jhc;
+
+import org.apache.camel.AsyncCallback;
+import org.apache.camel.AsyncProcessor;
+import org.apache.camel.Exchange;
+import org.apache.camel.Message;
+import org.apache.camel.impl.DefaultProducer;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.http.*;
+import org.apache.http.entity.ByteArrayEntity;
+import org.apache.http.impl.DefaultConnectionReuseStrategy;
+import org.apache.http.impl.nio.DefaultClientIOEventDispatch;
+import org.apache.http.impl.nio.reactor.DefaultConnectingIOReactor;
+import org.apache.http.message.BasicHttpEntityEnclosingRequest;
+import org.apache.http.message.BasicHttpRequest;
+import org.apache.http.nio.NHttpConnection;
+import org.apache.http.nio.protocol.BufferingHttpClientHandler;
+import org.apache.http.nio.protocol.EventListener;
+import org.apache.http.nio.protocol.HttpRequestExecutionHandler;
+import org.apache.http.nio.reactor.ConnectingIOReactor;
+import org.apache.http.nio.reactor.IOEventDispatch;
+import org.apache.http.nio.reactor.SessionRequest;
+import org.apache.http.nio.reactor.SessionRequestCallback;
+import org.apache.http.params.HttpParams;
+import org.apache.http.protocol.*;
+import org.apache.http.util.concurrent.ThreadFactory;
+
+import java.io.IOException;
+import java.io.InterruptedIOException;
+import java.net.InetSocketAddress;
+import java.net.SocketAddress;
+import java.util.Iterator;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: gnodet
+ * Date: Sep 7, 2007
+ * Time: 8:15:14 PM
+ * To change this template use File | Settings | File Templates.
+ */
+public class JhcProducer extends DefaultProducer<JhcExchange> implements AsyncProcessor {
+
+ private static Log LOG = LogFactory.getLog(JhcProducer.class);
+
+ private int nbThreads = 2;
+ private ConnectingIOReactor ioReactor;
+ private ThreadFactory threadFactory;
+ private Thread runner;
+
+ public JhcProducer(JhcEndpoint endpoint) {
+ super(endpoint);
+ }
+
+ @Override
+ public JhcEndpoint getEndpoint() {
+ return (JhcEndpoint) super.getEndpoint();
+ }
+
+ @Override
+ protected void doStart() throws Exception {
+ super.doStart();
+ HttpParams params = getEndpoint().getParams();
+ ioReactor = new DefaultConnectingIOReactor(nbThreads, threadFactory, params);
+ BasicHttpProcessor httpproc = new BasicHttpProcessor();
+ httpproc.addInterceptor(new RequestContent());
+ httpproc.addInterceptor(new RequestTargetHost());
+ httpproc.addInterceptor(new RequestConnControl());
+ httpproc.addInterceptor(new RequestUserAgent());
+ httpproc.addInterceptor(new RequestExpectContinue());
+ BufferingHttpClientHandler handler = new BufferingHttpClientHandler(
+ httpproc,
+ new MyHttpRequestExecutionHandler(),
+ new DefaultConnectionReuseStrategy(),
+ params);
+ handler.setEventListener(new EventLogger());
+ final IOEventDispatch ioEventDispatch = new DefaultClientIOEventDispatch(handler, params);
+ runner = new Thread(new Runnable() {
+ public void run() {
+ try {
+ ioReactor.execute(ioEventDispatch);
+ } catch (InterruptedIOException ex) {
+ LOG.info("Interrupted");
+ } catch (IOException e) {
+ LOG.warn("I/O error: " + e.getMessage());
+ }
+ LOG.debug("Shutdown");
+ }
+
+ });
+ runner.start();
+ }
+
+ @Override
+ protected void doStop() throws Exception {
+ ioReactor.shutdown();
+ runner.join();
+ super.doStop();
+ }
+
+ public void process(Exchange exchange) throws Exception {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("process: " + exchange);
+ }
+ AsyncCallback callback = new AsyncCallback() {
+ public synchronized void done(boolean doneSynchronously) {
+ notify();
+ }
+ };
+ synchronized (callback) {
+ process(exchange, callback);
+ callback.wait();
+ }
+ }
+
+ public boolean process(Exchange exchange, AsyncCallback callback) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("processAsync: " + exchange);
+ }
+ SocketAddress addr = new InetSocketAddress(getEndpoint().getHost(), getEndpoint().getPort());
+ exchange.setProperty(AsyncCallback.class.getName(), callback);
+ SessionRequest req = ioReactor.connect(addr, null, exchange, new MySessionRequestCallback());
+ return false;
+ }
+
+ protected HttpRequest createRequest(Exchange exchange) {
+ String uri = getEndpoint().getEndpointUri();
+ HttpEntity entity = createEntity(exchange);
+ if (entity == null) {
+ BasicHttpRequest req = new BasicHttpRequest("GET", getEndpoint().getPath());
+ return req;
+ } else {
+ BasicHttpEntityEnclosingRequest req = new BasicHttpEntityEnclosingRequest("POST", getEndpoint().getPath());
+ req.setEntity(entity);
+ return req;
+ }
+ }
+
+ protected HttpEntity createEntity(Exchange exchange) {
+ Message in = exchange.getIn();
+ HttpEntity entity = in.getBody(HttpEntity.class);
+ if (entity == null) {
+ byte[] data = in.getBody(byte[].class);
+ if (data == null) {
+ return null;
+ }
+ entity = new ByteArrayEntity(data);
+ String contentType = in.getHeader("Content-Type", String.class);
+ if (contentType != null) {
+ ((ByteArrayEntity) entity).setContentType(contentType);
+ }
+ String contentEncoding = in.getHeader("Content-Encoding", String.class);
+ if (contentEncoding != null) {
+ ((ByteArrayEntity) entity).setContentEncoding(contentEncoding);
+ }
+ }
+ return entity;
+ }
+
+
+ static class MySessionRequestCallback implements SessionRequestCallback {
+
+ public void completed(SessionRequest sessionRequest) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Completed");
+ }
+ }
+
+ public void failed(SessionRequest sessionRequest) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Failed");
+ }
+ }
+
+ public void timeout(SessionRequest sessionRequest) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Timeout");
+ }
+ }
+
+ public void cancelled(SessionRequest sessionRequest) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Cancelled");
+ }
+ }
+ }
+
+ class MyHttpRequestExecutionHandler implements HttpRequestExecutionHandler {
+
+ private final static String REQUEST_SENT = "request-sent";
+ private final static String RESPONSE_RECEIVED = "response-received";
+
+ public void initalizeContext(HttpContext httpContext, Object o) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Initialize context");
+ }
+ httpContext.setAttribute(Exchange.class.getName(), (Exchange) o);
+ }
+
+ public HttpRequest submitRequest(HttpContext httpContext) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Submit request: " + httpContext);
+ }
+ Object flag = httpContext.getAttribute(REQUEST_SENT);
+ if (flag == null) {
+ // Stick some object into the context
+ httpContext.setAttribute(REQUEST_SENT, Boolean.TRUE);
+ Exchange e = (Exchange) httpContext.getAttribute(Exchange.class.getName());
+ return createRequest(e);
+ } else {
+ return null;
+ }
+ }
+
+ public void handleResponse(HttpResponse httpResponse, HttpContext httpContext) throws IOException {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Handle response");
+ }
+ httpContext.setAttribute(RESPONSE_RECEIVED, Boolean.TRUE);
+ Exchange e = (Exchange) httpContext.getAttribute(Exchange.class.getName());
+ e.getOut().setBody(httpResponse.getEntity());
+ for (Iterator it = httpResponse.headerIterator(); it.hasNext();) {
+ Header h = (Header) it.next();
+ e.getOut().setHeader(h.getName(), h.getValue());
+ }
+ AsyncCallback callback = (AsyncCallback) e.removeProperty(AsyncCallback.class.getName());
+ callback.done(false);
+ }
+ }
+
+ static class EventLogger implements EventListener {
+
+ public void connectionOpen(final NHttpConnection conn) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Connection open: " + conn);
+ }
+ }
+
+ public void connectionTimeout(final NHttpConnection conn) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Connection timed out: " + conn);
+ }
+ }
+
+ public void connectionClosed(final NHttpConnection conn) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Connection closed: " + conn);
+ }
+ }
+
+ public void fatalIOException(final IOException ex, final NHttpConnection conn) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("I/O error: " + ex.getMessage());
+ }
+ }
+
+ public void fatalProtocolException(final HttpException ex, final NHttpConnection conn) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("HTTP error: " + ex.getMessage());
+ }
+ }
+
+ }
+
+}
Added: activemq/camel/trunk/components/camel-jhc/src/main/resources/META-INF/LICENSE.txt
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-jhc/src/main/resources/META-INF/LICENSE.txt?rev=574819&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-jhc/src/main/resources/META-INF/LICENSE.txt (added)
+++ activemq/camel/trunk/components/camel-jhc/src/main/resources/META-INF/LICENSE.txt Wed Sep 12 00:29:20 2007
@@ -0,0 +1,203 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed 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.
+
Propchange: activemq/camel/trunk/components/camel-jhc/src/main/resources/META-INF/LICENSE.txt
------------------------------------------------------------------------------
svn:executable = *
Added: activemq/camel/trunk/components/camel-jhc/src/main/resources/META-INF/NOTICE.txt
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-jhc/src/main/resources/META-INF/NOTICE.txt?rev=574819&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-jhc/src/main/resources/META-INF/NOTICE.txt (added)
+++ activemq/camel/trunk/components/camel-jhc/src/main/resources/META-INF/NOTICE.txt Wed Sep 12 00:29:20 2007
@@ -0,0 +1,11 @@
+ =========================================================================
+ == NOTICE file corresponding to the section 4 d of ==
+ == the Apache License, Version 2.0, ==
+ == in this case for the Apache Camel distribution. ==
+ =========================================================================
+
+ This product includes software developed by
+ The Apache Software Foundation (http://www.apache.org/).
+
+ Please read the different LICENSE files present in the licenses directory of
+ this distribution.
Added: activemq/camel/trunk/components/camel-jhc/src/main/resources/META-INF/services/org/apache/camel/TypeConverter
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-jhc/src/main/resources/META-INF/services/org/apache/camel/TypeConverter?rev=574819&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-jhc/src/main/resources/META-INF/services/org/apache/camel/TypeConverter (added)
+++ activemq/camel/trunk/components/camel-jhc/src/main/resources/META-INF/services/org/apache/camel/TypeConverter Wed Sep 12 00:29:20 2007
@@ -0,0 +1,18 @@
+#
+# 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.
+#
+
+org.apache.camel.component.jhc
\ No newline at end of file
Added: activemq/camel/trunk/components/camel-jhc/src/main/resources/META-INF/services/org/apache/camel/component/jhc
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-jhc/src/main/resources/META-INF/services/org/apache/camel/component/jhc?rev=574819&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-jhc/src/main/resources/META-INF/services/org/apache/camel/component/jhc (added)
+++ activemq/camel/trunk/components/camel-jhc/src/main/resources/META-INF/services/org/apache/camel/component/jhc Wed Sep 12 00:29:20 2007
@@ -0,0 +1,18 @@
+#
+# 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.
+#
+
+class=org.apache.camel.component.jhc.JhcComponent