You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by io...@apache.org on 2012/02/03 22:41:16 UTC

svn commit: r1240351 [1/2] - in /camel/trunk: camel-core/src/main/java/org/apache/camel/builder/ camel-core/src/main/java/org/apache/camel/model/ camel-core/src/main/java/org/apache/camel/model/dataformat/ camel-core/src/main/resources/org/apache/camel...

Author: iocanel
Date: Fri Feb  3 21:41:13 2012
New Revision: 1240351

URL: http://svn.apache.org/viewvc?rev=1240351&view=rev
Log:
Merge branch 'trunk' of git://git.apache.org/camel into trunk-avro

Conflicts:
	components/pom.xml

Added:
    camel/trunk/camel-core/src/main/java/org/apache/camel/model/dataformat/AvroDataFormat.java
    camel/trunk/components/camel-avro/
    camel/trunk/components/camel-avro/pom.xml
    camel/trunk/components/camel-avro/src/
    camel/trunk/components/camel-avro/src/main/
    camel/trunk/components/camel-avro/src/main/java/
    camel/trunk/components/camel-avro/src/main/java/org/
    camel/trunk/components/camel-avro/src/main/java/org/apache/
    camel/trunk/components/camel-avro/src/main/java/org/apache/camel/
    camel/trunk/components/camel-avro/src/main/java/org/apache/camel/component/
    camel/trunk/components/camel-avro/src/main/java/org/apache/camel/component/avro/
    camel/trunk/components/camel-avro/src/main/java/org/apache/camel/component/avro/AvroComponent.java
    camel/trunk/components/camel-avro/src/main/java/org/apache/camel/component/avro/AvroConfiguration.java
    camel/trunk/components/camel-avro/src/main/java/org/apache/camel/component/avro/AvroConstants.java
    camel/trunk/components/camel-avro/src/main/java/org/apache/camel/component/avro/AvroConsumer.java
    camel/trunk/components/camel-avro/src/main/java/org/apache/camel/component/avro/AvroEndpoint.java
    camel/trunk/components/camel-avro/src/main/java/org/apache/camel/component/avro/AvroHttpConsumer.java
    camel/trunk/components/camel-avro/src/main/java/org/apache/camel/component/avro/AvroHttpEndpoint.java
    camel/trunk/components/camel-avro/src/main/java/org/apache/camel/component/avro/AvroHttpProducer.java
    camel/trunk/components/camel-avro/src/main/java/org/apache/camel/component/avro/AvroNettyConsumer.java
    camel/trunk/components/camel-avro/src/main/java/org/apache/camel/component/avro/AvroNettyEndpoint.java
    camel/trunk/components/camel-avro/src/main/java/org/apache/camel/component/avro/AvroNettyProducer.java
    camel/trunk/components/camel-avro/src/main/java/org/apache/camel/component/avro/AvroProducer.java
    camel/trunk/components/camel-avro/src/main/java/org/apache/camel/component/avro/AvroRequestor.java
    camel/trunk/components/camel-avro/src/main/java/org/apache/camel/component/avro/AvroResponder.java
    camel/trunk/components/camel-avro/src/main/java/org/apache/camel/dataformat/
    camel/trunk/components/camel-avro/src/main/java/org/apache/camel/dataformat/avro/
    camel/trunk/components/camel-avro/src/main/java/org/apache/camel/dataformat/avro/AvroDataFormat.java
    camel/trunk/components/camel-avro/src/main/resources/
    camel/trunk/components/camel-avro/src/main/resources/META-INF/
    camel/trunk/components/camel-avro/src/main/resources/META-INF/services/
    camel/trunk/components/camel-avro/src/main/resources/META-INF/services/org/
    camel/trunk/components/camel-avro/src/main/resources/META-INF/services/org/apache/
    camel/trunk/components/camel-avro/src/main/resources/META-INF/services/org/apache/camel/
    camel/trunk/components/camel-avro/src/main/resources/META-INF/services/org/apache/camel/component/
    camel/trunk/components/camel-avro/src/main/resources/META-INF/services/org/apache/camel/component/avro
    camel/trunk/components/camel-avro/src/main/resources/META-INF/services/org/apache/camel/dataformat/
    camel/trunk/components/camel-avro/src/main/resources/META-INF/services/org/apache/camel/dataformat/avro
    camel/trunk/components/camel-avro/src/test/
    camel/trunk/components/camel-avro/src/test/avro/
    camel/trunk/components/camel-avro/src/test/avro/test.avpr
    camel/trunk/components/camel-avro/src/test/java/
    camel/trunk/components/camel-avro/src/test/java/org/
    camel/trunk/components/camel-avro/src/test/java/org/apache/
    camel/trunk/components/camel-avro/src/test/java/org/apache/camel/
    camel/trunk/components/camel-avro/src/test/java/org/apache/camel/avro/
    camel/trunk/components/camel-avro/src/test/java/org/apache/camel/avro/generated/
    camel/trunk/components/camel-avro/src/test/java/org/apache/camel/avro/generated/Key.java
    camel/trunk/components/camel-avro/src/test/java/org/apache/camel/avro/generated/KeyValueProtocol.java
    camel/trunk/components/camel-avro/src/test/java/org/apache/camel/avro/generated/Value.java
    camel/trunk/components/camel-avro/src/test/java/org/apache/camel/avro/impl/
    camel/trunk/components/camel-avro/src/test/java/org/apache/camel/avro/impl/KeyValueProtocolImpl.java
    camel/trunk/components/camel-avro/src/test/java/org/apache/camel/component/
    camel/trunk/components/camel-avro/src/test/java/org/apache/camel/component/avro/
    camel/trunk/components/camel-avro/src/test/java/org/apache/camel/component/avro/AvroConsumerTestSupport.java
    camel/trunk/components/camel-avro/src/test/java/org/apache/camel/component/avro/AvroHttpConsumerTest.java
    camel/trunk/components/camel-avro/src/test/java/org/apache/camel/component/avro/AvroHttpProducerTest.java
    camel/trunk/components/camel-avro/src/test/java/org/apache/camel/component/avro/AvroHttpSpringProducerTest.java
    camel/trunk/components/camel-avro/src/test/java/org/apache/camel/component/avro/AvroNettyConsumerTest.java
    camel/trunk/components/camel-avro/src/test/java/org/apache/camel/component/avro/AvroNettyProducerTest.java
    camel/trunk/components/camel-avro/src/test/java/org/apache/camel/component/avro/AvroNettySpringConsumerTest.java
    camel/trunk/components/camel-avro/src/test/java/org/apache/camel/component/avro/AvroNettySpringProducerTest.java
    camel/trunk/components/camel-avro/src/test/java/org/apache/camel/component/avro/AvroProducerTestSupport.java
    camel/trunk/components/camel-avro/src/test/java/org/apache/camel/component/avro/AvroTestSupport.java
    camel/trunk/components/camel-avro/src/test/java/org/apache/camel/component/avro/processors/
    camel/trunk/components/camel-avro/src/test/java/org/apache/camel/component/avro/processors/GetProcessor.java
    camel/trunk/components/camel-avro/src/test/java/org/apache/camel/component/avro/processors/PutProcessor.java
    camel/trunk/components/camel-avro/src/test/java/org/apache/camel/dataformat/
    camel/trunk/components/camel-avro/src/test/java/org/apache/camel/dataformat/avro/
    camel/trunk/components/camel-avro/src/test/java/org/apache/camel/dataformat/avro/AvroMarshalAndUnmarshalSpringTest.java
    camel/trunk/components/camel-avro/src/test/java/org/apache/camel/dataformat/avro/AvroMarshalAndUnmarshallTest.java
    camel/trunk/components/camel-avro/src/test/resources/
    camel/trunk/components/camel-avro/src/test/resources/org/
    camel/trunk/components/camel-avro/src/test/resources/org/apache/
    camel/trunk/components/camel-avro/src/test/resources/org/apache/camel/
    camel/trunk/components/camel-avro/src/test/resources/org/apache/camel/component/
    camel/trunk/components/camel-avro/src/test/resources/org/apache/camel/component/avro/
    camel/trunk/components/camel-avro/src/test/resources/org/apache/camel/component/avro/avro-http-consumer.xml
    camel/trunk/components/camel-avro/src/test/resources/org/apache/camel/component/avro/avro-http-producer.xml
    camel/trunk/components/camel-avro/src/test/resources/org/apache/camel/component/avro/avro-netty-consumer.xml
    camel/trunk/components/camel-avro/src/test/resources/org/apache/camel/component/avro/avro-netty-producer.xml
    camel/trunk/components/camel-avro/src/test/resources/org/apache/camel/dataformat/
    camel/trunk/components/camel-avro/src/test/resources/org/apache/camel/dataformat/avro/
    camel/trunk/components/camel-avro/src/test/resources/org/apache/camel/dataformat/avro/springDataFormat.xml
