[jboss-svn-commits] JBL Code SVN: r17275 - in labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta: src/org/jboss/internal/soa/esb/message/format and 12 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Sun Dec 16 23:59:04 EST 2007
Author: kevin.conner at jboss.com
Date: 2007-12-16 23:59:04 -0500 (Sun, 16 Dec 2007)
New Revision: 17275
Added:
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/message/format/DeferredDeserialisationException.java
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/message/format/serialized/SerializedValueImpl.java
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/CallImpl.java
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/SerializedValueImpl.java
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/marshal/MarshalValueImpl.java
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/util/stax/NamedElement.java
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/util/stax/TextElement.java
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/util/stax/URIElement.java
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/message/tests/DeserializedValuesMessageUnitTest.java
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/message/tests/SerializedValueUnitTest.java
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/message/tests/new_attachment.ser
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/message/tests/new_body.ser
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/message/tests/new_message.ser
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/message/tests/new_message.xml
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/message/tests/new_properties.ser
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/message/tests/old_attachment.ser
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/message/tests/old_body.ser
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/message/tests/old_message.ser
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/message/tests/old_message.xml
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/message/tests/old_properties.ser
Removed:
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/addressing/helpers/CallHelper.java
Modified:
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/addressing/helpers/EPRHelper.java
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/addressing/helpers/PortReferenceHelper.java
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/message/format/serialized/AttachmentImpl.java
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/message/format/serialized/BodyImpl.java
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/message/format/serialized/HeaderImpl.java
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/message/format/serialized/PropertiesImpl.java
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/message/format/serialized/body/content/MapBodyImpl.java
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/AttachmentImpl.java
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/BodyImpl.java
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/ContextImpl.java
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/FaultImpl.java
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/HeaderImpl.java
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/MessageImpl.java
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/PropertiesImpl.java
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/XMLUtil.java
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/body/content/MapBodyImpl.java
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/body/content/ObjectBodyImpl.java
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/body/content/TextBodyImpl.java
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/marshal/MarshalUnmarshalManager.java
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/marshal/MarshalUnmarshalPlugin.java
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/marshal/SerializedMarshalUnmarshalPlugin.java
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/util/stax/ParsingSupport.java
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/util/stax/StreamHelper.java
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/soa/esb/addressing/XMLUtil.java
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/soa/esb/addressing/util/EPRManager.java
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/soa/esb/util/Util.java
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/addressing/tests/CallUnitTest.java
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/addressing/tests/EPRUnitTest.java
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/message/MessageAttachmentSerializeTest.java
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/message/MessagePropertiesSerializeTest.java
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/message/tests/AttachmentUnitTest.java
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/message/tests/BodyUnitTest.java
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/message/tests/FaultUnitTest.java
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/message/tests/PropertiesUnitTest.java
Log:
Change message serialisation: JBESB-1252, JBESB-1392, JBESB-880
Deleted: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/addressing/helpers/CallHelper.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/addressing/helpers/CallHelper.java 2007-12-17 04:48:50 UTC (rev 17274)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/addressing/helpers/CallHelper.java 2007-12-17 04:59:04 UTC (rev 17275)
@@ -1,229 +0,0 @@
-package org.jboss.internal.soa.esb.addressing.helpers;
-
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, JBoss Inc., and others contributors as indicated
- * by the @authors tag. All rights reserved.
- * See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- * This copyrighted material is made available to anyone wishing to use,
- * modify, copy, or redistribute it subject to the terms and conditions
- * of the GNU Lesser General Public License, v. 2.1.
- * This program is distributed in the hope that it will be useful, but WITHOUT A
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public License,
- * v.2.1 along with this distribution; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301, USA.
- *
- * (C) 2005-2006,
- * @author mark.little at jboss.com
- */
-
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.jboss.internal.soa.esb.assertion.AssertArgument;
-import org.jboss.soa.esb.MarshalException;
-import org.jboss.soa.esb.UnmarshalException;
-import org.jboss.soa.esb.addressing.Call;
-import org.jboss.soa.esb.addressing.PortReference;
-import org.jboss.soa.esb.addressing.XMLUtil;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-public abstract class CallHelper
-{
-
- public static Element toXML(Call call, Document doc, Element header)
- throws MarshalException
- {
- AssertArgument.isNotNull(call, "call");
- AssertArgument.isNotNull(doc, "doc");
- AssertArgument.isNotNull(header, "header");
-
- header.setAttributeNS(XMLUtil.XMLNS_URI, XMLUtil.XMLNS_PREFIX
- + XMLUtil.WSA_PREFIX, XMLUtil.WSA_NAMESPACE_URI);
-
- if (call.getTo() != null)
- {
- final Element toElement = doc.createElementNS(
- XMLUtil.WSA_NAMESPACE_URI, XMLUtil.TO_TAG);
- toElement.setPrefix(XMLUtil.WSA_PREFIX);
- EPRHelper.toXML(call.getTo(), doc, header, toElement, true);
- header.appendChild(toElement);
- }
-
- if (call.getFrom() != null)
- {
- final Element fromElement = doc.createElementNS(
- XMLUtil.WSA_NAMESPACE_URI, XMLUtil.FROM_TAG);
- fromElement.setPrefix(XMLUtil.WSA_PREFIX);
- EPRHelper.toXML(call.getFrom(), doc, header, fromElement, false);
- header.appendChild(fromElement);
- }
-
- if (call.getReplyTo() != null)
- {
- final Element replyToElement = doc.createElementNS(
- XMLUtil.WSA_NAMESPACE_URI, XMLUtil.REPLY_TO_TAG);
- replyToElement.setPrefix(XMLUtil.WSA_PREFIX);
- EPRHelper.toXML(call.getReplyTo(), doc, header, replyToElement,
- false);
- header.appendChild(replyToElement);
- }
-
- if (call.getRelatesTo() != null)
- {
- final Element relatesToElement = doc.createElementNS(
- XMLUtil.WSA_NAMESPACE_URI, XMLUtil.RELATES_TO_TAG);
- relatesToElement.setPrefix(XMLUtil.WSA_PREFIX);
- relatesToElement.setTextContent(call.getRelatesTo().toString());
- header.appendChild(relatesToElement);
- }
-
- if (call.getFaultTo() != null)
- {
- final Element faultToElement = doc.createElementNS(
- XMLUtil.WSA_NAMESPACE_URI, XMLUtil.FAULT_TO_TAG);
- faultToElement.setPrefix(XMLUtil.WSA_PREFIX);
- EPRHelper.toXML(call.getFaultTo(), doc, header, faultToElement,
- false);
- header.appendChild(faultToElement);
- }
-
- if (call.getAction() != null)
- {
- final Element actionElement = doc.createElementNS(
- XMLUtil.WSA_NAMESPACE_URI, XMLUtil.ACTION_TAG);
- actionElement.setPrefix(XMLUtil.WSA_PREFIX);
- actionElement.setTextContent(call.getAction().toString());
- header.appendChild(actionElement);
- }
-
- if (call.getMessageID() != null)
- {
- final Element messageIDElement = doc.createElementNS(
- XMLUtil.WSA_NAMESPACE_URI, XMLUtil.MESSAGE_IDENTIFIER_TAG);
- messageIDElement.setPrefix(XMLUtil.WSA_PREFIX);
- messageIDElement.setTextContent(call.getMessageID().toString());
- header.appendChild(messageIDElement);
- }
-
- return header;
- }
-
- public static Call fromXML(Element header) throws UnmarshalException
- {
- AssertArgument.isNotNull(header, "header");
-
- Call call = new Call();
- NodeList nl = header.getChildNodes();
-
- final List<Node> extensions = new ArrayList<Node>() ;
- for (int i = 0; i < nl.getLength(); i++)
- {
- Node n = nl.item(i);
- if (!(n instanceof Element))
- {
- continue ;
- }
- if (XMLUtil.WSA_NAMESPACE_URI.equals(n.getNamespaceURI()))
- {
- final String name = n.getLocalName() ;
- if (XMLUtil.TO_TAG.equals(name))
- {
- call.setTo(EPRHelper.fromXML((Element) header, true));
- }
- else if (XMLUtil.FROM_TAG.equals(name))
- {
- call.setFrom(EPRHelper.fromXML((Element) n, false));
- }
- else if (XMLUtil.REPLY_TO_TAG.equals(name))
- {
- call.setReplyTo(EPRHelper.fromXML((Element) n, false));
- }
- else if (XMLUtil.RELATES_TO_TAG.equals(name))
- {
- try
- {
- call.setRelatesTo(new URI(n.getTextContent()));
- }
- catch (URISyntaxException e)
- {
- throw new UnmarshalException("'" + XMLUtil.RELATES_TO_TAG
- + "' must be a valid URI", e);
- }
- catch (Exception ex)
- {
- throw new UnmarshalException("'" + XMLUtil.RELATES_TO_TAG
- + "' has invalid content", ex);
- }
- }
- else if (XMLUtil.FAULT_TO_TAG.equals(name))
- {
- call.setFaultTo(EPRHelper.fromXML((Element) n, false));
- }
- else if (XMLUtil.ACTION_TAG.equals(name))
- {
- try
- {
- call.setAction(new URI(n.getTextContent()));
- }
- catch (URISyntaxException e)
- {
- throw new UnmarshalException("'" + XMLUtil.ACTION_TAG
- + "' must be a valid URI", e);
- }
- catch (Exception ex)
- {
- throw new UnmarshalException("'" + XMLUtil.ACTION_TAG
- + "' has invalid content", ex);
- }
- }
- else if (XMLUtil.MESSAGE_IDENTIFIER_TAG.equals(name))
- {
- try
- {
- call.setMessageID(new URI(n.getTextContent()));
- }
- catch (URISyntaxException e)
- {
- throw new UnmarshalException("'"
- + XMLUtil.MESSAGE_IDENTIFIER_TAG
- + "' must be a valid URI", e);
- }
- catch (Exception ex)
- {
- throw new UnmarshalException("'" + XMLUtil.MESSAGE_IDENTIFIER_TAG
- + "' has invalid content", ex);
- }
- }
- else
- {
- extensions.add(n) ;
- }
- }
- else
- {
- extensions.add(n) ;
- }
- }
-
- if (extensions.size() > 0)
- {
- final PortReference to = call.getTo().getAddr() ;
- for(Node node:extensions)
- {
- to.addExtension(node.getLocalName(), node.getPrefix(), node.getNamespaceURI(), node.getTextContent()) ;
- }
- }
- return call;
- }
-
-}
\ No newline at end of file
Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/addressing/helpers/EPRHelper.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/addressing/helpers/EPRHelper.java 2007-12-17 04:48:50 UTC (rev 17274)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/addressing/helpers/EPRHelper.java 2007-12-17 04:59:04 UTC (rev 17275)
@@ -21,9 +21,9 @@
* @author mark.little at jboss.com
*/
-import com.sun.org.apache.xml.internal.serialize.OutputFormat;
-import com.sun.org.apache.xml.internal.serialize.XMLSerializer;
import org.jboss.internal.soa.esb.assertion.AssertArgument;
+import org.jboss.internal.soa.esb.util.XMLHelper;
+import org.jboss.internal.soa.esb.util.stax.StreamHelper;
import org.jboss.soa.esb.MarshalException;
import org.jboss.soa.esb.UnmarshalException;
import org.jboss.soa.esb.addressing.EPR;
@@ -31,118 +31,39 @@
import org.jboss.soa.esb.addressing.XMLUtil;
import org.jboss.soa.esb.addressing.PortReference.Extension;
import org.jboss.soa.esb.addressing.eprs.*;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.xml.sax.SAXException;
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+
+import java.io.StringReader;
import java.io.StringWriter;
import java.util.List;
public class EPRHelper
{
public static final String EPR_TYPE = "type";
+
+ private static final QName HEADER = new QName("header") ;
- /**
- * Serialize the EPR to an XML representation.
- *
- * @param epr
- * @param doc
- * @param header
- * @return
- */
- public static final Element toXML(EPR epr, Document doc, Element header,
- Element packElement) throws MarshalException
- {
- return toXML(epr, doc, header, packElement, false);
- }
+ public static void toXML(final XMLStreamWriter out, final QName name,
+ final EPR epr)
+ throws XMLStreamException
+ {
+ setSpecificEPR(epr) ;
+ PortReferenceHelper.toXML(out, name, epr.getAddr()) ;
+ }
+ public static EPR fromXML(XMLStreamReader in)
+ throws XMLStreamException
+ {
+ final PortReference portReference = PortReferenceHelper.fromXML(in) ;
+ return getSpecificEPR(new EPR(portReference)) ;
+ }
+
/**
- * Serialize the EPR to an XML representation. Specify whether this is a To
- * node in the Call.
- *
- * @param epr
- * @param doc
- * @param header
- * @return
- */
-
- public static final Element toXML(EPR epr, Document doc, Element header,
- Element packElement, boolean to) throws MarshalException
- {
- AssertArgument.isNotNull(epr, "epr");
-
- // TODO
- // The EPR type really should be doing this itself.
-
- setSpecificEPR(epr);
- PortReferenceHelper.toXML(header, doc, packElement, epr.getAddr(), to);
-
- return header;
- }
-
- /**
- * Deserialize the EPR from an XML representation.
- *
- * @param header
- * @return
- */
-
- public static final EPR fromXML(Element header) throws UnmarshalException
- {
- return fromXML(header, false);
- }
-
- /**
- * Deserialize the EPR from an XML representation. Specify whether this is a
- * To node in the Call.
- *
- * @param header
- * @return
- */
-
- public static final EPR fromXML(Element header, boolean to)
- throws UnmarshalException
- {
- AssertArgument.isNotNull(header, "header");
-
- if (to)
- {
- NodeList children = header.getChildNodes();
-
- for (int i = 0; i < children.getLength(); i++)
- {
- Node n = children.item(i);
-
- if (n instanceof Element)
- {
- Element el = (Element) n;
- String prefix = el.getPrefix();
- String tag = el.getLocalName();
-
- if ((prefix != null) && (prefix.equals(XMLUtil.WSA_PREFIX)))
- {
- if ((tag != null) && (tag.equals(XMLUtil.TO_TAG)))
- {
- return getSpecificEPR(new EPR(PortReferenceHelper
- .fromXML(el, true)), header);
- }
- }
- }
- }
- }
-
- return getSpecificEPR(new EPR(PortReferenceHelper.fromXML(header, to)));
- }
-
- /**
* Create a string version of the XML representation for this EPR. If the
* EPR is a specific type (e.g., JMSEpr) then that type information will
* also be encoded.
@@ -154,7 +75,7 @@
public static final String toXMLString(EPR epr) throws MarshalException
{
- return toXMLString(epr, false, XMLUtil.FROM_TAG);
+ return toXMLString(epr, XMLUtil.QNAME_FROM_TAG);
}
/**
@@ -167,62 +88,33 @@
* @throws MarshalException
*/
- public static final String toXMLString(EPR epr, boolean to, String tag) throws MarshalException
+ public static final String toXMLString(EPR epr, QName name) throws MarshalException
{
AssertArgument.isNotNull(epr, "epr");
- AssertArgument.isNotNull(tag, "tag");
+ AssertArgument.isNotNull(name, "name");
try
{
- DocumentBuilderFactory factory = DocumentBuilderFactory
- .newInstance();
-
- factory.setNamespaceAware(true);
-
- DocumentBuilder builder = factory.newDocumentBuilder();
- Document doc = builder.newDocument();
- Element portReferenceElement = doc.createElementNS(
- XMLUtil.WSA_NAMESPACE_URI, tag);
-
- setSpecificEPR(epr);
-
- if (to)
- {
- Element header = doc.createElement("header");
- doc.appendChild(header);
- header.setAttributeNS(XMLUtil.XMLNS_URI, XMLUtil.XMLNS_PREFIX
- + XMLUtil.WSA_PREFIX, XMLUtil.WSA_NAMESPACE_URI);
- toXML(epr, doc, header, portReferenceElement, to);
- header.appendChild(portReferenceElement);
- }
- else
- {
- portReferenceElement.setAttributeNS(XMLUtil.XMLNS_URI, XMLUtil.XMLNS_PREFIX
- + XMLUtil.WSA_PREFIX, XMLUtil.WSA_NAMESPACE_URI);
-
- doc.appendChild(portReferenceElement);
- toXML(epr, doc, portReferenceElement, portReferenceElement, to);
- }
-
- StringWriter sWriter = new StringWriter();
- OutputFormat format = new OutputFormat();
- format.setIndenting(true);
-
- XMLSerializer xmlS = new XMLSerializer(sWriter, format);
-
- xmlS.asDOMSerializer();
- xmlS.serialize(doc);
-
- return sWriter.toString();
+ final StringWriter writer = new StringWriter() ;
+ final XMLStreamWriter out = XMLHelper.getXMLStreamWriter(writer) ;
+
+ if (XMLUtil.QNAME_TO_TAG.equals(name))
+ {
+ final String origURI = StreamHelper.writeStartElement(out, HEADER) ;
+ toXML(out, name, epr) ;
+ StreamHelper.writeEndElement(out, HEADER.getPrefix(), origURI) ;
+ }
+ else
+ {
+ toXML(out, name, epr) ;
+ }
+ out.flush() ;
+ return writer.toString() ;
}
- catch (ParserConfigurationException ex)
+ catch (XMLStreamException xmlse)
{
- throw new MarshalException("Failed to construct DOM Document Builder.", ex);
+ throw new MarshalException("Failed to serialise EPR.", xmlse);
}
- catch (IOException ex)
- {
- throw new MarshalException("Error during DOM to String serialisation.", ex);
- }
}
/**
@@ -237,49 +129,24 @@
public static final EPR fromXMLString(String xml) throws UnmarshalException
{
- return fromXMLString(xml, false);
- }
-
- /**
- * Get the EPR from the string representation. If the EPR was a specific
- * type (e.g., JMSEpr) then it will be returned as an instance of the
- * appropriate class. Specify whether this is a To node in the Call.
- *
- * @param xml
- * @return
- * @throws UnmarshalException
- */
-
- public static final EPR fromXMLString(String xml, boolean to) throws UnmarshalException
- {
AssertArgument.isNotNull(xml, "xml");
try
{
- DocumentBuilderFactory factory = DocumentBuilderFactory
- .newInstance();
-
- factory.setNamespaceAware(true);
-
- DocumentBuilder builder = factory.newDocumentBuilder();
- Document doc = builder.parse(new ByteArrayInputStream(xml
- .getBytes()));
- Element rootElement = (Element) doc.getDocumentElement();
-
- return fromXML(rootElement, to);
+ final StringReader reader = new StringReader(xml) ;
+ final XMLStreamReader in = XMLHelper.getXMLStreamReader(reader) ;
+ StreamHelper.skipToStartElement(in) ;
+ if (HEADER.equals(in.getName()))
+ {
+ StreamHelper.skipToNextStartElement(in) ;
+ }
+
+ return fromXML(in) ;
}
- catch (SAXException ex)
+ catch (final XMLStreamException xmlse)
{
- throw new UnmarshalException("Unable to parse EPR XML.", ex);
+ throw new UnmarshalException("Unable to parse EPR XML.", xmlse);
}
- catch (IOException ex)
- {
- throw new UnmarshalException("Unable to read EPR XML stream.", ex);
- }
- catch (ParserConfigurationException ex)
- {
- throw new UnmarshalException("Failed to construct DOM Document Builder.", ex);
- }
}
private final static void setSpecificEPR(EPR epr)
@@ -318,7 +185,7 @@
}
}
- private final static EPR getSpecificEPR(EPR epr)
+ public final static EPR getSpecificEPR(EPR epr)
{
String eprType = epr.getAddr().getExtensionValue(EPR_TYPE);
@@ -353,66 +220,6 @@
}
}
- /**
- * Because of WS-A rules, if this was a To node then all of the elements
- * within the EPR are now at top-level in the header and not easily
- * obtained. We need to ask each EPR type to reconstitute itself.
- *
- * @param epr
- * @param header
- * @return
- */
-
- private final static EPR getSpecificEPR(EPR epr, Element header)
- {
- NodeList children = header.getChildNodes();
- String eprType = null;
-
- for (int i = 0; i < children.getLength(); i++)
- {
- String prefix = children.item(i).getPrefix();
- String tag = children.item(i).getLocalName();
-
- if ((prefix != null) && (prefix.equals(XMLUtil.JBOSSESB_PREFIX)))
- {
- if ((tag != null) && (tag.equals(EPR_TYPE)))
- {
- eprType = children.item(i).getTextContent();
- }
- }
- }
-
- if (eprType != null)
- {
- /*
- * Do not re-order.
- */
-
- if (eprType.equals(EmailEpr.type().toString()))
- return new EmailEpr(epr, header);
- else if (eprType.equals(SFTPEpr.type().toString()))
- return new SFTPEpr(epr, header);
- else if (eprType.equals(HTTPEpr.type().toString()))
- return new HTTPEpr(epr, header);
- else if (eprType.equals(JDBCEpr.type().toString()))
- return new JDBCEpr(epr, header);
- else if (eprType.equals(HibernateEpr.type().toString()))
- return new HibernateEpr(epr, header);
- else if (eprType.equals(JMSEpr.type().toString()))
- return new JMSEpr(epr, header);
- else if (eprType.equals(FTPEpr.type().toString()))
- return new FTPEpr(epr, header);
- else if (eprType.equals(FileEpr.type().toString()))
- return new FileEpr(epr, header);
- else if (eprType.equals(LogicalEPR.type().toString()))
- return new LogicalEPR(epr, header);
- else
- return epr;
- } else {
- return epr;
- }
- }
-
/**
* Create a copy of the EPR, including the specified extensions.
* @param epr The current EPR.
@@ -437,5 +244,4 @@
}
return copyEPR ;
}
-
}
\ No newline at end of file
Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/addressing/helpers/PortReferenceHelper.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/addressing/helpers/PortReferenceHelper.java 2007-12-17 04:48:50 UTC (rev 17274)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/addressing/helpers/PortReferenceHelper.java 2007-12-17 04:59:04 UTC (rev 17275)
@@ -27,21 +27,24 @@
package org.jboss.internal.soa.esb.addressing.helpers;
+import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.Map;
+import java.util.List;
+import java.util.Map.Entry;
-import org.jboss.soa.esb.MarshalException;
-import org.jboss.soa.esb.UnmarshalException;
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.jboss.internal.soa.esb.util.stax.ElementContent;
+import org.jboss.internal.soa.esb.util.stax.QNameHelper;
+import org.jboss.internal.soa.esb.util.stax.StreamHelper;
+import org.jboss.internal.soa.esb.util.stax.TextElement;
import org.jboss.soa.esb.addressing.PortReference;
import org.jboss.soa.esb.addressing.XMLUtil;
-import org.w3c.dom.Attr;
-import org.w3c.dom.Element;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.w3c.dom.Text;
+import org.jboss.soa.esb.addressing.PortReference.Extension;
/*
* This should pack the PortReference into an ERP.
@@ -53,307 +56,234 @@
public class PortReferenceHelper
{
- /**
- * WS-Addressing is broken in that the To field is a URI, even if the From
- * field was an EPR! You have to use the EPR bits separately. So, the
- * toField is used to indicate whether we are packing this address as a To
- * field (when we need to treat it differently) or as an EPR.
- */
-
- /** ************************************************** */
- public static void toXML(org.w3c.dom.Element header,
- org.w3c.dom.Document document,
- org.w3c.dom.Element portReferenceElement,
- PortReference portReference, boolean toField)
- throws MarshalException
+ public static void toXML(final XMLStreamWriter out, final QName name,
+ final PortReference portReference)
+ throws XMLStreamException
{
- try
- {
- if (!toField)
- {
- Element addressElement = document.createElementNS(
- XMLUtil.WSA_NAMESPACE_URI, XMLUtil.ADDRESS_TAG);
- addressElement.setPrefix(XMLUtil.WSA_PREFIX);
- addressElement.appendChild(document
- .createTextNode(portReference.getAddress()));
- portReferenceElement.appendChild(addressElement);
- }
- else
- {
- portReferenceElement.appendChild(document
- .createTextNode(portReference.getAddress()));
- }
-
- Iterator extensions = portReference.getExtensions();
- Element referenceProperties = null;
-
- while (extensions.hasNext())
- {
- PortReference.Extension extension = (PortReference.Extension) extensions
- .next();
-
- /*
- * WS-Addressing is broken in that the To field is a URI, even
- * if the From field was an EPR! You have to use the EPR bits
- * separately. Doh!
- */
-
- if (!toField)
- {
- if (referenceProperties == null)
- {
- referenceProperties = document.createElementNS(
- XMLUtil.WSA_NAMESPACE_URI,
- XMLUtil.REFERENCE_PROPERTIES_TAG);
- referenceProperties.setPrefix(XMLUtil.WSA_PREFIX);
- portReferenceElement.appendChild(referenceProperties);
- }
- }
- else
- referenceProperties = header;
-
- extensionToXML(referenceProperties, document, extension);
- }
- }
- catch (Exception exception)
- {
- exception.printStackTrace();
- throw new MarshalException("Marshal failure: " + exception);
- }
+ if (XMLUtil.QNAME_TO_TAG.equals(name))
+ {
+ writeToXML(out, name, portReference) ;
+ }
+ else
+ {
+ writeXML(out, name, portReference) ;
+ }
}
-
- /** **************************** */
- public static PortReference fromXML(
- org.w3c.dom.Element portReferenceElement, boolean toField)
- throws UnmarshalException
+
+ private static void writeToXML(final XMLStreamWriter out, final QName name, final PortReference portReference)
+ throws XMLStreamException
{
- PortReference portReference = new PortReference();
-
- if (toField)
- {
- portReference.setAddress(portReferenceElement.getTextContent());
- }
-
- org.w3c.dom.NodeList elements = portReferenceElement.getChildNodes();
-
- for (int i = 0; i < elements.getLength(); i++)
- {
- final Object extensionObject = elements.item(i);
-
- if (extensionObject instanceof Element)
- {
- int parentNodeType = PortReference.Extension.NEITHER;
- Element extensionElement = (Element) extensionObject;
- NodeList children = extensionElement.getChildNodes();
- String parentName = extensionElement.getNodeName();
- boolean haveChildren = false;
-
- if (parentName.equals(XMLUtil.REFERENCE_PROPERTIES_TAG))
- parentNodeType = PortReference.Extension.REFERENCE_PROPERTIES;
- else
- {
- if (parentName.equals(XMLUtil.REFERENCE_PARAMETERS_TAG))
- parentNodeType = PortReference.Extension.REFERENCE_PARAMETERS;
- else
- {
- if (!toField
- && parentName.equals(XMLUtil.WSA_PREFIX + ":"
- + XMLUtil.ADDRESS_TAG))
- {
- portReference.setAddress(extensionElement
- .getTextContent());
- }
- }
- }
-
- final int numChildren = children.getLength();
-
- for (int count = 0; count < numChildren; count++)
- {
- final Object childObject = children.item(count);
-
- if (childObject instanceof Element)
- {
- Element childElement = (Element) childObject;
-
- portReference
- .addExtension(childrenFromXML(childElement));
- haveChildren = true;
- }
- }
-
- if (!haveChildren && !parentName.equals(XMLUtil.WSA_PREFIX + ":"+ XMLUtil.ADDRESS_TAG))
- {
- PortReference.Extension ext = new PortReference.Extension(
- extensionElement.getNodeName(), null, null,
- extensionElement.getNodeValue(), parentNodeType);
-
- portReference.addExtension(ext);
-
- final NamedNodeMap attrs = extensionElement.getAttributes();
- final int numAttrs = attrs.getLength();
- if (numAttrs > 0)
- {
- final HashMap<ArjunaName, String> p = new HashMap<ArjunaName, String>();
- for (int count = 0; count < numAttrs; count++)
- {
- final Attr attr = (Attr) attrs.item(count);
- if (!"http://www.w3.org/2000/xmlns/".equals(attr
- .getNamespaceURI()))
- {
- final ArjunaName name = generateName(attr);
- p.put(name, attr.getValue());
- }
- }
-
- ext.addAttributes(p);
- }
- }
- }
- }
-
- return portReference;
+ final TextElement toElement = new TextElement(portReference.getAddress()) ;
+ StreamHelper.writeElement(out, name, toElement) ;
+
+ writeExtensions(out, portReference) ;
}
-
- private final static PortReference.Extension childrenFromXML(
- Element childRoot)
+
+ private static void writeXML(final XMLStreamWriter out, final QName name, final PortReference portReference)
+ throws XMLStreamException
{
- final NodeList children = childRoot.getChildNodes();
- final int numChildNodes = children.getLength();
-
- final PortReference.Extension extension;
- if (numChildNodes > 0)
- {
- Object childObject = children.item(0);
- if (childObject instanceof Element)
- {
- extension = new PortReference.Extension(
- childRoot.getNodeName(), childRoot.getPrefix(),
- childRoot.getNamespaceURI());
-
- for (int count = 1; count < numChildNodes; count++)
- {
- extension.addChild(childrenFromXML((Element) childObject));
- childObject = children.item(count);
- }
- }
- else
- {
- extension = new PortReference.Extension(
- childRoot.getNodeName(), childRoot.getPrefix(),
- childRoot.getNamespaceURI(), ((Node) childObject)
- .getNodeValue());
- }
- }
- else
- {
- extension = new PortReference.Extension(childRoot.getNodeName(),
- childRoot.getPrefix(), childRoot.getNamespaceURI(),
- childRoot.getNodeValue());
- }
-
- final NamedNodeMap attrs = childRoot.getAttributes();
- final int numAttrs = attrs.getLength();
- if (numAttrs > 0)
- {
- final HashMap<ArjunaName, String> p = new HashMap<ArjunaName, String>();
- for (int count = 0; count < numAttrs; count++)
- {
- final Attr attr = (Attr) attrs.item(count);
- if (!"http://www.w3.org/2000/xmlns/".equals(attr
- .getNamespaceURI()))
- {
- final ArjunaName name = generateName(attr);
- p.put(name, attr.getValue());
- }
- }
-
- extension.addAttributes(p);
- }
- return extension;
+ final String origURI = StreamHelper.writeStartElement(out, name) ;
+
+ final TextElement addressElement = new TextElement(portReference.getAddress()) ;
+ StreamHelper.writeElement(out, XMLUtil.QNAME_ADDRESS_TAG, addressElement) ;
+
+ if (portReference.getAllExtensions().size() > 0)
+ {
+ final String origReferenceURI = StreamHelper.writeStartElement(out, XMLUtil.QNAME_REFERENCE_PROPERTIES_TAG) ;
+ writeExtensions(out, portReference) ;
+ StreamHelper.writeEndElement(out, XMLUtil.QNAME_REFERENCE_PROPERTIES_TAG.getPrefix(), origReferenceURI) ;
+ }
+
+ StreamHelper.writeEndElement(out, name.getPrefix(), origURI) ;
}
-
- private final static Element extensionToXML(Element packInto,
- org.w3c.dom.Document document, PortReference.Extension toPack)
- throws MarshalException
+
+ private static void writeExtensions(final XMLStreamWriter out, final PortReference portReference)
+ throws XMLStreamException
+ {
+ for(Extension extension: portReference.getAllExtensions())
+ {
+ writeExtension(out, extension) ;
+ }
+ }
+
+ private static void writeExtension(final XMLStreamWriter out, final Extension extension)
+ throws XMLStreamException
{
- final String uri = toPack.getURI();
- final Element element;
- if (uri == null)
- {
- element = document.createElement(toPack.getTag());
- }
- else
- {
- final String prefix = toPack.getPrefix();
- element = document.createElementNS(uri, toPack.getTag());
- element.setPrefix(prefix);
- element.setAttributeNS(XMLUtil.XMLNS_URI, XMLUtil.XMLNS_PREFIX
- + toPack.getPrefix(), uri);
- }
- packInto.appendChild(element);
+ final String uri = QNameHelper.getNormalisedValue(extension.getURI()) ;
+ final String prefix = QNameHelper.getNormalisedValue(extension.getPrefix()) ;
+ final QName name = new QName(uri, extension.getTag(), prefix) ;
+ final String origURI = StreamHelper.writeStartElement(out, name) ;
+
+ final HashMap attributes = extension.getAttributes() ;
+ if (attributes != null)
+ {
+ final Iterator entryIter = attributes.entrySet().iterator() ;
+ while(entryIter.hasNext())
+ {
+ final Entry entry = (Entry)entryIter.next() ;
+ final ArjunaName arjunaName = (ArjunaName)entry.getKey() ;
+ final String value = (String)entry.getValue() ;
+
+ final String attributeURI = QNameHelper.getNormalisedValue(arjunaName.getURI()) ;
+ final String atributePrefix = QNameHelper.getNormalisedValue(arjunaName.getPrefix()) ;
+ final QName attributeName = new QName(uri, arjunaName.getLocalName(), prefix) ;
+
+ StreamHelper.writeAttribute(out, attributeName, value) ;
+ }
+ }
+
+ final TextElement value = new TextElement(extension.getValue()) ;
+ value.writeContent(out) ;
+
+ StreamHelper.writeEndElement(out, name.getPrefix(), origURI) ;
- if (toPack.getValue() != null)
- {
- final Text text = document.createTextNode(toPack.getValue());
- element.appendChild(text);
- }
+ final List children = extension.getChildren() ;
+ if (children != null)
+ {
+ final Iterator childIter = extension.getChildren().iterator() ;
+ while(childIter.hasNext())
+ {
+ writeExtension(out, (Extension)childIter.next()) ;
+ }
+ }
+ }
- LinkedList extensions = toPack.getChildren();
-
- if (extensions != null)
- {
- for (int i = 0; i < extensions.size(); i++)
- {
- PortReference.Extension ext = (PortReference.Extension) extensions
- .get(i);
-
- extensionToXML(element, document, ext);
- }
- }
-
- HashMap attrs = toPack.getAttributes();
-
- if (attrs != null)
- {
- Iterator names = attrs.entrySet().iterator();
-
- while (names.hasNext())
- {
- Map.Entry entry = (Map.Entry) names.next();
- ArjunaName name = (ArjunaName) entry.getKey();
- final String value = (String) entry.getValue();
- final String attrURI = name.getURI();
- if (attrURI != null)
- {
- element.setAttributeNS(attrURI, name.getQualifiedName(),
- value);
- }
- else
- {
- element.setAttribute(name.getQualifiedName(), value);
- }
- }
- }
-
- return element;
+ /** **************************** */
+ public static PortReference fromXML(final XMLStreamReader in)
+ throws XMLStreamException
+ {
+ final boolean toField = XMLUtil.QNAME_TO_TAG.equals(in.getName()) ;
+ if (toField)
+ {
+ return readToXML(in) ;
+ }
+ else
+ {
+ return readXML(in) ;
+ }
}
-
- /**
- * Generate a name based on the attribute.
- *
- * @param attr
- * The current attribute.
- * @return The name
- */
- private static ArjunaName generateName(final Attr attr)
+
+ private static PortReference readToXML(final XMLStreamReader in)
+ throws XMLStreamException
{
- final String localName = attr.getNodeName();
- final String uri = attr.getNamespaceURI();
- final String prefix = attr.getPrefix();
-
- return new ArjunaName(uri, prefix, localName);
+ final PortReference portReference = new PortReference() ;
+ final TextElement toElement = new TextElement(in) ;
+ portReference.setAddress(toElement.getText()) ;
+ return portReference ;
}
+
+ private static PortReference readXML(final XMLStreamReader in)
+ throws XMLStreamException
+ {
+ final PortReferenceImpl portReferenceImpl = new PortReferenceImpl(in) ;
+ return portReferenceImpl.getPortReference() ;
+ }
+
+ private static class PortReferenceImpl extends ElementContent
+ {
+ private final PortReference portReference = new PortReference() ;
+
+ PortReferenceImpl(final XMLStreamReader in)
+ throws XMLStreamException
+ {
+ parse(in) ;
+ }
+
+ PortReference getPortReference()
+ {
+ return portReference ;
+ }
+
+ @Override
+ protected void putElement(XMLStreamReader in, QName elementName)
+ throws XMLStreamException
+ {
+ if (XMLUtil.QNAME_ADDRESS_TAG.equals(elementName))
+ {
+ final TextElement address = new TextElement(in) ;
+ portReference.setAddress(address.getText()) ;
+ }
+ else if (XMLUtil.QNAME_REFERENCE_PROPERTIES_TAG.equals(elementName))
+ {
+ final ReferencePropertiesImpl referenceProperties = new ReferencePropertiesImpl(in) ;
+ portReference.addExtensions(referenceProperties.getExtensions()) ;
+ }
+ else
+ {
+ throw new XMLStreamException("Unrecognised element name: " + elementName) ;
+ }
+ }
+ }
+
+ private static class ReferencePropertiesImpl extends ElementContent
+ {
+ private List<Extension> extensions = new ArrayList<Extension>() ;
+
+ ReferencePropertiesImpl(final XMLStreamReader in)
+ throws XMLStreamException
+ {
+ parse(in) ;
+ }
+
+ List<Extension> getExtensions()
+ {
+ return extensions ;
+ }
+
+ @Override
+ protected void putElement(XMLStreamReader in, QName elementName)
+ throws XMLStreamException
+ {
+ final ExtensionImpl extension = new ExtensionImpl(in) ;
+ extensions.add(extension.getExtension()) ;
+ }
+ }
+
+ private static class ExtensionImpl extends ElementContent
+ {
+ private final List<Extension> extensions = new ArrayList<Extension>() ;
+ private final HashMap<ArjunaName, String> attributes = new HashMap<ArjunaName, String>() ;
+ private final Extension extension ;
+ private String value ;
+
+ ExtensionImpl(final XMLStreamReader in)
+ throws XMLStreamException
+ {
+ final QName name = in.getName() ;
+ parse(in) ;
+ extension = new Extension(name.getLocalPart(), name.getPrefix(),
+ name.getNamespaceURI(), value) ;
+ }
+
+ Extension getExtension()
+ {
+ return extension ;
+ }
+
+ @Override
+ protected void putAttribute(XMLStreamReader in, QName attributeName,
+ String attributeValue) throws XMLStreamException
+ {
+ final ArjunaName name = new ArjunaName(attributeName.getNamespaceURI(),
+ attributeName.getPrefix(), attributeName.getLocalPart()) ;
+ attributes.put(name, attributeValue) ;
+ }
+
+ @Override
+ protected void putValue(XMLStreamReader in, String value)
+ throws XMLStreamException
+ {
+ this.value = value ;
+ }
+
+ @Override
+ protected void putElement(XMLStreamReader in, QName elementName)
+ throws XMLStreamException
+ {
+ final ExtensionImpl extension = new ExtensionImpl(in) ;
+ extensions.add(extension.getExtension()) ;
+ }
+ }
private static class ArjunaName
{
Added: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/message/format/DeferredDeserialisationException.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/message/format/DeferredDeserialisationException.java (rev 0)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/message/format/DeferredDeserialisationException.java 2007-12-17 04:59:04 UTC (rev 17275)
@@ -0,0 +1,71 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2005-2006,
+ */
+
+package org.jboss.internal.soa.esb.message.format;
+
+/**
+ * Exception thrown for errors occurring during deferred deserialisation of values.
+ *
+ * @author <a href='kevin.conner at jboss.com'>Kevin Conner</a>
+ */
+
+public class DeferredDeserialisationException extends RuntimeException
+{
+ /**
+ * The serial version UID for this exception.
+ */
+ private static final long serialVersionUID = -8941603736543453117L;
+
+ /**
+ * Construct a default deferred deserialisation exception.
+ */
+ public DeferredDeserialisationException()
+ {
+ super() ;
+ }
+
+ /**
+ * Construct a deferred deserialisation exception.
+ * @param message The message associated with the exception.
+ */
+ public DeferredDeserialisationException(final String message)
+ {
+ super(message) ;
+ }
+
+ /**
+ * Construct a deferred deserialisation exception.
+ * @param cause The origianl cause of the exception.
+ */
+ public DeferredDeserialisationException(final Throwable cause)
+ {
+ super(cause);
+ }
+
+ /**
+ * Construct a deferred deserialisation exception.
+ * @param message The message associated with the exception.
+ * @param cause The origianl cause of the exception.
+ */
+ public DeferredDeserialisationException(final String message, final Throwable cause)
+ {
+ super(message, cause) ;
+ }
+}
Property changes on: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/message/format/DeferredDeserialisationException.java
___________________________________________________________________
Name: svn:keywords
+ Rev Date
Name: svn:eol-style
+ native
Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/message/format/serialized/AttachmentImpl.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/message/format/serialized/AttachmentImpl.java 2007-12-17 04:48:50 UTC (rev 17274)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/message/format/serialized/AttachmentImpl.java 2007-12-17 04:59:04 UTC (rev 17275)
@@ -21,10 +21,11 @@
package org.jboss.internal.soa.esb.message.format.serialized;
+import java.io.IOException;
+import java.io.ObjectInputStream;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Hashtable;
-import java.util.Map;
import org.jboss.soa.esb.message.Attachment;
@@ -41,19 +42,23 @@
public Object get(String name)
{
- return _table.get(name);
+ return SerializedValueImpl.unwrap(_table.get(name));
}
public Object put(String name, Object value)
{
if (value instanceof Serializable)
- return _table.put(name,(Serializable)value);
+ {
+ final Serializable wrapped = SerializedValueImpl.wrap((Serializable)value) ;
+ final Serializable previous = _table.put(name, wrapped) ;
+ return SerializedValueImpl.unwrap(previous);
+ }
throw new IllegalArgumentException("value must be Serializable");
}
public Object remove(String name)
{
- return _table.remove(name);
+ return SerializedValueImpl.unwrap(_table.remove(name));
}
public String[] getNames()
@@ -63,25 +68,29 @@
public Object itemAt(int index) throws IndexOutOfBoundsException
{
- return _list.get(index);
+ return SerializedValueImpl.unwrap(_list.get(index));
}
public Object removeItemAt(int index) throws IndexOutOfBoundsException
{
- return _list.remove(index);
+ return SerializedValueImpl.unwrap(_list.remove(index));
}
public Object replaceItemAt(int index, Object value) throws IndexOutOfBoundsException
{
if (value instanceof Serializable)
- return _list.set(index,(Serializable)value);
+ {
+ final Serializable wrapped = SerializedValueImpl.wrap((Serializable)value) ;
+ final Serializable previous = _list.set(index, wrapped) ;
+ return SerializedValueImpl.unwrap(previous);
+ }
throw new IllegalArgumentException("value must be Serializable");
}
public void addItem(Object value)
{
if (value instanceof Serializable)
- _list.add((Serializable)value);
+ _list.add(SerializedValueImpl.wrap((Serializable)value)) ;
else
throw new IllegalArgumentException("value must be Serializable");
}
@@ -89,7 +98,7 @@
public void addItemAt(int index, Object value) throws IndexOutOfBoundsException
{
if (value instanceof Serializable)
- _list.add(index,(Serializable)value);
+ _list.add(index, SerializedValueImpl.wrap((Serializable)value));
else
throw new IllegalArgumentException("value must be Serializable");
}
@@ -112,44 +121,14 @@
.toString()+" ]";
}
- @Override
- public boolean equals(Object arg)
- {
- if (! (arg instanceof Attachment))
- return false;
- Attachment other = (Attachment)arg;
+ private void readObject(final ObjectInputStream stream)
+ throws IOException, ClassNotFoundException
+ {
+ stream.defaultReadObject() ;
+ SerializedValueImpl.wrapList(_list) ;
+ SerializedValueImpl.wrapMap(_table) ;
+ }
- if (other.getNamedCount() != _table.size())
- return false;
- for(Map.Entry<String,Serializable>oCurr : _table.entrySet())
- {
- Object val = other.get(oCurr.getKey());
- if (null==oCurr.getValue())
- if (null==val)
- continue;
- else
- return false;
- if (!oCurr.getValue().equals(val))
- return false;
- }
-
- if (other.getUnnamedCount() != _list.size())
- return false;
- int index = 0;
- for (Serializable oCurr : _list)
- {
- Object val = other.itemAt(index++);
- if (null==oCurr)
- if (null==val)
- continue;
- else
- return false;
- if (!oCurr.equals(val))
- return false;
- }
- return true;
- }
-
- ArrayList<Serializable> _list = new ArrayList<Serializable>();
- Hashtable<String,Serializable> _table = new Hashtable<String,Serializable>();
+ private final ArrayList<Serializable> _list = new ArrayList<Serializable>();
+ private final Hashtable<String, Serializable> _table = new Hashtable<String,Serializable>();
}
Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/message/format/serialized/BodyImpl.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/message/format/serialized/BodyImpl.java 2007-12-17 04:48:50 UTC (rev 17274)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/message/format/serialized/BodyImpl.java 2007-12-17 04:59:04 UTC (rev 17275)
@@ -1,7 +1,9 @@
package org.jboss.internal.soa.esb.message.format.serialized;
import java.io.Serializable;
+import java.util.Enumeration;
import java.util.Hashtable;
+import java.util.Map;
import java.util.Set;
import org.jboss.internal.soa.esb.assertion.AssertArgument;
@@ -75,10 +77,7 @@
if (value instanceof Serializable)
{
- synchronized (_objects)
- {
- _objects.put(name, (Serializable) value);
- }
+ _objects.put(name, SerializedValueImpl.wrap((Serializable) value));
}
else
throw new IllegalArgumentException("Object must be Serializable.");
@@ -93,32 +92,23 @@
{
AssertArgument.isNotNull(name, "name");
- synchronized (_objects)
- {
- return _objects.get(name);
- }
+ return SerializedValueImpl.unwrap(_objects.get(name));
}
public String[] getNames()
{
- Set<String> keys = _objects.keySet();
-
- if (keys != null)
- {
- String[] toReturn = new String[keys.size()];
-
- return keys.toArray(toReturn);
- }
- else
- return null;
+ final Set<String> keys = _objects.keySet() ;
+ return keys.toArray(new String[0]) ;
}
+ public Enumeration<String> getEnumeratedNames()
+ {
+ return _objects.keys() ;
+ }
+
public Object remove(String name)
{
- synchronized (_objects)
- {
- return _objects.remove(name);
- }
+ return SerializedValueImpl.unwrap(_objects.remove(name));
}
public void replace(Body b)
@@ -159,36 +149,30 @@
if (content != null)
toReturn += "byte[]: " + Util.format(new String(content));
- if (_objects != null)
- {
- if (content != null)
- toReturn += ", ";
+ if (content != null)
+ toReturn += ", ";
- toReturn += "objects: " + _objects.toString();
- }
+ toReturn += "objects: " + _objects.toString();
return toReturn + " ]";
}
- public boolean equals(Object o)
- {
- if (o instanceof BodyImpl)
- {
- BodyImpl toCompare = (BodyImpl) o;
-
- return _objects.equals(toCompare._objects);
- }
- else
- return false;
- }
-
// copy constructor.
protected BodyImpl(BodyImpl orig)
{
- _objects = orig._objects;
+ _objects = new Hashtable<String, Serializable>(orig._objects);
}
+
+ protected void initialiseMap(final Map<String, Serializable> payload)
+ {
+ synchronized(_objects)
+ {
+ _objects.clear() ;
+ _objects.putAll(payload) ;
+ SerializedValueImpl.wrapMap(_objects) ;
+ }
+ }
- protected Hashtable<String, Serializable> _objects;
-
+ private Hashtable<String, Serializable> _objects;
}
\ No newline at end of file
Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/message/format/serialized/HeaderImpl.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/message/format/serialized/HeaderImpl.java 2007-12-17 04:48:50 UTC (rev 17274)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/message/format/serialized/HeaderImpl.java 2007-12-17 04:59:04 UTC (rev 17275)
@@ -21,28 +21,15 @@
* @author mark.little at jboss.com
*/
-import java.io.ByteArrayInputStream;
import java.io.IOException;
-import java.io.InputStream;
import java.io.Serializable;
-import java.io.StringWriter;
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.stream.XMLStreamException;
-import org.jboss.internal.soa.esb.addressing.helpers.CallHelper;
-import org.jboss.soa.esb.MarshalException;
-import org.jboss.soa.esb.UnmarshalException;
+import org.jboss.internal.soa.esb.message.format.xml.CallImpl;
import org.jboss.soa.esb.addressing.Call;
import org.jboss.soa.esb.message.Header;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.xml.sax.SAXException;
-import com.sun.org.apache.xml.internal.serialize.OutputFormat;
-import com.sun.org.apache.xml.internal.serialize.XMLSerializer;
-
/**
* The message header. Contains such things as routing information.
*/
@@ -51,8 +38,6 @@
{
private static final long serialVersionUID = 0x0;
- public static final String HEADER_TAG = "Header";
-
public HeaderImpl ()
{
_call = new Call();
@@ -92,39 +77,14 @@
{
try
{
- DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
-
- factory.setNamespaceAware(true);
-
- DocumentBuilder builder = factory.newDocumentBuilder();
- Document doc = builder.newDocument();
- Element header = doc.createElement(HEADER_TAG);
-
- doc.appendChild(header);
-
- header = CallHelper.toXML(_call, doc, header);
-
- StringWriter sWriter = new StringWriter();
- OutputFormat format = new OutputFormat();
- format.setIndenting(true);
- XMLSerializer xmlS = new XMLSerializer(sWriter, format);
- xmlS.asDOMSerializer();
- xmlS.serialize(doc);
-
- out.writeObject(sWriter.toString());
+ out.writeObject(CallImpl.toXML(_call)) ;
}
- catch (MarshalException ex)
+ catch (final XMLStreamException xmlse)
{
- ex.printStackTrace();
-
- throw new IOException(ex.toString());
+ final IOException ioe = new IOException("Caught XMLStreamException serialising Call") ;
+ ioe.initCause(xmlse) ;
+ throw ioe ;
}
- catch (ParserConfigurationException ex)
- {
- ex.printStackTrace();
-
- throw new IOException(ex.toString());
- }
}
}
@@ -132,37 +92,15 @@
{
try
{
- String header = (String) in.readObject();
- InputStream inStream = new ByteArrayInputStream(header.getBytes());
- DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
-
- factory.setNamespaceAware(true);
-
- DocumentBuilder builder = factory.newDocumentBuilder();
- Document doc = builder.parse(inStream);
-
- Element headerElement = doc.getDocumentElement();
-
- _call = CallHelper.fromXML(headerElement);
+ final String header = (String) in.readObject();
+ _call = CallImpl.fromXML(header) ;
}
- catch (UnmarshalException ex)
+ catch (final XMLStreamException xmlse)
{
- ex.printStackTrace();
-
- throw new IOException(ex.toString());
+ final IOException ioe = new IOException("Caught XMLStreamException deserialising Call") ;
+ ioe.initCause(xmlse) ;
+ throw ioe ;
}
- catch (ParserConfigurationException ex)
- {
- ex.printStackTrace();
-
- throw new IOException(ex.toString());
- }
- catch (SAXException ex)
- {
- ex.printStackTrace();
-
- throw new IOException(ex.toString());
- }
}
private Call _call;
Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/message/format/serialized/PropertiesImpl.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/message/format/serialized/PropertiesImpl.java 2007-12-17 04:48:50 UTC (rev 17274)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/message/format/serialized/PropertiesImpl.java 2007-12-17 04:59:04 UTC (rev 17275)
@@ -22,7 +22,6 @@
import java.io.Serializable;
import java.util.Hashtable;
-import java.util.Map;
import org.jboss.soa.esb.message.Properties;
@@ -32,7 +31,7 @@
public Object getProperty(String name)
{
- return _table.get(name);
+ return SerializedValueImpl.unwrap(_table.get(name));
}
public Object getProperty(String name, Object defaultVal)
@@ -44,21 +43,25 @@
public Object setProperty(String name, Object value)
{
if (value instanceof Serializable)
- return _table.put(name, (Serializable) value);
+ {
+ final Serializable wrapped = SerializedValueImpl.wrap((Serializable)value) ;
+ final Serializable previous = _table.put(name, wrapped) ;
+ return SerializedValueImpl.unwrap(previous);
+ }
else
throw new IllegalArgumentException("Value must be serializable");
}
public Object remove(String name)
{
- return _table.remove(name);
+ return SerializedValueImpl.unwrap(_table.remove(name));
}
public int size() {return _table.size(); }
public String[] getNames()
{
- return _table.keySet().toArray(new String[_table.size()]);
+ return _table.keySet().toArray(new String[0]);
}
public String toString()
@@ -66,27 +69,5 @@
return "properties: [ "+_table.toString()+" ]";
}
- @Override
- public boolean equals(Object arg)
- {
- if (! (arg instanceof Properties))
- return false;
- Properties other = (Properties)arg;
- if (other.size() != _table.size())
- return false;
- for(Map.Entry<String,Serializable>oCurr : _table.entrySet())
- {
- Object val = other.getProperty(oCurr.getKey());
- if (null==oCurr.getValue())
- if (null==val)
- continue;
- else
- return false;
- if (!oCurr.getValue().equals(val))
- return false;
- }
- return true;
- }
-
- Hashtable<String, Serializable> _table = new Hashtable<String, Serializable>();
+ private Hashtable<String, Serializable> _table = new Hashtable<String, Serializable>();
}
Added: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/message/format/serialized/SerializedValueImpl.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/message/format/serialized/SerializedValueImpl.java (rev 0)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/message/format/serialized/SerializedValueImpl.java 2007-12-17 04:59:04 UTC (rev 17275)
@@ -0,0 +1,252 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2005-2006,
+ */
+
+package org.jboss.internal.soa.esb.message.format.serialized;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
+import java.util.Hashtable;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import org.jboss.internal.soa.esb.message.format.DeferredDeserialisationException;
+import org.jboss.soa.esb.util.ContextObjectInputStream;
+
+/**
+ * Wrapper class for serialised values, supporting JIT deserialisation.
+ *
+ * @author <a href='kevin.conner at jboss.com'>Kevin Conner</a>
+ */
+
+public class SerializedValueImpl implements Serializable
+{
+ /**
+ * The serial version UID for this class.
+ */
+ private static final long serialVersionUID = -5354588126152655437L;
+
+ /**
+ * The transient value.
+ */
+ private transient Serializable value ;
+
+ /**
+ * The serialised form.
+ */
+ private byte[] serialisedForm ;
+
+ /**
+ * Construct the serialised value wrapper for the specific value.
+ * @param value The serializable value.
+ */
+ private SerializedValueImpl(final Serializable value)
+ {
+ this.value = value ;
+ }
+
+ /**
+ * Get the wrapped value.
+ * @return The wrapped value.
+ */
+ public Serializable getValue()
+ {
+ if ((value == null) && (serialisedForm != null))
+ {
+ final ByteArrayInputStream bais = new ByteArrayInputStream(serialisedForm) ;
+ final ObjectInputStream ois ;
+ try
+ {
+ ois = new ContextObjectInputStream(bais) ;
+ }
+ catch (final IOException ioe)
+ {
+ throw new DeferredDeserialisationException("Error creating object input stream", ioe) ;
+ }
+
+ try
+ {
+ value = (Serializable)ois.readObject() ;
+ }
+ catch (final IOException ioe)
+ {
+ throw new DeferredDeserialisationException("Error reading object input stream", ioe) ;
+ }
+ catch (final ClassNotFoundException cnfe)
+ {
+ throw new DeferredDeserialisationException("Error constructing object value", cnfe) ;
+ }
+ serialisedForm = null ;
+ }
+ return value ;
+ }
+
+ /**
+ * Handle the serialisation.
+ * @param stream The object output stream.
+ * @throws IOException For errors during serialisation.
+ */
+ private void writeObject(final ObjectOutputStream stream)
+ throws IOException
+ {
+ if (value != null)
+ {
+ final ByteArrayOutputStream baos = new ByteArrayOutputStream() ;
+ final ObjectOutputStream oos = new ObjectOutputStream(baos) ;
+ oos.writeObject(value) ;
+ serialisedForm = baos.toByteArray() ;
+ }
+ stream.defaultWriteObject() ;
+ }
+
+ /**
+ * Return a string representation of this object.
+ * @return the string representation of the value or a deferred identifier.
+ */
+ public String toString()
+ {
+ if (value != null)
+ {
+ return value.toString() ;
+ }
+ else
+ {
+ return "Deferred serialized value: " + Integer.toHexString(System.identityHashCode(this)) ;
+ }
+ }
+
+ /**
+ * Create a wrapper for the specific value.
+ * @param value The value to wrap.
+ * @return a wrapped value or the value it serialisation is safe.
+ */
+ public static Serializable wrap(final Serializable value)
+ {
+ if (value != null)
+ {
+ final Class<?> componentType = getComponentType(value.getClass()) ;
+
+ if ((componentType != Boolean.class) &&
+ (componentType != Boolean.TYPE) &&
+ (componentType != Byte.class) &&
+ (componentType != Byte.TYPE) &&
+ (componentType != Short.class) &&
+ (componentType != Short.TYPE) &&
+ (componentType != Character.class) &&
+ (componentType != Character.TYPE) &&
+ (componentType != Integer.class) &&
+ (componentType != Integer.TYPE) &&
+ (componentType != Long.class) &&
+ (componentType != Long.TYPE) &&
+ (componentType != Float.class) &&
+ (componentType != Float.TYPE) &&
+ (componentType != Double.class) &&
+ (componentType != Double.TYPE) &&
+ (componentType != String.class) &&
+ (componentType != SerializedValueImpl.class))
+ {
+ return new SerializedValueImpl(value) ;
+ }
+ }
+ return value ;
+ }
+
+ /**
+ * Unwrap the object, returning the value.
+ * @param wrapped The wrapped value.
+ * @return the unwrapped object.
+ */
+ public static Serializable unwrap(final Serializable value)
+ {
+ if (value instanceof SerializedValueImpl)
+ {
+ return ((SerializedValueImpl)value).getValue() ;
+ }
+ return value ;
+ }
+
+ /**
+ * Wrap the entries in the specified list.
+ * @param list The list to be wrapped.
+ */
+ public static void wrapList(final List<Serializable> list)
+ {
+ final int listSize = list.size() ;
+ for(int count = 0 ; count < listSize ; count++)
+ {
+ final Serializable current = list.get(count) ;
+ final Serializable wrapped = SerializedValueImpl.wrap(current) ;
+ if (current != wrapped)
+ {
+ list.set(count, wrapped) ;
+ }
+ }
+ }
+
+ /**
+ * Wrap the values in the specified map.
+ * @param map The map to be wrapped.
+ */
+ public static <K> void wrapMap(final Map<K, Serializable> map)
+ {
+ if (map.size() > 0)
+ {
+ Hashtable<K, Serializable> wrappedMap = null ;
+ for(Entry<K, Serializable> entry: map.entrySet())
+ {
+ final Serializable current = entry.getValue() ;
+ final Serializable wrapped = SerializedValueImpl.wrap(current) ;
+ if (current != wrapped)
+ {
+ if (wrappedMap == null)
+ {
+ wrappedMap = new Hashtable<K, Serializable>() ;
+ }
+ wrappedMap.put(entry.getKey(), wrapped) ;
+ }
+ }
+ if (wrappedMap != null)
+ {
+ map.putAll(wrappedMap) ;
+ }
+ }
+ }
+
+ /**
+ * Get the component type for this class.
+ * @param clazz The class to check.
+ * @return The component type for the class.
+ */
+ private static Class<?> getComponentType(final Class<?> clazz)
+ {
+ if (clazz.isArray())
+ {
+ return getComponentType(clazz.getComponentType()) ;
+ }
+ else
+ {
+ return clazz ;
+ }
+ }
+}
Property changes on: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/message/format/serialized/SerializedValueImpl.java
___________________________________________________________________
Name: svn:keywords
+ Rev Date
Name: svn:eol-style
+ native
Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/message/format/serialized/body/content/MapBodyImpl.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/message/format/serialized/body/content/MapBodyImpl.java 2007-12-17 04:48:50 UTC (rev 17274)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/message/format/serialized/body/content/MapBodyImpl.java 2007-12-17 04:59:04 UTC (rev 17275)
@@ -2,7 +2,6 @@
import java.io.Serializable;
import java.util.Enumeration;
-import java.util.Hashtable;
import java.util.Map;
import org.jboss.internal.soa.esb.message.format.serialized.BodyImpl;
@@ -49,9 +48,7 @@
public void setMap (Map<String, Serializable> payload)
{
- super._objects = new Hashtable<String, Serializable>();
-
- super._objects.putAll(payload);
+ initialiseMap(payload) ;
}
public boolean getBoolean (String name) throws InvalidPayloadException
@@ -164,7 +161,7 @@
public Enumeration<String> getMapNames ()
{
- return super._objects.keys();
+ return getEnumeratedNames();
}
public boolean itemExists (String name)
Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/AttachmentImpl.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/AttachmentImpl.java 2007-12-17 04:48:50 UTC (rev 17274)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/AttachmentImpl.java 2007-12-17 04:59:04 UTC (rev 17275)
@@ -21,21 +21,20 @@
package org.jboss.internal.soa.esb.message.format.xml;
-import java.io.IOException;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Hashtable;
-import java.util.Map;
+import java.util.Map.Entry;
-import org.jboss.internal.soa.esb.util.Encoding;
-import org.jboss.soa.esb.MarshalException;
-import org.jboss.soa.esb.UnmarshalException;
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.jboss.internal.soa.esb.util.stax.ElementContent;
+import org.jboss.internal.soa.esb.util.stax.StreamHelper;
+import org.jboss.internal.soa.esb.util.stax.TextElement;
import org.jboss.soa.esb.message.Attachment;
-import org.w3c.dom.CDATASection;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
/**
* Messages may contain attachments that do not appear in the main payload body.
@@ -44,64 +43,76 @@
* @author Mark Little
*/
-public class AttachmentImpl implements Attachment, java.io.Serializable
+public class AttachmentImpl extends ElementContent implements Attachment
{
- public static final String ATTACHMENT_TAG = "Attachment";
- public static final String NAME_ATTR = "name";
- public static final String NAMED_TAG = "Named";
- public static final String UNNAMED_TAG = "UnNamed";
-
- private static final long serialVersionUID = 0x0;
-
+ /**
+ * Default constructor.
+ */
+ public AttachmentImpl()
+ {
+ }
+
+ /**
+ * Construct the attachments from the input stream.
+ *
+ * @param in The input stream.
+ * @throws XMLStreamException For errors during parsing.
+ */
+ public AttachmentImpl(final XMLStreamReader in)
+ throws XMLStreamException
+ {
+ parse(in) ;
+ }
+
public Object get(String name)
{
- return _table.get(name);
+ return unwrap(_table.get(name));
}
public Object put(String name, Object value)
{
assertValidAttachment(value);
- return _table.put(name, (Serializable) value);
+ return unwrap(_table.put(name, new SerializedValueImpl((Serializable) value)));
}
public Object remove(String name)
{
- return _table.remove(name);
+ return unwrap(_table.remove(name));
}
public String[] getNames()
{
- return _table.keySet().toArray(new String[_table.size()]);
+ return _table.keySet().toArray(new String[0]);
}
public Object itemAt(int index) throws IndexOutOfBoundsException
{
- return _list.get(index);
+ return unwrap(_list.get(index));
}
public Object removeItemAt(int index) throws IndexOutOfBoundsException
{
- return _list.remove(index);
+ return unwrap(_list.remove(index));
}
public Object replaceItemAt(int index, Object value)
throws IndexOutOfBoundsException
{
assertValidAttachment(value);
- return _list.set(index, (Serializable) value);
+ return unwrap(_list.set(index, new SerializedValueImpl((Serializable) value)));
}
public void addItem(Object value)
{
assertValidAttachment(value);
- _list.add((Serializable) value);
+ _list.add(new SerializedValueImpl((Serializable) value));
}
public void addItemAt(int index, Object value)
throws IndexOutOfBoundsException
{
assertValidAttachment(value);
- _list.add(index, (Serializable) value);
+ _list.add(index, new SerializedValueImpl((Serializable) value));
}
public int getNamedCount()
@@ -122,172 +133,59 @@
}
/**
- * toXML(elem) - Will build a child element with appropriate values and
- * append it to arg0
- *
- * @param elem
- * Element - where to add 'this' as a child node
- * @return Element - 'this' as the added Element, or <null> if no
- * properties in table and nothing was appended to arg0
- * @see XMLUtil.ATTACHMENT_TAG
- */
- public Element toXML(Element elem) throws MarshalException
- {
- if (_table.size() < 1 && _list.size() < 1)
- return null;
-
- Document doc = elem.getOwnerDocument();
- Element thisElement = doc.createElement(ATTACHMENT_TAG);
-
- try
- {
- listToXml(doc, thisElement);
- tableToXml(doc, thisElement);
- }
- catch (IOException ex)
- {
- throw new MarshalException(ex);
- }
-
- elem.appendChild(thisElement);
- return thisElement;
- }
-
- private void tableToXml(Document doc, Element elem) throws IOException
- {
- for (Map.Entry<String, Serializable> oCurr : _table.entrySet())
- {
- Element named = doc.createElement(NAMED_TAG);
- named.setAttribute(NAME_ATTR, oCurr.getKey());
- named.appendChild(doc.createCDATASection(Encoding.encodeObject(oCurr
- .getValue())));
- elem.appendChild(named);
- }
- }
-
- private void listToXml(Document doc, Element elem) throws IOException
- {
- for (Serializable oCurr : _list)
- {
- Element anonymous = doc.createElement(UNNAMED_TAG);
- anonymous.appendChild(doc.createCDATASection(Encoding
- .encodeObject(oCurr)));
- elem.appendChild(anonymous);
- }
- }
-
- /**
- * fromXml(elem) - Populate properties found in appropriate child element
- *
- * @see XMLUtil.ATTACHMENT_TAG
- * @param elem -
- * Element where to look for child nodes
- */
- public void fromXML(Element elem) throws UnmarshalException
- {
- _table.clear();
- _list.clear();
-
- NodeList NL = elem.getElementsByTagName(ATTACHMENT_TAG);
- for (int i1 = 0; i1 < NL.getLength(); i1++)
- {
- Node oCurr = NL.item(i1);
- if ((oCurr instanceof Element))
- {
- try
- {
- listFromXml((Element) oCurr);
- tableFromXml((Element) oCurr);
- }
- catch (IOException ex)
- {
- throw new UnmarshalException(ex);
- }
- catch (ClassNotFoundException ex)
- {
- throw new UnmarshalException(ex);
- }
- }
- }
- }
-
- private void listFromXml(Element elem) throws IOException, ClassNotFoundException
- {
- NodeList anonymous = elem.getElementsByTagName(UNNAMED_TAG);
-
- if (anonymous != null)
- {
- for (int i1 = 0; i1 < anonymous.getLength(); i1++)
- {
- Node oCurr = anonymous.item(i1);
- if (oCurr instanceof Element)
- {
- CDATASection cdata = (CDATASection) oCurr.getFirstChild();
- Object value = Encoding.decodeToObject(cdata.getWholeText());
- _list.add((Serializable) value);
- }
- }
- }
- }
-
- private void tableFromXml(Element elem) throws IOException, ClassNotFoundException
- {
- NodeList named = elem.getElementsByTagName(NAMED_TAG);
-
- if (named != null)
- {
- for (int i1 = 0; i1 < named.getLength(); i1++)
- {
- Node oCurr = named.item(i1);
- if (oCurr instanceof Element)
- {
- CDATASection cdata = (CDATASection) oCurr.getFirstChild();
- String name = ((Element) oCurr).getAttribute(NAME_ATTR);
- Object value = Encoding.decodeToObject(cdata.getWholeText());
- _table.put(name, (Serializable) value);
- }
- }
- }
- }
-
+ * Write the child content of the element.
+ * @param out The output stream.
+ * @throws XMLStreamException For errors during output.
+ */
@Override
- public boolean equals(Object arg)
+ protected void writeChildContent(XMLStreamWriter out)
+ throws XMLStreamException
{
- if (! (arg instanceof Attachment))
- return false;
- Attachment other = (Attachment)arg;
-
- if (other.getNamedCount() != _table.size())
- return false;
- for(Map.Entry<String,Serializable>oCurr : _table.entrySet())
- {
- Object val = other.get(oCurr.getKey());
- if (null==oCurr.getValue())
- if (null==val)
- continue;
- else
- return false;
- if (!oCurr.getValue().equals(val))
- return false;
- }
-
- if (other.getUnnamedCount() != _list.size())
- return false;
- int index = 0;
- for (Serializable oCurr : _list)
- {
- Object val = other.itemAt(index++);
- if (null==oCurr)
- if (null==val)
- continue;
- else
- return false;
- if (!oCurr.equals(val))
- return false;
- }
- return true;
+ for (SerializedValueImpl value : _list)
+ {
+ final TextElement unnamed = new TextElement(value.getSerialisedForm()) ;
+ StreamHelper.writeElement(out, XMLUtil.ESB_QNAME_ATTACHMENT_UNNAMED, unnamed) ;
+ }
+
+ for (Entry<String, SerializedValueImpl> entry : _table.entrySet())
+ {
+ final TextElement named = new TextElement(entry.getValue().getSerialisedForm()) ;
+ final String origNamedURI = StreamHelper.writeStartElement(out, XMLUtil.ESB_QNAME_ATTACHMENT_NAMED) ;
+ StreamHelper.writeAttribute(out, XMLUtil.ESB_QNAME_ATTRIBUTE_ATTACHMENT_NAMED_NAME, entry.getKey()) ;
+ named.writeContent(out) ;
+ StreamHelper.writeEndElement(out, XMLUtil.ESB_QNAME_ATTACHMENT_NAMED.getPrefix(), origNamedURI) ;
+ }
}
-
+
+ /**
+ * Add the element.
+ * @param in The current input stream.
+ * @param elementName The qualified element name.
+ * @throws XMLStreamException For errors during parsing.
+ */
+ protected void putElement(final XMLStreamReader in,
+ final QName elementName)
+ throws XMLStreamException
+ {
+ if (XMLUtil.ESB_QNAME_ATTACHMENT_UNNAMED.equals(elementName))
+ {
+ final TextElement unnamed = new TextElement(in) ;
+ final SerializedValueImpl value = new SerializedValueImpl(unnamed.getText());
+ _list.add(value);
+ }
+ else if (XMLUtil.ESB_QNAME_ATTACHMENT_NAMED.equals(elementName))
+ {
+ final String name = StreamHelper.getAttributeValue(in, XMLUtil.ESB_QNAME_ATTRIBUTE_ATTACHMENT_NAMED_NAME) ;
+ final TextElement valueElement = new TextElement(in) ;
+ final SerializedValueImpl value = new SerializedValueImpl(valueElement.getText()) ;
+ _table.put(name, value) ;
+ }
+ else
+ {
+ throw new XMLStreamException("Unexpected element name: " + elementName) ;
+ }
+ }
+
private void assertValidAttachment(Object attachment) {
if(attachment == null) {
throw new IllegalArgumentException("Cannot set null object as a message attachment. Attachment objects must be non-null and Serializable.");
@@ -296,6 +194,11 @@
}
}
- ArrayList<Serializable> _list = new ArrayList<Serializable>();
- Hashtable<String, Serializable> _table = new Hashtable<String, Serializable>();
+ private Object unwrap(final SerializedValueImpl value)
+ {
+ return (value == null ? null : value.getValue()) ;
+ }
+
+ private ArrayList<SerializedValueImpl> _list = new ArrayList<SerializedValueImpl>();
+ private Hashtable<String, SerializedValueImpl> _table = new Hashtable<String, SerializedValueImpl>();
}
Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/BodyImpl.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/BodyImpl.java 2007-12-17 04:48:50 UTC (rev 17274)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/BodyImpl.java 2007-12-17 04:59:04 UTC (rev 17275)
@@ -1,21 +1,27 @@
package org.jboss.internal.soa.esb.message.format.xml;
+import java.io.Serializable;
import java.util.Enumeration;
import java.util.Hashtable;
+import java.util.Map;
import java.util.Set;
+import java.util.Map.Entry;
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+
import org.jboss.internal.soa.esb.assertion.AssertArgument;
import org.jboss.internal.soa.esb.message.format.xml.marshal.MarshalUnmarshalManager;
+import org.jboss.internal.soa.esb.message.format.xml.marshal.MarshalValueImpl;
import org.jboss.internal.soa.esb.thirdparty.Base64;
-import org.jboss.soa.esb.MarshalException;
-import org.jboss.soa.esb.UnmarshalException;
+import org.jboss.internal.soa.esb.util.stax.ElementContent;
+import org.jboss.internal.soa.esb.util.stax.StreamHelper;
+import org.jboss.internal.soa.esb.util.stax.TextElement;
import org.jboss.soa.esb.message.Body;
import org.jboss.soa.esb.message.body.content.BytesBody;
import org.jboss.soa.esb.util.Util;
-import org.w3c.dom.CDATASection;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.NodeList;
/*
* JBoss, Home of Professional Open Source
@@ -47,35 +53,24 @@
* classes.
*/
-public class BodyImpl implements Body
+public class BodyImpl extends ElementContent implements Body
{
- public static final String BODY_TAG = "Body";
-
- public static final String BYTES_TAG = "Bytes";
-
- public static final String CONTENT_TAG = "Content";
-
- public static final String KEY_TAG = "Key";
-
- public static final String VALUE_TAG = "Value";
-
public BodyImpl()
{
- _objects = new Hashtable<String, Object>();
}
+
+ /**
+ * Construct a body from the input stream.
+ *
+ * @param in The input stream.
+ * @throws XMLStreamException For errors during parsing.
+ */
+ public BodyImpl(final XMLStreamReader in)
+ throws XMLStreamException
+ {
+ parse(in) ;
+ }
- public boolean equals(Object o)
- {
- if (o instanceof BodyImpl)
- {
- BodyImpl toCompare = (BodyImpl) o;
-
- return _objects.equals(toCompare._objects);
- }
- else
- return false;
- }
-
public void add(Object value)
{
add(Body.DEFAULT_LOCATION, value);
@@ -86,10 +81,7 @@
AssertArgument.isNotNull(value, "value");
AssertArgument.isNotNull(name, "name");
- synchronized (_objects)
- {
- _objects.put(name, value);
- }
+ _objects.put(name, new MarshalValueImpl(value));
}
public Object get()
@@ -101,172 +93,108 @@
{
AssertArgument.isNotNull(name, "name");
- synchronized (_objects)
- {
- return _objects.get(name);
- }
+ return unwrap(_objects.get(name));
}
public String[] getNames()
{
Set<String> keys = _objects.keySet();
-
- if (keys != null)
- {
- String[] toReturn = new String[keys.size()];
-
- return keys.toArray(toReturn);
- }
- else
- return null;
+ return keys.toArray(new String[0]) ;
}
+
+ public Enumeration<String> getEnumeratedNames()
+ {
+ return _objects.keys() ;
+ }
public Object remove(String name)
{
- synchronized (_objects)
- {
- return _objects.remove(name);
- }
+ return unwrap(_objects.remove(name));
}
- public Element toXML(Element envelope) throws MarshalException
+ /**
+ * Write the child content of the element.
+ * @param out The output stream.
+ * @throws XMLStreamException For errors during output.
+ */
+ @Override
+ protected void writeChildContent(XMLStreamWriter out)
+ throws XMLStreamException
{
- Document doc = envelope.getOwnerDocument();
- Element bodyElement = doc.createElement(BODY_TAG);
-
- envelope.appendChild(bodyElement);
-
- /*
- * Keep separate byte array section for now, in case anyone is looking
- * for it within the XML (e.g., roll-your-own CBR).
- */
-
- byte[] content = getByteArray();
-
- if (content != null)
- {
- Element byteElement = doc.createElement(BYTES_TAG);
-
- byteElement.appendChild(doc.createCDATASection(Base64
- .encodeBytes(content)));
-
- bodyElement.appendChild(byteElement);
- }
-
- /*
- * This would normally be handled by an external adapter.
- */
-
- Enumeration<String> keys = _objects.keys();
-
- while (keys.hasMoreElements())
- {
- String key = keys.nextElement();
- Object value = _objects.get(key);
-
- Element objElement = doc.createElement(CONTENT_TAG);
- Element keyElement = doc.createElement(KEY_TAG);
- Element valueElement = doc.createElement(VALUE_TAG);
-
- keyElement.appendChild(doc.createCDATASection(Base64
- .encodeBytes(key.getBytes())));
-
- objElement.appendChild(keyElement);
- objElement.appendChild(valueElement);
-
- if (MarshalUnmarshalManager.getInstance().marshal(valueElement,
- value))
- {
- bodyElement.appendChild(objElement);
- }
- else
- throw new MarshalException("Cannot pack object " + key);
- }
-
- return bodyElement;
+ /*
+ * Keep separate byte array section for now, in case anyone is looking
+ * for it within the XML (e.g., roll-your-own CBR).
+ */
+ final byte[] content = getByteArray() ;
+ if (content != null)
+ {
+ final TextElement bytesContent = new TextElement(Base64.encodeBytes(content)) ;
+ StreamHelper.writeElement(out, XMLUtil.ESB_QNAME_BODY_BYTES_CONTENT, bytesContent) ;
+ }
+
+ // These should be handled by a proper element content
+ for(Entry<String, MarshalValueImpl> entry: _objects.entrySet())
+ {
+ final String origContentURI = StreamHelper.writeStartElement(out, XMLUtil.ESB_QNAME_BODY_CONTENT) ;
+
+ final TextElement key = new TextElement(Base64.encodeBytes(entry.getKey().getBytes())) ;
+ StreamHelper.writeElement(out, XMLUtil.ESB_QNAME_BODY_CONTENT_KEY, key) ;
+
+ final String origValueURI = StreamHelper.writeStartElement(out, XMLUtil.ESB_QNAME_BODY_CONTENT_VALUE) ;
+ if (!MarshalUnmarshalManager.getInstance().marshal(out, entry.getValue()))
+ {
+ throw new XMLStreamException("Cannot pack object:" + entry.getKey()) ;
+ }
+ StreamHelper.writeEndElement(out, XMLUtil.ESB_QNAME_BODY_CONTENT_VALUE.getPrefix(), origValueURI) ;
+
+ StreamHelper.writeEndElement(out, XMLUtil.ESB_QNAME_BODY_CONTENT.getPrefix(), origContentURI) ;
+ }
}
+
+ /**
+ * Add the element.
+ * @param in The current input stream.
+ * @param elementName The qualified element name.
+ */
+ @Override
+ protected void putElement(final XMLStreamReader in, final QName elementName)
+ throws XMLStreamException
+ {
+ if (XMLUtil.ESB_QNAME_BODY_CONTENT.equals(elementName))
+ {
+ StreamHelper.checkNextStartTag(in, XMLUtil.ESB_QNAME_BODY_CONTENT_KEY) ;
+ final TextElement keyElement = new TextElement(in) ;
+ final String key = new String(Base64.decode(keyElement.getText())) ;
- public void fromXML(Element envelope) throws UnmarshalException
- {
- NodeList nl = envelope.getChildNodes();
+ StreamHelper.checkNextStartTag(in, XMLUtil.ESB_QNAME_BODY_CONTENT_VALUE) ;
+ final MarshalValueImpl value = MarshalUnmarshalManager.getInstance().unmarshal(in) ;
+ StreamHelper.checkParentFinished(in) ;
+ StreamHelper.checkParentFinished(in) ;
+
+ if (value == null)
+ throw new XMLStreamException("Cannot unpack object: " + key) ;
+ else
+ _objects.put(key, value) ;
+ }
+ else if (XMLUtil.ESB_QNAME_BODY_BYTES_CONTENT.equals(elementName))
+ {
+ final TextElement textElement = new TextElement(in) ;
+ final String value = textElement.getText();
+ if (value != null)
+ {
+ setByteArray(Base64.decode(value)) ;
+ }
+ else
+ {
+ setByteArray(new byte[0]) ;
+ }
+ }
+ else
+ {
+ throw new XMLStreamException("Unexpected element name: " + elementName) ;
+ }
+ }
- for (int i = 0; i < nl.getLength(); i++)
- {
- /*
- * TODO
- *
- * In the past, bugs in certain Dom implementations mean that
- * getElementsByName did not always work. Still the case? Plus this
- * way is quicker.
- */
-
- if (nl.item(i).getNodeName().equals(BODY_TAG))
- {
- NodeList children = nl.item(i).getChildNodes();
-
- for (int j = 0; j < children.getLength(); j++)
- {
- Object xxx = children.item(j);
-
- if (!(xxx instanceof Element))
- continue;
-
- Element node = (Element) xxx;
-
- if (node.getNodeName().equals(BYTES_TAG))
- {
- CDATASection cdata = (CDATASection) node
- .getFirstChild();
-
- // support empty byte (null files etc.)
-
- if (cdata != null)
- setByteArray(Base64.decode(cdata.getWholeText()));
- else
- setByteArray(new byte[0]);
- }
- else
- {
- if (node.getNodeName().equals(CONTENT_TAG))
- {
- final NodeList childList = node.getChildNodes();
-
- String key = null;
- Object value = null;
-
- for (int k = 0; k < childList.getLength(); k++)
- {
- if (childList.item(k).getNodeName().equals(
- VALUE_TAG))
- value = MarshalUnmarshalManager
- .getInstance()
- .unmarshal(
- (Element) childList.item(k));
-
- if (childList.item(k).getNodeName().equals(
- KEY_TAG))
- {
- CDATASection cdata = (CDATASection) childList
- .item(k).getFirstChild();
-
- key = new String(Base64.decode(cdata
- .getWholeText()));
- }
- }
-
- if (value == null)
- throw new UnmarshalException(
- "Cannot unpack object "
- + node.getNodeName());
- else
- _objects.put(key, value);
- }
- }
- }
- }
- }
- }
-
public void setByteArray(byte[] content)
{
add(BytesBody.BYTES_LOCATION, content);
@@ -343,6 +271,22 @@
_objects = copy._objects;
}
- protected Hashtable<String, Object> _objects;
-
+ private Object unwrap(final MarshalValueImpl value)
+ {
+ return (value == null ? null : value.getValue()) ;
+ }
+
+ protected void initialiseMap(final Map<String, Serializable> payload)
+ {
+ synchronized(_objects)
+ {
+ _objects.clear() ;
+ for(Entry<String, Serializable> entry: payload.entrySet())
+ {
+ _objects.put(entry.getKey(), new MarshalValueImpl(entry.getValue())) ;
+ }
+ }
+ }
+
+ private Hashtable<String, MarshalValueImpl> _objects = new Hashtable<String, MarshalValueImpl>();
}
\ No newline at end of file
Added: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/CallImpl.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/CallImpl.java (rev 0)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/CallImpl.java 2007-12-17 04:59:04 UTC (rev 17275)
@@ -0,0 +1,229 @@
+package org.jboss.internal.soa.esb.message.format.xml;
+
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.jboss.internal.soa.esb.addressing.helpers.EPRHelper;
+import org.jboss.internal.soa.esb.util.XMLHelper;
+import org.jboss.internal.soa.esb.util.stax.ElementContent;
+import org.jboss.internal.soa.esb.util.stax.NamedElement;
+import org.jboss.internal.soa.esb.util.stax.StreamHelper;
+import org.jboss.internal.soa.esb.util.stax.TextElement;
+import org.jboss.internal.soa.esb.util.stax.URIElement;
+import org.jboss.soa.esb.addressing.Call;
+import org.jboss.soa.esb.addressing.EPR;
+import org.jboss.soa.esb.addressing.PortReference;
+import org.jboss.soa.esb.addressing.XMLUtil;
+import org.jboss.soa.esb.message.Context;
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2005-2006,
+ */
+
+public class CallImpl extends ElementContent implements Context
+{
+ /**
+ * The call object associated with this type.
+ */
+ private final Call call ;
+ /**
+ * Extensions discovered while parsing.
+ */
+ private List<NamedElement> extensions = new ArrayList<NamedElement>() ;
+
+ /**
+ * Default constructor for the call.
+ */
+ public CallImpl(final Call call)
+ {
+ this.call = call ;
+ }
+
+ /**
+ * Construct a context from the input stream.
+ *
+ * @param in The input stream.
+ * @throws XMLStreamException For errors during parsing.
+ */
+ public CallImpl(final XMLStreamReader in)
+ throws XMLStreamException
+ {
+ this.call = new Call() ;
+ parse(in) ;
+
+ if (extensions.size() > 0)
+ {
+ final EPR origEPR = call.getTo() ;
+ final PortReference to = origEPR.getAddr() ;
+ for(NamedElement element: extensions)
+ {
+ final QName name = element.getName() ;
+ final TextElement content = (TextElement)element.getElementContent() ;
+ to.addExtension(name.getLocalPart(), name.getPrefix(), name.getNamespaceURI(), content.getText()) ;
+ }
+
+ call.setTo(EPRHelper.getSpecificEPR(origEPR)) ;
+ }
+ }
+
+ /**
+ * Return the call object.
+ * @return The call object.
+ */
+ public Call getCall()
+ {
+ return call ;
+ }
+
+ /**
+ * Write the child content of the element.
+ * @param out The output stream.
+ * @throws XMLStreamException For errors during output.
+ */
+ @Override
+ protected void writeChildContent(XMLStreamWriter out)
+ throws XMLStreamException
+ {
+ StreamHelper.writeNamespace(out, XMLUtil.WSA_PREFIX, XMLUtil.WSA_NAMESPACE_URI) ;
+
+ if (call.getTo() != null)
+ {
+ EPRHelper.toXML(out, XMLUtil.QNAME_TO_TAG, call.getTo());
+ }
+
+ if (call.getFrom() != null)
+ {
+ EPRHelper.toXML(out, XMLUtil.QNAME_FROM_TAG, call.getFrom());
+ }
+
+ if (call.getReplyTo() != null)
+ {
+ EPRHelper.toXML(out, XMLUtil.QNAME_REPLY_TO_TAG, call.getReplyTo());
+ }
+
+ if (call.getRelatesTo() != null)
+ {
+ final URIElement actionElement = new URIElement(call.getRelatesTo()) ;
+ StreamHelper.writeElement(out, XMLUtil.QNAME_RELATES_TO_TAG, actionElement) ;
+ }
+
+ if (call.getFaultTo() != null)
+ {
+ EPRHelper.toXML(out, XMLUtil.QNAME_FAULT_TO_TAG, call.getFaultTo());
+ }
+
+ if (call.getAction() != null)
+ {
+ final URIElement actionElement = new URIElement(call.getAction()) ;
+ StreamHelper.writeElement(out, XMLUtil.QNAME_ACTION_TAG, actionElement) ;
+ }
+
+ if (call.getMessageID() != null)
+ {
+ final URIElement messageIdElement = new URIElement(call.getMessageID()) ;
+ StreamHelper.writeElement(out, XMLUtil.QNAME_MESSAGE_IDENTIFIER_TAG, messageIdElement) ;
+ }
+ }
+
+ /**
+ * Add the element.
+ * @param in The current input stream.
+ * @param elementName The qualified element name.
+ */
+ protected void putElement(final XMLStreamReader in, final QName elementName)
+ throws XMLStreamException
+ {
+ if (XMLUtil.WSA_NAMESPACE_URI.equals(elementName.getNamespaceURI()))
+ {
+ final String name = elementName.getLocalPart() ;
+ if (XMLUtil.TO_TAG.equals(name))
+ {
+ call.setTo(EPRHelper.fromXML(in));
+ }
+ else if (XMLUtil.FROM_TAG.equals(name))
+ {
+ call.setFrom(EPRHelper.fromXML(in));
+ }
+ else if (XMLUtil.REPLY_TO_TAG.equals(name))
+ {
+ call.setReplyTo(EPRHelper.fromXML(in));
+ }
+ else if (XMLUtil.RELATES_TO_TAG.equals(name))
+ {
+ final URIElement relatesTo = new URIElement(in) ;
+ call.setRelatesTo(relatesTo.getValue()) ;
+ }
+ else if (XMLUtil.FAULT_TO_TAG.equals(name))
+ {
+ call.setFaultTo(EPRHelper.fromXML(in));
+ }
+ else if (XMLUtil.ACTION_TAG.equals(name))
+ {
+ final URIElement action = new URIElement(in) ;
+ call.setAction(action.getValue()) ;
+ }
+ else if (XMLUtil.MESSAGE_IDENTIFIER_TAG.equals(name))
+ {
+ final URIElement messageIdentifier = new URIElement(in) ;
+ call.setMessageID(messageIdentifier.getValue()) ;
+ }
+ else
+ {
+ final TextElement content = new TextElement(in) ;
+ extensions.add(new NamedElement(elementName, content)) ;
+ }
+ }
+ else
+ {
+ final TextElement content = new TextElement(in) ;
+ extensions.add(new NamedElement(elementName, content)) ;
+ }
+ }
+
+ public static String toXML(final Call call)
+ throws XMLStreamException
+ {
+ final CallImpl callImpl = new CallImpl(call) ;
+ final StringWriter writer = new StringWriter() ;
+ final XMLStreamWriter out = XMLHelper.getXMLStreamWriter(writer) ;
+ final QName name = org.jboss.internal.soa.esb.message.format.xml.XMLUtil.ESB_QNAME_HEADER ;
+ final String origURI = StreamHelper.writeStartElement(out, name) ;
+ callImpl.writeContent(out) ;
+ StreamHelper.writeEndElement(out, name.getPrefix(), origURI) ;
+ out.flush();
+ return writer.toString() ;
+ }
+
+ public static Call fromXML(final String content)
+ throws XMLStreamException
+ {
+ final StringReader reader = new StringReader(content) ;
+ final XMLStreamReader in = XMLHelper.getXMLStreamReader(reader) ;
+ StreamHelper.checkNextStartTag(in,
+ org.jboss.internal.soa.esb.message.format.xml.XMLUtil.ESB_QNAME_HEADER) ;
+ final CallImpl callImpl = new CallImpl(in) ;
+ return callImpl.getCall() ;
+ }
+}
\ No newline at end of file
Property changes on: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/CallImpl.java
___________________________________________________________________
Name: svn:keywords
+ Rev Date
Name: svn:eol-style
+ native
Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/ContextImpl.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/ContextImpl.java 2007-12-17 04:48:50 UTC (rev 17274)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/ContextImpl.java 2007-12-17 04:59:04 UTC (rev 17275)
@@ -1,10 +1,11 @@
package org.jboss.internal.soa.esb.message.format.xml;
-import org.jboss.soa.esb.MarshalException;
-import org.jboss.soa.esb.UnmarshalException;
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.jboss.internal.soa.esb.util.stax.ElementContent;
import org.jboss.soa.esb.message.Context;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
/*
* JBoss, Home of Professional Open Source
@@ -27,26 +28,40 @@
* @author mark.little at jboss.com
*/
-public class ContextImpl implements Context
+public class ContextImpl extends ElementContent implements Context
{
- public static final String CONTEXT_TAG = "Context";
+ /**
+ * Default constructor for the context.
+ */
+ public ContextImpl()
+ {
+ }
- public String toString ()
- {
- return "context: [ ]";
- }
-
- public Element toXML (Element envelope) throws MarshalException
- {
- Document doc = envelope.getOwnerDocument();
- Element contextElement = doc.createElement(CONTEXT_TAG);
-
- envelope.appendChild(contextElement);
-
- return contextElement;
- }
-
- public void fromXML (Element envelope) throws UnmarshalException
- {
- }
+ /**
+ * Construct a context from the input stream.
+ *
+ * @param in The input stream.
+ * @throws XMLStreamException For errors during parsing.
+ */
+ public ContextImpl(final XMLStreamReader in)
+ throws XMLStreamException
+ {
+ parse(in) ;
+ }
+
+ public String toString ()
+ {
+ return "context: [ ]";
+ }
+
+ /**
+ * Add the element.
+ * @param in The current input stream.
+ * @param elementName The qualified element name.
+ */
+ protected void putElement(final XMLStreamReader in, final QName elementName)
+ throws XMLStreamException
+ {
+ throw new XMLStreamException("Unexpected element name: " + elementName) ;
+ }
}
\ No newline at end of file
Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/FaultImpl.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/FaultImpl.java 2007-12-17 04:48:50 UTC (rev 17274)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/FaultImpl.java 2007-12-17 04:59:04 UTC (rev 17275)
@@ -2,10 +2,7 @@
import java.net.URI;
-import org.jboss.soa.esb.MarshalException;
-import org.jboss.soa.esb.UnmarshalException;
import org.jboss.soa.esb.message.Fault;
-import org.w3c.dom.Element;
/*
* JBoss, Home of Professional Open Source
@@ -88,16 +85,7 @@
else
return "fault: [ "+((code != null) ? code : "null")+", "+((reason != null) ? reason : "null")+", "+((cause != null) ? cause : "null")+" ]";
}
-
- public Element toXML(Element envelope) throws MarshalException
- {
- return envelope;
- }
- public void fromXML (Element envelope) throws UnmarshalException
- {
- }
-
FaultImpl (BodyImpl body)
{
_body = body;
Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/HeaderImpl.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/HeaderImpl.java 2007-12-17 04:48:50 UTC (rev 17274)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/HeaderImpl.java 2007-12-17 04:59:04 UTC (rev 17275)
@@ -21,29 +21,39 @@
* @author mark.little at jboss.com
*/
-import org.jboss.internal.soa.esb.addressing.helpers.CallHelper;
-import org.jboss.soa.esb.MarshalException;
-import org.jboss.soa.esb.UnmarshalException;
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.jboss.internal.soa.esb.util.stax.ElementContent;
import org.jboss.soa.esb.addressing.Call;
import org.jboss.soa.esb.message.Header;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
/**
* The message header. Contains such things as routing information.
*/
-public class HeaderImpl implements Header
+public class HeaderImpl extends ElementContent implements Header
{
- public static final String HEADER_TAG = "Header";
-
public HeaderImpl ()
{
_call = new Call();
}
+ /**
+ * Construct a header from the input stream.
+ *
+ * @param in The input stream.
+ * @throws XMLStreamException For errors during parsing.
+ */
+ public HeaderImpl(final XMLStreamReader in)
+ throws XMLStreamException
+ {
+ final CallImpl callImpl = new CallImpl(in) ;
+ _call = callImpl.getCall() ;
+ }
+
// TODO add other setters/getters for artibitrary attributes
public Call getCall ()
@@ -67,44 +77,27 @@
return "header: [ ]";
}
- public Element toXML (Element envelope) throws MarshalException
+ /**
+ * Write the child content of the element.
+ * @param out The output stream.
+ * @throws XMLStreamException For errors during output.
+ */
+ @Override
+ protected void writeChildContent(XMLStreamWriter out)
+ throws XMLStreamException
{
- Document doc = envelope.getOwnerDocument();
-
- // TODO remove MAGIC strings!!
-
- Element headerElement = doc.createElement(HEADER_TAG);
-
- envelope.appendChild(headerElement);
-
- if (_call != null)
- return CallHelper.toXML(_call, doc, headerElement);
- else
- return headerElement;
+ if (_call != null)
+ {
+ final CallImpl callImpl = new CallImpl(_call) ;
+ callImpl.writeContent(out) ;
+ }
}
- public void fromXML (Element envelope) throws UnmarshalException
+ @Override
+ protected void putElement(XMLStreamReader in, QName elementName)
+ throws XMLStreamException
{
- _call = new Call();
-
- NodeList nl = envelope.getChildNodes();
- Element headerElement = null;
-
- for (int i = 0; i < nl.getLength(); i++)
- {
- Node n = nl.item(i);
-
- if (n.getNodeName().equals(HEADER_TAG))
- {
- headerElement = (Element) n;
- break;
- }
- }
-
- // TODO error handling!!
-
- if (headerElement != null)
- _call = CallHelper.fromXML(headerElement);
+ throw new XMLStreamException("Unexpected element name: " + elementName) ;
}
private Call _call;
Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/MessageImpl.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/MessageImpl.java 2007-12-17 04:48:50 UTC (rev 17274)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/MessageImpl.java 2007-12-17 04:59:04 UTC (rev 17275)
@@ -22,9 +22,13 @@
import java.net.URI;
-import org.apache.log4j.Logger;
-import org.jboss.soa.esb.MarshalException;
-import org.jboss.soa.esb.UnmarshalException;
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.jboss.internal.soa.esb.util.stax.ElementContent;
+import org.jboss.internal.soa.esb.util.stax.StreamHelper;
import org.jboss.soa.esb.message.Attachment;
import org.jboss.soa.esb.message.Body;
import org.jboss.soa.esb.message.Context;
@@ -35,10 +39,6 @@
import org.jboss.soa.esb.message.body.content.Payload;
import org.jboss.soa.esb.message.format.MessageFactory;
import org.jboss.soa.esb.message.format.MessageType;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
/**
* This is the basic internal core message abstraction. A message consists of
@@ -62,12 +62,8 @@
*
*/
-public class MessageImpl implements Message
+public class MessageImpl extends ElementContent implements Message
{
- private static final long serialVersionUID = 0x0;
-
- public static final String ENVELOPE_TAG = "Envelope";
-
public MessageImpl()
{
_theHeader = new HeaderImpl();
@@ -77,7 +73,31 @@
_theAttachment = new AttachmentImpl();
_theProperties = new PropertiesImpl();
}
+
+ /**
+ * Construct a message from the input stream.
+ *
+ * @param in The input stream.
+ * @throws XMLStreamException For errors during parsing.
+ */
+ public MessageImpl(final XMLStreamReader in)
+ throws XMLStreamException
+ {
+ this() ;
+ parse(in) ;
+
+ // Replace the body
+ final String payloadType = Payload.bodyType(this);
+ if ((payloadType != null)
+ && (!payloadType.equals(Payload.RAW_BODY)))
+ {
+ _theBody = (BodyImpl) MessageFactory.getInstance()
+ .createBodyType(this, payloadType);
+ }
+ _theFault = new FaultImpl(_theBody) ;
+ }
+
/**
* @return get the header component of the message.
*/
@@ -153,98 +173,55 @@
// to/from XML here, rather than on individual elements
- public Document toXML(Document doc) throws MarshalException
+ /**
+ * Write the child content of the element.
+ * @param out The output stream.
+ * @throws XMLStreamException For errors during output.
+ */
+ public void writeChildContent(final XMLStreamWriter out)
+ throws XMLStreamException
{
- try
- {
- // TODO remove magic strings!
-
- Element envelope = doc.createElement(ENVELOPE_TAG);
-
- doc.appendChild(envelope);
-
- _theHeader.toXML(envelope);
- _theContext.toXML(envelope);
- _theBody.toXML(envelope);
- _theFault.toXML(envelope);
- _theAttachment.toXML(envelope);
- _theProperties.toXML(envelope);
-
- return doc;
- }
- catch (MarshalException ex)
- {
- throw ex;
- }
- catch (Exception ex)
- {
- LOGGER.warn("MessageImpl.toXML caught unexpected exception:", ex);
-
- throw new MarshalException(ex);
- }
+ StreamHelper.writeElement(out, XMLUtil.ESB_QNAME_HEADER, _theHeader) ;
+ StreamHelper.writeElement(out, XMLUtil.ESB_QNAME_CONTEXT, _theContext) ;
+ StreamHelper.writeElement(out, XMLUtil.ESB_QNAME_BODY, _theBody) ;
+ StreamHelper.writeElement(out, XMLUtil.ESB_QNAME_ATTACHMENT, _theAttachment) ;
+ StreamHelper.writeElement(out, XMLUtil.ESB_QNAME_PROPERTIES, _theProperties) ;
}
+
+ /**
+ * Add the element.
+ * @param in The current input stream.
+ * @param elementName The qualified element name.
+ */
+ protected void putElement(final XMLStreamReader in, final QName elementName)
+ throws XMLStreamException
+ {
+ if (XMLUtil.ESB_QNAME_HEADER.equals(elementName))
+ {
+ _theHeader = new HeaderImpl(in) ;
+ }
+ else if (XMLUtil.ESB_QNAME_CONTEXT.equals(elementName))
+ {
+ _theContext = new ContextImpl(in) ;
+ }
+ else if (XMLUtil.ESB_QNAME_BODY.equals(elementName))
+ {
+ _theBody = new BodyImpl(in) ;
+ }
+ else if (XMLUtil.ESB_QNAME_ATTACHMENT.equals(elementName))
+ {
+ _theAttachment = new AttachmentImpl(in) ;
+ }
+ else if (XMLUtil.ESB_QNAME_PROPERTIES.equals(elementName))
+ {
+ _theProperties = new PropertiesImpl(in) ;
+ }
+ else
+ {
+ throw new XMLStreamException("Unexpected element name: " + elementName) ;
+ }
+ }
- public void fromXML(Document doc) throws UnmarshalException
- {
- try
- {
- NodeList nl = doc.getChildNodes();
- Element envelope = null;
-
- for (int i = 0; i < nl.getLength(); i++)
- {
- Node n = nl.item(i);
-
- if (n.getNodeName().equals(ENVELOPE_TAG))
- {
- envelope = (Element) n;
- break;
- }
- }
-
- _theHeader.fromXML(envelope);
- _theContext.fromXML(envelope);
- _theBody.fromXML(envelope);
- _theFault.fromXML(envelope);
- _theAttachment.fromXML(envelope);
- _theProperties.fromXML(envelope);
-
- /*
- * Disclaimer: You are not expected to understand this (tm). Best
- * way of achieving this without changing any of the public
- * interfaces that may already exist.
- *
- * TODO: change public interfaces in subsequent major revision.
- */
-
- String payloadType = Payload.bodyType(this);
-
- if ((payloadType != null)
- && (!payloadType.equals(Payload.RAW_BODY)))
- {
- try
- {
- _theBody = (BodyImpl) MessageFactory.getInstance()
- .createBodyType(this, payloadType);
- }
- catch (Exception ex)
- {
- ex.printStackTrace();
- }
- }
- }
- catch (UnmarshalException ex)
- {
- throw ex;
- }
- catch (Exception ex)
- {
- LOGGER.warn("MessageImpl.fromXML caught unexpected exception:", ex);
-
- throw new UnmarshalException(ex);
- }
- }
-
// should be a capability on the base interface, but no changes for 4.2
// ...
@@ -267,9 +244,4 @@
private AttachmentImpl _theAttachment;
private PropertiesImpl _theProperties;
-
- /**
- * The logger for this class.
- */
- private static final Logger LOGGER = Logger.getLogger(MessageImpl.class);
}
Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/PropertiesImpl.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/PropertiesImpl.java 2007-12-17 04:48:50 UTC (rev 17274)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/PropertiesImpl.java 2007-12-17 04:59:04 UTC (rev 17275)
@@ -20,35 +20,46 @@
*/
package org.jboss.internal.soa.esb.message.format.xml;
-import java.io.IOException;
import java.io.Serializable;
import java.util.Hashtable;
-import java.util.Map;
+import java.util.Map.Entry;
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+
import org.jboss.internal.soa.esb.assertion.AssertArgument;
import org.jboss.internal.soa.esb.util.Encoding;
-import org.jboss.soa.esb.MarshalException;
-import org.jboss.soa.esb.UnmarshalException;
+import org.jboss.internal.soa.esb.util.stax.ElementContent;
+import org.jboss.internal.soa.esb.util.stax.StreamHelper;
+import org.jboss.internal.soa.esb.util.stax.TextElement;
import org.jboss.soa.esb.message.Properties;
-import org.w3c.dom.CDATASection;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-public class PropertiesImpl implements Properties
+public class PropertiesImpl extends ElementContent implements Properties
{
- public static final String PROPERTIES_TAG = "Properties";
+ /**
+ * The default constructor
+ */
+ public PropertiesImpl()
+ {
+ }
+
+ /**
+ * Construct a set of properties from the input stream.
+ *
+ * @param in The input stream.
+ * @throws XMLStreamException For errors during parsing.
+ */
+ public PropertiesImpl(final XMLStreamReader in)
+ throws XMLStreamException
+ {
+ parse(in) ;
+ }
- public static final String PROPERTY_TAG = "Property";
-
- public static final String KEY_TAG = "Key";
-
- public static final String VALUE_TAG = "Value";
-
public Object getProperty(String name)
{
- return _table.get(name);
+ return unwrap(_table.get(name));
}
public Object getProperty(String name, Object defaultVal)
@@ -66,12 +77,12 @@
throw new IllegalArgumentException("Value of property '" + name + "' must implement " + Serializable.class.getName() + ". Value is of type " + value.getClass().getName());
}
- return _table.put(name, (Serializable) value);
+ return unwrap(_table.put(name, new SerializedValueImpl((Serializable)value)));
}
public Object remove(String name)
{
- return _table.remove(name);
+ return unwrap(_table.remove(name));
}
public int size()
@@ -81,164 +92,74 @@
public String[] getNames()
{
- return _table.keySet().toArray(new String[_table.size()]);
+ return _table.keySet().toArray(new String[0]);
}
- /**
- * toXML(elem) - Will build a child element with appropriate values and
- * append it to arg0
- *
- * @param elem
- * Element - where to add 'this' as a child node
- * @return Element - 'this' as the added Element, or <null> if no
- * properties in table and nothing was appended to arg0
- */
- public Element toXML(Element elem) throws MarshalException
+ /**
+ * Write the child content of the element.
+ * @param out The output stream.
+ * @throws XMLStreamException For errors during output.
+ */
+ @Override
+ protected void writeChildContent(XMLStreamWriter out)
+ throws XMLStreamException
{
- if (_table.size() < 1)
- return null;
-
- Document doc = elem.getOwnerDocument();
- Element thisElement = doc.createElement(PROPERTIES_TAG);
-
- boolean bAdd = false;
- for (Map.Entry<String, Serializable> oCurr : _table.entrySet())
- {
- Element oProp = doc.createElement(PROPERTY_TAG);
- Element keyElement = doc.createElement(KEY_TAG);
- Element valueElement = doc.createElement(VALUE_TAG);
-
- keyElement.appendChild(doc.createCDATASection(Encoding.encodeBytes(oCurr.getKey().getBytes())));
- oProp.appendChild(keyElement);
-
- try
- {
- valueElement.appendChild(doc.createCDATASection(Encoding.encodeObject(oCurr.getValue())));
- }
- catch (IOException ex)
- {
- throw new MarshalException(ex);
- }
-
- oProp.appendChild(valueElement);
-
- thisElement.appendChild(oProp);
- bAdd = true;
- }
- if (bAdd)
- {
- elem.appendChild(thisElement);
- return thisElement;
- }
- else
- return null;
+ for (Entry<String, SerializedValueImpl> entry: _table.entrySet())
+ {
+ final String origPropertyURI = StreamHelper.writeStartElement(out, XMLUtil.ESB_QNAME_PROPERTY) ;
+
+ final TextElement keyElement = new TextElement(Encoding.encodeBytes(entry.getKey().getBytes())) ;
+ StreamHelper.writeElement(out, XMLUtil.ESB_QNAME_PROPERTY_KEY, keyElement) ;
+
+ final String value = entry.getValue().getSerialisedForm() ;
+ final TextElement valueElement = new TextElement(value) ;
+ StreamHelper.writeElement(out, XMLUtil.ESB_QNAME_PROPERTY_VALUE, valueElement) ;
+
+ StreamHelper.writeEndElement(out, XMLUtil.ESB_QNAME_PROPERTY.getPrefix(), origPropertyURI) ;
+ }
}
-
- /**
- * fromXml(elem) - Populate properties found in appropriate child element
- *
- * @see XMLUtil.PROPERTIES_TAG
- * @param elem -
- * Element where to look for child nodes
- */
- public void fromXML(Element elem) throws UnmarshalException
- {
- _table.clear();
-
- /*
- * There should be only one!
- */
-
- NodeList NL = elem.getElementsByTagName(PROPERTIES_TAG);
-
- if (NL.getLength() > 1)
- throw new UnmarshalException("More "+PROPERTIES_TAG+" than we expected!");
-
- if (NL.getLength() == 1)
- NL = NL.item(0).getChildNodes();
-
- for (int i1 = 0; i1 < NL.getLength(); i1++)
- {
- Node oCurr = NL.item(i1);
-
- if (!(oCurr instanceof Element))
- continue;
-
- if (oCurr.getNodeName().equals(PROPERTY_TAG))
- {
- NodeList props = oCurr.getChildNodes();
- String key = null;
- Object value = null;
-
- for (int i2 = 0; i2 < props.getLength(); i2++)
- {
- Node oProp = props.item(i2);
-
- if (oProp instanceof Element)
- {
- if (oProp.getNodeName().equals(VALUE_TAG))
- {
- CDATASection cdata = (CDATASection) oProp.getFirstChild();
-
- try
- {
- value = Encoding.decodeToObject(cdata.getWholeText());
- }
- catch (ClassNotFoundException ex)
- {
- throw new UnmarshalException(ex);
- }
- catch (IOException ex)
- {
- throw new UnmarshalException(ex);
- }
- }
- else
- {
- if (oProp.getNodeName().equals(KEY_TAG))
- {
- CDATASection cdata = (CDATASection) oProp.getFirstChild();
- key = new String(Encoding.decodeToBytes(cdata.getWholeText()));
- }
- }
- }
- }
-
- if ((key != null) && (value != null))
- _table.put(key, (Serializable) value);
- else
- throw new UnmarshalException("Could not get tuple for "+oCurr.getNodeName());
- }
- }
- }
-
+
+ /**
+ * Add the element.
+ * @param in The current input stream.
+ * @param elementName The qualified element name.
+ * @throws XMLStreamException For errors during parsing.
+ */
+ @Override
+ protected void putElement(final XMLStreamReader in,
+ final QName elementName)
+ throws XMLStreamException
+ {
+ if (XMLUtil.ESB_QNAME_PROPERTY.equals(elementName))
+ {
+ StreamHelper.checkNextStartTag(in, XMLUtil.ESB_QNAME_PROPERTY_KEY) ;
+ final TextElement keyElement = new TextElement(in) ;
+ final String key = new String(Encoding.decodeToBytes(keyElement.getText())) ;
+
+ StreamHelper.checkNextStartTag(in, XMLUtil.ESB_QNAME_PROPERTY_VALUE) ;
+ final TextElement valueElement = new TextElement(in) ;
+ final SerializedValueImpl value = new SerializedValueImpl(valueElement.getText()) ;
+
+ StreamHelper.checkParentFinished(in) ;
+
+ _table.put(key, value) ;
+ }
+ else
+ {
+ throw new XMLStreamException("Unexpected element name: " + elementName) ;
+ }
+ }
+
public String toString()
{
return "properties: [ "+_table.toString()+" ]";
}
- @Override
- public boolean equals(Object arg)
+ private Object unwrap(final SerializedValueImpl value)
{
- if (!(arg instanceof Properties))
- return false;
- Properties other = (Properties) arg;
- if (other.size() != _table.size())
- return false;
- for (Map.Entry<String, Serializable> oCurr : _table.entrySet())
- {
- Object val = other.getProperty(oCurr.getKey());
- if (null == oCurr.getValue())
- if (null == val)
- continue;
- else
- return false;
- if (!oCurr.getValue().equals(val))
- return false;
- }
- return true;
+ return (value == null ? null : value.getValue()) ;
}
+
+ private Hashtable<String, SerializedValueImpl> _table = new Hashtable<String, SerializedValueImpl>();
- Hashtable<String, Serializable> _table = new Hashtable<String, Serializable>();
-
}
Added: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/SerializedValueImpl.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/SerializedValueImpl.java (rev 0)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/SerializedValueImpl.java 2007-12-17 04:59:04 UTC (rev 17275)
@@ -0,0 +1,125 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2005-2006,
+ */
+
+package org.jboss.internal.soa.esb.message.format.xml;
+
+import java.io.IOException;
+import java.io.Serializable;
+
+import org.jboss.internal.soa.esb.message.format.DeferredDeserialisationException;
+import org.jboss.internal.soa.esb.util.Encoding;
+
+/**
+ * Wrapper class for serialised values, supporting JIT deserialisation.
+ *
+ * @author <a href='kevin.conner at jboss.com'>Kevin Conner</a>
+ */
+
+public class SerializedValueImpl
+{
+ /**
+ * The value.
+ */
+ private Serializable value ;
+
+ /**
+ * The serialised form.
+ */
+ private String serialisedForm ;
+
+ /**
+ * Construct the serialised value wrapper for the specific value.
+ * @param value The serializable value.
+ */
+ public SerializedValueImpl(final Serializable value)
+ {
+ this.value = value ;
+ }
+
+ /**
+ * Construct the serialised value wrapper for the specific serialised form.
+ * @param serialisedForm The serialised form.
+ */
+ public SerializedValueImpl(final String serialisedForm)
+ {
+ this.serialisedForm = serialisedForm ;
+ }
+
+ /**
+ * Get the wrapped value.
+ * @return The wrapped value.
+ */
+ public Serializable getValue()
+ {
+ if ((value == null) && (serialisedForm != null))
+ {
+ try
+ {
+ value = Encoding.decodeToObject(serialisedForm) ;
+ }
+ catch (final IOException ioe)
+ {
+ throw new DeferredDeserialisationException("Error reading object input stream", ioe) ;
+ }
+ catch (final ClassNotFoundException cnfe)
+ {
+ throw new DeferredDeserialisationException("Error constructing object value", cnfe) ;
+ }
+ }
+ serialisedForm = null ;
+ return value ;
+ }
+
+ /**
+ * Get the serialised form.
+ * @return The serialised form.
+ */
+ public String getSerialisedForm()
+ {
+ if ((serialisedForm == null) && (value != null))
+ {
+ try
+ {
+ serialisedForm = Encoding.encodeObject(value) ;
+ }
+ catch (final IOException ioe)
+ {
+ throw new DeferredDeserialisationException("Error writing object input stream", ioe) ;
+ }
+ }
+ return serialisedForm ;
+ }
+
+ /**
+ * Return a string representation of this object.
+ * @return the string representation of the value or a deferred identifier.
+ */
+ public String toString()
+ {
+ if (value != null)
+ {
+ return value.toString() ;
+ }
+ else
+ {
+ return "Deferred serialized value: " + Integer.toHexString(System.identityHashCode(this)) ;
+ }
+ }
+}
Property changes on: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/SerializedValueImpl.java
___________________________________________________________________
Name: svn:keywords
+ Rev Date
Name: svn:eol-style
+ native
Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/XMLUtil.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/XMLUtil.java 2007-12-17 04:48:50 UTC (rev 17274)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/XMLUtil.java 2007-12-17 04:59:04 UTC (rev 17275)
@@ -27,8 +27,157 @@
package org.jboss.internal.soa.esb.message.format.xml;
+import javax.xml.namespace.QName;
+
public class XMLUtil
{
public static final String ESB_PREFIX = "jbesb";
public static final String ESB_NAMESPACE_URI = "http://www.jboss.org/ws/2006/09/esb";
+
+ // Element names
+ /**
+ * The name of the envelope element.
+ */
+ public static final String ESB_ELEMENT_ENVELOPE = "Envelope";
+ /**
+ * The qualified name of the envelope element.
+ */
+ public static final QName ESB_QNAME_ENVELOPE = new QName(ESB_ELEMENT_ENVELOPE) ;
+ /**
+ * The name of the header element.
+ */
+ public static final String ESB_ELEMENT_HEADER = "Header" ;
+ /**
+ * The qualified name of the header element.
+ */
+ public static final QName ESB_QNAME_HEADER = new QName(ESB_ELEMENT_HEADER) ;
+ /**
+ * The name of the context element.
+ */
+ public static final String ESB_ELEMENT_CONTEXT = "Context" ;
+ /**
+ * The qualified name of the context element.
+ */
+ public static final QName ESB_QNAME_CONTEXT = new QName(ESB_ELEMENT_CONTEXT) ;
+ /**
+ * The name of the body element.
+ */
+ public static final String ESB_ELEMENT_BODY = "Body" ;
+ /**
+ * The qualified name of the body element.
+ */
+ public static final QName ESB_QNAME_BODY = new QName(ESB_ELEMENT_BODY) ;
+ /**
+ * The name of the body bytes content element.
+ */
+ public static final String ESB_ELEMENT_BODY_BYTES_CONTENT = "Bytes" ;
+ /**
+ * The qualified name of the body bytes content element.
+ */
+ public static final QName ESB_QNAME_BODY_BYTES_CONTENT = new QName(ESB_ELEMENT_BODY_BYTES_CONTENT) ;
+ /**
+ * The name of the body content element.
+ */
+ public static final String ESB_ELEMENT_BODY_CONTENT = "Content" ;
+ /**
+ * The qualified name of the body content element.
+ */
+ public static final QName ESB_QNAME_BODY_CONTENT = new QName(ESB_ELEMENT_BODY_CONTENT) ;
+ /**
+ * The name of the body content key element.
+ */
+ public static final String ESB_ELEMENT_BODY_CONTENT_KEY = "Key" ;
+ /**
+ * The qualified name of the body content key element.
+ */
+ public static final QName ESB_QNAME_BODY_CONTENT_KEY = new QName(ESB_ELEMENT_BODY_CONTENT_KEY) ;
+ /**
+ * The name of the body content value element.
+ */
+ public static final String ESB_ELEMENT_BODY_CONTENT_VALUE = "Value" ;
+ /**
+ * The qualified name of the body content value element.
+ */
+ public static final QName ESB_QNAME_BODY_CONTENT_VALUE = new QName(ESB_ELEMENT_BODY_CONTENT_VALUE) ;
+ /**
+ * The name of the marshal element.
+ */
+ public static final String ESB_ELEMENT_BODY_CONTENT_MARSHAL = "marshalunmarshal" ;
+ /**
+ * The qualified name of the marshal element.
+ */
+ public static final QName ESB_QNAME_BODY_CONTENT_MARSHAL = new QName(ESB_ELEMENT_BODY_CONTENT_MARSHAL) ;
+ /**
+ * The name of the marshal type element.
+ */
+ public static final String ESB_ELEMENT_BODY_CONTENT_MARSHAL_TYPE = "plugin-type" ;
+ /**
+ * The qualified name of the marshal type element.
+ */
+ public static final QName ESB_QNAME_BODY_CONTENT_MARSHAL_TYPE = new QName(ESB_ELEMENT_BODY_CONTENT_MARSHAL_TYPE) ;
+ /**
+ * The name of the attachment element.
+ */
+ public static final String ESB_ELEMENT_ATTACHMENT = "Attachment" ;
+ /**
+ * The qualified name of the attachment element.
+ */
+ public static final QName ESB_QNAME_ATTACHMENT = new QName(ESB_ELEMENT_ATTACHMENT) ;
+ /**
+ * The name of the unnamed attachment element.
+ */
+ public static final String ESB_ELEMENT_ATTACHMENT_UNNAMED = "UnNamed" ;
+ /**
+ * The qualified name of the unnamed attachment element.
+ */
+ public static final QName ESB_QNAME_ATTACHMENT_UNNAMED = new QName(ESB_ELEMENT_ATTACHMENT_UNNAMED) ;
+ /**
+ * The name of the named attachment element.
+ */
+ public static final String ESB_ELEMENT_ATTACHMENT_NAMED = "Named" ;
+ /**
+ * The qualified name of the named attachment element.
+ */
+ public static final QName ESB_QNAME_ATTACHMENT_NAMED = new QName(ESB_ELEMENT_ATTACHMENT_NAMED) ;
+ /**
+ * The name of the properties element.
+ */
+ public static final String ESB_ELEMENT_PROPERTIES = "Properties" ;
+ /**
+ * The qualified name of the properties element.
+ */
+ public static final QName ESB_QNAME_PROPERTIES = new QName(ESB_ELEMENT_PROPERTIES) ;
+ /**
+ * The name of the property element.
+ */
+ public static final String ESB_ELEMENT_PROPERTY = "Property" ;
+ /**
+ * The qualified name of the property element.
+ */
+ public static final QName ESB_QNAME_PROPERTY = new QName(ESB_ELEMENT_PROPERTY) ;
+ /**
+ * The name of the property key element.
+ */
+ public static final String ESB_ELEMENT_PROPERTY_KEY = "Key" ;
+ /**
+ * The qualified name of the property key element.
+ */
+ public static final QName ESB_QNAME_PROPERTY_KEY = new QName(ESB_ELEMENT_PROPERTY_KEY) ;
+ /**
+ * The name of the property value element.
+ */
+ public static final String ESB_ELEMENT_PROPERTY_VALUE = "Value" ;
+ /**
+ * The qualified name of the property value element.
+ */
+ public static final QName ESB_QNAME_PROPERTY_VALUE = new QName(ESB_ELEMENT_PROPERTY_VALUE) ;
+
+ /**
+ * The name attribute of the named attachment element.
+ */
+ public static final String ESB_ATTRIBUTE_ATTACHMENT_NAMED_NAME = "name" ;
+ /**
+ * The qualified name of the property value element.
+ */
+ public static final QName ESB_QNAME_ATTRIBUTE_ATTACHMENT_NAMED_NAME = new QName(ESB_ATTRIBUTE_ATTACHMENT_NAMED_NAME) ;
}
Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/body/content/MapBodyImpl.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/body/content/MapBodyImpl.java 2007-12-17 04:48:50 UTC (rev 17274)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/body/content/MapBodyImpl.java 2007-12-17 04:59:04 UTC (rev 17275)
@@ -38,8 +38,6 @@
public class MapBodyImpl extends BodyImpl implements MapBody
{
- private static final long serialVersionUID = 0xdeadbeef;
-
public MapBodyImpl (BodyImpl b)
{
super(b);
@@ -49,9 +47,7 @@
public void setMap (Map<String, Serializable> payload)
{
- super._objects = new Hashtable<String, Object>();
-
- super._objects.putAll(payload);
+ initialiseMap(payload) ;
}
public boolean getBoolean (String name) throws InvalidPayloadException
@@ -164,7 +160,7 @@
public Enumeration<String> getMapNames ()
{
- return super._objects.keys();
+ return getEnumeratedNames();
}
public boolean itemExists (String name)
Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/body/content/ObjectBodyImpl.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/body/content/ObjectBodyImpl.java 2007-12-17 04:48:50 UTC (rev 17274)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/body/content/ObjectBodyImpl.java 2007-12-17 04:59:04 UTC (rev 17275)
@@ -34,8 +34,6 @@
public class ObjectBodyImpl extends BodyImpl implements ObjectBody
{
- private static final long serialVersionUID = 0xdeadbeef;
-
public static final String ELEMENT_NAME = "org.jboss.soa.esb.message.body.object.content";
public ObjectBodyImpl (BodyImpl body)
Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/body/content/TextBodyImpl.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/body/content/TextBodyImpl.java 2007-12-17 04:48:50 UTC (rev 17274)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/body/content/TextBodyImpl.java 2007-12-17 04:59:04 UTC (rev 17275)
@@ -34,8 +34,6 @@
{
public static final String ELEMENT_NAME = "org.jboss.soa.esb.message.payload.text";
- private static final long serialVersionUID = 0xdeadbeef;
-
public TextBodyImpl (BodyImpl b)
{
super(b);
Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/marshal/MarshalUnmarshalManager.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/marshal/MarshalUnmarshalManager.java 2007-12-17 04:48:50 UTC (rev 17274)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/marshal/MarshalUnmarshalManager.java 2007-12-17 04:59:04 UTC (rev 17275)
@@ -4,12 +4,20 @@
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Properties;
+import java.util.Map.Entry;
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.jboss.internal.soa.esb.message.format.xml.XMLUtil;
+import org.jboss.internal.soa.esb.util.stax.ElementContent;
+import org.jboss.internal.soa.esb.util.stax.StreamHelper;
+import org.jboss.internal.soa.esb.util.stax.URIElement;
import org.jboss.soa.esb.MarshalException;
-import org.jboss.soa.esb.UnmarshalException;
import org.jboss.soa.esb.common.ModulePropertyManager;
import org.jboss.soa.esb.util.ClassUtil;
-import org.w3c.dom.Element;
/*
* JBoss, Home of Professional Open Source
@@ -105,24 +113,49 @@
/**
* Pack the provided object into the document.
*
- * @param doc the XML document.
+ * @param out the XML stream writer.
* @param param the object to pack.
*
* @return <code>true</code> if the object was packed, <code>false</code> otherwise.
* @throws MarshalException thrown if there is a problem packing.
*/
- public boolean marshal (Element doc, Object param) throws MarshalException
+ public boolean marshal (XMLStreamWriter out, MarshalValueImpl param) throws XMLStreamException
{
- if ((doc == null) || (param == null))
+ if ((out == null) || (param == null))
throw new IllegalArgumentException();
- Enumeration<URI> keys = _plugins.keys();
+ final String serialisedForm = param.getMarshalledForm() ;
+ if (serialisedForm != null)
+ {
+ final MarshalImpl marshal = new MarshalImpl(param.getMarshalledType(), serialisedForm) ;
+ StreamHelper.writeElement(out, XMLUtil.ESB_QNAME_BODY_CONTENT_MARSHAL, marshal) ;
+ return true ;
+ }
- while (keys.hasMoreElements())
+ final Object obj = param.getValue() ;
+ for(Entry<URI, MarshalUnmarshalPlugin> entry: _plugins.entrySet())
{
- if (_plugins.get(keys.nextElement()).marshal(doc, param))
- return true;
+ final MarshalUnmarshalPlugin plugin = entry.getValue() ;
+ if (plugin.canPack(obj))
+ {
+ final String value ;
+ try
+ {
+ value = plugin.marshal(obj) ;
+ }
+ catch (final MarshalException me)
+ {
+ throw new XMLStreamException(me) ;
+ }
+ param.setMarshalledForm(value) ;
+ param.setMarshalledType(plugin.type()) ;
+
+ final MarshalImpl marshal = new MarshalImpl(entry.getKey(), value) ;
+ StreamHelper.writeElement(out, XMLUtil.ESB_QNAME_BODY_CONTENT_MARSHAL, marshal) ;
+
+ return true ;
+ }
}
return false;
@@ -131,31 +164,91 @@
/**
* Unpack the object from the document.
*
- * @param doc the document.
+ * @param in the XML Stream reader.
*
* @return the object, or <code>null</code> if this implementation cannot deal with the
* format.
- * @throws UnmarshalException thrown if there is a problem unpacking.
+ * @throws XMLStreamException thrown if there is a problem unpacking.
*/
- public Object unmarshal (Element doc) throws UnmarshalException
+ public MarshalValueImpl unmarshal (XMLStreamReader in) throws XMLStreamException
{
- if (doc == null)
- throw new IllegalArgumentException();
-
- Enumeration<URI> keys = _plugins.keys();
-
- while (keys.hasMoreElements())
- {
- Object result = _plugins.get(keys.nextElement()).unmarshal(doc);
-
- if (result != null)
- return result;
- }
-
- return null;
+ StreamHelper.checkNextStartTag(in, XMLUtil.ESB_QNAME_BODY_CONTENT_MARSHAL) ;
+ final MarshalImpl marshal = new MarshalImpl(in) ;
+ StreamHelper.checkEndTag(in, XMLUtil.ESB_QNAME_BODY_CONTENT_MARSHAL) ;
+
+ final MarshalUnmarshalPlugin plugin = _plugins.get(marshal.getType()) ;
+ if (plugin == null)
+ {
+ throw new XMLStreamException("Unrecognised marshal type: " + marshal.getType()) ;
+ }
+
+ return new MarshalValueImpl(marshal.getType(), marshal.getContent()) ;
}
+ MarshalUnmarshalPlugin getPlugin(final URI type)
+ {
+ return _plugins.get(type) ;
+ }
+
+ private static class MarshalImpl extends ElementContent
+ {
+ private URI type ;
+ private String content ;
+
+ MarshalImpl(final URI type, final String content)
+ {
+ this.type = type ;
+ this.content = content ;
+ }
+
+ MarshalImpl(final XMLStreamReader in)
+ throws XMLStreamException
+ {
+ super.parse(in) ;
+ }
+
+ URI getType()
+ {
+ return type ;
+ }
+
+ String getContent()
+ {
+ return content ;
+ }
+
+ @Override
+ protected void putElement(XMLStreamReader in, QName elementName)
+ throws XMLStreamException
+ {
+ if (XMLUtil.ESB_QNAME_BODY_CONTENT_MARSHAL_TYPE.equals(elementName))
+ {
+ final URIElement typeURI = new URIElement(in) ;
+ type = typeURI.getValue() ;
+ }
+ else
+ {
+ throw new XMLStreamException("Unrecognised element: " + elementName) ;
+ }
+ }
+
+ @Override
+ protected void putValue(XMLStreamReader in, String value)
+ throws XMLStreamException
+ {
+ content = value ;
+ }
+
+ @Override
+ protected void writeChildContent(XMLStreamWriter out)
+ throws XMLStreamException
+ {
+ final URIElement typeURI = new URIElement(type) ;
+ StreamHelper.writeElement(out, XMLUtil.ESB_QNAME_BODY_CONTENT_MARSHAL_TYPE, typeURI) ;
+ out.writeCharacters(content) ;
+ }
+ }
private Hashtable<URI,MarshalUnmarshalPlugin> _plugins = new Hashtable<URI,MarshalUnmarshalPlugin>();
private static final MarshalUnmarshalManager _instance = new MarshalUnmarshalManager();
Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/marshal/MarshalUnmarshalPlugin.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/marshal/MarshalUnmarshalPlugin.java 2007-12-17 04:48:50 UTC (rev 17274)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/marshal/MarshalUnmarshalPlugin.java 2007-12-17 04:59:04 UTC (rev 17275)
@@ -4,7 +4,6 @@
import org.jboss.soa.esb.MarshalException;
import org.jboss.soa.esb.UnmarshalException;
-import org.w3c.dom.Element;
/*
* JBoss, Home of Professional Open Source
@@ -41,32 +40,35 @@
{
public static final String MARSHAL_UNMARSHAL_PLUGIN = "org.jboss.soa.esb.message.format.xml.plugin";
- public static final String tagName = "marshalunmarshal";
- public static final String pluginType = "plugin-type";
-
+ /**
+ * Can the plugin pack the specified object?
+ * @param value The object to pack.
+ * @return true if the object can be packed, false otherwise.
+ */
+ public boolean canPack(final Object value) ;
+
/**
* Pack the provided object into the document.
*
- * @param doc the XML document.
* @param param the object to pack.
+ * @return the packed version of the object.
*
- * @return <code>true</code> if the object was packed, <code>false</code> otherwise.
* @throws MarshalException thrown if there is a problem packing.
*/
- public boolean marshal (Element doc, Object param) throws MarshalException;
+ public String marshal (Object param) throws MarshalException ;
/**
* Unpack the object from the document.
*
- * @param doc the document.
+ * @param content the object content.
*
* @return the object, or <code>null</code> if this implementation cannot deal with the
* format.
* @throws UnmarshalException thrown if there is a problem unpacking.
*/
- public Object unmarshal (Element doc) throws UnmarshalException;
+ public Object unmarshal (final String content) throws UnmarshalException;
/**
* @return the unique name for this plugin.
Added: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/marshal/MarshalValueImpl.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/marshal/MarshalValueImpl.java (rev 0)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/marshal/MarshalValueImpl.java 2007-12-17 04:59:04 UTC (rev 17275)
@@ -0,0 +1,147 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2005-2006,
+ */
+
+package org.jboss.internal.soa.esb.message.format.xml.marshal;
+
+import java.net.URI;
+
+import org.jboss.internal.soa.esb.message.format.DeferredDeserialisationException;
+import org.jboss.soa.esb.UnmarshalException;
+
+/**
+ * Wrapper class for marshalled values, supporting JIT deserialisation.
+ *
+ * @author <a href='kevin.conner at jboss.com'>Kevin Conner</a>
+ */
+
+public class MarshalValueImpl
+{
+ /**
+ * The value.
+ */
+ private Object value ;
+
+ /**
+ * The marshalled form.
+ */
+ private String marshalledForm ;
+ /**
+ * The plugin type.
+ */
+ private URI type ;
+
+ /**
+ * Construct the marshalled value wrapper for the specific value.
+ * @param value The serializable value.
+ */
+ public MarshalValueImpl(final Object value)
+ {
+ this.value = value ;
+ }
+
+ /**
+ * Construct the marshalled value wrapper for the specific marshalled form.
+ * @param type The plugin type.
+ * @param marshalledForm The marshalled form.
+ */
+ public MarshalValueImpl(final URI type, final String marshalledForm)
+ {
+ this.type = type ;
+ this.marshalledForm = marshalledForm ;
+ }
+
+ /**
+ * Get the wrapped value.
+ * @return The wrapped value.
+ */
+ public Object getValue()
+ {
+ if ((value == null) && (marshalledForm != null))
+ {
+ final MarshalUnmarshalPlugin plugin = MarshalUnmarshalManager.getInstance().getPlugin(type) ;
+ if (plugin == null)
+ {
+ throw new DeferredDeserialisationException("Could not locate plugin for type: " + type) ;
+ }
+ try
+ {
+ value = plugin.unmarshal(marshalledForm) ;
+ }
+ catch (final UnmarshalException ue)
+ {
+ throw new DeferredDeserialisationException("Error constructing object value", ue) ;
+ }
+ }
+ marshalledForm = null ;
+ return value ;
+ }
+
+ /**
+ * Get the marshalled type.
+ * @return The marshalled type.
+ */
+ URI getMarshalledType()
+ {
+ return type ;
+ }
+
+ /**
+ * Set the marshalled type.
+ * @param type The marshalled type.
+ */
+ void setMarshalledType(final URI type)
+ {
+ this.type = type ;
+ }
+
+ /**
+ * Get the marshalled form.
+ * @return The marshalled form.
+ */
+ String getMarshalledForm()
+ {
+ return marshalledForm ;
+ }
+
+ /**
+ * Set the marshalled form.
+ * @return The marshalled form.
+ */
+ void setMarshalledForm(final String marshalledForm)
+ {
+ this.marshalledForm = marshalledForm ;
+ }
+
+ /**
+ * Return a string representation of this object.
+ * @return the string representation of the value or a deferred identifier.
+ */
+ public String toString()
+ {
+ if (value != null)
+ {
+ return value.toString() ;
+ }
+ else
+ {
+ return "Deferred serialized value: " + Integer.toHexString(System.identityHashCode(this)) ;
+ }
+ }
+}
Property changes on: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/marshal/MarshalValueImpl.java
___________________________________________________________________
Name: svn:keywords
+ Rev Date
Name: svn:eol-style
+ native
Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/marshal/SerializedMarshalUnmarshalPlugin.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/marshal/SerializedMarshalUnmarshalPlugin.java 2007-12-17 04:48:50 UTC (rev 17274)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/marshal/SerializedMarshalUnmarshalPlugin.java 2007-12-17 04:59:04 UTC (rev 17275)
@@ -1,5 +1,6 @@
package org.jboss.internal.soa.esb.message.format.xml.marshal;
+import java.io.IOException;
import java.io.Serializable;
import java.net.URI;
import java.net.URISyntaxException;
@@ -7,10 +8,6 @@
import org.jboss.internal.soa.esb.util.Encoding;
import org.jboss.soa.esb.MarshalException;
import org.jboss.soa.esb.UnmarshalException;
-import org.w3c.dom.CDATASection;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
/*
* JBoss, Home of Professional Open Source
@@ -46,7 +43,6 @@
public class SerializedMarshalUnmarshalPlugin implements MarshalUnmarshalPlugin
{
-
public SerializedMarshalUnmarshalPlugin()
{
try
@@ -60,105 +56,67 @@
}
/**
- * Pack the provided object into the document.
- *
- * @param doc
- * the XML document.
- * @param param
- * the object to pack.
- *
- * @return <code>true</code> if the object was packed, <code>false</code>
- * otherwise.
- * @throws MarshalException
- * thrown if there is a problem packing.
+ * Can the plugin pack the specified object?
+ * @param value The object to pack.
+ * @return true if the object can be packed, false otherwise.
*/
-
- public boolean marshal(Element doc, Object param) throws MarshalException
+ public boolean canPack(final Object value)
+ {
+ return (value instanceof Serializable) ;
+ }
+
+ /**
+ * Pack the provided object into the document.
+ *
+ * @param param the object to pack.
+ * @return the packed version of the object.
+ *
+ * @throws MarshalException thrown if there is a problem packing.
+ */
+ public String marshal (Object param)
+ throws MarshalException
{
- if (param instanceof Serializable)
- {
- // we can deal with this type!
-
- try
- {
- Element nodeElement = doc.getOwnerDocument().createElement(
- MarshalUnmarshalPlugin.tagName);
-
- Element pluginType = doc.getOwnerDocument().createElement(
- MarshalUnmarshalPlugin.pluginType);
- pluginType.appendChild(doc.getOwnerDocument().createTextNode(
- type().toString()));
- nodeElement.appendChild(pluginType);
-
- nodeElement.appendChild(doc.getOwnerDocument()
- .createCDATASection(
- Encoding.encodeObject((Serializable) param)));
-
- doc.appendChild(nodeElement);
- }
- catch (Exception ex)
- {
- ex.printStackTrace();
-
- throw new MarshalException(ex);
- }
-
- return true;
- }
- else
- return false;
+ if (param instanceof Serializable)
+ {
+ try
+ {
+ return Encoding.encodeObject((Serializable)param) ;
+ }
+ catch (final IOException ioe)
+ {
+ throw new MarshalException("Failed to encode value", ioe) ;
+ }
+ }
+ else
+ {
+ throw new MarshalException("Invalid value type for marshaling plugin:" + param.getClass().getName()) ;
+ }
}
- /**
- * Unpack the object from the document.
- *
- * @param doc
- * the document.
- *
- * @return the object, or <code>null</code> if this implementation cannot
- * deal with the format.
- * @throws UnmarshalException
- * thrown if there is a problem unpacking.
- */
-
- public Object unmarshal(Element doc) throws UnmarshalException
+ /**
+ * Unpack the object from the document.
+ *
+ * @param content the object content.
+ *
+ * @return the object, or <code>null</code> if this implementation cannot deal with the
+ * format.
+ * @throws UnmarshalException thrown if there is a problem unpacking.
+ */
+ public Object unmarshal (final String content)
+ throws UnmarshalException
{
- try
- {
- NodeList nl = doc.getChildNodes();
-
- for (int i = 0; i < nl.getLength(); i++)
- {
- if (nl.item(i).getNodeName().equals(MarshalUnmarshalPlugin.tagName))
- {
- NodeList childList = nl.item(i).getChildNodes();
-
- for (int j = 0; j < childList.getLength(); j++)
- {
- Node el = childList.item(j);
-
- if (el.getNodeName().equals(
- MarshalUnmarshalPlugin.pluginType))
- {
- if (el.getTextContent().equals(type().toString()))
- {
- CDATASection cdata = (CDATASection) childList
- .item(j + 1);
-
- return Encoding.decodeToObject(cdata
- .getWholeText());
- }
- }
- }
- }
- }
-
- return null;
- }
- catch (Exception ex)
- {
- throw new UnmarshalException(ex);
- }
+ try
+ {
+ return Encoding.decodeToObject(content) ;
+ }
+ catch (final ClassNotFoundException cnfe)
+ {
+ throw new UnmarshalException("Failed to decode value", cnfe) ;
+ }
+ catch (final IOException ioe)
+ {
+ throw new UnmarshalException("Failed to decode value", ioe) ;
+ }
}
/**
@@ -171,5 +129,4 @@
}
private URI _type = null;
-
}
Added: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/util/stax/NamedElement.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/util/stax/NamedElement.java (rev 0)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/util/stax/NamedElement.java 2007-12-17 04:59:04 UTC (rev 17275)
@@ -0,0 +1,68 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags.
+ * See the copyright.txt in the distribution for a full listing
+ * of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU General Public License, v. 2.0.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ * You should have received a copy of the GNU General Public License,
+ * v. 2.0 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2005-2006,
+ * @author JBoss Inc.
+ */
+package org.jboss.internal.soa.esb.util.stax;
+
+import javax.xml.namespace.QName;
+
+/**
+ * Utility class to wrap an element and its name.
+ * @author kevin
+ */
+public class NamedElement
+{
+ /**
+ * The element name of the any element.
+ */
+ private final QName name ;
+ /**
+ * The any element content.
+ */
+ private final ElementContent elementContent ;
+
+ /**
+ * Construct the any element utility class.
+ * @param name The name of the element.
+ * @param elementContent The contents of the element.
+ */
+ public NamedElement(final QName name, final ElementContent elementContent)
+ {
+ this.name = name ;
+ this.elementContent = elementContent ;
+ }
+
+ /**
+ * Get the element name.
+ * @return The element name.
+ */
+ public QName getName()
+ {
+ return name ;
+ }
+
+ /**
+ * Get the element content.
+ * @return The element content.
+ */
+ public ElementContent getElementContent()
+ {
+ return elementContent ;
+ }
+}
Property changes on: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/util/stax/NamedElement.java
___________________________________________________________________
Name: svn:keywords
+ Rev Date
Name: svn:eol-style
+ native
Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/util/stax/ParsingSupport.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/util/stax/ParsingSupport.java 2007-12-17 04:48:50 UTC (rev 17274)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/util/stax/ParsingSupport.java 2007-12-17 04:59:04 UTC (rev 17275)
@@ -66,11 +66,10 @@
case XMLStreamConstants.START_ELEMENT:
final QName startElementName = in.getName() ;
putElement(in, startElementName) ;
- in.require(XMLStreamConstants.END_ELEMENT, startElementName.getNamespaceURI(),
- startElementName.getLocalPart()) ;
+ StreamHelper.checkEndTag(in, startElementName) ;
break ;
case XMLStreamConstants.END_ELEMENT:
- in.require(type, name.getNamespaceURI(), name.getLocalPart()) ;
+ StreamHelper.checkEndTag(in, name) ;
finished = true ;
break ;
case XMLStreamConstants.CDATA:
Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/util/stax/StreamHelper.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/util/stax/StreamHelper.java 2007-12-17 04:48:50 UTC (rev 17274)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/util/stax/StreamHelper.java 2007-12-17 04:59:04 UTC (rev 17275)
@@ -337,6 +337,19 @@
}
/**
+ * Check the end tag is as expected.
+ * @param streamReader The stream reader.
+ * @param expected The expected qualified name.
+ * @throws XMLStreamException For errors during parsing.
+ */
+ public static void checkEndTag(final XMLStreamReader streamReader, final QName expected)
+ throws XMLStreamException
+ {
+ streamReader.require(XMLStreamConstants.END_ELEMENT,
+ expected.getNamespaceURI(), expected.getLocalPart()) ;
+ }
+
+ /**
* Compare the element tag with the expected qualified name.
* @param streamReader The current stream reader.
* @param expected The expected qualified name.
@@ -363,4 +376,15 @@
{
return (streamReader.nextTag() == XMLStreamConstants.END_ELEMENT) ;
}
+
+ /**
+ * Get the value of the specified attribute.
+ * @param streamReader The current XML stream reader.
+ * @param name The name of the attribute.
+ * @return The value of the attribute.
+ */
+ public static String getAttributeValue(final XMLStreamReader streamReader, final QName name)
+ {
+ return streamReader.getAttributeValue(name.getNamespaceURI(), name.getLocalPart()) ;
+ }
}
Added: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/util/stax/TextElement.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/util/stax/TextElement.java (rev 0)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/util/stax/TextElement.java 2007-12-17 04:59:04 UTC (rev 17275)
@@ -0,0 +1,106 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags.
+ * See the copyright.txt in the distribution for a full listing
+ * of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU General Public License, v. 2.0.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ * You should have received a copy of the GNU General Public License,
+ * v. 2.0 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2005-2006,
+ * @author JBoss Inc.
+ */
+package org.jboss.internal.soa.esb.util.stax;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+
+/**
+ * Utility class representing a text element.
+ * @author kevin
+ */
+public class TextElement extends ElementContent
+{
+ /**
+ * The value of the text element.
+ */
+ private String text ;
+
+ /**
+ * Construct the text element.
+ * @param text The text element.
+ */
+ public TextElement(final String text)
+ {
+ this.text = text ;
+ }
+
+ /**
+ * Construct the text element.
+ * @param in The current input stream.
+ * @throws XMLStreamException For errors during reading.
+ */
+ public TextElement(final XMLStreamReader in)
+ throws XMLStreamException
+ {
+ parse(in) ;
+ }
+
+ /**
+ * Get the text value of this element.
+ * @return The text value of this element.
+ */
+ public String getText()
+ {
+ return text ;
+ }
+
+ /**
+ * Set the text value of this element.
+ * @param in The current input stream.
+ * @param value The text value of this element.
+ * @throws XMLStreamException For errors during parsing.
+ */
+ protected void putValue(final XMLStreamReader in, final String value)
+ throws XMLStreamException
+ {
+ text = value ;
+ }
+
+ /**
+ * Add the element.
+ * @param in The current input stream.
+ * @param elementName The qualified element name.
+ * @throws XMLStreamException For errors during parsing.
+ */
+ protected void putElement(final XMLStreamReader in,
+ final QName elementName)
+ throws XMLStreamException
+ {
+ throw new XMLStreamException("Text elements cannot have embedded elements.") ;
+ }
+
+ /**
+ * Write the child content of the element.
+ * @param out The output stream.
+ * @throws XMLStreamException For errors during output.
+ */
+ protected void writeChildContent(final XMLStreamWriter out)
+ throws XMLStreamException
+ {
+ if (text != null)
+ {
+ out.writeCharacters(text) ;
+ }
+ }
+}
Property changes on: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/util/stax/TextElement.java
___________________________________________________________________
Name: svn:keywords
+ Rev Date
Name: svn:eol-style
+ native
Added: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/util/stax/URIElement.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/util/stax/URIElement.java (rev 0)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/util/stax/URIElement.java 2007-12-17 04:59:04 UTC (rev 17275)
@@ -0,0 +1,144 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags.
+ * See the copyright.txt in the distribution for a full listing
+ * of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU General Public License, v. 2.0.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ * You should have received a copy of the GNU General Public License,
+ * v. 2.0 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2005-2006,
+ * @author JBoss Inc.
+ */
+package org.jboss.internal.soa.esb.util.stax;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+
+
+/*
+ * xs:anyURI
+ */
+/**
+ * Representation of a URI
+ * @author kevin
+ */
+public class URIElement extends ElementContent
+{
+ /**
+ * The URI value of this element.
+ */
+ private URI value ;
+
+ /**
+ * Default constructor.
+ */
+ public URIElement()
+ {
+ }
+
+ /**
+ * Create the URI with a specific value.
+ * @param value The URI value.
+ */
+ public URIElement(final URI value)
+ {
+ setValue(value) ;
+ }
+
+ /**
+ * Construct the attributed uri from the input stream.
+ * @param in The input stream.
+ * @throws XMLStreamException for errors during reading.
+ */
+ public URIElement(final XMLStreamReader in)
+ throws XMLStreamException
+ {
+ parse(in) ;
+ }
+
+ /**
+ * Set the text value of this element.
+ * @param in The current input stream.
+ * @param value The text value.
+ */
+ protected void putValue(final XMLStreamReader in, final String value)
+ throws XMLStreamException
+ {
+ final URI uriValue ;
+ try
+ {
+ uriValue = new URI(value) ;
+ }
+ catch (final URISyntaxException urise)
+ {
+ throw new XMLStreamException("Failed to parse URI: " + value, urise) ;
+ }
+ setValue(uriValue) ;
+ }
+
+ /**
+ * Set the URI value of this element.
+ * @param value The URI value of the element.
+ */
+ public void setValue(final URI value)
+ {
+ this.value = value ;
+ }
+
+ /**
+ * Get the URI value of this element.
+ * @return The URI value of the element or null if not set.
+ */
+ public URI getValue()
+ {
+ return value ;
+ }
+
+ /**
+ * Write the child content of the element.
+ * @param out The output stream.
+ */
+ protected void writeChildContent(final XMLStreamWriter out)
+ throws XMLStreamException
+ {
+ if (value != null)
+ {
+ out.writeCharacters(value.toString()) ;
+ }
+ }
+
+ /**
+ * Add the element.
+ * @param in The current input stream.
+ * @param elementName The qualified element name.
+ */
+ protected void putElement(final XMLStreamReader in,
+ final QName elementName)
+ throws XMLStreamException
+ {
+ // Ignore elements.
+ }
+
+ /**
+ * Is the configuration of this element valid?
+ * @return true if valid, false otherwise.
+ */
+ public boolean isValid()
+ {
+ return (value != null) && super.isValid() ;
+ }
+}
Property changes on: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/util/stax/URIElement.java
___________________________________________________________________
Name: svn:keywords
+ Rev Date
Name: svn:eol-style
+ native
Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/soa/esb/addressing/XMLUtil.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/soa/esb/addressing/XMLUtil.java 2007-12-17 04:48:50 UTC (rev 17274)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/soa/esb/addressing/XMLUtil.java 2007-12-17 04:59:04 UTC (rev 17275)
@@ -27,6 +27,8 @@
package org.jboss.soa.esb.addressing;
+import javax.xml.namespace.QName;
+
public class XMLUtil
{
// WS-Addr
@@ -34,18 +36,29 @@
public static final String WSA_PREFIX = "wsa";
public static final String WSA_NAMESPACE_URI = "http://schemas.xmlsoap.org/ws/2004/08/addressing";
- public static final String ENDPOINT_REFERENCE_TAG = "EndpointReference";
- public static final String MESSAGE_IDENTIFIER_TAG = "MessageID";
- public static final String REFERENCE_PROPERTIES_TAG = "ReferenceProperties";
- public static final String REFERENCE_PARAMETERS_TAG = "ReferenceParameters";
- public static final String REPLY_TO_TAG = "ReplyTo";
- public static final String FROM_TAG = "From";
+ public static final String ENDPOINT_REFERENCE_TAG = "EndpointReference";
+ public static final QName QNAME_ENDPOINT_REFERENCE_TAG = new QName(WSA_NAMESPACE_URI, "EndpointReference", WSA_PREFIX);
+ public static final String MESSAGE_IDENTIFIER_TAG = "MessageID";
+ public static final QName QNAME_MESSAGE_IDENTIFIER_TAG = new QName(WSA_NAMESPACE_URI, "MessageID", WSA_PREFIX);
+ public static final String REFERENCE_PROPERTIES_TAG = "ReferenceProperties";
+ public static final QName QNAME_REFERENCE_PROPERTIES_TAG = new QName(WSA_NAMESPACE_URI, "ReferenceProperties", WSA_PREFIX);
+ public static final String REFERENCE_PARAMETERS_TAG = "ReferenceParameters";
+ public static final QName QNAME_REFERENCE_PARAMETERS_TAG = new QName(WSA_NAMESPACE_URI, "ReferenceParameters", WSA_PREFIX);
+ public static final String REPLY_TO_TAG = "ReplyTo";
+ public static final QName QNAME_REPLY_TO_TAG = new QName(WSA_NAMESPACE_URI, "ReplyTo", WSA_PREFIX);
+ public static final String FROM_TAG = "From";
+ public static final QName QNAME_FROM_TAG = new QName(WSA_NAMESPACE_URI, "From", WSA_PREFIX);
public static final String TO_TAG = "To";
+ public static final QName QNAME_TO_TAG = new QName(WSA_NAMESPACE_URI, "To", WSA_PREFIX);
public static final String ADDRESS_TAG = "Address";
+ public static final QName QNAME_ADDRESS_TAG = new QName(WSA_NAMESPACE_URI, "Address", WSA_PREFIX);
public static final String ACTION_TAG = "Action";
+ public static final QName QNAME_ACTION_TAG = new QName(WSA_NAMESPACE_URI, "Action", WSA_PREFIX);
public static final String RELATES_TO_TAG = "RelatesTo";
+ public static final QName QNAME_RELATES_TO_TAG = new QName(WSA_NAMESPACE_URI, "RelatesTo", WSA_PREFIX);
public static final String FAULT_TO_TAG = "FaultTo";
+ public static final QName QNAME_FAULT_TO_TAG = new QName(WSA_NAMESPACE_URI, "FaultTo", WSA_PREFIX);
// JBossESB
Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/soa/esb/addressing/util/EPRManager.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/soa/esb/addressing/util/EPRManager.java 2007-12-17 04:48:50 UTC (rev 17274)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/soa/esb/addressing/util/EPRManager.java 2007-12-17 04:59:04 UTC (rev 17275)
@@ -24,19 +24,17 @@
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
+import java.io.FileReader;
import java.io.IOException;
import java.util.Hashtable;
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
import org.jboss.internal.soa.esb.addressing.helpers.EPRHelper;
-import org.jboss.soa.esb.UnmarshalException;
+import org.jboss.internal.soa.esb.util.XMLHelper;
+import org.jboss.internal.soa.esb.util.stax.StreamHelper;
import org.jboss.soa.esb.addressing.EPR;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.xml.sax.SAXException;
/**
* Allows EPRs to be saved to and loaded from files. Mainly for testing
@@ -193,32 +191,28 @@
{
if (theFile.exists())
{
- DocumentBuilderFactory factory = DocumentBuilderFactory
- .newInstance();
-
- factory.setNamespaceAware(true);
-
- DocumentBuilder builder = factory.newDocumentBuilder();
- Document doc = builder.parse(theFile);
- Element rootElement = doc.getDocumentElement();
+ final FileReader reader = new FileReader(theFile) ;
+ try
+ {
+ final XMLStreamReader in = XMLHelper.getXMLStreamReader(reader) ;
+ StreamHelper.skipToNextStartElement(in) ;
- return EPRHelper.fromXML(rootElement);
+ return EPRHelper.fromXML(in);
+ }
+ finally
+ {
+ reader.close() ;
+ }
}
else
throw new FileNotFoundException(theFile.toString());
}
- catch (UnmarshalException ex)
+ catch (XMLStreamException xmlse)
{
- throw new IOException(ex.toString());
+ final IOException ioe = new IOException("Failed to parse EPR file: " + theFile.getAbsolutePath()) ;
+ ioe.initCause(xmlse) ;
+ throw ioe ;
}
- catch (SAXException ex)
- {
- throw new IOException(ex.toString());
- }
- catch (ParserConfigurationException ex)
- {
- throw new IllegalArgumentException(ex.toString());
- }
}
protected EPRManager(String domain)
Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/soa/esb/util/Util.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/soa/esb/util/Util.java 2007-12-17 04:48:50 UTC (rev 17274)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/soa/esb/util/Util.java 2007-12-17 04:59:04 UTC (rev 17275)
@@ -25,18 +25,19 @@
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
-import java.io.InputStream;
import java.io.PrintStream;
import java.io.Serializable;
+import java.io.StringReader;
import java.io.StringWriter;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
import javax.xml.transform.ErrorListener;
import javax.xml.transform.OutputKeys;
import javax.xml.transform.Transformer;
@@ -49,15 +50,13 @@
import org.apache.log4j.ConsoleAppender;
import org.apache.log4j.Logger;
import org.apache.log4j.TTCCLayout;
-import org.apache.xml.serialize.OutputFormat;
-import org.apache.xml.serialize.XMLSerializer;
-import org.jboss.internal.soa.esb.message.format.serialized.MessageImpl;
-import org.jboss.soa.esb.MarshalException;
-import org.jboss.soa.esb.UnmarshalException;
+import org.jboss.internal.soa.esb.message.format.xml.MessageImpl;
+import org.jboss.internal.soa.esb.message.format.xml.XMLUtil;
+import org.jboss.internal.soa.esb.util.XMLHelper;
+import org.jboss.internal.soa.esb.util.stax.StreamHelper;
import org.jboss.soa.esb.common.ModulePropertyManager;
import org.jboss.soa.esb.helpers.KeyValuePair;
import org.jboss.soa.esb.message.Message;
-import org.w3c.dom.Document;
import org.xml.sax.SAXException;
public class Util
@@ -171,6 +170,8 @@
return oRet;
} // __________________________________
+ // ParserConfigurationException is no longer thrown but,
+ // unfortunately, it is in the signature of the method!
public static Serializable serialize (Message message)
throws ParserConfigurationException, IOException
{
@@ -180,56 +181,42 @@
try
{
- DocumentBuilderFactory factory = DocumentBuilderFactory
- .newInstance();
-
- factory.setNamespaceAware(true);
-
- Document doc = factory.newDocumentBuilder().newDocument();
- ((org.jboss.internal.soa.esb.message.format.xml.MessageImpl) message)
- .toXML(doc);
- StringWriter sWriter = new StringWriter();
- OutputFormat format = new OutputFormat();
- format.setIndenting(true);
- XMLSerializer xmlS = new XMLSerializer(sWriter, format);
- xmlS.asDOMSerializer();
- xmlS.serialize(doc);
- return sWriter.toString();
+ final StringWriter writer = new StringWriter() ;
+ final XMLStreamWriter out = XMLHelper.getXMLStreamWriter(writer) ;
+ final String origURI = StreamHelper.writeStartElement(out, XMLUtil.ESB_QNAME_ENVELOPE) ;
+ ((MessageImpl) message).writeContent(out) ;
+ StreamHelper.writeEndElement(out, XMLUtil.ESB_QNAME_ENVELOPE.getPrefix(), origURI) ;
+ out.flush();
+ return writer.toString() ;
}
- catch (MarshalException ex)
+ catch (final XMLStreamException xmlse)
{
- final IOException ioe = new IOException("Util.serialize caught MarshalException:") ;
- ioe.initCause(ex) ;
+ final IOException ioe = new IOException("Util.serialize caught XMLStreamException:") ;
+ ioe.initCause(xmlse) ;
throw ioe ;
}
}// ________________________________
+ // ParserConfigurationException and SAXException are no longer thrown
+ // but, unfortunately, they are in the signature of the method!
public static Message deserialize (Serializable serial)
throws ParserConfigurationException, SAXException, IOException
{
- if (serial instanceof MessageImpl) // MessageType.JAVA_SERIALIZED
+ if (serial instanceof Message) // MessageType.JAVA_SERIALIZED
return (Message) serial;
try
{
- // MessageType.JBOSS_XML
- InputStream inStream = new ByteArrayInputStream(((String) serial)
- .getBytes());
- DocumentBuilderFactory factory = DocumentBuilderFactory
- .newInstance();
- factory.setNamespaceAware(true);
-
- DocumentBuilder builder = factory.newDocumentBuilder();
- Document doc = builder.parse(inStream);
-
- org.jboss.internal.soa.esb.message.format.xml.MessageImpl message = new org.jboss.internal.soa.esb.message.format.xml.MessageImpl();
- message.fromXML(doc);
- return message;
+ // MessageType.JBOSS_XML
+ final StringReader reader = new StringReader((String)serial) ;
+ final XMLStreamReader in = XMLHelper.getXMLStreamReader(reader) ;
+ StreamHelper.checkNextStartTag(in, XMLUtil.ESB_QNAME_ENVELOPE) ;
+ return new MessageImpl(in) ;
}
- catch (UnmarshalException ex)
+ catch (XMLStreamException xmlse)
{
- final IOException ioe = new IOException("Util.deserialize caught UnmarshalException") ;
- ioe.initCause(ex) ;
+ final IOException ioe = new IOException("Util.deserialize caught XMLStreamException") ;
+ ioe.initCause(xmlse) ;
throw ioe ;
}
} // ________________________________
Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/addressing/tests/CallUnitTest.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/addressing/tests/CallUnitTest.java 2007-12-17 04:48:50 UTC (rev 17274)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/addressing/tests/CallUnitTest.java 2007-12-17 04:59:04 UTC (rev 17275)
@@ -25,16 +25,11 @@
import java.net.URI;
import java.net.URISyntaxException;
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-
import junit.framework.TestCase;
-import org.jboss.internal.soa.esb.addressing.helpers.CallHelper;
+import org.jboss.internal.soa.esb.message.format.xml.CallImpl;
import org.jboss.soa.esb.addressing.Call;
import org.jboss.soa.esb.addressing.EPR;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
/**
* Unit tests for the Class class.
@@ -211,20 +206,9 @@
call.setReplyTo(getEPR("urn:replyTo", "replyToTag", "replyToValue")) ;
call.setTo(getEPR("urn:to", "toTag", "toValue")) ;
- DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+ final String content = CallImpl.toXML(call) ;
+ final Call result = CallImpl.fromXML(content) ;
- factory.setNamespaceAware(true);
-
- DocumentBuilder builder = factory.newDocumentBuilder();
- Document doc = builder.newDocument();
- Element header = doc.createElement("HEADER");
-
- doc.appendChild(header);
-
- CallHelper.toXML(call, doc, header);
-
- final Call result = CallHelper.fromXML(header) ;
-
assertEquals("Action URI", call.getAction(), result.getAction()) ;
assertEquals("FaultTo EPR", call.getFaultTo(), result.getFaultTo()) ;
assertEquals("From EPR", call.getFrom(), result.getFrom()) ;
Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/addressing/tests/EPRUnitTest.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/addressing/tests/EPRUnitTest.java 2007-12-17 04:48:50 UTC (rev 17274)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/addressing/tests/EPRUnitTest.java 2007-12-17 04:59:04 UTC (rev 17275)
@@ -22,27 +22,26 @@
package org.jboss.soa.esb.addressing.tests;
+import java.io.StringReader;
import java.io.StringWriter;
import java.net.URI;
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
import junit.framework.TestCase;
import org.apache.log4j.Logger;
import org.jboss.internal.soa.esb.addressing.helpers.PortReferenceHelper;
+import org.jboss.internal.soa.esb.util.XMLHelper;
+import org.jboss.internal.soa.esb.util.stax.StreamHelper;
import org.jboss.soa.esb.addressing.EPR;
import org.jboss.soa.esb.addressing.PortReference;
import org.jboss.soa.esb.addressing.XMLUtil;
import org.jboss.soa.esb.addressing.eprs.EmailEpr;
import org.jboss.soa.esb.message.tests.XMLMessageUnitTest;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import com.sun.org.apache.xml.internal.serialize.OutputFormat;
-import com.sun.org.apache.xml.internal.serialize.XMLSerializer;
-
/**
* Unit tests for the EPR class.
*
@@ -118,30 +117,27 @@
{
EmailEpr email = new EmailEpr(EmailEpr.SMTP_PROTOCOL, "foobar", "25", "me", "letmein");
- final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
- final DocumentBuilder builder = factory.newDocumentBuilder();
- Document doc = builder.newDocument();
- Element header = doc.createElement("header");
- Element fromElement = doc.createElementNS(XMLUtil.WSA_NAMESPACE_URI, XMLUtil.WSA_PREFIX+":"+XMLUtil.FROM_TAG);
+ final StringWriter writer = new StringWriter() ;
+ final XMLStreamWriter out = XMLHelper.getXMLStreamWriter(writer) ;
- doc.appendChild(header);
- header.appendChild(fromElement);
+ final QName header = new QName("header") ;
+ final String origHeaderURI = StreamHelper.writeStartElement(out, header) ;
+ PortReferenceHelper.toXML(out, XMLUtil.QNAME_FROM_TAG, email.getAddr()) ;
+ StreamHelper.writeEndElement(out, header.getPrefix(), origHeaderURI) ;
+ out.flush() ;
+
+ final String content = writer.toString() ;
+ log.debug("Exported XML: "+content);
+
+ final StringReader reader = new StringReader(content) ;
+ final XMLStreamReader in = XMLHelper.getXMLStreamReader(reader) ;
+ StreamHelper.checkNextStartTag(in, header) ;
+ StreamHelper.checkNextStartTag(in, XMLUtil.QNAME_FROM_TAG) ;
- PortReferenceHelper.toXML(header, doc, fromElement, email.getAddr(), false);
-
- final StringWriter sWriter = new StringWriter() ;
- final OutputFormat format = new OutputFormat() ;
- format.setIndenting(true) ;
-
- final XMLSerializer xmlS = new XMLSerializer(sWriter, format) ;
-
- xmlS.asDOMSerializer() ;
- xmlS.serialize(doc) ;
-
- log.debug("Exported XML: "+sWriter.toString());
+ PortReference pr = PortReferenceHelper.fromXML(in);
+ StreamHelper.checkEndTag(in, XMLUtil.QNAME_FROM_TAG) ;
+ StreamHelper.checkParentFinished(in) ;
- PortReference pr = PortReferenceHelper.fromXML(fromElement, false);
-
EPR basicEpr = new EPR(pr);
EmailEpr nEpr = new EmailEpr(basicEpr);
Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/message/MessageAttachmentSerializeTest.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/message/MessageAttachmentSerializeTest.java 2007-12-17 04:48:50 UTC (rev 17274)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/message/MessageAttachmentSerializeTest.java 2007-12-17 04:59:04 UTC (rev 17275)
@@ -27,15 +27,18 @@
import java.io.FileOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
+import java.io.StringReader;
+import java.io.StringWriter;
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
import junit.framework.TestCase;
+import org.jboss.internal.soa.esb.message.format.xml.XMLUtil;
+import org.jboss.internal.soa.esb.util.XMLHelper;
+import org.jboss.internal.soa.esb.util.stax.StreamHelper;
import org.jboss.soa.esb.message.Attachment;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
/**
* QA tests for the Message interface and implementations.
@@ -75,35 +78,40 @@
inp.readObject();
inp.close();
- assertEquals(old,oNew);
+ assertEquals("name1", old.get("name1"), oNew.get("name1")) ;
+ assertEquals("name2", old.get("name2"), oNew.get("name2")) ;
+ assertEquals("unnamed 0", old.itemAt(0), oNew.itemAt(0)) ;
+ assertEquals("unnamed 1", old.itemAt(1), oNew.itemAt(1)) ;
}
public void testXml() throws Exception
{
- DocumentBuilder oDB = DocumentBuilderFactory.newInstance().newDocumentBuilder();
- Document oDoc = oDB.newDocument();
- Element oRoot = oDoc.createElement("root");
- oDoc.appendChild(oRoot);
-
- org.jboss.internal.soa.esb.message.format.xml.AttachmentImpl
- old = new org.jboss.internal.soa.esb.message.format.xml.AttachmentImpl();
- populateAttachment(old);
- old.toXML(oRoot);
-
- org.jboss.internal.soa.esb.message.format.xml.AttachmentImpl
- oNew = new org.jboss.internal.soa.esb.message.format.xml.AttachmentImpl();
- oNew.fromXML(oRoot);
+ final StringWriter writer = new StringWriter() ;
+ final XMLStreamWriter out = XMLHelper.getXMLStreamWriter(writer) ;
+ final String origURI = StreamHelper.writeStartElement(out, XMLUtil.ESB_QNAME_ATTACHMENT) ;
+
+ org.jboss.internal.soa.esb.message.format.xml.AttachmentImpl old =
+ new org.jboss.internal.soa.esb.message.format.xml.AttachmentImpl();
+ populateAttachment(old);
+ old.writeContent(out) ;
+
+ StreamHelper.writeEndElement(out, XMLUtil.ESB_QNAME_ATTACHMENT.getPrefix(), origURI) ;
+
+ out.flush() ;
+
+ final String content = writer.toString() ;
+
+ final StringReader reader = new StringReader(content) ;
+ final XMLStreamReader in = XMLHelper.getXMLStreamReader(reader) ;
+ StreamHelper.checkNextStartTag(in, XMLUtil.ESB_QNAME_ATTACHMENT) ;
+
+ org.jboss.internal.soa.esb.message.format.xml.AttachmentImpl oNew =
+ new org.jboss.internal.soa.esb.message.format.xml.AttachmentImpl(in);
- assertEquals(old,oNew);
-
- Document oD2 = oDB.newDocument();
- Element oR2 = oD2.createElement("root");
- oD2.appendChild(oR2);
- oNew.toXML(oR2);
-
- String s1 = Util.toString(oRoot);
- String s2 = Util.toString(oR2);
- assertEquals(s1,s2);
+ assertEquals("name1", old.get("name1"), oNew.get("name1")) ;
+ assertEquals("name2", old.get("name2"), oNew.get("name2")) ;
+ assertEquals("unnamed 0", old.itemAt(0), oNew.itemAt(0)) ;
+ assertEquals("unnamed 1", old.itemAt(1), oNew.itemAt(1)) ;
}
private void populateAttachment(Attachment att)
Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/message/MessagePropertiesSerializeTest.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/message/MessagePropertiesSerializeTest.java 2007-12-17 04:48:50 UTC (rev 17274)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/message/MessagePropertiesSerializeTest.java 2007-12-17 04:59:04 UTC (rev 17275)
@@ -27,15 +27,19 @@
import java.io.FileOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
+import java.io.StringReader;
+import java.io.StringWriter;
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
import junit.framework.TestCase;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
+import org.jboss.internal.soa.esb.message.format.xml.XMLUtil;
+import org.jboss.internal.soa.esb.util.XMLHelper;
+import org.jboss.internal.soa.esb.util.stax.StreamHelper;
+
/**
* QA tests for the Message interface and implementations.
* @author <a href="mailto:schifest at heuristica.com.ar">schifest at heuristica.com.ar</a>
@@ -74,35 +78,36 @@
inp.readObject();
inp.close();
- assertEquals(old,oNew);
+ assertEquals("p1", old.getProperty("p1"), oNew.getProperty("p1")) ;
+ assertEquals("p2", old.getProperty("p2"), oNew.getProperty("p2")) ;
}
public void testXml() throws Exception
{
- DocumentBuilder oDB = DocumentBuilderFactory.newInstance().newDocumentBuilder();
- Document oDoc = oDB.newDocument();
- Element oRoot = oDoc.createElement("root");
- oDoc.appendChild(oRoot);
-
- org.jboss.internal.soa.esb.message.format.xml.PropertiesImpl
- old = new org.jboss.internal.soa.esb.message.format.xml.PropertiesImpl();
- populateProperties(old);
- old.toXML(oRoot);
-
- org.jboss.internal.soa.esb.message.format.xml.PropertiesImpl
- oNew = new org.jboss.internal.soa.esb.message.format.xml.PropertiesImpl();
- oNew.fromXML(oRoot);
+ final StringWriter writer = new StringWriter() ;
+ final XMLStreamWriter out = XMLHelper.getXMLStreamWriter(writer) ;
+ final String origURI = StreamHelper.writeStartElement(out, XMLUtil.ESB_QNAME_PROPERTIES) ;
+
+ org.jboss.internal.soa.esb.message.format.xml.PropertiesImpl old =
+ new org.jboss.internal.soa.esb.message.format.xml.PropertiesImpl();
+ populateProperties(old);
+ old.writeContent(out) ;
+
+ StreamHelper.writeEndElement(out, XMLUtil.ESB_QNAME_PROPERTIES.getPrefix(), origURI) ;
+
+ out.flush() ;
+
+ final String content = writer.toString() ;
+
+ final StringReader reader = new StringReader(content) ;
+ final XMLStreamReader in = XMLHelper.getXMLStreamReader(reader) ;
+ StreamHelper.checkNextStartTag(in, XMLUtil.ESB_QNAME_PROPERTIES) ;
+
+ org.jboss.internal.soa.esb.message.format.xml.PropertiesImpl oNew =
+ new org.jboss.internal.soa.esb.message.format.xml.PropertiesImpl(in);
- assertEquals(old,oNew);
-
- Document oD2 = oDB.newDocument();
- Element oR2 = oD2.createElement("root");
- oD2.appendChild(oR2);
- oNew.toXML(oR2);
-
- String s1 = Util.toString(oRoot);
- String s2 = Util.toString(oR2);
- assertEquals(s1,s2);
+ assertEquals("p1", old.getProperty("p1"), oNew.getProperty("p1")) ;
+ assertEquals("p2", old.getProperty("p2"), oNew.getProperty("p2")) ;
}
private void populateProperties(org.jboss.soa.esb.message.Properties props)
Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/message/tests/AttachmentUnitTest.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/message/tests/AttachmentUnitTest.java 2007-12-17 04:48:50 UTC (rev 17274)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/message/tests/AttachmentUnitTest.java 2007-12-17 04:59:04 UTC (rev 17275)
@@ -26,11 +26,7 @@
import java.io.ByteArrayOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
-import java.io.StringWriter;
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-
import junit.framework.TestCase;
import org.apache.log4j.Logger;
@@ -39,11 +35,8 @@
import org.jboss.soa.esb.message.Message;
import org.jboss.soa.esb.message.format.MessageFactory;
import org.jboss.soa.esb.message.format.MessageType;
-import org.w3c.dom.Document;
+import org.jboss.soa.esb.util.Util;
-import com.sun.org.apache.xml.internal.serialize.OutputFormat;
-import com.sun.org.apache.xml.internal.serialize.XMLSerializer;
-
/**
* Unit tests for the Class class.
*
@@ -55,6 +48,7 @@
private Logger log = Logger.getLogger( AttachmentUnitTest.class );
public void testSerializeAttachment()
+ throws Exception
{
Message msg = MessageFactory.getInstance().getMessage(
MessageType.JAVA_SERIALIZED);
@@ -77,10 +71,6 @@
catch (IllegalArgumentException ex)
{
}
- catch (Exception ex)
- {
- fail(ex.toString());
- }
assertEquals(at.getUnnamedCount(), 2);
@@ -101,28 +91,22 @@
int count = at.getUnnamedCount();
- try
- {
- ByteArrayOutputStream s = new ByteArrayOutputStream();
- ObjectOutputStream o = new ObjectOutputStream(s);
+ ByteArrayOutputStream s = new ByteArrayOutputStream();
+ ObjectOutputStream o = new ObjectOutputStream(s);
- o.writeObject(msg);
- o.close();
+ o.writeObject(msg);
+ o.close();
- ByteArrayInputStream is = new ByteArrayInputStream(s.toByteArray());
- ObjectInputStream io = new ObjectInputStream(is);
+ ByteArrayInputStream is = new ByteArrayInputStream(s.toByteArray());
+ ObjectInputStream io = new ObjectInputStream(is);
- MessageImpl nImpl = (MessageImpl) io.readObject();
+ MessageImpl nImpl = (MessageImpl) io.readObject();
- assertEquals(nImpl.getAttachment().getUnnamedCount(), count);
- }
- catch (Exception ex)
- {
- fail(ex.toString());
- }
+ assertEquals(nImpl.getAttachment().getUnnamedCount(), count);
}
public void testXMLAttachment()
+ throws Exception
{
Message msg = MessageFactory.getInstance().getMessage(
MessageType.JBOSS_XML);
@@ -145,10 +129,6 @@
catch (IllegalArgumentException ex)
{
}
- catch (Exception ex)
- {
- fail(ex.toString());
- }
assertEquals(at.getUnnamedCount(), 2);
@@ -169,41 +149,11 @@
int count = at.getUnnamedCount();
- try
- {
- DocumentBuilderFactory factory = DocumentBuilderFactory
- .newInstance();
- DocumentBuilder builder = factory.newDocumentBuilder();
- Document doc = builder.newDocument();
- org.jboss.internal.soa.esb.message.format.xml.MessageImpl theImpl = (org.jboss.internal.soa.esb.message.format.xml.MessageImpl) msg;
-
- doc = theImpl.toXML(doc);
-
- StringWriter sWriter = new StringWriter();
- OutputFormat format = new OutputFormat();
- format.setIndenting(true);
-
- XMLSerializer xmlS = new XMLSerializer(sWriter, format);
-
- xmlS.asDOMSerializer();
- xmlS.serialize(doc);
-
- String documentAsString = sWriter.toString();
-
- log.debug("Message looks like: " + documentAsString);
-
- org.jboss.internal.soa.esb.message.format.xml.MessageImpl nImpl = new org.jboss.internal.soa.esb.message.format.xml.MessageImpl();
-
- nImpl.fromXML(doc);
-
- assertEquals(nImpl.getAttachment().getUnnamedCount(), count);
- }
- catch (Exception ex)
- {
- log.error( ex );
-
- fail(ex.toString());
- }
+ final String documentAsString = (String)Util.serialize(msg) ;
+ log.debug("Message looks like: " + documentAsString);
+ final Message nImpl = Util.deserialize(documentAsString) ;
+
+ assertEquals(nImpl.getAttachment().getUnnamedCount(), count);
}
}
Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/message/tests/BodyUnitTest.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/message/tests/BodyUnitTest.java 2007-12-17 04:48:50 UTC (rev 17274)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/message/tests/BodyUnitTest.java 2007-12-17 04:59:04 UTC (rev 17275)
@@ -26,23 +26,15 @@
import java.io.ByteArrayOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
-import java.io.StringWriter;
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-
import junit.framework.TestCase;
import org.apache.log4j.Logger;
-import org.jboss.internal.soa.esb.message.format.xml.MessageImpl;
import org.jboss.soa.esb.message.Message;
import org.jboss.soa.esb.message.format.MessageFactory;
import org.jboss.soa.esb.message.format.MessageType;
-import org.w3c.dom.Document;
+import org.jboss.soa.esb.util.Util;
-import com.sun.org.apache.xml.internal.serialize.OutputFormat;
-import com.sun.org.apache.xml.internal.serialize.XMLSerializer;
-
/**
* Unit tests for the Class class.
*
@@ -68,33 +60,11 @@
assertEquals(msg.getBody().get("foo"), "bar");
- DocumentBuilderFactory factory = DocumentBuilderFactory
- .newInstance();
-
- factory.setNamespaceAware(true);
-
- DocumentBuilder builder = factory.newDocumentBuilder();
- Document doc = builder.newDocument();
- MessageImpl theImpl = (MessageImpl) msg;
+ final String documentAsString = (String)Util.serialize(msg) ;
- doc = theImpl.toXML(doc);
-
- StringWriter sWriter = new StringWriter();
- OutputFormat format = new OutputFormat();
- format.setIndenting(true);
-
- XMLSerializer xmlS = new XMLSerializer(sWriter, format);
-
- xmlS.asDOMSerializer();
- xmlS.serialize(doc);
-
- String documentAsString = sWriter.toString();
-
- MessageImpl nImpl = new MessageImpl();
-
log.debug("Document is "+documentAsString);
- nImpl.fromXML(doc);
+ final Message nImpl = Util.deserialize(documentAsString);
assertEquals(nImpl.getBody().get("foo"), "bar");
}
@@ -121,33 +91,12 @@
assertEquals(msg.getBody().get("foo"), new Boolean(true));
- DocumentBuilderFactory factory = DocumentBuilderFactory
- .newInstance();
- factory.setNamespaceAware(true);
-
- DocumentBuilder builder = factory.newDocumentBuilder();
- Document doc = builder.newDocument();
- MessageImpl theImpl = (MessageImpl) msg;
+ final String documentAsString = (String)Util.serialize(msg) ;
- doc = theImpl.toXML(doc);
-
- StringWriter sWriter = new StringWriter();
- OutputFormat format = new OutputFormat();
- format.setIndenting(true);
-
- XMLSerializer xmlS = new XMLSerializer(sWriter, format);
-
- xmlS.asDOMSerializer();
- xmlS.serialize(doc);
-
- String documentAsString = sWriter.toString();
-
- MessageImpl nImpl = new MessageImpl();
-
- log.debug("Document is "+documentAsString);
+ log.debug("Document is "+documentAsString);
+
+ final Message nImpl = Util.deserialize(documentAsString);
- nImpl.fromXML(doc);
-
assertEquals(nImpl.getBody().get("foo"), new Boolean(true));
}
catch (Exception ex)
Added: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/message/tests/DeserializedValuesMessageUnitTest.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/message/tests/DeserializedValuesMessageUnitTest.java (rev 0)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/message/tests/DeserializedValuesMessageUnitTest.java 2007-12-17 04:59:04 UTC (rev 17275)
@@ -0,0 +1,229 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.soa.esb.message.tests;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.ObjectInputStream;
+
+import junit.framework.TestCase;
+
+import org.jboss.internal.soa.esb.message.format.DeferredDeserialisationException;
+import org.jboss.soa.esb.message.Attachment;
+import org.jboss.soa.esb.message.Body;
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.message.Properties;
+import org.jboss.soa.esb.util.Util;
+
+/**
+ * Unit tests for checking deserialisation of old formats and just in time resolving
+ * of object values.
+ *
+ * @author <a href='mailto:kevin.conner at jboss.com'>Kevin Conner</a>
+ */
+
+public class DeserializedValuesMessageUnitTest extends TestCase
+{
+ public void testOldSerializedAttachmentDeserialisation()
+ throws Exception
+ {
+ final Attachment attachment = (Attachment)deserialise("old_attachment.ser") ;
+ validateOldAttachment(attachment) ;
+ }
+
+ public void testOldSerializedBodyDeserialisation()
+ throws Exception
+ {
+ final Body body = (Body)deserialise("old_body.ser") ;
+ validateOldBody(body) ;
+ }
+
+ public void testOldSerializedPropertiesDeserialisation()
+ throws Exception
+ {
+ final Properties properties = (Properties)deserialise("old_properties.ser") ;
+ validateOldProperties(properties) ;
+ }
+
+ public void testOldSerializedMessageDeserialisation()
+ throws Exception
+ {
+ final Message message = (Message)deserialise("old_message.ser") ;
+ validateOldAttachment(message.getAttachment()) ;
+ validateOldBody(message.getBody()) ;
+ validateOldProperties(message.getProperties()) ;
+ }
+
+ public void testOldXMLMessageDeserialisation()
+ throws Exception
+ {
+ final String contents = getContents("old_message.xml") ;
+ final Message message = Util.deserialize(contents) ;
+ validateOldAttachment(message.getAttachment()) ;
+ validateOldBody(message.getBody()) ;
+ validateOldProperties(message.getProperties()) ;
+ }
+
+ public void testNewSerializedAttachmentDeserialisation()
+ throws Exception
+ {
+ final Attachment attachment = (Attachment)deserialise("new_attachment.ser") ;
+ validateNewAttachment(attachment) ;
+ }
+
+ public void testNewSerializedBodyDeserialisation()
+ throws Exception
+ {
+ final Body body = (Body)deserialise("new_body.ser") ;
+ validateNewBody(body) ;
+ }
+
+ public void testNewSerializedPropertiesDeserialisation()
+ throws Exception
+ {
+ final Properties properties = (Properties)deserialise("new_properties.ser") ;
+ validateNewProperties(properties) ;
+ }
+
+ public void testNewSerializedMessageDeserialisation()
+ throws Exception
+ {
+ final Message message = (Message)deserialise("new_message.ser") ;
+ validateNewAttachment(message.getAttachment()) ;
+ validateNewBody(message.getBody()) ;
+ validateNewProperties(message.getProperties()) ;
+ }
+
+ public void testNewXMLMessageDeserialisation()
+ throws Exception
+ {
+ final String contents = getContents("new_message.xml") ;
+ final Message message = Util.deserialize(contents) ;
+ validateNewAttachment(message.getAttachment()) ;
+ validateNewBody(message.getBody()) ;
+ validateNewProperties(message.getProperties()) ;
+ }
+
+ private void validateOldAttachment(final Attachment attachment)
+ {
+ assertEquals("unnamed count", 1, attachment.getUnnamedCount()) ;
+ assertEquals("named count", 1, attachment.getNamedCount()) ;
+ final Object namedAttachment = attachment.get("testAttribute") ;
+ assertEquals("Named attachment", "Named value", namedAttachment) ;
+ final Object unnamedAttachment = attachment.itemAt(0) ;
+ assertEquals("Unnamed attachment", "Unnamed value", unnamedAttachment) ;
+ }
+
+ private void validateOldBody(final Body body)
+ {
+ final Object bodyValue = body.get() ;
+ assertEquals("Body value", "Body value", bodyValue) ;
+ }
+
+ private void validateOldProperties(final Properties properties)
+ {
+ final Object propertyValue = properties.getProperty("testProperty") ;
+ assertEquals("Property value", "Property value", propertyValue) ;
+ }
+
+ private void validateNewAttachment(final Attachment attachment)
+ {
+ assertEquals("unnamed count", 1, attachment.getUnnamedCount()) ;
+ assertEquals("named count", 1, attachment.getNamedCount()) ;
+ try
+ {
+ attachment.get("testAttribute") ;
+ fail("Expected DeferredDeserialisationException for named attachment") ;
+ }
+ catch (final DeferredDeserialisationException dse) {}
+
+ try
+ {
+ attachment.itemAt(0) ;
+ fail("Expected DeferredDeserialisationException for unnamed attachment") ;
+ }
+ catch (final DeferredDeserialisationException dse) {}
+ }
+
+ private void validateNewBody(final Body body)
+ {
+ try
+ {
+ body.get() ;
+ fail("Expected DeferredDeserialisationException for body contents") ;
+ }
+ catch (final DeferredDeserialisationException dse) {}
+ }
+
+ private void validateNewProperties(final Properties properties)
+ {
+ try
+ {
+ properties.getProperty("testProperty") ;
+ fail("Expected DeferredDeserialisationException for named property") ;
+ }
+ catch (final DeferredDeserialisationException dse) {}
+ }
+
+ private Object deserialise(final String resource)
+ throws IOException, ClassNotFoundException
+ {
+ final InputStream is = getClass().getResourceAsStream(resource) ;
+ try
+ {
+ final ObjectInputStream ois = new ObjectInputStream(is) ;
+ return ois.readObject() ;
+ }
+ finally
+ {
+ is.close() ;
+ }
+ }
+
+ private String getContents(final String resource)
+ throws IOException
+ {
+ final InputStream is = getClass().getResourceAsStream(resource) ;
+ try
+ {
+ final InputStreamReader isr = new InputStreamReader(is) ;
+ final StringBuilder sb = new StringBuilder() ;
+ final char[] buffer = new char[256] ;
+ while(true)
+ {
+ final int count = isr.read(buffer) ;
+ if (count <= 0)
+ {
+ break ;
+ }
+ sb.append(buffer, 0, count) ;
+ }
+ return sb.toString();
+ }
+ finally
+ {
+ is.close() ;
+ }
+ }
+}
Property changes on: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/message/tests/DeserializedValuesMessageUnitTest.java
___________________________________________________________________
Name: svn:keywords
+ Rev Date
Name: svn:eol-style
+ native
Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/message/tests/FaultUnitTest.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/message/tests/FaultUnitTest.java 2007-12-17 04:48:50 UTC (rev 17274)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/message/tests/FaultUnitTest.java 2007-12-17 04:59:04 UTC (rev 17275)
@@ -26,12 +26,8 @@
import java.io.ByteArrayOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
-import java.io.StringWriter;
import java.net.URI;
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-
import junit.framework.TestCase;
import org.apache.log4j.Logger;
@@ -39,11 +35,8 @@
import org.jboss.soa.esb.message.Message;
import org.jboss.soa.esb.message.format.MessageFactory;
import org.jboss.soa.esb.message.format.MessageType;
-import org.w3c.dom.Document;
+import org.jboss.soa.esb.util.Util;
-import com.sun.org.apache.xml.internal.serialize.OutputFormat;
-import com.sun.org.apache.xml.internal.serialize.XMLSerializer;
-
/**
* Unit tests for the Class class.
*
@@ -111,31 +104,12 @@
assertEquals(msg.getFault().getCode(), code);
assertEquals(msg.getFault().getReason(), "because");
- DocumentBuilderFactory factory = DocumentBuilderFactory
- .newInstance();
- DocumentBuilder builder = factory.newDocumentBuilder();
- Document doc = builder.newDocument();
- org.jboss.internal.soa.esb.message.format.xml.MessageImpl theImpl = (org.jboss.internal.soa.esb.message.format.xml.MessageImpl) msg;
+ final String documentAsString = (String)Util.serialize(msg) ;
- doc = theImpl.toXML(doc);
-
- StringWriter sWriter = new StringWriter();
- OutputFormat format = new OutputFormat();
- format.setIndenting(true);
-
- XMLSerializer xmlS = new XMLSerializer(sWriter, format);
-
- xmlS.asDOMSerializer();
- xmlS.serialize(doc);
-
- String documentAsString = sWriter.toString();
-
- log.debug("Message looks like: " + documentAsString);
+ log.debug("Message looks like: " + documentAsString);
+
+ final Message nImpl = Util.deserialize(documentAsString);
- org.jboss.internal.soa.esb.message.format.xml.MessageImpl nImpl = new org.jboss.internal.soa.esb.message.format.xml.MessageImpl();
-
- nImpl.fromXML(doc);
-
assertEquals(nImpl.getFault().getReason(), "because");
}
catch (Exception ex)
Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/message/tests/PropertiesUnitTest.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/message/tests/PropertiesUnitTest.java 2007-12-17 04:48:50 UTC (rev 17274)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/message/tests/PropertiesUnitTest.java 2007-12-17 04:59:04 UTC (rev 17275)
@@ -27,16 +27,13 @@
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-
import junit.framework.TestCase;
import org.jboss.internal.soa.esb.message.format.serialized.MessageImpl;
import org.jboss.soa.esb.message.Message;
import org.jboss.soa.esb.message.format.MessageFactory;
import org.jboss.soa.esb.message.format.MessageType;
-import org.w3c.dom.Document;
+import org.jboss.soa.esb.util.Util;
/**
* Unit tests for the Class class.
@@ -136,19 +133,11 @@
try
{
- DocumentBuilderFactory factory = DocumentBuilderFactory
- .newInstance();
- DocumentBuilder builder = factory.newDocumentBuilder();
- Document doc = builder.newDocument();
- org.jboss.internal.soa.esb.message.format.xml.MessageImpl theImpl = (org.jboss.internal.soa.esb.message.format.xml.MessageImpl) msg;
+ final String documentAsString = (String)Util.serialize(msg) ;
- doc = theImpl.toXML(doc);
+ final Message nImpl = Util.deserialize(documentAsString);
- org.jboss.internal.soa.esb.message.format.xml.MessageImpl nImpl = new org.jboss.internal.soa.esb.message.format.xml.MessageImpl();
-
- nImpl.fromXML(doc);
-
- assertEquals(nImpl.getProperties().getProperty("foo"), "bar");
+ assertEquals(nImpl.getProperties().getProperty("foo"), "bar");
}
catch (Exception ex)
{
Added: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/message/tests/SerializedValueUnitTest.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/message/tests/SerializedValueUnitTest.java (rev 0)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/message/tests/SerializedValueUnitTest.java 2007-12-17 04:59:04 UTC (rev 17275)
@@ -0,0 +1,140 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.soa.esb.message.tests;
+
+import java.io.Serializable;
+
+import org.jboss.internal.soa.esb.message.format.serialized.SerializedValueImpl;
+
+import junit.framework.TestCase;
+
+/**
+ * Unit tests for checking serialised wrapping of values.
+ *
+ * @author <a href='mailto:kevin.conner at jboss.com'>Kevin Conner</a>
+ */
+
+public class SerializedValueUnitTest extends TestCase
+{
+ public void testObjectTypes()
+ {
+ // Objects
+ verifyEquality("Null value", null) ;
+ verifyEquality("Boolean type", Boolean.TRUE) ;
+ verifyEquality("Byte type", Byte.valueOf((byte)1)) ;
+ verifyEquality("Short type", Short.valueOf((short)2)) ;
+ verifyEquality("Character type", Character.valueOf((char)3)) ;
+ verifyEquality("Integer type", Integer.valueOf(4)) ;
+ verifyEquality("Long type", Long.valueOf(5)) ;
+ verifyEquality("Float type", Float.valueOf(6)) ;
+ verifyEquality("Double type", Double.valueOf(7)) ;
+ verifyEquality("String type", "8") ;
+ final SerializedValueImpl wrapped = (SerializedValueImpl)SerializedValueImpl.wrap(new NonNativeType()) ;
+ verifyEquality("Wrapped type", wrapped) ;
+ }
+
+ public void testBaseTypeArrays()
+ {
+ // base type arrays
+ verifyEquality("boolean array type", new boolean[] {true, false}) ;
+ verifyEquality("byte array type", new byte[] {0, 1}) ;
+ verifyEquality("short array type", new short[] {2, 3}) ;
+ verifyEquality("char array type", new char[] {4, 5}) ;
+ verifyEquality("int array type", new int[] {6, 7}) ;
+ verifyEquality("long array type", new long[] {8, 9}) ;
+ verifyEquality("float array type", new float[] {10, 11}) ;
+ verifyEquality("double array type", new double[] {12, 13}) ;
+ }
+
+ public void testBaseTypeNestedArrays()
+ {
+ // base type nested arrays
+ verifyEquality("boolean nested array type", new boolean[][] {{true, false}, {true, false}}) ;
+ verifyEquality("byte nested array type", new byte[][] {{0, 1}, {0, 1}}) ;
+ verifyEquality("short nested array type", new short[][] {{2, 3}, {2, 3}}) ;
+ verifyEquality("char nested array type", new char[][] {{4, 5}, {4, 5}}) ;
+ verifyEquality("int nested array type", new int[][] {{6, 7}, {6, 7}}) ;
+ verifyEquality("long nested array type", new long[][] {{8, 9}, {8, 9}}) ;
+ verifyEquality("float nested array type", new float[][] {{10, 11}, {10, 11}}) ;
+ verifyEquality("double nested array type", new double[][] {{12, 13}, {12, 13}}) ;
+ }
+
+ public void testObjectTypeArrays()
+ {
+ // object type arrays
+ verifyEquality("Boolean array type", new Boolean[] {Boolean.TRUE}) ;
+ verifyEquality("Byte array type", new Byte[] {Byte.valueOf((byte)1)}) ;
+ verifyEquality("Short array type", new Short[] {Short.valueOf((short)2)}) ;
+ verifyEquality("Character array type", new Character[] {Character.valueOf((char)3)}) ;
+ verifyEquality("Integer array type", new Integer[] {Integer.valueOf(4)}) ;
+ verifyEquality("Long array type", new Long[] {Long.valueOf(5)}) ;
+ verifyEquality("Float array type", new Float[] {Float.valueOf(6)}) ;
+ verifyEquality("Double array type", new Double[] {Double.valueOf(7)}) ;
+ verifyEquality("String array type", new String[] {"8"}) ;
+ final SerializedValueImpl wrapped = (SerializedValueImpl)SerializedValueImpl.wrap(new NonNativeType()) ;
+ verifyEquality("Wrapped type", new SerializedValueImpl[] {wrapped}) ;
+ }
+
+ public void testObjectTypeNestedArrays()
+ {
+ // object type nested arrays
+ verifyEquality("Boolean nested array type", new Boolean[][] {{Boolean.TRUE}, {Boolean.TRUE}}) ;
+ verifyEquality("Byte nested array type", new Byte[][] {{Byte.valueOf((byte)1)}, {Byte.valueOf((byte)1)}}) ;
+ verifyEquality("Short nested array type", new Short[][] {{Short.valueOf((short)2)}, {Short.valueOf((short)2)}}) ;
+ verifyEquality("Character nested array type", new Character[][] {{Character.valueOf((char)3)}, {Character.valueOf((char)3)}}) ;
+ verifyEquality("Integer nested array type", new Integer[][] {{Integer.valueOf(4)}, {Integer.valueOf(4)}}) ;
+ verifyEquality("Long nested array type", new Long[][] {{Long.valueOf(5)}, {Long.valueOf(5)}}) ;
+ verifyEquality("Float nested array type", new Float[][] {{Float.valueOf(6)}, {Float.valueOf(6)}}) ;
+ verifyEquality("Double nested array type", new Double[][] {{Double.valueOf(7)}, {Double.valueOf(7)}}) ;
+ verifyEquality("String nested array type", new String[][] {{"8"}, {"8"}}) ;
+ final SerializedValueImpl wrapped = (SerializedValueImpl)SerializedValueImpl.wrap(new NonNativeType()) ;
+ verifyEquality("Wrapped type", new SerializedValueImpl[][] {{wrapped}, {wrapped}}) ;
+ }
+
+ public void testNonNativeType()
+ {
+ verifyWrapped("Non-native type", new NonNativeType()) ;
+ }
+
+ private void verifyEquality(final String message, final Serializable value)
+ {
+ final Serializable serializable = SerializedValueImpl.wrap(value) ;
+ if (value != null)
+ {
+ assertNotNull(message, serializable) ;
+ }
+ assertEquals(message, value, serializable) ;
+ }
+
+ private void verifyWrapped(final String message, final Serializable value)
+ {
+ final Serializable serializable = SerializedValueImpl.wrap(value) ;
+ assertNotNull(message, serializable) ;
+ assertEquals(message, SerializedValueImpl.class, serializable.getClass()) ;
+ }
+
+ private class NonNativeType implements Serializable
+ {
+ private static final long serialVersionUID = 6703031480417642685L;
+ }
+}
Property changes on: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/message/tests/SerializedValueUnitTest.java
___________________________________________________________________
Name: svn:keywords
+ Rev Date
Name: svn:eol-style
+ native
Added: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/message/tests/new_attachment.ser
===================================================================
(Binary files differ)
Property changes on: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/message/tests/new_attachment.ser
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/message/tests/new_body.ser
===================================================================
(Binary files differ)
Property changes on: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/message/tests/new_body.ser
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/message/tests/new_message.ser
===================================================================
(Binary files differ)
Property changes on: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/message/tests/new_message.ser
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/message/tests/new_message.xml
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/message/tests/new_message.xml (rev 0)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/message/tests/new_message.xml 2007-12-17 04:59:04 UTC (rev 17275)
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Envelope>
+ <Header xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing"/>
+ <Context/>
+ <Body>
+ <Content>
+ <Key><![CDATA[b3JnLmpib3NzLnNvYS5lc2IubWVzc2FnZS5kZWZhdWx0RW50cnk=]]></Key>
+ <Value>
+ <marshalunmarshal>
+ <plugin-type>urn:xml/marshalunmarshal/plugin/serialization</plugin-type><![CDATA[rO0ABXNyABxrbnJjLnNlcmlhbGlzYXRpb24uQm9keVZhbHVlFUC+gJ5+pZsCAAB4cA==]]></marshalunmarshal>
+ </Value>
+ </Content>
+ </Body>
+ <Attachment>
+ <UnNamed><![CDATA[rO0ABXNyAB9rbnJjLnNlcmlhbGlzYXRpb24uVW5uYW1lZFZhbHVlR5i5iw0twBwCAAB4cA==]]></UnNamed>
+ <Named name="testAttribute"><![CDATA[rO0ABXNyAB1rbnJjLnNlcmlhbGlzYXRpb24uTmFtZWRWYWx1ZS3thWzi1Ho9AgAAeHA=]]></Named>
+ </Attachment>
+ <Properties>
+ <Property>
+ <Key><![CDATA[dGVzdFByb3BlcnR5]]></Key>
+ <Value><![CDATA[rO0ABXNyACBrbnJjLnNlcmlhbGlzYXRpb24uUHJvcGVydHlWYWx1ZYvcf2hIglUuAgAAeHA=]]></Value>
+ </Property>
+ </Properties>
+</Envelope>
Property changes on: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/message/tests/new_message.xml
___________________________________________________________________
Name: svn:mime-type
+ text/xml
Name: svn:keywords
+ Rev Date
Name: svn:eol-style
+ native
Added: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/message/tests/new_properties.ser
===================================================================
(Binary files differ)
Property changes on: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/message/tests/new_properties.ser
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/message/tests/old_attachment.ser
===================================================================
(Binary files differ)
Property changes on: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/message/tests/old_attachment.ser
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/message/tests/old_body.ser
===================================================================
(Binary files differ)
Property changes on: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/message/tests/old_body.ser
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/message/tests/old_message.ser
===================================================================
(Binary files differ)
Property changes on: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/message/tests/old_message.ser
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/message/tests/old_message.xml
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/message/tests/old_message.xml (rev 0)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/message/tests/old_message.xml 2007-12-17 04:59:04 UTC (rev 17275)
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Envelope>
+ <Header xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing"/>
+ <Context/>
+ <Body>
+ <Content>
+ <Key><![CDATA[b3JnLmpib3NzLnNvYS5lc2IubWVzc2FnZS5kZWZhdWx0RW50cnk=]]></Key>
+ <Value>
+ <marshalunmarshal>
+ <plugin-type>urn:xml/marshalunmarshal/plugin/serialization</plugin-type><![CDATA[rO0ABXQACkJvZHkgdmFsdWU=]]></marshalunmarshal>
+ </Value>
+ </Content>
+ </Body>
+ <Attachment>
+ <UnNamed><![CDATA[rO0ABXQADVVubmFtZWQgdmFsdWU=]]></UnNamed>
+ <Named name="testAttribute"><![CDATA[rO0ABXQAC05hbWVkIHZhbHVl]]></Named>
+ </Attachment>
+ <Properties>
+ <Property>
+ <Key><![CDATA[dGVzdFByb3BlcnR5]]></Key>
+ <Value><![CDATA[rO0ABXQADlByb3BlcnR5IHZhbHVl]]></Value>
+ </Property>
+ </Properties>
+</Envelope>
Property changes on: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/message/tests/old_message.xml
___________________________________________________________________
Name: svn:mime-type
+ text/xml
Name: svn:keywords
+ Rev Date
Name: svn:eol-style
+ native
Added: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/message/tests/old_properties.ser
===================================================================
(Binary files differ)
Property changes on: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/message/tests/old_properties.ser
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
More information about the jboss-svn-commits
mailing list