You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@camel.apache.org by "S. Ali Tokmen" <sa...@bull.net> on 2009/06/11 10:14:09 UTC

Re: svn commit: r783621 - /camel/tags/camel-2.0-M2/

Hello

The commit I've attached, that has been done a few seconds before the 
tag, breaks the OSGi compatibility since it includes com.sun.* classes.

I also see you've started releasing the M2 on the repositories... What 
shall we do?

Thanks

S. Ali Tokmen
savas-ali.tokmen@bull.net

Office: +33 4 76 29 76 19
GSM:    +33 66 43 00 555

Bull, Architect of an Open World TM
http://www.bull.com



hadrian@apache.org a �crit :
> Author: hadrian
> Date: Thu Jun 11 03:55:00 2009
> New Revision: 783621
>
> URL: http://svn.apache.org/viewvc?rev=783621&view=rev
> Log:
> Camel 2.0-M2 Release
>
> Added:
>     camel/tags/camel-2.0-M2/
>       - copied from r783619, camel/trunk/
>
>
>
>
>   

Re: svn commit: r783621 - /camel/tags/camel-2.0-M2/

Posted by Willem Jiang <wi...@gmail.com>.
Sorry , it's my fault, I will remove the com.sun's import in my next commit.

Thanks for point that out.


Willem