Modified:
    camel/trunk/camel-core/src/main/java/org/apache/camel/builder/DataFormatClause.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/model/MarshalDefinition.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/model/UnmarshalDefinition.java
    camel/trunk/camel-core/src/main/resources/org/apache/camel/model/dataformat/jaxb.index
    camel/trunk/components/pom.xml
    camel/trunk/parent/pom.xml
    camel/trunk/platforms/karaf/features/src/main/resources/features.xml

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/builder/DataFormatClause.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/DataFormatClause.java?rev=1240351&r1=1240350&r2=1240351&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/builder/DataFormatClause.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/builder/DataFormatClause.java Fri Feb  3 21:41:13 2012
@@ -23,6 +23,7 @@ import org.w3c.dom.Node;
 
 import org.apache.camel.model.DataFormatDefinition;
 import org.apache.camel.model.ProcessorDefinition;
+import org.apache.camel.model.dataformat.AvroDataFormat;
 import org.apache.camel.model.dataformat.BindyDataFormat;
 import org.apache.camel.model.dataformat.BindyType;
 import org.apache.camel.model.dataformat.CastorDataFormat;
@@ -71,6 +72,24 @@ public class DataFormatClause<T extends 
         this.operation = operation;
     }
 
+
+    /**
+     * Uses the Avro data format
+     */
+    public T avro() {
+        return dataFormat(new AvroDataFormat());
+    }
+
+    public T avro(Object schema) {
+        AvroDataFormat dataFormat = new AvroDataFormat();
+        dataFormat.setSchema(schema);
+        return dataFormat(dataFormat);
+    }
+
+    public T avro(String instanceClassName) {
+        return dataFormat(new AvroDataFormat(instanceClassName));
+    }
+
     /**
      * Uses the Bindy data format
      *

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/model/MarshalDefinition.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/model/MarshalDefinition.java?rev=1240351&r1=1240350&r2=1240351&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/model/MarshalDefinition.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/model/MarshalDefinition.java Fri Feb  3 21:41:13 2012
@@ -24,6 +24,7 @@ import javax.xml.bind.annotation.XmlElem
 import javax.xml.bind.annotation.XmlRootElement;
 
 import org.apache.camel.Processor;
+import org.apache.camel.model.dataformat.AvroDataFormat;
 import org.apache.camel.model.dataformat.BindyDataFormat;
 import org.apache.camel.model.dataformat.CastorDataFormat;
 import org.apache.camel.model.dataformat.CryptoDataFormat;
@@ -67,6 +68,7 @@ public class MarshalDefinition extends N
     private String ref;
     // cannot use @XmlElementRef as it doesn't allow optional properties
     @XmlElements({
+    @XmlElement(required = false, name = "avro", type = AvroDataFormat.class),
     @XmlElement(required = false, name = "bindy", type = BindyDataFormat.class),
     @XmlElement(required = false, name = "castor", type = CastorDataFormat.class),
     @XmlElement(required = false, name = "crypto", type = CryptoDataFormat.class),

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/model/UnmarshalDefinition.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/model/UnmarshalDefinition.java?rev=1240351&r1=1240350&r2=1240351&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/model/UnmarshalDefinition.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/model/UnmarshalDefinition.java Fri Feb  3 21:41:13 2012
@@ -24,6 +24,7 @@ import javax.xml.bind.annotation.XmlElem
 import javax.xml.bind.annotation.XmlRootElement;
 
 import org.apache.camel.Processor;
+import org.apache.camel.model.dataformat.AvroDataFormat;
 import org.apache.camel.model.dataformat.BindyDataFormat;
 import org.apache.camel.model.dataformat.CastorDataFormat;
 import org.apache.camel.model.dataformat.CryptoDataFormat;
@@ -67,6 +68,7 @@ public class UnmarshalDefinition extends
     private String ref;
     // cannot use @XmlElementRef as it doesn't allow optional properties
     @XmlElements({
+    @XmlElement(required = false, name = "avro", type = AvroDataFormat.class),
     @XmlElement(required = false, name = "bindy", type = BindyDataFormat.class),
     @XmlElement(required = false, name = "castor", type = CastorDataFormat.class),
     @XmlElement(required = false, name = "crypto", type = CryptoDataFormat.class),

Added: camel/trunk/camel-core/src/main/java/org/apache/camel/model/dataformat/AvroDataFormat.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/model/dataformat/AvroDataFormat.java?rev=1240351&view=auto
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/model/dataformat/AvroDataFormat.java (added)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/model/dataformat/AvroDataFormat.java Fri Feb  3 21:41:13 2012
@@ -0,0 +1,74 @@
+/**
+ * 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.model.dataformat;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlTransient;
+import org.apache.camel.model.DataFormatDefinition;
+import org.apache.camel.spi.DataFormat;
+
+/**
+ * Represents a avro DataFormat {@link org.apache.camel.spi.DataFormat}
+ *
+ * @version 
+ */
+@XmlRootElement(name = "avro")
+@XmlAccessorType(XmlAccessType.FIELD)
+public class AvroDataFormat extends DataFormatDefinition {
+    @XmlAttribute
+    private String instanceClassName;
+    @XmlTransient
+    private Object schema;
+
+    public AvroDataFormat() {
+        super("avro");
+    }
+
+    public AvroDataFormat(String instanceClassName) {
+        this();
+        setInstanceClassName(instanceClassName);
+    }
+
+    public String getInstanceClassName() {
+        return instanceClassName;
+    }
+
+    public void setInstanceClassName(String instanceClassName) {
+        this.instanceClassName = instanceClassName;
+    }
+
+    public Object getSchema() {
+        return schema;
+    }
+
+    public void setSchema(Object schema) {
+        this.schema = schema;
+    }
+
+    @Override
+    protected void configureDataFormat(DataFormat dataFormat) {
+        if (this.instanceClassName != null) {
+            setProperty(dataFormat, "instanceClass", instanceClassName);
+        }
+        if (this.schema != null) {
+            setProperty(dataFormat, "schema", schema);
+        }
+    }
+}

Modified: camel/trunk/camel-core/src/main/resources/org/apache/camel/model/dataformat/jaxb.index
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/resources/org/apache/camel/model/dataformat/jaxb.index?rev=1240351&r1=1240350&r2=1240351&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/resources/org/apache/camel/model/dataformat/jaxb.index (original)
+++ camel/trunk/camel-core/src/main/resources/org/apache/camel/model/dataformat/jaxb.index Fri Feb  3 21:41:13 2012
@@ -14,6 +14,7 @@
 ## See the License for the specific language governing permissions and
 ## limitations under the License.
 ## ------------------------------------------------------------------------
+AvroDataFormat
 BindyDataFormat
 BindyType
 CastorDataFormat

Added: camel/trunk/components/camel-avro/pom.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-avro/pom.xml?rev=1240351&view=auto
==============================================================================
--- camel/trunk/components/camel-avro/pom.xml (added)
+++ camel/trunk/components/camel-avro/pom.xml Fri Feb  3 21:41:13 2012
@@ -0,0 +1,91 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <parent>
+        <groupId>org.apache.camel</groupId>
+        <artifactId>camel-parent</artifactId>
+        <version>2.10-SNAPSHOT</version>
+        <relativePath>../../parent</relativePath>
+    </parent>
+
+    <modelVersion>4.0.0</modelVersion>
+
+    <groupId>org.apache.camel</groupId>
+    <artifactId>camel-avro</artifactId>
+    <packaging>bundle</packaging>
+    <name>Camel :: Avro</name>
+
+    <properties>
+        <camel.osgi.export.pkg>org.apache.camel.dataformat.avro*,org.apache.camel.component.avro*</camel.osgi.export.pkg>
+    </properties>
+
+    <build>
+        <plugins>
+            <!--plugin>
+                <groupId>org.apache.avro</groupId>
+                <artifactId>avro-maven-plugin</artifactId>
+                <version>${avro-version}</version>
+                <executions>
+                    <execution>
+                        <id>schemas</id>
+                        <phase>generate-sources</phase>
+                        <goals>
+                            <goal>schema</goal>
+                            <goal>protocol</goal>
+                            <goal>idl-protocol</goal>
+                        </goals>
+                        <configuration>
+                            <sourceDirectory>${project.basedir}/src/test/avro/</sourceDirectory>
+                            <outputDirectory>${project.basedir}/src/test/java/</outputDirectory>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin-->
+        </plugins>
+    </build>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.camel</groupId>
+            <artifactId>camel-core</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.avro</groupId>
+            <artifactId>avro</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.avro</groupId>
+            <artifactId>avro-ipc</artifactId>
+        </dependency>
+
+        <!-- testing -->
+        <dependency>
+            <groupId>org.apache.camel</groupId>
+            <artifactId>camel-test</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.camel</groupId>
+            <artifactId>camel-juel</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.camel</groupId>
+            <artifactId>camel-spring</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-log4j12</artifactId>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+
+
+</project>
\ No newline at end of file

Added: camel/trunk/components/camel-avro/src/main/java/org/apache/camel/component/avro/AvroComponent.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-avro/src/main/java/org/apache/camel/component/avro/AvroComponent.java?rev=1240351&view=auto
==============================================================================
--- camel/trunk/components/camel-avro/src/main/java/org/apache/camel/component/avro/AvroComponent.java (added)
+++ camel/trunk/components/camel-avro/src/main/java/org/apache/camel/component/avro/AvroComponent.java Fri Feb  3 21:41:13 2012
@@ -0,0 +1,88 @@
+/**
+ * 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.avro;
+
+import java.lang.reflect.Field;
+import java.net.URI;
+import java.util.Map;
+import org.apache.avro.Protocol;
+import org.apache.camel.CamelContext;
+import org.apache.camel.Endpoint;
+import org.apache.camel.impl.DefaultComponent;
+import org.apache.camel.util.URISupport;
+
+public class AvroComponent extends DefaultComponent {
+
+    private AvroConfiguration configuration;
+
+    public AvroComponent() {
+    }
+
+    public AvroComponent(CamelContext context) {
+        super(context);
+    }
+
+
+    /**
+     * A factory method allowing derived components to create a new endpoint
+     * from the given URI, remaining path and optional parameters
+     *
+     * @param uri        the full URI of the endpoint
+     * @param remaining  the remaining part of the URI without the query
+     *                   parameters or component prefix
+     * @param parameters the optional parameters passed in
+     * @return a newly created endpoint or null if the endpoint cannot be
+     *         created based on the inputs
+     */
+    @Override
+    protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception {
+        AvroConfiguration config;
+        if (configuration != null) {
+            config = configuration.copy();
+        } else {
+            config = new AvroConfiguration();
+        }
+        URI enpointUri = new URI(URISupport.normalizeUri(remaining));
+        config.parseURI(enpointUri, parameters, this);
+        setProperties(config, parameters);
+
+        if (config.getProtocol() == null && config.getProtocolClassName() != null) {
+            Class<?> protocolClass = getCamelContext().getClassResolver().resolveClass(config.getProtocolClassName());
+            Field f = protocolClass.getField("PROTOCOL");
+            Protocol protocol = (Protocol) f.get(null);
+            config.setProtocol(protocol);
+        }
+
+        if (AvroConstants.AVRO_NETTY_TRANSPORT.equals(enpointUri.getScheme())) {
+            return new AvroNettyEndpoint(remaining, this, config);
+        } else if (AvroConstants.AVRO_HTTP_TRANSPORT.equals(enpointUri.getScheme())) {
+            return new AvroHttpEndpoint(remaining, this, config);
+        } else {
+            throw new IllegalArgumentException("Unknown avro scheme. Should use either netty or http.");
+        }
+    }
+
+
+    public AvroConfiguration getConfiguration() {
+        return configuration;
+    }
+
+    public void setConfiguration(AvroConfiguration configuration) {
+        this.configuration = configuration;
+    }
+}

Added: camel/trunk/components/camel-avro/src/main/java/org/apache/camel/component/avro/AvroConfiguration.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-avro/src/main/java/org/apache/camel/component/avro/AvroConfiguration.java?rev=1240351&view=auto
==============================================================================
--- camel/trunk/components/camel-avro/src/main/java/org/apache/camel/component/avro/AvroConfiguration.java (added)
+++ camel/trunk/components/camel-avro/src/main/java/org/apache/camel/component/avro/AvroConfiguration.java Fri Feb  3 21:41:13 2012
@@ -0,0 +1,102 @@
+/**
+ * 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.avro;
+
+import java.net.URI;
+import java.util.Map;
+import org.apache.avro.Protocol;
+import org.apache.camel.RuntimeCamelException;
+
+public class AvroConfiguration implements Cloneable {
+
+    private String host;
+    private int port;
+    private Protocol protocol;
+    private String protocolLocation;
+    private String protocolClassName;
+    private String transport;
+
+
+    public AvroConfiguration copy() {
+        try {
+            AvroConfiguration answer = (AvroConfiguration) clone();
+            return answer;
+        } catch (CloneNotSupportedException e) {
+            throw new RuntimeCamelException(e);
+        }
+    }
+
+    public void parseURI(URI uri, Map<String, Object> parameters, AvroComponent component) throws Exception {
+        transport = uri.getScheme();
+
+        if ((!transport.equalsIgnoreCase("http")) && (!transport.equalsIgnoreCase("netty"))) {
+            throw new IllegalArgumentException("Unrecognized Avro IPC transport: " + protocol + " for uri: " + uri);
+        }
+
+        setHost(uri.getHost());
+        setPort(uri.getPort());
+    }
+
+    public String getHost() {
+        return host;
+    }
+
+    public void setHost(String host) {
+        this.host = host;
+    }
+
+    public int getPort() {
+        return port;
+    }
+
+    public void setPort(int port) {
+        this.port = port;
+    }
+
+    public Protocol getProtocol() {
+        return protocol;
+    }
+
+    public void setProtocol(Protocol protocol) {
+        this.protocol = protocol;
+    }
+
+    public String getTransport() {
+        return transport;
+    }
+
+    public void setTransport(String transport) {
+        this.transport = transport;
+    }
+
+    public String getProtocolLocation() {
+        return protocolLocation;
+    }
+
+    public void setProtocolLocation(String protocolLocation) {
+        this.protocolLocation = protocolLocation;
+    }
+
+    public String getProtocolClassName() {
+        return protocolClassName;
+    }
+
+    public void setProtocolClassName(String protocolClassName) {
+        this.protocolClassName = protocolClassName;
+    }
+}

Added: camel/trunk/components/camel-avro/src/main/java/org/apache/camel/component/avro/AvroConstants.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-avro/src/main/java/org/apache/camel/component/avro/AvroConstants.java?rev=1240351&view=auto
==============================================================================
--- camel/trunk/components/camel-avro/src/main/java/org/apache/camel/component/avro/AvroConstants.java (added)
+++ camel/trunk/components/camel-avro/src/main/java/org/apache/camel/component/avro/AvroConstants.java Fri Feb  3 21:41:13 2012
@@ -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.avro;
+
+public final class AvroConstants {
+
+
+    public static final transient String AVRO_NETTY_TRANSPORT = "netty";
+    public static final transient String AVRO_HTTP_TRANSPORT = "http";
+
+    public static final transient String AVRO_MESSAGE_NAME = "CamelAvroMessageName";
+
+    private AvroConstants() {
+        // Utility class
+    }
+}

Added: camel/trunk/components/camel-avro/src/main/java/org/apache/camel/component/avro/AvroConsumer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-avro/src/main/java/org/apache/camel/component/avro/AvroConsumer.java?rev=1240351&view=auto
==============================================================================
--- camel/trunk/components/camel-avro/src/main/java/org/apache/camel/component/avro/AvroConsumer.java (added)
+++ camel/trunk/components/camel-avro/src/main/java/org/apache/camel/component/avro/AvroConsumer.java Fri Feb  3 21:41:13 2012
@@ -0,0 +1,38 @@
+/**
+ * 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.avro;
+
+import org.apache.camel.Endpoint;
+import org.apache.camel.Processor;
+import org.apache.camel.impl.DefaultConsumer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public abstract class AvroConsumer extends DefaultConsumer {
+
+    private static final Logger LOG = LoggerFactory.getLogger(AvroConsumer.class);
+
+    public AvroConsumer(Endpoint endpoint, Processor processor) {
+        super(endpoint, processor);
+    }
+
+    @Override
+    public AvroEndpoint getEndpoint() {
+        return (AvroEndpoint) super.getEndpoint();
+    }
+}

Added: camel/trunk/components/camel-avro/src/main/java/org/apache/camel/component/avro/AvroEndpoint.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-avro/src/main/java/org/apache/camel/component/avro/AvroEndpoint.java?rev=1240351&view=auto
==============================================================================
--- camel/trunk/components/camel-avro/src/main/java/org/apache/camel/component/avro/AvroEndpoint.java (added)
+++ camel/trunk/components/camel-avro/src/main/java/org/apache/camel/component/avro/AvroEndpoint.java Fri Feb  3 21:41:13 2012
@@ -0,0 +1,75 @@
+/**
+ * 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.avro;
+
+import org.apache.avro.Protocol;
+import org.apache.avro.Schema;
+import org.apache.camel.Component;
+import org.apache.camel.Exchange;
+import org.apache.camel.ExchangePattern;
+import org.apache.camel.impl.DefaultEndpoint;
+
+public abstract class AvroEndpoint extends DefaultEndpoint {
+
+    private AvroConfiguration configuration;
+    private boolean sync;
+
+
+    /**
+     * Constructs a fully-initialized DefaultEndpoint instance. This is the
+     * preferred method of constructing an object from Java code (as opposed to
+     * Spring beans, etc.).
+     *
+     * @param endpointUri the full URI used to create this endpoint
+     * @param component   the component that created this endpoint
+     */
+    public AvroEndpoint(String endpointUri, Component component, AvroConfiguration configuration) {
+        super(endpointUri, component);
+        this.configuration = configuration;
+    }
+
+
+    public Exchange createExchange(Protocol.Message message, Object request) {
+        ExchangePattern pattern = ExchangePattern.InOut;
+        if (message.getResponse().equals(Schema.Type.NULL)) {
+            pattern = ExchangePattern.InOnly;
+        }
+        Exchange exchange = createExchange(pattern);
+        exchange.getIn().setBody(request);
+        exchange.getIn().setHeader(AvroConstants.AVRO_MESSAGE_NAME, message.getName());
+        return exchange;
+    }
+
+    /**
+     * Whether this class supports being singleton or not.
+     *
+     * @return <tt>true</tt> to be a single shared instance, <tt>false</tt> to create new instances.
+     */
+    @Override
+    public boolean isSingleton() {
+        return false;
+    }
+
+    public AvroConfiguration getConfiguration() {
+        return configuration;
+    }
+
+    public Protocol getProtocol() {
+        return configuration.getProtocol();
+    }
+}

