Return-Path: X-Original-To: apmail-camel-commits-archive@www.apache.org Delivered-To: apmail-camel-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 351FE966C for ; Mon, 17 Oct 2011 03:29:17 +0000 (UTC) Received: (qmail 12503 invoked by uid 500); 17 Oct 2011 03:29:17 -0000 Delivered-To: apmail-camel-commits-archive@camel.apache.org Received: (qmail 12472 invoked by uid 500); 17 Oct 2011 03:29:15 -0000 Mailing-List: contact commits-help@camel.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@camel.apache.org Delivered-To: mailing list commits@camel.apache.org Received: (qmail 12465 invoked by uid 99); 17 Oct 2011 03:29:15 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 17 Oct 2011 03:29:15 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 17 Oct 2011 03:29:13 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id B873D23889DE for ; Mon, 17 Oct 2011 03:28:53 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1184987 - /camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfPayload.java Date: Mon, 17 Oct 2011 03:28:53 -0000 To: commits@camel.apache.org From: dkulp@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20111017032853.B873D23889DE@eris.apache.org> Author: dkulp Date: Mon Oct 17 03:28:53 2011 New Revision: 1184987 URL: http://svn.apache.org/viewvc?rev=1184987&view=rev Log: Use an AbstractList subclass so the returned list is "live" and also only un-streams if the appropriate "get" is called. Modified: camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfPayload.java Modified: camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfPayload.java URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfPayload.java?rev=1184987&r1=1184986&r2=1184987&view=diff ============================================================================== --- camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfPayload.java (original) +++ camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfPayload.java Mon Oct 17 03:28:53 2011 @@ -16,11 +16,14 @@ */ package org.apache.camel.component.cxf; +import java.util.AbstractList; import java.util.ArrayList; +import java.util.Collection; import java.util.List; import java.util.Map; import javax.xml.XMLConstants; +import javax.xml.stream.XMLStreamException; import javax.xml.transform.Source; import javax.xml.transform.TransformerException; import javax.xml.transform.dom.DOMSource; @@ -62,19 +65,49 @@ public class CxfPayload { * @return */ public List getBody() { - List els = new ArrayList(); - for (int x = 0; x < body.size(); x++) { - Source s = body.get(x); - try { - Element el = StaxUtils.read(s).getDocumentElement(); - addNamespace(el, nsMap); - els.add(el); - body.set(x, new DOMSource(el)); - } catch (Exception ex) { - throw new RuntimeCamelException("Problem converting content to Element", ex); + return new AbstractList() { + public boolean add(Element e) { + return body.add(new DOMSource(e)); } - } - return els; + + public Element set(int index, Element element) { + Source s = body.set(index, new DOMSource(element)); + try { + return StaxUtils.read(s).getDocumentElement(); + } catch (XMLStreamException e) { + throw new RuntimeCamelException("Problem converting content to Element", e); + } + } + + public void add(int index, Element element) { + body.add(index, new DOMSource(element)); + } + + public Element remove(int index) { + Source s = body.remove(index); + try { + return StaxUtils.read(s).getDocumentElement(); + } catch (XMLStreamException e) { + throw new RuntimeCamelException("Problem converting content to Element", e); + } + } + + public Element get(int index) { + Source s = body.get(index); + try { + Element el = StaxUtils.read(s).getDocumentElement(); + addNamespace(el, nsMap); + body.set(index, new DOMSource(el)); + return el; + } catch (Exception ex) { + throw new RuntimeCamelException("Problem converting content to Element", ex); + } + } + + public int size() { + return body.size(); + } + }; } protected static void addNamespace(Element element, Map nsMap) {