S. Ali Tokmen wrote:
> Hello
> 
> The commit I've attached, that has been done a few seconds before the
> tag, breaks the OSGi compatibility since it includes com.sun.* classes.
> 
> I also see you've started releasing the M2 on the repositories... What
> shall we do?
> 
> Thanks
> 
> S. Ali Tokmen
> savas-ali.tokmen@bull.net
> 
> Office: +33 4 76 29 76 19
> GSM:    +33 66 43 00 555
> 
> Bull, Architect of an Open World TM
> http://www.bull.com
> 
> 
> 
> hadrian@apache.org a écrit :
>> Author: hadrian
>> Date: Thu Jun 11 03:55:00 2009
>> New Revision: 783621
>>
>> URL: http://svn.apache.org/viewvc?rev=783621&view=rev
>> Log:
>> Camel 2.0-M2 Release
>>
>> Added:
>>     camel/tags/camel-2.0-M2/
>>       - copied from r783619, camel/trunk/
>>
>>
>>
>>
>>   
> 
> ------------------------------------------------------------------------
> 
> Subject:
> svn commit: r783363 - in /camel/trunk/components/camel-cxf/src:
> main/java/org/apache/camel/component/cxf/util/CxfUtils.java
> test/java/org/apache/camel/component/cxf/util/SplitterWithXqureyTest.java
> From:
> ningjiang@apache.org
> Date:
> Wed, 10 Jun 2009 14:05:16 -0000
> To:
> commits@camel.apache.org
> 
> To:
> commits@camel.apache.org
> 
> 
> Author: ningjiang
> Date: Wed Jun 10 14:05:16 2009
> New Revision: 783363
> 
> URL: http://svn.apache.org/viewvc?rev=783363&view=rev
> Log:
> MR-161 added a util method to write the namespaces at the first element
> 
> Added:
>     camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/util/SplitterWithXqureyTest.java   (with props)
> Modified:
>     camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/util/CxfUtils.java
> 
> Modified: camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/util/CxfUtils.java
> URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/util/CxfUtils.java?rev=783363&r1=783362&r2=783363&view=diff
> ==============================================================================
> --- camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/util/CxfUtils.java (original)
> +++ camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/util/CxfUtils.java Wed Jun 10 14:05:16 2009
> @@ -17,10 +17,31 @@
>  
>  package org.apache.camel.component.cxf.util;
>  
> +
> +
> +import java.io.IOException;
>  import java.io.InputStream;
> +import java.io.StringWriter;
> +import java.util.HashMap;
> +import java.util.Map;
> +
> +import javax.xml.stream.XMLStreamException;
> +import javax.xml.stream.XMLStreamWriter;
> +
> +import org.w3c.dom.Document;
> +import org.w3c.dom.Element;
> +import org.w3c.dom.NamedNodeMap;
> +import org.w3c.dom.Node;
> +import org.w3c.dom.NodeList;
>  
> +import com.sun.org.apache.xml.internal.serialize.OutputFormat;
> +import com.sun.org.apache.xml.internal.serialize.XMLSerializer;
> +
> +import org.apache.cxf.common.util.StringUtils;
>  import org.apache.cxf.helpers.IOUtils;
>  import org.apache.cxf.io.CachedOutputStream;
> +import org.apache.cxf.staxutils.StaxUtils;
> +import org.apache.cxf.staxutils.W3CDOMStreamWriter;
>  
>  
>  public final class CxfUtils {
> @@ -36,5 +57,141 @@
>          bos.close();
>          return bos.getOut().toString();
>      }
> +    
> +    public static String elementToString(Element element) throws Exception {
> +        Map<String, String> namespaces = new HashMap<String, String>();
> +        visitNodesForNameSpace(element, namespaces);
> +        W3CDOMStreamWriter writer = new W3CDOMStreamWriter();
> +        writeElement(element, writer, namespaces);
> +        return getStringFromDoc(writer.getDocument());
> +        
> +    }
> +    
> +    private static void writeElement(Element e,
> +                                    XMLStreamWriter writer,                                    
> +                                    Map<String, String> namespaces)
> +        throws XMLStreamException {
> +        String prefix = e.getPrefix();
> +        String ns = e.getNamespaceURI();
> +        String localName = e.getLocalName();
> +
> +        if (prefix == null) {
> +            prefix = "";
> +        }
> +        if (localName == null) {
> +            localName = e.getNodeName();
> +
> +            if (localName == null) {
> +                throw new IllegalStateException("Element's local name cannot be null!");
> +            }
> +        }
> +
> +        String decUri = writer.getNamespaceContext().getNamespaceURI(prefix);
> +        boolean declareNamespace = decUri == null || !decUri.equals(ns);
> +
> +        if (ns == null || ns.length() == 0) {
> +            writer.writeStartElement(localName);
> +            if (StringUtils.isEmpty(decUri)) {
> +                declareNamespace = false;
> +            }
> +        } else {
> +            writer.writeStartElement(prefix, localName, ns);
> +        }
> +
> +        NamedNodeMap attrs = e.getAttributes();
> +        for (int i = 0; i < attrs.getLength(); i++) {
> +            Node attr = attrs.item(i);
> +
> +            String name = attr.getLocalName();
> +            String attrPrefix = attr.getPrefix();
> +            if (attrPrefix == null) {
> +                attrPrefix = "";
> +            }
> +            if (name == null) {
> +                name = attr.getNodeName();
> +            }
> +     
> +            if ("xmlns".equals(attrPrefix)) {
> +                writer.writeNamespace(name, attr.getNodeValue());
> +                if (name.equals(prefix) && attr.getNodeValue().equals(ns)) {
> +                    declareNamespace = false;
> +                }
> +            } else {
> +                if ("xmlns".equals(name) && "".equals(attrPrefix)) {
> +                    writer.writeNamespace("", attr.getNodeValue());
> +                    if (attr.getNodeValue().equals(ns)) {
> +                        declareNamespace = false;
> +                    } else if (StringUtils.isEmpty(attr.getNodeValue())
> +                        && StringUtils.isEmpty(ns)) {
> +                        declareNamespace = false;
> +                    }
> +                } else {
> +                    String attns = attr.getNamespaceURI();
> +                    String value = attr.getNodeValue();
> +                    if (attns == null || attns.length() == 0) {
> +                        writer.writeAttribute(name, value);
> +                    } else if (attrPrefix == null || attrPrefix.length() == 0) {
> +                        writer.writeAttribute(attns, name, value);
> +                    } else {
> +                        writer.writeAttribute(attrPrefix, attns, name, value);
> +                    }                    
> +                }
> +            }
> +        }
> +
> +        if (declareNamespace) {
> +            if (ns == null) {
> +                writer.writeNamespace(prefix, "");
> +            } else {
> +                writer.writeNamespace(prefix, ns);
> +            }
> +        }
> +        
> +        if (namespaces != null && namespaces.size() > 0) {
> +            for (String key : namespaces.keySet()) {
> +                String namespaceURI = namespaces.get(key);
> +                writer.writeNamespace(key, namespaceURI);
> +            }
> +        }
> +
> +        Node nd = e.getFirstChild();
> +        while (nd != null) {
> +            StaxUtils.writeNode(nd, writer, false);
> +            nd = nd.getNextSibling();
> +        }       
> +
> +        writer.writeEndElement();
> +        
> +    }
> +
> +    private static String getStringFromDoc(Document document) throws IOException {
> +        //Serialize DOM
> +        OutputFormat format    = new OutputFormat(document);
> +        format.setOmitXMLDeclaration(true);
> +        // as a String
> +        StringWriter stringOut = new StringWriter();    
> +        XMLSerializer serial   = new XMLSerializer(stringOut, 
> +                                                    format);
> +        serial.serialize(document);
> +       
> +        return stringOut.toString(); 
> +       
> +    }
> +
> +    private static void visitNodesForNameSpace(Node node, Map<String, String> namespaces) {
> +        if (node instanceof Element) {
> +            Element element = (Element)node;
> +            if (element.getPrefix() != null && element.getNamespaceURI() != null) {
> +                namespaces.put(element.getPrefix(), element.getNamespaceURI());
> +            }
> +            if (node.getChildNodes() != null) {
> +                NodeList nodelist = node.getChildNodes();
> +                for (int i = 0; i < nodelist.getLength(); i++) {
> +                    visitNodesForNameSpace(nodelist.item(i), namespaces);
> +                }
> +            }
> +        }
> +
> +    }
>  
>  }
> 
> Added: camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/util/SplitterWithXqureyTest.java
> URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/util/SplitterWithXqureyTest.java?rev=783363&view=auto
> ==============================================================================
> --- camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/util/SplitterWithXqureyTest.java (added)
> +++ camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/util/SplitterWithXqureyTest.java Wed Jun 10 14:05:16 2009
> @@ -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.cxf.util;
> +
> +import java.io.IOException;
> +import java.io.StringWriter;
> +import java.util.HashMap;
> +import java.util.Map;
> +
> +import javax.xml.parsers.ParserConfigurationException;
> +import javax.xml.stream.XMLStreamException;
> +import javax.xml.stream.XMLStreamWriter;
> +
> +import org.w3c.dom.Attr;
> +import org.w3c.dom.Document;
> +import org.w3c.dom.Element;
> +import org.w3c.dom.NamedNodeMap;
> +import org.w3c.dom.Node;
> +import org.w3c.dom.NodeList;
> +
> +import com.sun.org.apache.xerces.internal.dom.ElementImpl;
> +import com.sun.org.apache.xml.internal.serialize.OutputFormat;
> +import com.sun.org.apache.xml.internal.serialize.XMLSerializer;
> +
> +import org.apache.camel.ContextTestSupport;
> +import org.apache.camel.Exchange;
> +import org.apache.camel.builder.RouteBuilder;
> +import org.apache.camel.builder.xml.Namespaces;
> +import org.apache.camel.component.mock.MockEndpoint;
> +import org.apache.cxf.common.util.StringUtils;
> +import org.apache.cxf.staxutils.StaxUtils;
> +import org.apache.cxf.staxutils.W3CDOMStreamWriter;
> +
> +
> +public class SplitterWithXqureyTest extends ContextTestSupport {
> +    private static String xmlData = "<workflow id=\"12345\" xmlns=\"http://camel.apache.org/schema/one\" "
> +        + "xmlns:two=\"http://camel.apache.org/schema/two\">"
> +        + "<person><name>Willem</name></person> "
> +        + "<other><two:test name=\"123\">One</two:test></other>"
> +        + "<other><two:test name=\"456\">Two</two:test></other>"
> +        + "<other><test>Three</test></other>"
> +        + "<other><test>Foure</test></other></workflow>";
> +    private static String[] verifyStrings = new String[] {
> +        "<other xmlns=\"http://camel.apache.org/schema/one\" xmlns:two=\"http://camel.apache.org/schema/two\"><two:test name=\"123\">One</two:test></other>",
> +        "<other xmlns=\"http://camel.apache.org/schema/one\" xmlns:two=\"http://camel.apache.org/schema/two\"><two:test name=\"456\">Two</two:test></other>",
> +        "<other xmlns=\"http://camel.apache.org/schema/one\"><test>Three</test></other>",
> +        "<other xmlns=\"http://camel.apache.org/schema/one\"><test>Foure</test></other>"
> +    };
> +        
> +    
> +    protected RouteBuilder createRouteBuilder() {
> +        return new RouteBuilder() {
> +            public void configure() {
> +                // split the message with namespaces defined 
> +                Namespaces namespaces = new Namespaces("one", "http://camel.apache.org/schema/one");                
> +                from("direct:endpoint").split().xpath("//one:other", namespaces).to("mock:result");
> +            }
> +        };
> +    }
> +    
> +    public void testSenderXmlData() throws Exception {        
> +        MockEndpoint result = getMockEndpoint("mock:result");
> +        result.reset();
> +        result.expectedMessageCount(4);
> +        template.sendBody("direct:endpoint", xmlData);
> +        assertMockEndpointsSatisfied();
> +        int i = 0;
> +        for (Exchange exchange : result.getExchanges()) {
> +            ElementImpl element = (ElementImpl) exchange.getIn().getBody();           
> +            String message = CxfUtils.elementToString(element);            
> +            log.info("The splited message is " + message);
> +            assertTrue("The splitted message should start with <other", message.indexOf("<other") == 0);
> +            assertEquals("Get a wrong message", verifyStrings[i], message);
> +            i++;
> +        }
> +    }
> +    
> +   
> +
> +}
> 
> Propchange: camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/util/SplitterWithXqureyTest.java
> ------------------------------------------------------------------------------
>     svn:eol-style = native
> 
> Propchange: camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/util/SplitterWithXqureyTest.java
> ------------------------------------------------------------------------------
>     svn:keywords = Rev Date
> 
> 
> 
> 
> 


