camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cmuel...@apache.org
Subject svn commit: r1337262 - in /camel/trunk: camel-core/src/main/java/org/apache/camel/model/dataformat/ components/camel-jaxb/src/main/java/org/apache/camel/converter/jaxb/ components/camel-jaxb/src/test/java/org/apache/camel/converter/jaxb/ components/cam...
Date Fri, 11 May 2012 16:30:03 GMT
Author: cmueller
Date: Fri May 11 16:30:02 2012
New Revision: 1337262

URL: http://svn.apache.org/viewvc?rev=1337262&view=rev
Log:
Revert "CAMEL-5267: Improve camel-jaxb to be able to set a custom NameSpacePrefixMapper"

This reverts commit 65530247f507bddfc469e45dc85fac40faa8c4af.

Removed:
    camel/trunk/components/camel-jaxb/src/test/java/org/apache/camel/jaxb/MarshalWithNamespacePrefixMapperTest.java
    camel/trunk/components/camel-jaxb/src/test/java/org/apache/camel/jaxb/MyNameSpacePrefixMapper.java
    camel/trunk/components/camel-jaxb/src/test/resources/org/apache/camel/jaxb/marshalWithNamespacePrefixMapper.xml
Modified:
    camel/trunk/camel-core/src/main/java/org/apache/camel/model/dataformat/JaxbDataFormat.java
    camel/trunk/components/camel-jaxb/src/main/java/org/apache/camel/converter/jaxb/JaxbDataFormat.java
    camel/trunk/components/camel-jaxb/src/test/java/org/apache/camel/converter/jaxb/JaxbDataFormatMultipleNamespacesTest.java
    camel/trunk/components/camel-jaxb/src/test/resources/org/apache/camel/example/jaxb.index

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/model/dataformat/JaxbDataFormat.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/model/dataformat/JaxbDataFormat.java?rev=1337262&r1=1337261&r2=1337262&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/model/dataformat/JaxbDataFormat.java
(original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/model/dataformat/JaxbDataFormat.java
Fri May 11 16:30:02 2012
@@ -20,12 +20,10 @@ 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 javax.xml.namespace.QName;
 
 import org.apache.camel.model.DataFormatDefinition;
 import org.apache.camel.spi.DataFormat;
-import org.apache.camel.spi.RouteContext;
 import org.apache.camel.util.ObjectHelper;
 
 /**
@@ -53,10 +51,6 @@ public class JaxbDataFormat extends Data
     private String partClass;
     @XmlAttribute
     private String partNamespace;
-    @XmlAttribute
-    private String nameSpacePrefixMapper;
-    @XmlTransient
-    private Object nameSpacePrefixMapperInstance;
 
     public JaxbDataFormat() {
         super("jaxb");
@@ -131,27 +125,6 @@ public class JaxbDataFormat extends Data
         this.partNamespace = partNamespace;
     }
 
-    public String getNameSpacePrefixMapper() {
-        return nameSpacePrefixMapper;
-    }
-
-    public void setNameSpacePrefixMapper(String nameSpacePrefixMapper) {
-        this.nameSpacePrefixMapper = nameSpacePrefixMapper;
-    }
-    
-    protected DataFormat createDataFormat(RouteContext routeContext) {
-        if (nameSpacePrefixMapper != null) {
-            try {
-                Class<?> clazz = routeContext.getCamelContext().getClassResolver().resolveMandatoryClass(nameSpacePrefixMapper);
-                nameSpacePrefixMapperInstance = clazz.newInstance();
-            } catch (Exception e) {
-                throw ObjectHelper.wrapRuntimeCamelException(e);
-            }   
-        }
-        
-        return super.createDataFormat(routeContext);
-    }
-
     @Override
     protected void configureDataFormat(DataFormat dataFormat) {
         Boolean answer = ObjectHelper.toBoolean(getPrettyPrint());
@@ -188,8 +161,6 @@ public class JaxbDataFormat extends Data
             setProperty(dataFormat, "encoding", encoding);
         }
         setProperty(dataFormat, "contextPath", contextPath);
-        if (nameSpacePrefixMapperInstance != null) {
-            setProperty(dataFormat, "nameSpacePrefixMapper", nameSpacePrefixMapperInstance);
-        }
     }
+
 }
\ No newline at end of file

Modified: camel/trunk/components/camel-jaxb/src/main/java/org/apache/camel/converter/jaxb/JaxbDataFormat.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jaxb/src/main/java/org/apache/camel/converter/jaxb/JaxbDataFormat.java?rev=1337262&r1=1337261&r2=1337262&view=diff
==============================================================================
--- camel/trunk/components/camel-jaxb/src/main/java/org/apache/camel/converter/jaxb/JaxbDataFormat.java
(original)
+++ camel/trunk/components/camel-jaxb/src/main/java/org/apache/camel/converter/jaxb/JaxbDataFormat.java
Fri May 11 16:30:02 2012
@@ -32,8 +32,6 @@ import javax.xml.stream.XMLStreamExcepti
 import javax.xml.stream.XMLStreamReader;
 import javax.xml.stream.XMLStreamWriter;
 
-import com.sun.xml.bind.marshaller.NamespacePrefixMapper;
-
 import org.apache.camel.CamelContext;
 import org.apache.camel.CamelContextAware;
 import org.apache.camel.Exchange;
@@ -45,6 +43,8 @@ import org.apache.camel.util.ObjectHelpe
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import com.sun.xml.bind.marshaller.NamespacePrefixMapper;
+
 /**
  * A <a href="http://camel.apache.org/data-format.html">data format</a> ({@link
DataFormat})
  * using JAXB2 to marshal to and from XML

Modified: camel/trunk/components/camel-jaxb/src/test/java/org/apache/camel/converter/jaxb/JaxbDataFormatMultipleNamespacesTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jaxb/src/test/java/org/apache/camel/converter/jaxb/JaxbDataFormatMultipleNamespacesTest.java?rev=1337262&r1=1337261&r2=1337262&view=diff
==============================================================================
--- camel/trunk/components/camel-jaxb/src/test/java/org/apache/camel/converter/jaxb/JaxbDataFormatMultipleNamespacesTest.java
(original)
+++ camel/trunk/components/camel-jaxb/src/test/java/org/apache/camel/converter/jaxb/JaxbDataFormatMultipleNamespacesTest.java
Fri May 11 16:30:02 2012
@@ -23,10 +23,11 @@ import org.apache.camel.builder.RouteBui
 import org.apache.camel.component.mock.MockEndpoint;
 import org.apache.camel.example.Address;
 import org.apache.camel.example.Order;
-import org.apache.camel.jaxb.MyNameSpacePrefixMapper;
 import org.apache.camel.test.junit4.CamelTestSupport;
 import org.junit.Test;
 
+import com.sun.xml.bind.marshaller.NamespacePrefixMapper;
+
 public class JaxbDataFormatMultipleNamespacesTest extends CamelTestSupport {
 
     @EndpointInject(uri = "mock:marshall")
@@ -118,19 +119,28 @@ public class JaxbDataFormatMultipleNames
                 JaxbDataFormat jaxbDataFormat = new JaxbDataFormat(JAXBContext.newInstance(Order.class,
Address.class));
 
                 JaxbDataFormat jaxbDataFormatWithNamespacePrefixMapper = new JaxbDataFormat(JAXBContext.newInstance(Order.class,
Address.class));
-                jaxbDataFormatWithNamespacePrefixMapper.setNameSpacePrefixMapper(new MyNameSpacePrefixMapper());
+                jaxbDataFormatWithNamespacePrefixMapper.setNameSpacePrefixMapper(new NamespacePrefixMapper()
{
+                    public String getPreferredPrefix(String namespaceUri, String suggestion,
boolean requirePrefix) {
+                        if (namespaceUri.equals("http://www.camel.apache.org/jaxb/example/order/1"))
{
+                            return "order";
+                        } else if (namespaceUri.equals("http://www.camel.apache.org/jaxb/example/address/1"))
{
+                            return "address";
+                        }
+                        return "ns";
+                    }
+                });
                 
                 from("direct:marshall")
-                    .marshal(jaxbDataFormat)
-                    .to("mock:marshall");
+                        .marshal(jaxbDataFormat)
+                        .to("mock:marshall");
                 
                 from("direct:marshallWithNamespacePrefixMapper")
                     .marshal(jaxbDataFormatWithNamespacePrefixMapper)
                     .to("mock:marshall");
 
                 from("direct:unmarshall")
-                    .unmarshal(jaxbDataFormat)
-                    .to("mock:unmarshall");
+                        .unmarshal(jaxbDataFormat)
+                        .to("mock:unmarshall");
             }
         };
     }

Modified: camel/trunk/components/camel-jaxb/src/test/resources/org/apache/camel/example/jaxb.index
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jaxb/src/test/resources/org/apache/camel/example/jaxb.index?rev=1337262&r1=1337261&r2=1337262&view=diff
==============================================================================
--- camel/trunk/components/camel-jaxb/src/test/resources/org/apache/camel/example/jaxb.index
(original)
+++ camel/trunk/components/camel-jaxb/src/test/resources/org/apache/camel/example/jaxb.index
Fri May 11 16:30:02 2012
@@ -14,7 +14,6 @@
 ## See the License for the specific language governing permissions and
 ## limitations under the License.
 ## ------------------------------------------------------------------------
-Order
 PurchaseOrder
 Partial
 Foo



Mime
View raw message