Added: camel/trunk/components/camel-avro/src/main/java/org/apache/camel/component/avro/AvroHttpConsumer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-avro/src/main/java/org/apache/camel/component/avro/AvroHttpConsumer.java?rev=1240351&view=auto
==============================================================================
--- camel/trunk/components/camel-avro/src/main/java/org/apache/camel/component/avro/AvroHttpConsumer.java (added)
+++ camel/trunk/components/camel-avro/src/main/java/org/apache/camel/component/avro/AvroHttpConsumer.java Fri Feb  3 21:41:13 2012
@@ -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.avro;
+
+import org.apache.avro.ipc.HttpServer;
+import org.apache.camel.Endpoint;
+import org.apache.camel.Processor;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class AvroHttpConsumer extends AvroConsumer {
+
+    private static final Logger LOG = LoggerFactory.getLogger(AvroHttpConsumer.class);
+    HttpServer server;
+
+
+    public AvroHttpConsumer(Endpoint endpoint, Processor processor) {
+        super(endpoint, processor);
+        String uri = endpoint.getEndpointUri();
+    }
+
+    @Override
+    protected void doStart() throws Exception {
+        AvroConfiguration configuration = getEndpoint().getConfiguration();
+        server = new HttpServer(new AvroResponder(this), configuration.getPort());
+        server.start();
+    }
+
+    @Override
+    protected void doStop() throws Exception {
+        super.doStop();
+        if (server != null) {
+            server.close();
+        }
+    }
+
+    @Override
+    public AvroEndpoint getEndpoint() {
+        return (AvroEndpoint) super.getEndpoint();
+    }
+}

Added: camel/trunk/components/camel-avro/src/main/java/org/apache/camel/component/avro/AvroHttpEndpoint.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-avro/src/main/java/org/apache/camel/component/avro/AvroHttpEndpoint.java?rev=1240351&view=auto
==============================================================================
--- camel/trunk/components/camel-avro/src/main/java/org/apache/camel/component/avro/AvroHttpEndpoint.java (added)
+++ camel/trunk/components/camel-avro/src/main/java/org/apache/camel/component/avro/AvroHttpEndpoint.java Fri Feb  3 21:41:13 2012
@@ -0,0 +1,64 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.camel.component.avro;
+
+import org.apache.camel.Component;
+import org.apache.camel.Consumer;
+import org.apache.camel.Processor;
+import org.apache.camel.Producer;
+
+public class AvroHttpEndpoint extends AvroEndpoint {
+
+    /**
+     * Constructs a fully-initialized DefaultEndpoint instance. This is the
+     * preferred method of constructing an object from Java code (as opposed to
+     * Spring beans, etc.).
+     *
+     * @param endpointUri the full URI used to create this endpoint
+     * @param component   the component that created this endpoint
+     */
+    public AvroHttpEndpoint(String endpointUri, Component component, AvroConfiguration configuration) {
+        super(endpointUri, component, configuration);
+    }
+
+    /**
+     * Creates a new producer which is used send messages into the endpoint
+     *
+     * @return a newly created producer
+     * @throws Exception can be thrown
+     */
+    @Override
+    public Producer createProducer() throws Exception {
+        return new AvroHttpProducer(this);
+    }
+
+    /**
+     * Creates a new <a
+     * href="http://camel.apache.org/event-driven-consumer.html">Event
+     * Driven Consumer</a> which consumes messages from the endpoint using the
+     * given processor
+     *
+     * @param processor the given processor
+     * @return a newly created consumer
+     * @throws Exception can be thrown
+     */
+    @Override
+    public Consumer createConsumer(Processor processor) throws Exception {
+        return new AvroHttpConsumer(this, processor);
+    }
+}

Added: camel/trunk/components/camel-avro/src/main/java/org/apache/camel/component/avro/AvroHttpProducer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-avro/src/main/java/org/apache/camel/component/avro/AvroHttpProducer.java?rev=1240351&view=auto
==============================================================================
--- camel/trunk/components/camel-avro/src/main/java/org/apache/camel/component/avro/AvroHttpProducer.java (added)
+++ camel/trunk/components/camel-avro/src/main/java/org/apache/camel/component/avro/AvroHttpProducer.java Fri Feb  3 21:41:13 2012
@@ -0,0 +1,36 @@
+/**
+ * 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.avro;
+
+import java.net.URL;
+import org.apache.avro.ipc.HttpTransceiver;
+import org.apache.avro.ipc.Transceiver;
+import org.apache.camel.Endpoint;
+import org.apache.camel.util.URISupport;
+
+public class AvroHttpProducer extends AvroProducer {
+
+    public AvroHttpProducer(Endpoint endpoint) {
+        super(endpoint);
+    }
+
+    @Override
+    public Transceiver createTranceiver() throws Exception {
+        return new HttpTransceiver(new URL(URISupport.normalizeUri(getEndpoint().getEndpointUri())));
+    }
+}

Added: camel/trunk/components/camel-avro/src/main/java/org/apache/camel/component/avro/AvroNettyConsumer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-avro/src/main/java/org/apache/camel/component/avro/AvroNettyConsumer.java?rev=1240351&view=auto
==============================================================================
--- camel/trunk/components/camel-avro/src/main/java/org/apache/camel/component/avro/AvroNettyConsumer.java (added)
+++ camel/trunk/components/camel-avro/src/main/java/org/apache/camel/component/avro/AvroNettyConsumer.java Fri Feb  3 21:41:13 2012
@@ -0,0 +1,57 @@
+/**
+ * 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.avro;
+
+import java.net.InetSocketAddress;
+import org.apache.avro.ipc.NettyServer;
+import org.apache.camel.Endpoint;
+import org.apache.camel.Processor;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class AvroNettyConsumer extends AvroConsumer {
+
+    private static final Logger LOG = LoggerFactory.getLogger(AvroNettyConsumer.class);
+    NettyServer server;
+
+
+    public AvroNettyConsumer(Endpoint endpoint, Processor processor) {
+        super(endpoint, processor);
+        String uri = endpoint.getEndpointUri();
+    }
+
+    @Override
+    protected void doStart() throws Exception {
+        AvroConfiguration configuration = getEndpoint().getConfiguration();
+        server = new NettyServer(new AvroResponder(this), new InetSocketAddress(configuration.getHost(), configuration.getPort()));
+        server.start();
+    }
+
+    @Override
+    protected void doStop() throws Exception {
+        super.doStop();
+        if (server != null) {
+            server.close();
+        }
+    }
+
+    @Override
+    public AvroEndpoint getEndpoint() {
+        return (AvroEndpoint) super.getEndpoint();
+    }
+}

Added: camel/trunk/components/camel-avro/src/main/java/org/apache/camel/component/avro/AvroNettyEndpoint.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-avro/src/main/java/org/apache/camel/component/avro/AvroNettyEndpoint.java?rev=1240351&view=auto
==============================================================================
--- camel/trunk/components/camel-avro/src/main/java/org/apache/camel/component/avro/AvroNettyEndpoint.java (added)
+++ camel/trunk/components/camel-avro/src/main/java/org/apache/camel/component/avro/AvroNettyEndpoint.java Fri Feb  3 21:41:13 2012
@@ -0,0 +1,64 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.camel.component.avro;
+
+import org.apache.camel.Component;
+import org.apache.camel.Consumer;
+import org.apache.camel.Processor;
+import org.apache.camel.Producer;
+
+public class AvroNettyEndpoint extends AvroEndpoint {
+
+    /**
+     * Constructs a fully-initialized DefaultEndpoint instance. This is the
+     * preferred method of constructing an object from Java code (as opposed to
+     * Spring beans, etc.).
+     *
+     * @param endpointUri the full URI used to create this endpoint
+     * @param component   the component that created this endpoint
+     */
+    public AvroNettyEndpoint(String endpointUri, Component component, AvroConfiguration configuration) {
+        super(endpointUri, component, configuration);
+    }
+
+    /**
+     * Creates a new producer which is used send messages into the endpoint
+     *
+     * @return a newly created producer
+     * @throws Exception can be thrown
+     */
+    @Override
+    public Producer createProducer() throws Exception {
+        return new AvroNettyProducer(this);
+    }
+
+    /**
+     * Creates a new <a
+     * href="http://camel.apache.org/event-driven-consumer.html">Event
+     * Driven Consumer</a> which consumes messages from the endpoint using the
+     * given processor
+     *
+     * @param processor the given processor
+     * @return a newly created consumer
+     * @throws Exception can be thrown
+     */
+    @Override
+    public Consumer createConsumer(Processor processor) throws Exception {
+        return new AvroNettyConsumer(this, processor);
+    }
+}