Re: svn commit: r783621 - /camel/tags/camel-2.0-M2/

Posted by "S. Ali Tokmen" <sa...@bull.net>.
Great, Hadrian

If you ever come to France I'll get you a pint at O'Callaghan

Cheers

S. Ali Tokmen
savas-ali.tokmen@bull.net

Office: +33 4 76 29 76 19
GSM:    +33 66 43 00 555

Bull, Architect of an Open World TM
http://www.bull.com



Hadrian Zbarcea a écrit :
> Guys, I am proud of you, well spotted :).  I will rebuild the kits.
> Thanks, Hadrian
>
>
> On Jun 11, 2009, at 7:39 AM, S. Ali Tokmen wrote:
>
>> Hello Willem
>>
>> Thanks for your quick response :) Hope the 2.0-M2 tag can be done 
>> again with your patches.
>>
>> Perhaps Hadrian can tell us more in a few more hours, when sun rises 
>> on the other side of the Atlantic Ocean?
>>
>> Cheers
>>
>> S. Ali Tokmen
>> savas-ali.tokmen@bull.net
>>
>> Office: +33 4 76 29 76 19
>> GSM:    +33 66 43 00 555
>>
>> Bull, Architect of an Open World TM
>> http://www.bull.com
>>
>>
>>
>> Willem Jiang a écrit :
>>> Done, I just committed the patch which removed the "com.sun.*" 
>>> packages.
>>> The light of Camel 2.0-M2 release should be green now :)
>>>
>>> Willem
>>>
>>>
>>> Claus Ibsen wrote:
>>>
>>>> On Thu, Jun 11, 2009 at 10:23 AM, S. Ali
>>>> Tokmen<sa...@bull.net> wrote:
>>>>
>>>>> Hello
>>>>>
>>>>> Claus Ibsen a écrit :
>>>>>
>>>>>> On Thu, Jun 11, 2009 at 10:14 AM, S. Ali
>>>>>> Tokmen<sa...@bull.net> wrote:
>>>>>>
>>>>>>
>>>>>>> Hello
>>>>>>>
>>>>>>> The commit I've attached, that has been done a few seconds 
>>>>>>> before the
>>>>>>> tag,
>>>>>>> breaks the OSGi compatibility since it includes com.sun.* classes.
>>>>>>>
>>>>>>> I also see you've started releasing the M2 on the 
>>>>>>> repositories... What
>>>>>>> shall
>>>>>>> we do?
>>>>>>>
>>>>>>>
>>>>>> Well spotted. The commit should be reverted. It does not bring 
>>>>>> good value.
>>>>>> And have the com.sun imports that we should avoid.
>>>>>>
>>>>>>
>>>>> Good to see we're many to see the issue... What about the tag?
>>>>>
>>>> Hadrian is sleeping right now. Will ping him later when he gets up. He
>>>> lives in the US.
>>>>
>>>>
>>>>
>>>>> Thanks
>>>>>
>>>>> -- 
>>>>>
>>>>> S. Ali Tokmen
>>>>> savas-ali.tokmen@bull.net
>>>>>
>>>>> Office: +33 4 76 29 76 19
>>>>> GSM:    +33 66 43 00 555
>>>>>
>>>>> Bull, Architect of an Open World TM
>>>>> http://www.bull.com
>>>>>
>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>
>>>
>>>
>>>
>>
>
>
>
>


Re: svn commit: r783621 - /camel/tags/camel-2.0-M2/

Posted by Hadrian Zbarcea <hz...@gmail.com>.
Guys, I am proud of you, well spotted :).  I will rebuild the kits.
Thanks, Hadrian


On Jun 11, 2009, at 7:39 AM, S. Ali Tokmen wrote:

> Hello Willem
>
> Thanks for your quick response :) Hope the 2.0-M2 tag can be done  
> again with your patches.
>
> Perhaps Hadrian can tell us more in a few more hours, when sun rises  
> on the other side of the Atlantic Ocean?
>
> Cheers
>
> S. Ali Tokmen
> savas-ali.tokmen@bull.net
>
> Office: +33 4 76 29 76 19
> GSM:    +33 66 43 00 555
>
> Bull, Architect of an Open World TM
> http://www.bull.com
>
>
>
> Willem Jiang a écrit :
>> Done, I just committed the patch which removed the "com.sun.*"  
>> packages.
>> The light of Camel 2.0-M2 release should be green now :)
>>
>> Willem
>>
>>
>> Claus Ibsen wrote:
>>
>>> On Thu, Jun 11, 2009 at 10:23 AM, S. Ali
>>> Tokmen<sa...@bull.net> wrote:
>>>
>>>> Hello
>>>>
>>>> Claus Ibsen a écrit :
>>>>
>>>>> On Thu, Jun 11, 2009 at 10:14 AM, S. Ali
>>>>> Tokmen<sa...@bull.net> wrote:
>>>>>
>>>>>
>>>>>> Hello
>>>>>>
>>>>>> The commit I've attached, that has been done a few seconds  
>>>>>> before the
>>>>>> tag,
>>>>>> breaks the OSGi compatibility since it includes com.sun.*  
>>>>>> classes.
>>>>>>
>>>>>> I also see you've started releasing the M2 on the  
>>>>>> repositories... What
>>>>>> shall
>>>>>> we do?
>>>>>>
>>>>>>
>>>>> Well spotted. The commit should be reverted. It does not bring  
>>>>> good value.
>>>>> And have the com.sun imports that we should avoid.
>>>>>
>>>>>
>>>> Good to see we're many to see the issue... What about the tag?
>>>>
>>> Hadrian is sleeping right now. Will ping him later when he gets  
>>> up. He
>>> lives in the US.
>>>
>>>
>>>
>>>> Thanks
>>>>
>>>> --
>>>>
>>>> S. Ali Tokmen
>>>> savas-ali.tokmen@bull.net
>>>>
>>>> Office: +33 4 76 29 76 19
>>>> GSM:    +33 66 43 00 555
>>>>
>>>> Bull, Architect of an Open World TM
>>>> http://www.bull.com
>>>>
>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>>
>>
>>
>


