[jboss-svn-commits] JBL Code SVN: r6742 - in labs/jbossesb/trunk/product: core/rosetta/src/org/jboss/internal/soa/esb/message/format core/rosetta/src/org/jboss/internal/soa/esb/message/format/xml core/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/marshal core/rosetta/src/org/jboss/soa/esb core/rosetta/tests/src/org/jboss/soa/esb/message/tests etc/schemas/xml
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Wed Oct 11 07:35:55 EDT 2006
Author: mark.little at jboss.com
Date: 2006-10-11 07:35:43 -0400 (Wed, 11 Oct 2006)
New Revision: 6742
Added:
labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/marshal/
labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/marshal/MarshalUnmarshalManager.java
labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/marshal/MarshalUnmarshalPlugin.java
labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/marshal/SerializedMarshalUnmarshalPlugin.java
labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/soa/esb/UnmarshalException.java
Modified:
labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/message/format/MessageFactoryImpl.java
labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/BodyImpl.java
labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/FaultImpl.java
labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/MessageImpl.java
labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/soa/esb/MarshalException.java
labs/jbossesb/trunk/product/core/rosetta/tests/src/org/jboss/soa/esb/message/tests/AttachmentUnitTest.java
labs/jbossesb/trunk/product/etc/schemas/xml/message.xsd
Log:
Added plugin support for arbitrary object marshal/unmarshal.
Modified: labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/message/format/MessageFactoryImpl.java
===================================================================
--- labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/message/format/MessageFactoryImpl.java 2006-10-11 11:22:42 UTC (rev 6741)
+++ labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/message/format/MessageFactoryImpl.java 2006-10-11 11:35:43 UTC (rev 6742)
@@ -7,6 +7,7 @@
import org.jboss.internal.soa.esb.message.format.serialized.SerializedMessagePlugin;
import org.jboss.internal.soa.esb.message.format.xml.XMLMessagePlugin;
+import org.jboss.soa.esb.common.ModulePropertyManager;
import org.jboss.soa.esb.message.Message;
import org.jboss.soa.esb.message.format.MessageFactory;
import org.jboss.soa.esb.message.format.MessagePlugin;
@@ -58,7 +59,7 @@
* that we load and add to the list.
*/
- Properties properties = System.getProperties();
+ Properties properties = ModulePropertyManager.getPropertyManager(ModulePropertyManager.CORE_MODULE).getProperties();
if (properties != null)
{
Modified: labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/BodyImpl.java
===================================================================
--- labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/BodyImpl.java 2006-10-11 11:22:42 UTC (rev 6741)
+++ labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/BodyImpl.java 2006-10-11 11:35:43 UTC (rev 6742)
@@ -4,7 +4,10 @@
import java.util.Enumeration;
import java.util.Hashtable;
+import org.jboss.internal.soa.esb.message.format.xml.marshal.MarshalUnmarshalManager;
import org.jboss.internal.soa.esb.thirdparty.Base64;
+import org.jboss.soa.esb.MarshalException;
+import org.jboss.soa.esb.UnmarshalException;
import org.jboss.soa.esb.message.Body;
import org.w3c.dom.CDATASection;
import org.w3c.dom.Document;
@@ -38,153 +41,151 @@
public class BodyImpl implements Body
{
- public static final String BODY_TAG = "Body";
+ public static final String BODY_TAG = "Body";
+
public static final String BYTES_TAG = "Bytes";
-
- public BodyImpl ()
+
+ public BodyImpl()
{
_content = null;
_objects = new Hashtable<String, Object>();
}
-
- public void add (String name, Object value)
+
+ public void add(String name, Object value)
{
if ((name == null) || (value == null))
throw new IllegalArgumentException();
-
- if (value instanceof Serializable)
+
+ synchronized (_objects)
{
- synchronized (_objects)
- {
- _objects.put(name, value);
- }
+ _objects.put(name, value);
}
- else
- throw new IllegalArgumentException("Object must be Serializable in this release.");
}
-
- public Object get (String name)
+
+ public Object get(String name)
{
synchronized (_objects)
{
return _objects.get(name);
}
}
-
- public Object remove (String name)
+
+ public Object remove(String name)
{
synchronized (_objects)
{
return _objects.remove(name);
}
}
-
- public Element toXML (Element envelope)
+
+ public Element toXML(Element envelope) throws MarshalException
{
Document doc = envelope.getOwnerDocument();
Element bodyElement = doc.createElement(BODY_TAG);
-
+
envelope.appendChild(bodyElement);
-
+
if (_content != null)
{
Element byteElement = doc.createElement(BYTES_TAG);
-
- byteElement.appendChild(doc.createCDATASection(Base64.encodeBytes(_content)));
-
+
+ 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(key);
-
- // we already checked values are Serializable when they were added.
-
- objElement.appendChild(doc.createCDATASection(Base64.encodeObject((Serializable) value)));
-
- bodyElement.appendChild(objElement);
+
+ if (MarshalUnmarshalManager.getInstance().marshal(objElement, value))
+ bodyElement.appendChild(objElement);
+ else
+ throw new MarshalException("Cannot pack object "+key);
}
-
-
+
return bodyElement;
}
-
- public void fromXML (Element envelope)
+
+ public void fromXML(Element envelope) throws UnmarshalException
{
NodeList nl = envelope.getChildNodes();
-
+
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.
+ * 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++)
{
Element child = (Element) children.item(j);
-
- // treat bytes specially.
- CDATASection cdata = (CDATASection) child.getFirstChild();
-
+
if (child.getNodeName().equals(BYTES_TAG))
{
+ CDATASection cdata = (CDATASection) child.getFirstChild();
+
_content = Base64.decode(cdata.getWholeText());
}
else
{
- Object value = Base64.decodeToObject(cdata.getWholeText());
+ Object value = MarshalUnmarshalManager.getInstance().unmarshal((Element) child.getFirstChild());
- _objects.put(child.getNodeName(), value);
+ if (value == null)
+ throw new UnmarshalException("Cannot unpack object "+child.getNodeName());
+ else
+ _objects.put(child.getNodeName(), value);
}
}
}
}
}
-
- public void setContents (byte[] content)
+
+ public void setContents(byte[] content)
{
_content = content;
}
- public byte[] getContents ()
+ public byte[] getContents()
{
return _content;
}
-
- public void replace (Body b)
+
+ public void replace(Body b)
{
if (b == null)
throw new IllegalArgumentException();
-
+
setContents(b.getContents());
-
+
_objects = ((BodyImpl) b)._objects;
}
-
- public void merge (Body b)
+
+ public void merge(Body b)
{
if (b == null)
throw new IllegalArgumentException();
-
+
byte[] toAdd = b.getContents();
-
+
if ((toAdd != null) && (toAdd.length > 0))
{
if ((_content == null) || (_content.length == 0))
@@ -192,21 +193,23 @@
_content = toAdd;
}
else
- {
+ {
int newSize = _content.length + toAdd.length;
byte[] buffer = new byte[newSize];
-
+
System.arraycopy(_content, 0, buffer, 0, _content.length);
- System.arraycopy(toAdd, 0, buffer, _content.length, toAdd.length);
-
+ System.arraycopy(toAdd, 0, buffer, _content.length,
+ toAdd.length);
+
_content = buffer;
}
}
-
+
_objects.putAll(((BodyImpl) b)._objects);
}
-
+
private byte[] _content;
+
private Hashtable<String, Object> _objects;
-
+
}
\ No newline at end of file
Modified: labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/FaultImpl.java
===================================================================
--- labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/FaultImpl.java 2006-10-11 11:22:42 UTC (rev 6741)
+++ labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/FaultImpl.java 2006-10-11 11:35:43 UTC (rev 6742)
@@ -62,37 +62,34 @@
Document doc = envelope.getOwnerDocument();
Element faultElement = doc.createElement(FAULT_TAG);
- envelope.appendChild(faultElement);
-
if (_code != null)
{
- //Attr codeElement = doc.createAttribute(CODE_TAG);
-
Element codeElement = doc.createElement(CODE_TAG);
Text content = doc.createTextNode(_code.toString());
codeElement.appendChild(content);
faultElement.appendChild(codeElement);
-
- //faultElement.setAttributeNode(codeElement);
}
if (_reason != null)
{
- //Attr reasonElement = doc.createAttribute(REASON_TAG);
-
Element reasonElement = doc.createElement(REASON_TAG);
Text content = doc.createTextNode(_reason);
reasonElement.appendChild(content);
faultElement.appendChild(reasonElement);
-
- //faultElement.setAttributeNode(reasonElement);
}
- return faultElement;
+ if ((_code != null) || (_reason != null))
+ {
+ envelope.appendChild(faultElement);
+
+ return faultElement;
+ }
+ else
+ return envelope;
}
public void fromXML (Element envelope)
@@ -132,7 +129,6 @@
}
private URI _code = null;
-
private String _reason = null;
}
\ No newline at end of file
Modified: labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/MessageImpl.java
===================================================================
--- labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/MessageImpl.java 2006-10-11 11:22:42 UTC (rev 6741)
+++ labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/MessageImpl.java 2006-10-11 11:35:43 UTC (rev 6742)
@@ -57,7 +57,7 @@
*
*/
-public class MessageImpl implements Message // also implement XmlSerializable ?
+public class MessageImpl implements Message
{
public static final String ENVELOPE_TAG = "Envelope";
Added: labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/marshal/MarshalUnmarshalManager.java
===================================================================
--- labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/marshal/MarshalUnmarshalManager.java 2006-10-11 11:22:42 UTC (rev 6741)
+++ labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/marshal/MarshalUnmarshalManager.java 2006-10-11 11:35:43 UTC (rev 6742)
@@ -0,0 +1,160 @@
+package org.jboss.internal.soa.esb.message.format.xml.marshal;
+
+import java.net.URI;
+import java.util.Enumeration;
+import java.util.Hashtable;
+import java.util.Properties;
+
+import org.jboss.soa.esb.MarshalException;
+import org.jboss.soa.esb.UnmarshalException;
+import org.jboss.soa.esb.common.ModulePropertyManager;
+import org.jboss.soa.esb.message.format.MessagePlugin;
+import org.w3c.dom.Element;
+
+/*
+ * 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
+ */
+
+/**
+ * Used to plug in new Object marshal/unmarshal formats dynamically. When packing
+ * objects in XML, the system runs through the list of registered plug-ins until it
+ * finds one that can deal with the object type (or faults). When packing, the name (type)
+ * of the plug-in that packed the object is also attached to facilitate unpacking.
+ *
+ * @author Mark Little
+ *
+ */
+
+public class MarshalUnmarshalManager
+{
+ public static MarshalUnmarshalManager getInstance ()
+ {
+ return _instance;
+ }
+
+ private MarshalUnmarshalManager ()
+ {
+ /*
+ * Go through the properties loaded from the property file. Anything
+ * starting with MessagePlugin.MESSAGE_PLUGIN is assumed to be a plugin
+ * that we load and add to the list.
+ */
+
+ Properties properties = ModulePropertyManager.getPropertyManager(ModulePropertyManager.CORE_MODULE).getProperties();
+
+ if (properties != null)
+ {
+ Enumeration names = properties.propertyNames();
+
+ while (names.hasMoreElements())
+ {
+ String attrName = (String) names.nextElement();
+
+ if (attrName.startsWith(MarshalUnmarshalPlugin.MARSHAL_UNMARSHAL_PLUGIN))
+ {
+ try
+ {
+ String pluginName = properties.getProperty(attrName);
+ Class c = Class.forName(pluginName);
+ MarshalUnmarshalPlugin thePlugin = (MarshalUnmarshalPlugin) c.newInstance();
+
+ _plugins.put(thePlugin.type(), thePlugin);
+ }
+ catch (ClassNotFoundException ex)
+ {
+ ex.printStackTrace();
+ }
+ catch (IllegalAccessException ex)
+ {
+ ex.printStackTrace();
+ }
+ catch (InstantiationException ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+ }
+
+ /*
+ * Add in the default plugin.
+ */
+
+ SerializedMarshalUnmarshalPlugin defaultPlugin = new SerializedMarshalUnmarshalPlugin();
+
+ _plugins.put(defaultPlugin.type(), defaultPlugin);
+ }
+ }
+
+ /**
+ * 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.
+ */
+
+ public boolean marshal (Element doc, Object param) throws MarshalException
+ {
+ Enumeration<URI> keys = _plugins.keys();
+
+ while (keys.hasMoreElements())
+ {
+ if (_plugins.get(keys.nextElement()).marshal(doc, param))
+ return true;
+ }
+
+ return false;
+ }
+
+ /**
+ * 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
+ {
+ Enumeration<URI> keys = _plugins.keys();
+
+ while (keys.hasMoreElements())
+ {
+ URI uri = keys.nextElement();
+
+ System.err.println("**comparing "+doc.getNodeName()+" and "+uri.toString());
+
+ if (doc.getNodeName().equals(uri.toString()))
+ {
+ return _plugins.get(uri).unmarshal(doc);
+ }
+ }
+
+ return null;
+ }
+
+ private Hashtable<URI,MarshalUnmarshalPlugin> _plugins = new Hashtable<URI,MarshalUnmarshalPlugin>();
+
+ private static final MarshalUnmarshalManager _instance = new MarshalUnmarshalManager();
+}
Added: labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/marshal/MarshalUnmarshalPlugin.java
===================================================================
--- labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/marshal/MarshalUnmarshalPlugin.java 2006-10-11 11:22:42 UTC (rev 6741)
+++ labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/marshal/MarshalUnmarshalPlugin.java 2006-10-11 11:35:43 UTC (rev 6742)
@@ -0,0 +1,73 @@
+package org.jboss.internal.soa.esb.message.format.xml.marshal;
+
+import java.net.URI;
+
+import org.jboss.soa.esb.MarshalException;
+import org.jboss.soa.esb.UnmarshalException;
+import org.w3c.dom.Element;
+
+/*
+ * 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
+ */
+
+/**
+ * Used to plug in new Object marshal/unmarshal formats dynamically. When packing
+ * objects in XML, the system runs through the list of registered plug-ins until it
+ * finds one that can deal with the object type (or faults). When packing, the name (type)
+ * of the plug-in that packed the object is also attached to facilitate unpacking.
+ *
+ * @author Mark Little
+ *
+ */
+
+public interface MarshalUnmarshalPlugin
+{
+ public static final String MARSHAL_UNMARSHAL_PLUGIN = "org.jboss.soa.esb.message.format.xml.plugin";
+
+ /**
+ * 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.
+ */
+
+ public boolean marshal (Element doc, Object param) throws MarshalException;
+
+ /**
+ * 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;
+
+ /**
+ * @return the unique name for this plugin.
+ */
+
+ public URI type ();
+}
Added: labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/marshal/SerializedMarshalUnmarshalPlugin.java
===================================================================
--- labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/marshal/SerializedMarshalUnmarshalPlugin.java 2006-10-11 11:22:42 UTC (rev 6741)
+++ labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/marshal/SerializedMarshalUnmarshalPlugin.java 2006-10-11 11:35:43 UTC (rev 6742)
@@ -0,0 +1,126 @@
+package org.jboss.internal.soa.esb.message.format.xml.marshal;
+
+import java.io.Serializable;
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import org.jboss.internal.soa.esb.thirdparty.Base64;
+import org.jboss.soa.esb.MarshalException;
+import org.jboss.soa.esb.UnmarshalException;
+import org.w3c.dom.CDATASection;
+import org.w3c.dom.Element;
+
+/*
+ * 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
+ */
+
+/**
+ * Used to plug in new Object marshal/unmarshal formats dynamically. When packing
+ * objects in XML, the system runs through the list of registered plug-ins until it
+ * finds one that can deal with the object type (or faults). When packing, the name (type)
+ * of the plug-in that packed the object is also attached to facilitate unpacking.
+ *
+ * @author Mark Little
+ *
+ */
+
+public class SerializedMarshalUnmarshalPlugin implements MarshalUnmarshalPlugin
+{
+ public SerializedMarshalUnmarshalPlugin ()
+ {
+ try
+ {
+ _type = new URI("urn:xml:marshalunmarshal:plugin:serialization");
+ }
+ catch (URISyntaxException ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+
+ /**
+ * 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.
+ */
+
+ public boolean marshal (Element doc, Object param) throws MarshalException
+ {
+ if (param instanceof Serializable)
+ {
+ // we can deal with this type!
+
+ try
+ {
+ Element nodeElement = doc.getOwnerDocument().createElement(type().toString());
+
+ nodeElement.appendChild(doc.getOwnerDocument().createCDATASection(Base64.encodeObject((Serializable) param)));
+
+ doc.appendChild(nodeElement);
+ }
+ catch (Exception ex)
+ {
+ throw new MarshalException(ex.toString());
+ }
+
+ return true;
+ }
+ else
+ return false;
+ }
+
+ /**
+ * 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
+ {
+ if (doc.getNodeName().equals(type().toString()))
+ {
+ CDATASection cdata = (CDATASection) doc.getFirstChild();
+
+ return Base64.decodeToObject(cdata.getWholeText());
+ }
+ else
+ return null;
+ }
+
+ /**
+ * @return the unique name for this plugin.
+ */
+
+ public URI type ()
+ {
+ return _type;
+ }
+
+ private URI _type = null;
+
+}
Modified: labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/soa/esb/MarshalException.java
===================================================================
--- labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/soa/esb/MarshalException.java 2006-10-11 11:22:42 UTC (rev 6741)
+++ labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/soa/esb/MarshalException.java 2006-10-11 11:35:43 UTC (rev 6742)
@@ -21,6 +21,9 @@
* @author mark.little at jboss.com
*/
+/**
+ * Thrown if marshalling failed.
+ */
public class MarshalException extends Exception
{
Added: labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/soa/esb/UnmarshalException.java
===================================================================
--- labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/soa/esb/UnmarshalException.java 2006-10-11 11:22:42 UTC (rev 6741)
+++ labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/soa/esb/UnmarshalException.java 2006-10-11 11:35:43 UTC (rev 6742)
@@ -0,0 +1,42 @@
+package org.jboss.soa.esb;
+
+/*
+ * 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
+ */
+
+/**
+ * Thrown if unmarshalling failed.
+ */
+
+public class UnmarshalException extends Exception
+{
+ public static final long serialVersionUID = 0xE;
+
+ public UnmarshalException()
+ {
+ super();
+ }
+
+ public UnmarshalException(String s)
+ {
+ super(s);
+ }
+
+}
Modified: labs/jbossesb/trunk/product/core/rosetta/tests/src/org/jboss/soa/esb/message/tests/AttachmentUnitTest.java
===================================================================
--- labs/jbossesb/trunk/product/core/rosetta/tests/src/org/jboss/soa/esb/message/tests/AttachmentUnitTest.java 2006-10-11 11:22:42 UTC (rev 6741)
+++ labs/jbossesb/trunk/product/core/rosetta/tests/src/org/jboss/soa/esb/message/tests/AttachmentUnitTest.java 2006-10-11 11:35:43 UTC (rev 6742)
@@ -198,6 +198,8 @@
}
catch (Exception ex)
{
+ ex.printStackTrace();
+
fail(ex.toString());
}
}
Modified: labs/jbossesb/trunk/product/etc/schemas/xml/message.xsd
===================================================================
--- labs/jbossesb/trunk/product/etc/schemas/xml/message.xsd 2006-10-11 11:22:42 UTC (rev 6741)
+++ labs/jbossesb/trunk/product/etc/schemas/xml/message.xsd 2006-10-11 11:35:43 UTC (rev 6742)
@@ -1,4 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
+<!-- Work in progress. Treat it as such. -->
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:wsa="common/ws-addr.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:complexType name="Header">
<xs:sequence>
More information about the jboss-svn-commits
mailing list