Added: camel/trunk/components/camel-avro/src/main/java/org/apache/camel/component/avro/AvroNettyProducer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-avro/src/main/java/org/apache/camel/component/avro/AvroNettyProducer.java?rev=1240351&view=auto
==============================================================================
--- camel/trunk/components/camel-avro/src/main/java/org/apache/camel/component/avro/AvroNettyProducer.java (added)
+++ camel/trunk/components/camel-avro/src/main/java/org/apache/camel/component/avro/AvroNettyProducer.java Fri Feb  3 21:41:13 2012
@@ -0,0 +1,38 @@
+/**
+ * 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.avro;
+
+import java.net.InetSocketAddress;
+import org.apache.avro.ipc.NettyTransceiver;
+import org.apache.avro.ipc.Transceiver;
+import org.apache.camel.Endpoint;
+
+public class AvroNettyProducer extends AvroProducer {
+
+
+    public AvroNettyProducer(Endpoint endpoint) {
+        super(endpoint);
+    }
+
+    @Override
+    public Transceiver createTranceiver() throws Exception {
+        AvroConfiguration configuration = getEndpoint().getConfiguration();
+        return transceiver = new NettyTransceiver(new InetSocketAddress(configuration.getHost(), configuration.getPort()));
+    }
+
+}

Added: camel/trunk/components/camel-avro/src/main/java/org/apache/camel/component/avro/AvroProducer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-avro/src/main/java/org/apache/camel/component/avro/AvroProducer.java?rev=1240351&view=auto
==============================================================================
--- camel/trunk/components/camel-avro/src/main/java/org/apache/camel/component/avro/AvroProducer.java (added)
+++ camel/trunk/components/camel-avro/src/main/java/org/apache/camel/component/avro/AvroProducer.java Fri Feb  3 21:41:13 2012
@@ -0,0 +1,95 @@
+/**
+ * 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.avro;
+
+import org.apache.avro.ipc.Callback;
+import org.apache.avro.ipc.Requestor;
+import org.apache.avro.ipc.Transceiver;
+import org.apache.camel.Endpoint;
+import org.apache.camel.Exchange;
+import org.apache.camel.ServicePoolAware;
+import org.apache.camel.impl.DefaultProducer;
+
+public abstract class AvroProducer extends DefaultProducer implements ServicePoolAware {
+
+    Transceiver transceiver;
+    Requestor requestor;
+
+    public AvroProducer(Endpoint endpoint) {
+        super(endpoint);
+    }
+
+    public abstract Transceiver createTranceiver() throws Exception;
+
+    /**
+     * Processes the message exchange
+     *
+     * @param exchange the message exchange
+     * @throws Exception if an internal processing error has occurred.
+     */
+    @Override
+    public void process(final Exchange exchange) throws Exception {
+        Object request = exchange.getIn().getBody();
+
+        if (transceiver == null) {
+            transceiver = createTranceiver();
+            requestor = new AvroRequestor(getEndpoint().getProtocol(), transceiver);
+        }
+
+        requestor.request(exchange.getIn().getHeader(AvroConstants.AVRO_MESSAGE_NAME, String.class), wrapObjectToArray(request), new Callback<Object>() {
+
+            @Override
+            public void handleResult(Object result) {
+                exchange.getOut().setBody(result);
+            }
+
+            @Override
+            public void handleError(Throwable error) {
+                exchange.setException(error);
+            }
+        });
+    }
+
+    public Object[] wrapObjectToArray(Object object) {
+        if (object instanceof Object[]) {
+            return (Object[]) object;
+        } else {
+            Object[] wrapper = new Object[1];
+            wrapper[0] = object;
+            return wrapper;
+        }
+    }
+
+    @Override
+    protected void doStart() throws Exception {
+        super.doStart();
+    }
+
+    @Override
+    protected void doStop() throws Exception {
+        super.doStop();
+        if (transceiver != null) {
+            transceiver.close();
+        }
+    }
+
+    @Override
+    public AvroEndpoint getEndpoint() {
+        return (AvroEndpoint) super.getEndpoint();
+    }
+}

Added: camel/trunk/components/camel-avro/src/main/java/org/apache/camel/component/avro/AvroRequestor.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-avro/src/main/java/org/apache/camel/component/avro/AvroRequestor.java?rev=1240351&view=auto
==============================================================================
--- camel/trunk/components/camel-avro/src/main/java/org/apache/camel/component/avro/AvroRequestor.java (added)
+++ camel/trunk/components/camel-avro/src/main/java/org/apache/camel/component/avro/AvroRequestor.java Fri Feb  3 21:41:13 2012
@@ -0,0 +1,30 @@
+/**
+ * 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.avro;
+
+import java.io.IOException;
+import org.apache.avro.Protocol;
+import org.apache.avro.ipc.Transceiver;
+import org.apache.avro.ipc.specific.SpecificRequestor;
+
+public class AvroRequestor extends SpecificRequestor {
+
+    public AvroRequestor(Protocol protocol, Transceiver transceiver) throws IOException {
+        super(protocol, transceiver);
+    }
+}

Added: camel/trunk/components/camel-avro/src/main/java/org/apache/camel/component/avro/AvroResponder.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-avro/src/main/java/org/apache/camel/component/avro/AvroResponder.java?rev=1240351&view=auto
==============================================================================
--- camel/trunk/components/camel-avro/src/main/java/org/apache/camel/component/avro/AvroResponder.java (added)
+++ camel/trunk/components/camel-avro/src/main/java/org/apache/camel/component/avro/AvroResponder.java Fri Feb  3 21:41:13 2012
@@ -0,0 +1,80 @@
+/**
+ * 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.avro;
+
+import org.apache.avro.Protocol;
+import org.apache.avro.Schema;
+import org.apache.avro.generic.GenericRecord;
+import org.apache.avro.ipc.specific.SpecificResponder;
+import org.apache.avro.specific.SpecificData;
+import org.apache.camel.Exchange;
+import org.apache.camel.util.ExchangeHelper;
+
+public class AvroResponder extends SpecificResponder {
+
+    private AvroConsumer consumer;
+
+    /**
+     * Constructor
+     *
+     * @param consumer
+     */
+    public AvroResponder(AvroConsumer consumer) {
+        super(consumer.getEndpoint().getProtocol(), null);
+        this.consumer = consumer;
+    }
+
+    @Override
+    public Object respond(Protocol.Message message, Object request) throws Exception {
+        Object response = null;
+        int numParams = message.getRequest().getFields().size();
+        Object[] params = new Object[numParams];
+        Class[] paramTypes = new Class[numParams];
+        int i = 0;
+        for (Schema.Field param : message.getRequest().getFields()) {
+            params[i] = ((GenericRecord) request).get(param.name());
+            paramTypes[i] = SpecificData.get().getClass(param.schema());
+            i++;
+        }
+        Exchange exchange = consumer.getEndpoint().createExchange(message, params);
+
+        try {
+            consumer.getProcessor().process(exchange);
+        } catch (Throwable e) {
+            consumer.getExceptionHandler().handleException(e);
+        }
+
+        if (ExchangeHelper.isOutCapable(exchange)) {
+            response = exchange.getOut().getBody();
+        } else {
+            response = null;
+        }
+
+        boolean failed = exchange.isFailed();
+        if (failed) {
+            if (exchange.getException() != null) {
+                response = exchange.getException();
+            } else {
+                // failed and no exception, must be a fault
+                response = exchange.getOut().getBody();
+            }
+        }
+        return response;
+
+    }
+}

Added: camel/trunk/components/camel-avro/src/main/java/org/apache/camel/dataformat/avro/AvroDataFormat.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-avro/src/main/java/org/apache/camel/dataformat/avro/AvroDataFormat.java?rev=1240351&view=auto
==============================================================================
--- camel/trunk/components/camel-avro/src/main/java/org/apache/camel/dataformat/avro/AvroDataFormat.java (added)
+++ camel/trunk/components/camel-avro/src/main/java/org/apache/camel/dataformat/avro/AvroDataFormat.java Fri Feb  3 21:41:13 2012
@@ -0,0 +1,123 @@
+/**
+ * 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.dataformat.avro;
+
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.lang.reflect.Method;
+import org.apache.avro.Schema;
+import org.apache.avro.generic.GenericContainer;
+import org.apache.avro.generic.GenericRecord;
+import org.apache.avro.io.DatumReader;
+import org.apache.avro.io.DatumWriter;
+import org.apache.avro.io.Decoder;
+import org.apache.avro.io.DecoderFactory;
+import org.apache.avro.io.Encoder;
+import org.apache.avro.io.EncoderFactory;
+import org.apache.avro.specific.SpecificDatumReader;
+import org.apache.avro.specific.SpecificDatumWriter;
+import org.apache.camel.CamelContext;
+import org.apache.camel.CamelException;
+import org.apache.camel.Exchange;
+import org.apache.camel.spi.DataFormat;
+import org.apache.camel.util.ObjectHelper;
+
+public class AvroDataFormat implements DataFormat {
+
+    private Schema schema;
+    private String instanceClassName;
+
+
+    /**
+     * @param schema
+     */
+    public AvroDataFormat(Schema schema) {
+        this.schema = schema;
+    }
+
+    public AvroDataFormat() {
+    }
+
+    public synchronized Schema getSchema(Exchange exchange, Object graph) throws Exception {
+        if (schema == null) {
+            if (instanceClassName != null) {
+                return loadDefaultSchema(instanceClassName, exchange.getContext());
+            }
+            if (graph != null && graph instanceof GenericContainer) {
+                return loadDefaultSchema(graph.getClass().getName(), exchange.getContext());
+            } else {
+                throw new CamelException("There is not schema for avro marshaling / unmarshaling");
+            }
+        }
+        return schema;
+    }
+
+    public void setSchema(Object schema) {
+        if (schema instanceof Schema) {
+            this.schema = (Schema) schema;
+        } else {
+            throw new IllegalArgumentException("The argument for setDefaultInstance should be subClass of " + Schema.class.getName());
+        }
+    }
+
+    public void setInstanceClass(String className) throws Exception {
+        ObjectHelper.notNull(className, "AvroDataFormat messageClass");
+        instanceClassName = className;
+    }
+
+    protected Schema loadDefaultSchema(String className, CamelContext context) throws CamelException, ClassNotFoundException {
+        Class<?> instanceClass = context.getClassResolver().resolveMandatoryClass(className);
+        if (GenericContainer.class.isAssignableFrom(instanceClass)) {
+            try {
+                Method method = instanceClass.getMethod("getSchema", new Class[0]);
+                return (Schema) method.invoke(instanceClass.newInstance(), new Object[0]);
+            } catch (Exception ex) {
+                throw new CamelException("Can't set the defaultInstance of AvroDataFormat with "
+                        + className + ", caused by " + ex);
+            }
+        } else {
+            throw new CamelException("Can't set the shcema of AvroDataFormat with "
+                    + className + ", as the class is not a subClass of SpecificData");
+        }
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see org.apache.camel.spi.DataFormat#marshal(org.apache.camel.Exchange,
+     * java.lang.Object, java.io.OutputStream)
+     */
+    public void marshal(Exchange exchange, Object graph, OutputStream outputStream) throws Exception {
+        DatumWriter datum = new SpecificDatumWriter(getSchema(exchange, graph));
+        Encoder encoder = EncoderFactory.get().binaryEncoder(outputStream, null);
+        datum.write(graph, encoder);
+        encoder.flush();
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see org.apache.camel.spi.DataFormat#unmarshal(org.apache.camel.Exchange,
+     * java.io.InputStream)
+     */
+    public Object unmarshal(Exchange exchange, InputStream inputStream) throws Exception {
+        DatumReader<GenericRecord> reader = new SpecificDatumReader(getSchema(exchange, null));
+        Decoder decoder = DecoderFactory.get().binaryDecoder(inputStream, null);
+        Object result = reader.read(null, decoder);
+        return result;
+    }
+
+}

Added: camel/trunk/components/camel-avro/src/main/resources/META-INF/services/org/apache/camel/component/avro
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-avro/src/main/resources/META-INF/services/org/apache/camel/component/avro?rev=1240351&view=auto
==============================================================================
--- camel/trunk/components/camel-avro/src/main/resources/META-INF/services/org/apache/camel/component/avro (added)
+++ camel/trunk/components/camel-avro/src/main/resources/META-INF/services/org/apache/camel/component/avro Fri Feb  3 21:41:13 2012
@@ -0,0 +1,17 @@
+#
+# 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.avro.AvroComponent

Added: camel/trunk/components/camel-avro/src/main/resources/META-INF/services/org/apache/camel/dataformat/avro
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-avro/src/main/resources/META-INF/services/org/apache/camel/dataformat/avro?rev=1240351&view=auto
==============================================================================
--- camel/trunk/components/camel-avro/src/main/resources/META-INF/services/org/apache/camel/dataformat/avro (added)
+++ camel/trunk/components/camel-avro/src/main/resources/META-INF/services/org/apache/camel/dataformat/avro Fri Feb  3 21:41:13 2012
@@ -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.dataformat.avro.AvroDataFormat

Added: camel/trunk/components/camel-avro/src/test/avro/test.avpr
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-avro/src/test/avro/test.avpr?rev=1240351&view=auto
==============================================================================
--- camel/trunk/components/camel-avro/src/test/avro/test.avpr (added)
+++ camel/trunk/components/camel-avro/src/test/avro/test.avpr Fri Feb  3 21:41:13 2012
@@ -0,0 +1,27 @@
+{"namespace": "org.apache.camel.avro.generated",
+ "protocol": "KeyValueProtocol",
+
+ "types": [
+     {"name": "Key", "type": "record",
+      "fields": [
+          {"name": "key",   "type": "string"}
+      ]
+     },
+     {"name": "Value", "type": "record",
+      "fields": [
+          {"name": "value",   "type": "string"}
+      ]
+     }
+ ],
+
+ "messages": {
+     "put": {
+         "request": [{"name": "key", "type": "Key"}, {"name": "value", "type": "Value"} ],
+         "response": "null"
+     },
+     "get": {
+         "request": [{"name": "key", "type": "Key"}],
+         "response": "Value"
+     }
+ }
+}
\ No newline at end of file

Added: camel/trunk/components/camel-avro/src/test/java/org/apache/camel/avro/generated/Key.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-avro/src/test/java/org/apache/camel/avro/generated/Key.java?rev=1240351&view=auto
==============================================================================
--- camel/trunk/components/camel-avro/src/test/java/org/apache/camel/avro/generated/Key.java (added)
+++ camel/trunk/components/camel-avro/src/test/java/org/apache/camel/avro/generated/Key.java Fri Feb  3 21:41:13 2012
@@ -0,0 +1,121 @@
+/**
+ * Autogenerated by Avro
+ * 
+ * DO NOT EDIT DIRECTLY
+ */
+package org.apache.camel.avro.generated;  
+@SuppressWarnings("all")
+public class Key extends org.apache.avro.specific.SpecificRecordBase implements org.apache.avro.specific.SpecificRecord {
+  public static final org.apache.avro.Schema SCHEMA$ = org.apache.avro.Schema.parse("{\"type\":\"record\",\"name\":\"Key\",\"namespace\":\"org.apache.camel.avro.generated\",\"fields\":[{\"name\":\"key\",\"type\":\"string\"}]}");
+  @Deprecated public java.lang.CharSequence key;
+  public org.apache.avro.Schema getSchema() { return SCHEMA$; }
+  // Used by DatumWriter.  Applications should not call. 
+  public java.lang.Object get(int field$) {
+    switch (field$) {
+    case 0: return key;
+    default: throw new org.apache.avro.AvroRuntimeException("Bad index");
+    }
+  }
+  // Used by DatumReader.  Applications should not call. 
+  @SuppressWarnings(value="unchecked")
+  public void put(int field$, java.lang.Object value$) {
+    switch (field$) {
+    case 0: key = (java.lang.CharSequence)value$; break;
+    default: throw new org.apache.avro.AvroRuntimeException("Bad index");
+    }
+  }
+
+  /**
+   * Gets the value of the 'key' field.
+   */
+  public java.lang.CharSequence getKey() {
+    return key;
+  }
+
+  /**
+   * Sets the value of the 'key' field.
+   * @param value the value to set.
+   */
+  public void setKey(java.lang.CharSequence value) {
+    this.key = value;
+  }
+
+  /** Creates a new Key RecordBuilder */
+  public static org.apache.camel.avro.generated.Key.Builder newBuilder() {
+    return new org.apache.camel.avro.generated.Key.Builder();
+  }
+  
+  /** Creates a new Key RecordBuilder by copying an existing Builder */
+  public static org.apache.camel.avro.generated.Key.Builder newBuilder(org.apache.camel.avro.generated.Key.Builder other) {
+    return new org.apache.camel.avro.generated.Key.Builder(other);
+  }
+  
+  /** Creates a new Key RecordBuilder by copying an existing Key instance */
+  public static org.apache.camel.avro.generated.Key.Builder newBuilder(org.apache.camel.avro.generated.Key other) {
+    return new org.apache.camel.avro.generated.Key.Builder(other);
+  }
+  
+  /**
+   * RecordBuilder for Key instances.
+   */
+  public static class Builder extends org.apache.avro.specific.SpecificRecordBuilderBase<Key>
+    implements org.apache.avro.data.RecordBuilder<Key> {
+
+    private java.lang.CharSequence key;
+
+    /** Creates a new Builder */
+    private Builder() {
+      super(org.apache.camel.avro.generated.Key.SCHEMA$);
+    }
+    
+    /** Creates a Builder by copying an existing Builder */
+    private Builder(org.apache.camel.avro.generated.Key.Builder other) {
+      super(other);
+    }
+    
+    /** Creates a Builder by copying an existing Key instance */
+    private Builder(org.apache.camel.avro.generated.Key other) {
+            super(org.apache.camel.avro.generated.Key.SCHEMA$);
+      if (isValidValue(fields()[0], other.key)) {
+        this.key = (java.lang.CharSequence) data().deepCopy(fields()[0].schema(), other.key);
+        fieldSetFlags()[0] = true;
+      }
+    }
+
+    /** Gets the value of the 'key' field */
+    public java.lang.CharSequence getKey() {
+      return key;
+    }
+    
+    /** Sets the value of the 'key' field */
+    public org.apache.camel.avro.generated.Key.Builder setKey(java.lang.CharSequence value) {
+      validate(fields()[0], value);
+      this.key = value;
+      fieldSetFlags()[0] = true;
+      return this; 
+    }
+    
+    /** Checks whether the 'key' field has been set */
+    public boolean hasKey() {
+      return fieldSetFlags()[0];
+    }
+    
+    /** Clears the value of the 'key' field */
+    public org.apache.camel.avro.generated.Key.Builder clearKey() {
+      key = null;
+      fieldSetFlags()[0] = false;
+      return this;
+    }
+
+    @Override
+    public Key build() {
+      try {
+        Key record = new Key();
+        record.key = fieldSetFlags()[0] ? this.key : (java.lang.CharSequence) defaultValue(fields()[0]);
+        return record;
+      } catch (Exception e) {
+        throw new org.apache.avro.AvroRuntimeException(e);
+      }
+    }
+  }
+}

Added: camel/trunk/components/camel-avro/src/test/java/org/apache/camel/avro/generated/KeyValueProtocol.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-avro/src/test/java/org/apache/camel/avro/generated/KeyValueProtocol.java?rev=1240351&view=auto
==============================================================================
--- camel/trunk/components/camel-avro/src/test/java/org/apache/camel/avro/generated/KeyValueProtocol.java (added)
+++ camel/trunk/components/camel-avro/src/test/java/org/apache/camel/avro/generated/KeyValueProtocol.java Fri Feb  3 21:41:13 2012
@@ -0,0 +1,20 @@
+/**
+ * Autogenerated by Avro
+ * 
+ * DO NOT EDIT DIRECTLY
+ */
+package org.apache.camel.avro.generated;
+
+@SuppressWarnings("all")
+public interface KeyValueProtocol {
+  public static final org.apache.avro.Protocol PROTOCOL = org.apache.avro.Protocol.parse("{\"protocol\":\"KeyValueProtocol\",\"namespace\":\"org.apache.camel.avro.generated\",\"types\":[{\"type\":\"record\",\"name\":\"Key\",\"fields\":[{\"name\":\"key\",\"type\":\"string\"}]},{\"type\":\"record\",\"name\":\"Value\",\"fields\":[{\"name\":\"value\",\"type\":\"string\"}]}],\"messages\":{\"put\":{\"request\":[{\"name\":\"key\",\"type\":\"Key\"},{\"name\":\"value\",\"type\":\"Value\"}],\"response\":\"null\"},\"get\":{\"request\":[{\"name\":\"key\",\"type\":\"Key\"}],\"response\":\"Value\"}}}");
+  java.lang.Void put(org.apache.camel.avro.generated.Key key, org.apache.camel.avro.generated.Value value) throws org.apache.avro.AvroRemoteException;
+  org.apache.camel.avro.generated.Value get(org.apache.camel.avro.generated.Key key) throws org.apache.avro.AvroRemoteException;
+
+  @SuppressWarnings("all")
+  public interface Callback extends KeyValueProtocol {
+    public static final org.apache.avro.Protocol PROTOCOL = org.apache.camel.avro.generated.KeyValueProtocol.PROTOCOL;
+    void put(org.apache.camel.avro.generated.Key key, org.apache.camel.avro.generated.Value value, org.apache.avro.ipc.Callback<java.lang.Void> callback) throws java.io.IOException;
+    void get(org.apache.camel.avro.generated.Key key, org.apache.avro.ipc.Callback<org.apache.camel.avro.generated.Value> callback) throws java.io.IOException;
+  }
+}
\ No newline at end of file

Added: camel/trunk/components/camel-avro/src/test/java/org/apache/camel/avro/generated/Value.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-avro/src/test/java/org/apache/camel/avro/generated/Value.java?rev=1240351&view=auto
==============================================================================
--- camel/trunk/components/camel-avro/src/test/java/org/apache/camel/avro/generated/Value.java (added)
+++ camel/trunk/components/camel-avro/src/test/java/org/apache/camel/avro/generated/Value.java Fri Feb  3 21:41:13 2012
@@ -0,0 +1,121 @@
+/**
+ * Autogenerated by Avro
+ * 
+ * DO NOT EDIT DIRECTLY
+ */
+package org.apache.camel.avro.generated;  
+@SuppressWarnings("all")
+public class Value extends org.apache.avro.specific.SpecificRecordBase implements org.apache.avro.specific.SpecificRecord {
+  public static final org.apache.avro.Schema SCHEMA$ = org.apache.avro.Schema.parse("{\"type\":\"record\",\"name\":\"Value\",\"namespace\":\"org.apache.camel.avro.generated\",\"fields\":[{\"name\":\"value\",\"type\":\"string\"}]}");
+  @Deprecated public java.lang.CharSequence value;
+  public org.apache.avro.Schema getSchema() { return SCHEMA$; }
+  // Used by DatumWriter.  Applications should not call. 
+  public java.lang.Object get(int field$) {
+    switch (field$) {
+    case 0: return value;
+    default: throw new org.apache.avro.AvroRuntimeException("Bad index");
+    }
+  }
+  // Used by DatumReader.  Applications should not call. 
+  @SuppressWarnings(value="unchecked")
+  public void put(int field$, java.lang.Object value$) {
+    switch (field$) {
+    case 0: value = (java.lang.CharSequence)value$; break;
+    default: throw new org.apache.avro.AvroRuntimeException("Bad index");
+    }
+  }
+
+  /**
+   * Gets the value of the 'value' field.
+   */
+  public java.lang.CharSequence getValue() {
+    return value;
+  }
+
+  /**
+   * Sets the value of the 'value' field.
+   * @param value the value to set.
+   */
+  public void setValue(java.lang.CharSequence value) {
+    this.value = value;
+  }
+
+  /** Creates a new Value RecordBuilder */
+  public static org.apache.camel.avro.generated.Value.Builder newBuilder() {
+    return new org.apache.camel.avro.generated.Value.Builder();
+  }
+  
+  /** Creates a new Value RecordBuilder by copying an existing Builder */
+  public static org.apache.camel.avro.generated.Value.Builder newBuilder(org.apache.camel.avro.generated.Value.Builder other) {
+    return new org.apache.camel.avro.generated.Value.Builder(other);
+  }
+  
+  /** Creates a new Value RecordBuilder by copying an existing Value instance */
+  public static org.apache.camel.avro.generated.Value.Builder newBuilder(org.apache.camel.avro.generated.Value other) {
+    return new org.apache.camel.avro.generated.Value.Builder(other);
+  }
+  
+  /**
+   * RecordBuilder for Value instances.
+   */
+  public static class Builder extends org.apache.avro.specific.SpecificRecordBuilderBase<Value>
+    implements org.apache.avro.data.RecordBuilder<Value> {
+
+    private java.lang.CharSequence value;
+
+    /** Creates a new Builder */
+    private Builder() {
+      super(org.apache.camel.avro.generated.Value.SCHEMA$);
+    }
+    
+    /** Creates a Builder by copying an existing Builder */
+    private Builder(org.apache.camel.avro.generated.Value.Builder other) {
+      super(other);
+    }
+    
+    /** Creates a Builder by copying an existing Value instance */
+    private Builder(org.apache.camel.avro.generated.Value other) {
+            super(org.apache.camel.avro.generated.Value.SCHEMA$);
+      if (isValidValue(fields()[0], other.value)) {
+        this.value = (java.lang.CharSequence) data().deepCopy(fields()[0].schema(), other.value);
+        fieldSetFlags()[0] = true;
+      }
+    }
+
+    /** Gets the value of the 'value' field */
+    public java.lang.CharSequence getValue() {
+      return value;
+    }
+    
+    /** Sets the value of the 'value' field */
+    public org.apache.camel.avro.generated.Value.Builder setValue(java.lang.CharSequence value) {
+      validate(fields()[0], value);
+      this.value = value;
+      fieldSetFlags()[0] = true;
+      return this; 
+    }
+    
+    /** Checks whether the 'value' field has been set */
+    public boolean hasValue() {
+      return fieldSetFlags()[0];
+    }
+    
+    /** Clears the value of the 'value' field */
+    public org.apache.camel.avro.generated.Value.Builder clearValue() {
+      value = null;
+      fieldSetFlags()[0] = false;
+      return this;
+    }
+
+    @Override
+    public Value build() {
+      try {
+        Value record = new Value();
+        record.value = fieldSetFlags()[0] ? this.value : (java.lang.CharSequence) defaultValue(fields()[0]);
+        return record;
+      } catch (Exception e) {
+        throw new org.apache.avro.AvroRuntimeException(e);
+      }
+    }
+  }
+}

Added: camel/trunk/components/camel-avro/src/test/java/org/apache/camel/avro/impl/KeyValueProtocolImpl.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-avro/src/test/java/org/apache/camel/avro/impl/KeyValueProtocolImpl.java?rev=1240351&view=auto
==============================================================================
--- camel/trunk/components/camel-avro/src/test/java/org/apache/camel/avro/impl/KeyValueProtocolImpl.java (added)
+++ camel/trunk/components/camel-avro/src/test/java/org/apache/camel/avro/impl/KeyValueProtocolImpl.java Fri Feb  3 21:41:13 2012
@@ -0,0 +1,49 @@
+/**
+ * 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.avro.impl;
+
+import java.util.HashMap;
+import java.util.Map;
+import org.apache.avro.AvroRemoteException;
+import org.apache.camel.avro.generated.Key;
+import org.apache.camel.avro.generated.KeyValueProtocol;
+import org.apache.camel.avro.generated.Value;
+
+public class KeyValueProtocolImpl implements KeyValueProtocol {
+
+    private Map<Key, Value> store = new HashMap<Key, Value>();
+
+    @Override
+    public Void put(Key key, Value value) throws AvroRemoteException {
+        store.put(key, value);
+        return null;
+    }
+
+    @Override
+    public Value get(Key key) throws AvroRemoteException {
+        return store.get(key);
+    }
+
+    public Map<Key, Value> getStore() {
+        return store;
+    }
+
+    public void setStore(Map<Key, Value> store) {
+        this.store = store;
+    }
+}

Added: camel/trunk/components/camel-avro/src/test/java/org/apache/camel/component/avro/AvroConsumerTestSupport.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-avro/src/test/java/org/apache/camel/component/avro/AvroConsumerTestSupport.java?rev=1240351&view=auto
==============================================================================
--- camel/trunk/components/camel-avro/src/test/java/org/apache/camel/component/avro/AvroConsumerTestSupport.java (added)
+++ camel/trunk/components/camel-avro/src/test/java/org/apache/camel/component/avro/AvroConsumerTestSupport.java Fri Feb  3 21:41:13 2012
@@ -0,0 +1,91 @@
+/**
+ * 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.avro;
+
+import java.io.IOException;
+import junit.framework.Assert;
+import org.apache.avro.Protocol;
+import org.apache.avro.ipc.Requestor;
+import org.apache.avro.ipc.Transceiver;
+import org.apache.camel.CamelContext;
+import org.apache.camel.avro.generated.Key;
+import org.apache.camel.avro.generated.KeyValueProtocol;
+import org.apache.camel.avro.generated.Value;
+import org.apache.camel.avro.impl.KeyValueProtocolImpl;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.test.CamelTestSupport;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+public abstract class AvroConsumerTestSupport extends AvroTestSupport {
+
+    Transceiver transceiver;
+    Requestor requestor;
+    KeyValueProtocolImpl keyValue = new KeyValueProtocolImpl();
+
+    protected abstract void initializeTranceiver() throws IOException;
+
+    @Before
+    protected void setUp() throws Exception {
+        super.setUp();
+    }
+
+    @After
+    protected void tearDown() throws Exception {
+        super.tearDown();
+        if (transceiver != null) {
+            transceiver.close();
+        }
+    }
+
+
+    @Test
+    public void testInOnly() throws Exception {
+        initializeTranceiver();
+        Key key = Key.newBuilder().setKey("1").build();
+        Value value = Value.newBuilder().setValue("test value").build();
+        Object[] request = {key, value};
+        requestor.request("put", request);
+    }
+
+
+    @Test
+    public void testInOut() throws Exception {
+        initializeTranceiver();
+        keyValue.getStore().clear();
+        Key key = Key.newBuilder().setKey("2").build();
+        Value value = Value.newBuilder().setValue("test value").build();
+        keyValue.getStore().put(key, value);
+        Object[] request = {key};
+        Object response = requestor.request("get", request);
+        Assert.assertEquals(value, response);
+    }
+
+    @Override
+    protected CamelContext createCamelContext() throws Exception {
+        CamelContext context = super.createCamelContext();
+        Protocol protocol = KeyValueProtocol.PROTOCOL;
+        AvroConfiguration configuration = new AvroConfiguration();
+        configuration.setProtocol(protocol);
+        AvroComponent component = new AvroComponent(context);
+        component.setConfiguration(configuration);
+        context.addComponent("avro", component);
+        return context;
+    }
+}
\ No newline at end of file

Added: camel/trunk/components/camel-avro/src/test/java/org/apache/camel/component/avro/AvroHttpConsumerTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-avro/src/test/java/org/apache/camel/component/avro/AvroHttpConsumerTest.java?rev=1240351&view=auto
==============================================================================
--- camel/trunk/components/camel-avro/src/test/java/org/apache/camel/component/avro/AvroHttpConsumerTest.java (added)
+++ camel/trunk/components/camel-avro/src/test/java/org/apache/camel/component/avro/AvroHttpConsumerTest.java Fri Feb  3 21:41:13 2012
@@ -0,0 +1,50 @@
+/**
+ * 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.avro;
+
+import java.io.IOException;
+import java.net.URL;
+import org.apache.avro.ipc.HttpTransceiver;
+import org.apache.avro.ipc.specific.SpecificRequestor;
+import org.apache.camel.avro.generated.KeyValueProtocol;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.avro.processors.GetProcessor;
+import org.apache.camel.component.avro.processors.PutProcessor;
+
+public class AvroHttpConsumerTest extends AvroConsumerTestSupport {
+
+    static int avroPort = setupFreePort("avroport");
+
+    @Override
+    protected void initializeTranceiver() throws IOException {
+        transceiver = new HttpTransceiver(new URL("http://localhost:" + avroPort));
+        requestor = new SpecificRequestor(KeyValueProtocol.class, transceiver);
+    }
+
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                //In Only
+                from("avro:http:localhost:" + avroPort).choice()
+                        .when().el("${in.headers." + AvroConstants.AVRO_MESSAGE_NAME + " == 'put'}").process(new PutProcessor(keyValue))
+                        .when().el("${in.headers." + AvroConstants.AVRO_MESSAGE_NAME + " == 'get'}").process(new GetProcessor(keyValue));
+            }
+        };
+    }
+}