Re: svn commit: r783621 - /camel/tags/camel-2.0-M2/

Posted by "S. Ali Tokmen" <sa...@bull.net>.
Hello Willem

Thanks for your quick response :) Hope the 2.0-M2 tag can be done again 
with your patches.

Perhaps Hadrian can tell us more in a few more hours, when sun rises on 
the other side of the Atlantic Ocean?

Cheers

S. Ali Tokmen
savas-ali.tokmen@bull.net

Office: +33 4 76 29 76 19
GSM:    +33 66 43 00 555

Bull, Architect of an Open World TM
http://www.bull.com



Willem Jiang a écrit :
> Done, I just committed the patch which removed the "com.sun.*" packages.
> The light of Camel 2.0-M2 release should be green now :)
>
> Willem
>
>
> Claus Ibsen wrote:
>   
>> On Thu, Jun 11, 2009 at 10:23 AM, S. Ali
>> Tokmen<sa...@bull.net> wrote:
>>     
>>> Hello
>>>
>>> Claus Ibsen a écrit :
>>>       
>>>> On Thu, Jun 11, 2009 at 10:14 AM, S. Ali
>>>> Tokmen<sa...@bull.net> wrote:
>>>>
>>>>         
>>>>> Hello
>>>>>
>>>>> The commit I've attached, that has been done a few seconds before the
>>>>> tag,
>>>>> breaks the OSGi compatibility since it includes com.sun.* classes.
>>>>>
>>>>> I also see you've started releasing the M2 on the repositories... What
>>>>> shall
>>>>> we do?
>>>>>
>>>>>           
>>>> Well spotted. The commit should be reverted. It does not bring good value.
>>>> And have the com.sun imports that we should avoid.
>>>>
>>>>         
>>> Good to see we're many to see the issue... What about the tag?
>>>       
>> Hadrian is sleeping right now. Will ping him later when he gets up. He
>> lives in the US.
>>
>>
>>     
>>> Thanks
>>>
>>> --
>>>
>>> S. Ali Tokmen
>>> savas-ali.tokmen@bull.net
>>>
>>> Office: +33 4 76 29 76 19
>>> GSM:    +33 66 43 00 555
>>>
>>> Bull, Architect of an Open World TM
>>> http://www.bull.com
>>>
>>>
>>>
>>>       
>>
>>     
>
>
>
>
>   


Re: svn commit: r783621 - /camel/tags/camel-2.0-M2/

Posted by Willem Jiang <wi...@gmail.com>.
Done, I just committed the patch which removed the "com.sun.*" packages.
The light of Camel 2.0-M2 release should be green now :)

Willem


Claus Ibsen wrote:
> On Thu, Jun 11, 2009 at 10:23 AM, S. Ali
> Tokmen<sa...@bull.net> wrote:
>> Hello
>>
>> Claus Ibsen a écrit :
>>> On Thu, Jun 11, 2009 at 10:14 AM, S. Ali
>>> Tokmen<sa...@bull.net> wrote:
>>>
>>>> Hello
>>>>
>>>> The commit I've attached, that has been done a few seconds before the
>>>> tag,
>>>> breaks the OSGi compatibility since it includes com.sun.* classes.
>>>>
>>>> I also see you've started releasing the M2 on the repositories... What
>>>> shall
>>>> we do?
>>>>
>>> Well spotted. The commit should be reverted. It does not bring good value.
>>> And have the com.sun imports that we should avoid.
>>>
>> Good to see we're many to see the issue... What about the tag?
> Hadrian is sleeping right now. Will ping him later when he gets up. He
> lives in the US.
> 
> 
>> Thanks
>>
>> --
>>
>> S. Ali Tokmen
>> savas-ali.tokmen@bull.net
>>
>> Office: +33 4 76 29 76 19
>> GSM:    +33 66 43 00 555
>>
>> Bull, Architect of an Open World TM
>> http://www.bull.com
>>
>>
>>
> 
> 
> 


Re: svn commit: r783621 - /camel/tags/camel-2.0-M2/

Posted by Claus Ibsen <cl...@gmail.com>.
On Thu, Jun 11, 2009 at 10:23 AM, S. Ali
Tokmen<sa...@bull.net> wrote:
> Hello
>
> Claus Ibsen a écrit :
>>
>> On Thu, Jun 11, 2009 at 10:14 AM, S. Ali
>> Tokmen<sa...@bull.net> wrote:
>>
>>>
>>> Hello
>>>
>>> The commit I've attached, that has been done a few seconds before the
>>> tag,
>>> breaks the OSGi compatibility since it includes com.sun.* classes.
>>>
>>> I also see you've started releasing the M2 on the repositories... What
>>> shall
>>> we do?
>>>
>>
>> Well spotted. The commit should be reverted. It does not bring good value.
>> And have the com.sun imports that we should avoid.
>>
>
> Good to see we're many to see the issue... What about the tag?
Hadrian is sleeping right now. Will ping him later when he gets up. He
lives in the US.


>
> Thanks
>
> --
>
> S. Ali Tokmen
> savas-ali.tokmen@bull.net
>
> Office: +33 4 76 29 76 19
> GSM:    +33 66 43 00 555
>
> Bull, Architect of an Open World TM
> http://www.bull.com
>
>
>



-- 
Claus Ibsen
Apache Camel Committer

Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus

Re: svn commit: r783621 - /camel/tags/camel-2.0-M2/

Posted by "S. Ali Tokmen" <sa...@bull.net>.
Hello

Claus Ibsen a écrit :
> On Thu, Jun 11, 2009 at 10:14 AM, S. Ali
> Tokmen<sa...@bull.net> wrote:
>   
>> Hello
>>
>> The commit I've attached, that has been done a few seconds before the tag,
>> breaks the OSGi compatibility since it includes com.sun.* classes.
>>
>> I also see you've started releasing the M2 on the repositories... What shall
>> we do?
>>     
> Well spotted. The commit should be reverted. It does not bring good value.
> And have the com.sun imports that we should avoid.
>   
Good to see we're many to see the issue... What about the tag?

Thanks

-- 

S. Ali Tokmen
savas-ali.tokmen@bull.net

Office: +33 4 76 29 76 19
GSM:    +33 66 43 00 555

Bull, Architect of an Open World TM
http://www.bull.com



Re: svn commit: r783621 - /camel/tags/camel-2.0-M2/

Posted by Claus Ibsen <cl...@gmail.com>.
On Thu, Jun 11, 2009 at 10:14 AM, S. Ali
Tokmen<sa...@bull.net> wrote:
> Hello
>
> The commit I've attached, that has been done a few seconds before the tag,
> breaks the OSGi compatibility since it includes com.sun.* classes.
>
> I also see you've started releasing the M2 on the repositories... What shall
> we do?
Well spotted. The commit should be reverted. It does not bring good value.
And have the com.sun imports that we should avoid.


>
> Thanks
>
> S. Ali Tokmen
> savas-ali.tokmen@bull.net
>
> Office: +33 4 76 29 76 19
> GSM:    +33 66 43 00 555
>
> Bull, Architect of an Open World TM
> http://www.bull.com
>
>
>
> hadrian@apache.org a écrit :
>>
>> Author: hadrian
>> Date: Thu Jun 11 03:55:00 2009
>> New Revision: 783621
>>
>> URL: http://svn.apache.org/viewvc?rev=783621&view=rev
>> Log:
>> Camel 2.0-M2 Release
>>
>> Added:
>>    camel/tags/camel-2.0-M2/
>>      - copied from r783619, camel/trunk/
>>
>>
>>
>>
>>
>
>
> ---------- Forwarded message ----------
> From: ningjiang@apache.org
> To: commits@camel.apache.org
> Date: Wed, 10 Jun 2009 14:05:16 -0000
> Subject: svn commit: r783363 - in /camel/trunk/components/camel-cxf/src:
> main/java/org/apache/camel/component/cxf/util/CxfUtils.java
> test/java/org/apache/camel/component/cxf/util/SplitterWithXqureyTest.java
> Author: ningjiang
> Date: Wed Jun 10 14:05:16 2009
> New Revision: 783363
>
> URL: http://svn.apache.org/viewvc?rev=783363&view=rev
> Log:
> MR-161 added a util method to write the namespaces at the first element
>
> Added:
>
>  camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/util/SplitterWithXqureyTest.java
>   (with props)
> Modified:
>
>  camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/util/CxfUtils.java
>
> Modified:
> camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/util/CxfUtils.java
> URL:
> http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/util/CxfUtils.java?rev=783363&r1=783362&r2=783363&view=diff
> ==============================================================================
> ---
> camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/util/CxfUtils.java
> (original)
> +++
> camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/util/CxfUtils.java
> Wed Jun 10 14:05:16 2009
> @@ -17,10 +17,31 @@
>
>  package org.apache.camel.component.cxf.util;
>
> +
> +
> +import java.io.IOException;
>  import java.io.InputStream;
> +import java.io.StringWriter;
> +import java.util.HashMap;
> +import java.util.Map;
> +
> +import javax.xml.stream.XMLStreamException;
> +import javax.xml.stream.XMLStreamWriter;
> +
> +import org.w3c.dom.Document;
> +import org.w3c.dom.Element;
> +import org.w3c.dom.NamedNodeMap;
> +import org.w3c.dom.Node;
> +import org.w3c.dom.NodeList;
>
> +import com.sun.org.apache.xml.internal.serialize.OutputFormat;
> +import com.sun.org.apache.xml.internal.serialize.XMLSerializer;
> +
> +import org.apache.cxf.common.util.StringUtils;
>  import org.apache.cxf.helpers.IOUtils;
>  import org.apache.cxf.io.CachedOutputStream;
> +import org.apache.cxf.staxutils.StaxUtils;
> +import org.apache.cxf.staxutils.W3CDOMStreamWriter;
>
>
>  public final class CxfUtils {
> @@ -36,5 +57,141 @@
>         bos.close();
>         return bos.getOut().toString();
>     }
> +
> +    public static String elementToString(Element element) throws Exception
> {
> +        Map<String, String> namespaces = new HashMap<String, String>();
> +        visitNodesForNameSpace(element, namespaces);
> +        W3CDOMStreamWriter writer = new W3CDOMStreamWriter();
> +        writeElement(element, writer, namespaces);
> +        return getStringFromDoc(writer.getDocument());
> +
> +    }
> +
> +    private static void writeElement(Element e,
> +                                    XMLStreamWriter writer,
> +                                    Map<String, String> namespaces)
> +        throws XMLStreamException {
> +        String prefix = e.getPrefix();
> +        String ns = e.getNamespaceURI();
> +        String localName = e.getLocalName();
> +
> +        if (prefix == null) {
> +            prefix = "";
> +        }
> +        if (localName == null) {
> +            localName = e.getNodeName();
> +
> +            if (localName == null) {
> +                throw new IllegalStateException("Element's local name
> cannot be null!");
> +            }
> +        }
> +
> +        String decUri =
> writer.getNamespaceContext().getNamespaceURI(prefix);
> +        boolean declareNamespace = decUri == null || !decUri.equals(ns);
> +
> +        if (ns == null || ns.length() == 0) {
> +            writer.writeStartElement(localName);
> +            if (StringUtils.isEmpty(decUri)) {
> +                declareNamespace = false;
> +            }
> +        } else {
> +            writer.writeStartElement(prefix, localName, ns);
> +        }
> +
> +        NamedNodeMap attrs = e.getAttributes();
> +        for (int i = 0; i < attrs.getLength(); i++) {
> +            Node attr = attrs.item(i);
> +
> +            String name = attr.getLocalName();
> +            String attrPrefix = attr.getPrefix();
> +            if (attrPrefix == null) {
> +                attrPrefix = "";
> +            }
> +            if (name == null) {
> +                name = attr.getNodeName();
> +            }
> +
> +            if ("xmlns".equals(attrPrefix)) {
> +                writer.writeNamespace(name, attr.getNodeValue());
> +                if (name.equals(prefix) && attr.getNodeValue().equals(ns))
> {
> +                    declareNamespace = false;
> +                }
> +            } else {
> +                if ("xmlns".equals(name) && "".equals(attrPrefix)) {
> +                    writer.writeNamespace("", attr.getNodeValue());
> +                    if (attr.getNodeValue().equals(ns)) {
> +                        declareNamespace = false;
> +                    } else if (StringUtils.isEmpty(attr.getNodeValue())
> +                        && StringUtils.isEmpty(ns)) {
> +                        declareNamespace = false;
> +                    }
> +                } else {
> +                    String attns = attr.getNamespaceURI();
> +                    String value = attr.getNodeValue();
> +                    if (attns == null || attns.length() == 0) {
> +                        writer.writeAttribute(name, value);
> +                    } else if (attrPrefix == null || attrPrefix.length() ==
> 0) {
> +                        writer.writeAttribute(attns, name, value);
> +                    } else {
> +                        writer.writeAttribute(attrPrefix, attns, name,
> value);
> +                    }
> +                }
> +            }
> +        }
> +
> +        if (declareNamespace) {
> +            if (ns == null) {
> +                writer.writeNamespace(prefix, "");
> +            } else {
> +                writer.writeNamespace(prefix, ns);
> +            }
> +        }
> +
> +        if (namespaces != null && namespaces.size() > 0) {
> +            for (String key : namespaces.keySet()) {
> +                String namespaceURI = namespaces.get(key);
> +                writer.writeNamespace(key, namespaceURI);
> +            }
> +        }
> +
> +        Node nd = e.getFirstChild();
> +        while (nd != null) {
> +            StaxUtils.writeNode(nd, writer, false);
> +            nd = nd.getNextSibling();
> +        }
> +
> +        writer.writeEndElement();
> +
> +    }
> +
> +    private static String getStringFromDoc(Document document) throws
> IOException {
> +        //Serialize DOM
> +        OutputFormat format    = new OutputFormat(document);
> +        format.setOmitXMLDeclaration(true);
> +        // as a String
> +        StringWriter stringOut = new StringWriter();
> +        XMLSerializer serial   = new XMLSerializer(stringOut,
> +                                                    format);
> +        serial.serialize(document);
> +
> +        return stringOut.toString();
> +
> +    }
> +
> +    private static void visitNodesForNameSpace(Node node, Map<String,
> String> namespaces) {
> +        if (node instanceof Element) {
> +            Element element = (Element)node;
> +            if (element.getPrefix() != null && element.getNamespaceURI() !=
> null) {
> +                namespaces.put(element.getPrefix(),
> element.getNamespaceURI());
> +            }
> +            if (node.getChildNodes() != null) {
> +                NodeList nodelist = node.getChildNodes();
> +                for (int i = 0; i < nodelist.getLength(); i++) {
> +                    visitNodesForNameSpace(nodelist.item(i), namespaces);
> +                }
> +            }
> +        }
> +
> +    }
>
>  }
>
> Added:
> camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/util/SplitterWithXqureyTest.java
> URL:
> http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/util/SplitterWithXqureyTest.java?rev=783363&view=auto
> ==============================================================================
> ---
> camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/util/SplitterWithXqureyTest.java
> (added)
> +++
> camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/util/SplitterWithXqureyTest.java
> Wed Jun 10 14:05:16 2009
> @@ -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.cxf.util;
> +
> +import java.io.IOException;
> +import java.io.StringWriter;
> +import java.util.HashMap;
> +import java.util.Map;
> +
> +import javax.xml.parsers.ParserConfigurationException;
> +import javax.xml.stream.XMLStreamException;
> +import javax.xml.stream.XMLStreamWriter;
> +
> +import org.w3c.dom.Attr;
> +import org.w3c.dom.Document;
> +import org.w3c.dom.Element;
> +import org.w3c.dom.NamedNodeMap;
> +import org.w3c.dom.Node;
> +import org.w3c.dom.NodeList;
> +
> +import com.sun.org.apache.xerces.internal.dom.ElementImpl;
> +import com.sun.org.apache.xml.internal.serialize.OutputFormat;
> +import com.sun.org.apache.xml.internal.serialize.XMLSerializer;
> +
> +import org.apache.camel.ContextTestSupport;
> +import org.apache.camel.Exchange;
> +import org.apache.camel.builder.RouteBuilder;
> +import org.apache.camel.builder.xml.Namespaces;
> +import org.apache.camel.component.mock.MockEndpoint;
> +import org.apache.cxf.common.util.StringUtils;
> +import org.apache.cxf.staxutils.StaxUtils;
> +import org.apache.cxf.staxutils.W3CDOMStreamWriter;
> +
> +
> +public class SplitterWithXqureyTest extends ContextTestSupport {
> +    private static String xmlData = "<workflow id=\"12345\"
> xmlns=\"http://camel.apache.org/schema/one\" "
> +        + "xmlns:two=\"http://camel.apache.org/schema/two\">"
> +        + "<person><name>Willem</name></person> "
> +        + "<other><two:test name=\"123\">One</two:test></other>"
> +        + "<other><two:test name=\"456\">Two</two:test></other>"
> +        + "<other><test>Three</test></other>"
> +        + "<other><test>Foure</test></other></workflow>";
> +    private static String[] verifyStrings = new String[] {
> +        "<other xmlns=\"http://camel.apache.org/schema/one\"
> xmlns:two=\"http://camel.apache.org/schema/two\"><two:test
> name=\"123\">One</two:test></other>",
> +        "<other xmlns=\"http://camel.apache.org/schema/one\"
> xmlns:two=\"http://camel.apache.org/schema/two\"><two:test
> name=\"456\">Two</two:test></other>",
> +        "<other
> xmlns=\"http://camel.apache.org/schema/one\"><test>Three</test></other>",
> +        "<other
> xmlns=\"http://camel.apache.org/schema/one\"><test>Foure</test></other>"
> +    };
> +
> +
> +    protected RouteBuilder createRouteBuilder() {
> +        return new RouteBuilder() {
> +            public void configure() {
> +                // split the message with namespaces defined
> +                Namespaces namespaces = new Namespaces("one",
> "http://camel.apache.org/schema/one");
> +                from("direct:endpoint").split().xpath("//one:other",
> namespaces).to("mock:result");
> +            }
> +        };
> +    }
> +
> +    public void testSenderXmlData() throws Exception {
> +        MockEndpoint result = getMockEndpoint("mock:result");
> +        result.reset();
> +        result.expectedMessageCount(4);
> +        template.sendBody("direct:endpoint", xmlData);
> +        assertMockEndpointsSatisfied();
> +        int i = 0;
> +        for (Exchange exchange : result.getExchanges()) {
> +            ElementImpl element = (ElementImpl) exchange.getIn().getBody();
> +            String message = CxfUtils.elementToString(element);
> +            log.info("The splited message is " + message);
> +            assertTrue("The splitted message should start with <other",
> message.indexOf("<other") == 0);
> +            assertEquals("Get a wrong message", verifyStrings[i], message);
> +            i++;
> +        }
> +    }
> +
> +
> +
> +}
>
> Propchange:
> camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/util/SplitterWithXqureyTest.java
> ------------------------------------------------------------------------------
>    svn:eol-style = native
>
> Propchange:
> camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/util/SplitterWithXqureyTest.java
> ------------------------------------------------------------------------------
>    svn:keywords = Rev Date
>
>
>
>
>
>
>



-- 
Claus Ibsen
Apache Camel Committer

Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus