You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ni...@apache.org on 2010/09/14 15:58:59 UTC

svn commit: r996902 - in /camel/trunk: camel-core/src/main/java/org/apache/camel/model/dataformat/ components/camel-protobuf/src/test/java/org/apache/camel/dataformat/protobuf/ components/camel-protobuf/src/test/resources/org/ components/camel-protobuf...

Author: ningjiang
Date: Tue Sep 14 13:58:59 2010
New Revision: 996902

URL: http://svn.apache.org/viewvc?rev=996902&view=rev
Log:
CAMEL-3112 fixed the issue of protobuf Spring DSL

Added:
    camel/trunk/components/camel-protobuf/src/test/java/org/apache/camel/dataformat/protobuf/ProtobufMarshalAndUnmarshalSpringTest.java   (with props)
    camel/trunk/components/camel-protobuf/src/test/java/org/apache/camel/dataformat/protobuf/ProtobufMarshalAndUnmarshallTest.java   (contents, props changed)
      - copied, changed from r996045, camel/trunk/components/camel-protobuf/src/test/java/org/apache/camel/dataformat/protobuf/ProtobufMarshalTest.java
    camel/trunk/components/camel-protobuf/src/test/resources/org/
    camel/trunk/components/camel-protobuf/src/test/resources/org/apache/
    camel/trunk/components/camel-protobuf/src/test/resources/org/apache/camel/
    camel/trunk/components/camel-protobuf/src/test/resources/org/apache/camel/dataformat/
    camel/trunk/components/camel-protobuf/src/test/resources/org/apache/camel/dataformat/protobuf/
    camel/trunk/components/camel-protobuf/src/test/resources/org/apache/camel/dataformat/protobuf/springDataFormat.xml   (with props)
Removed:
    camel/trunk/components/camel-protobuf/src/test/java/org/apache/camel/dataformat/protobuf/ProtobufMarshalTest.java
Modified:
    camel/trunk/camel-core/src/main/java/org/apache/camel/model/dataformat/DataFormatsDefinition.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/model/dataformat/ProtobufDataFormat.java

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/model/dataformat/DataFormatsDefinition.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/model/dataformat/DataFormatsDefinition.java?rev=996902&r1=996901&r2=996902&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/model/dataformat/DataFormatsDefinition.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/model/dataformat/DataFormatsDefinition.java Tue Sep 14 13:58:59 2010
@@ -46,6 +46,7 @@ public class DataFormatsDefinition {
         @XmlElement(required = false, name = "hl7", type = HL7DataFormat.class),
         @XmlElement(required = false, name = "jaxb", type = JaxbDataFormat.class),
         @XmlElement(required = false, name = "json", type = JsonDataFormat.class),
+        @XmlElement(required = false, name = "protobuf", type = ProtobufDataFormat.class),
         @XmlElement(required = false, name = "rss", type = RssDataFormat.class),
         @XmlElement(required = false, name = "secureXML", type = XMLSecurityDataFormat.class),
         @XmlElement(required = false, name = "serialization", type = SerializationDataFormat.class),

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/model/dataformat/ProtobufDataFormat.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/model/dataformat/ProtobufDataFormat.java?rev=996902&r1=996901&r2=996902&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/model/dataformat/ProtobufDataFormat.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/model/dataformat/ProtobufDataFormat.java Tue Sep 14 13:58:59 2010
@@ -20,6 +20,7 @@ import javax.xml.bind.annotation.XmlAcce
 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;
@@ -37,7 +38,7 @@ import org.apache.camel.util.ObjectHelpe
 public class ProtobufDataFormat extends DataFormatDefinition {
     @XmlAttribute(required = false)
     private String instanceClass;
-    
+    @XmlTransient
     private Object defaultInstance;
     
     public ProtobufDataFormat() {

Added: camel/trunk/components/camel-protobuf/src/test/java/org/apache/camel/dataformat/protobuf/ProtobufMarshalAndUnmarshalSpringTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-protobuf/src/test/java/org/apache/camel/dataformat/protobuf/ProtobufMarshalAndUnmarshalSpringTest.java?rev=996902&view=auto
==============================================================================
--- camel/trunk/components/camel-protobuf/src/test/java/org/apache/camel/dataformat/protobuf/ProtobufMarshalAndUnmarshalSpringTest.java (added)
+++ camel/trunk/components/camel-protobuf/src/test/java/org/apache/camel/dataformat/protobuf/ProtobufMarshalAndUnmarshalSpringTest.java Tue Sep 14 13:58:59 2010
@@ -0,0 +1,27 @@
+/**
+ * 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.protobuf;
+
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+public class ProtobufMarshalAndUnmarshalSpringTest extends ProtobufMarshalAndUnmarshallTest {
+
+    protected ClassPathXmlApplicationContext createApplicationContext() {
+        return new ClassPathXmlApplicationContext("org/apache/camel/dataformat/protobuf/springDataFormat.xml");
+    }
+
+}

Propchange: camel/trunk/components/camel-protobuf/src/test/java/org/apache/camel/dataformat/protobuf/ProtobufMarshalAndUnmarshalSpringTest.java
------------------------------------------------------------------------------
    svn:mergeinfo = 

Copied: camel/trunk/components/camel-protobuf/src/test/java/org/apache/camel/dataformat/protobuf/ProtobufMarshalAndUnmarshallTest.java (from r996045, camel/trunk/components/camel-protobuf/src/test/java/org/apache/camel/dataformat/protobuf/ProtobufMarshalTest.java)
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-protobuf/src/test/java/org/apache/camel/dataformat/protobuf/ProtobufMarshalAndUnmarshallTest.java?p2=camel/trunk/components/camel-protobuf/src/test/java/org/apache/camel/dataformat/protobuf/ProtobufMarshalAndUnmarshallTest.java&p1=camel/trunk/components/camel-protobuf/src/test/java/org/apache/camel/dataformat/protobuf/ProtobufMarshalTest.java&r1=996045&r2=996902&rev=996902&view=diff
==============================================================================
--- camel/trunk/components/camel-protobuf/src/test/java/org/apache/camel/dataformat/protobuf/ProtobufMarshalTest.java (original)
+++ camel/trunk/components/camel-protobuf/src/test/java/org/apache/camel/dataformat/protobuf/ProtobufMarshalAndUnmarshallTest.java Tue Sep 14 13:58:59 2010
@@ -25,7 +25,7 @@ import org.apache.camel.dataformat.proto
 import org.apache.camel.test.junit4.CamelTestSupport;
 import org.junit.Test;
 
-public class ProtobufMarshalTest extends CamelTestSupport {
+public class ProtobufMarshalAndUnmarshallTest extends CamelTestSupport {
 
     @Test
     public void testMarshalAndUnmarshalWithDataFormat() throws Exception {

Propchange: camel/trunk/components/camel-protobuf/src/test/java/org/apache/camel/dataformat/protobuf/ProtobufMarshalAndUnmarshallTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-protobuf/src/test/java/org/apache/camel/dataformat/protobuf/ProtobufMarshalAndUnmarshallTest.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: camel/trunk/components/camel-protobuf/src/test/java/org/apache/camel/dataformat/protobuf/ProtobufMarshalAndUnmarshallTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: camel/trunk/components/camel-protobuf/src/test/java/org/apache/camel/dataformat/protobuf/ProtobufMarshalAndUnmarshallTest.java
------------------------------------------------------------------------------
    svn:mergeinfo = 

Added: camel/trunk/components/camel-protobuf/src/test/resources/org/apache/camel/dataformat/protobuf/springDataFormat.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-protobuf/src/test/resources/org/apache/camel/dataformat/protobuf/springDataFormat.xml?rev=996902&view=auto
==============================================================================
--- camel/trunk/components/camel-protobuf/src/test/resources/org/apache/camel/dataformat/protobuf/springDataFormat.xml (added)
+++ camel/trunk/components/camel-protobuf/src/test/resources/org/apache/camel/dataformat/protobuf/springDataFormat.xml Tue Sep 14 13:58:59 2010
@@ -0,0 +1,74 @@
+<?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.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xsi:schemaLocation="
+       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+       http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
+    ">
+
+  <!-- START SNIPPET: example 
+   from("direct:in").marshal(format);
+   from("direct:back").unmarshal(format).to("mock:reverse");
+             
+   from("direct:marshal").marshal().protobuf();
+   from("direct:unmarshalA").unmarshal().protobuf("org.apache.camel.dataformat.protobuf.generated.AddressBookProtos$Person").to("mock:reverse");
+                
+   from("direct:unmarshalB").unmarshal().protobuf(Person.getDefaultInstance()).to("mock:reverse");
+  -->
+  
+  
+    
+  <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
+    <dataFormats>
+      <protobuf id="protobuf1" instanceClass="org.apache.camel.dataformat.protobuf.generated.AddressBookProtos$Person"/>
+    </dataFormats>
+    <route>
+      <from uri="direct:in"/>
+      <marshal>
+        <protobuf instanceClass="org.apache.camel.dataformat.protobuf.generated.AddressBookProtos$Person"/>
+      </marshal>
+    </route>
+    <route>
+      <from uri="direct:back"/>
+      <unmarshal>
+        <protobuf instanceClass="org.apache.camel.dataformat.protobuf.generated.AddressBookProtos$Person"/>
+      </unmarshal>
+      <to uri="mock:reverse"/>
+    </route>
+    <route>
+      <from uri="direct:marshal"/>
+      <marshal ref="protobuf1"/>
+    </route>
+    <route>
+      <from uri="direct:unmarshalA"/>
+      <unmarshal ref="protobuf1"/>
+      <to uri="mock:reverse"/>
+    </route>
+    <route>
+      <from uri="direct:unmarshalB"/>
+      <unmarshal ref="protobuf1"/>
+      <to uri="mock:reverse"/>
+    </route>
+  </camelContext>
+ 
+  <bean id="protobuf2" class="org.apache.camel.datafromat.protobuf.ProtobufDataFormat">
+    <property name="instanceClassName" value="org.apache.camel.dataformat.protobuf.generated.AddressBookProtos$Person"/>
+  </bean>
+
+</beans>

Propchange: camel/trunk/components/camel-protobuf/src/test/resources/org/apache/camel/dataformat/protobuf/springDataFormat.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-protobuf/src/test/resources/org/apache/camel/dataformat/protobuf/springDataFormat.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: camel/trunk/components/camel-protobuf/src/test/resources/org/apache/camel/dataformat/protobuf/springDataFormat.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml