[jboss-svn-commits] JBL Code SVN: r9843 - in labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss: internal/soa/esb/message/format/xml and 1 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Wed Feb 28 11:07:13 EST 2007


Author: mark.little at jboss.com
Date: 2007-02-28 11:07:13 -0500 (Wed, 28 Feb 2007)
New Revision: 9843

Modified:
   labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/format/serialized/AttachmentImpl.java
   labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/format/serialized/BodyImpl.java
   labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/format/serialized/ContextImpl.java
   labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/format/serialized/HeaderImpl.java
   labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/format/serialized/PropertiesImpl.java
   labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/format/xml/AttachmentImpl.java
   labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/format/xml/BodyImpl.java
   labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/format/xml/ContextImpl.java
   labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/format/xml/HeaderImpl.java
   labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/format/xml/PropertiesImpl.java
   labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/message/Attachment.java
   labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/message/Body.java
   labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/message/Context.java
   labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/message/Header.java
   labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/message/Properties.java
Log:
Added set via Maps.

Modified: labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/format/serialized/AttachmentImpl.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/format/serialized/AttachmentImpl.java	2007-02-28 15:56:58 UTC (rev 9842)
+++ labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/format/serialized/AttachmentImpl.java	2007-02-28 16:07:13 UTC (rev 9843)
@@ -35,7 +35,7 @@
  * @author Mark Little
  */
 
-public class AttachmentImpl implements Attachment, java.io.Serializable
+public class AttachmentImpl extends Attachment implements java.io.Serializable
 {
 	private static final long serialVersionUID = 0x0;
 

Modified: labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/format/serialized/BodyImpl.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/format/serialized/BodyImpl.java	2007-02-28 15:56:58 UTC (rev 9842)
+++ labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/format/serialized/BodyImpl.java	2007-02-28 16:07:13 UTC (rev 9843)
@@ -31,7 +31,7 @@
  * This implementation requires that all contents are serializable.
  */
 
-public class BodyImpl implements Body, java.io.Serializable
+public class BodyImpl extends Body implements java.io.Serializable
 {
 	private static final long serialVersionUID = 0x0;
 	

Modified: labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/format/serialized/ContextImpl.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/format/serialized/ContextImpl.java	2007-02-28 15:56:58 UTC (rev 9842)
+++ labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/format/serialized/ContextImpl.java	2007-02-28 16:07:13 UTC (rev 9843)
@@ -23,7 +23,7 @@
  * @author mark.little at jboss.com
  */
 
-public class ContextImpl implements Context, java.io.Serializable
+public class ContextImpl extends Context implements java.io.Serializable
 {
 	private static final long serialVersionUID = 0x0;
 }
\ No newline at end of file

Modified: labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/format/serialized/HeaderImpl.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/format/serialized/HeaderImpl.java	2007-02-28 15:56:58 UTC (rev 9842)
+++ labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/format/serialized/HeaderImpl.java	2007-02-28 16:07:13 UTC (rev 9843)
@@ -47,7 +47,7 @@
  * The message header. Contains such things as routing information.
  */
 
-public class HeaderImpl implements Header, Serializable
+public class HeaderImpl extends Header implements Serializable
 {
 	private static final long serialVersionUID = 0x0;
 	

Modified: labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/format/serialized/PropertiesImpl.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/format/serialized/PropertiesImpl.java	2007-02-28 15:56:58 UTC (rev 9842)
+++ labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/format/serialized/PropertiesImpl.java	2007-02-28 16:07:13 UTC (rev 9843)
@@ -26,7 +26,7 @@
 
 import org.jboss.soa.esb.message.Properties;
 
-public class PropertiesImpl implements Properties, Serializable
+public class PropertiesImpl extends Properties implements Serializable
 {
 	private static final long serialVersionUID = 0x0;
 

Modified: labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/format/xml/AttachmentImpl.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/format/xml/AttachmentImpl.java	2007-02-28 15:56:58 UTC (rev 9842)
+++ labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/format/xml/AttachmentImpl.java	2007-02-28 16:07:13 UTC (rev 9843)
@@ -43,7 +43,7 @@
  * @author Mark Little
  */
 
-public class AttachmentImpl implements Attachment, java.io.Serializable
+public class AttachmentImpl extends Attachment implements java.io.Serializable
 {
 	public static final String ATTACHMENT_TAG = "Attachment";
 	public static final String NAME_ATTR = "name";

Modified: labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/format/xml/BodyImpl.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/format/xml/BodyImpl.java	2007-02-28 15:56:58 UTC (rev 9842)
+++ labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/format/xml/BodyImpl.java	2007-02-28 16:07:13 UTC (rev 9843)
@@ -12,7 +12,6 @@
 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;
 
 /*
@@ -40,7 +39,7 @@
  * A Body implementation that serializes to XML.
  */
 
-public class BodyImpl implements Body
+public class BodyImpl extends Body
 {
 	public static final String BODY_TAG = "Body";
 

Modified: labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/format/xml/ContextImpl.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/format/xml/ContextImpl.java	2007-02-28 15:56:58 UTC (rev 9842)
+++ labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/format/xml/ContextImpl.java	2007-02-28 16:07:13 UTC (rev 9843)
@@ -27,7 +27,7 @@
  * @author mark.little at jboss.com
  */
 
-public class ContextImpl implements Context
+public class ContextImpl extends Context
 {
     public static final String CONTEXT_TAG = "Context";
     

Modified: labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/format/xml/HeaderImpl.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/format/xml/HeaderImpl.java	2007-02-28 15:56:58 UTC (rev 9842)
+++ labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/format/xml/HeaderImpl.java	2007-02-28 16:07:13 UTC (rev 9843)
@@ -35,7 +35,7 @@
  * The message header. Contains such things as routing information.
  */
 
-public class HeaderImpl implements Header
+public class HeaderImpl extends Header
 {
     public static final String HEADER_TAG = "Header";
     

Modified: labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/format/xml/PropertiesImpl.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/format/xml/PropertiesImpl.java	2007-02-28 15:56:58 UTC (rev 9842)
+++ labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/format/xml/PropertiesImpl.java	2007-02-28 16:07:13 UTC (rev 9843)
@@ -34,7 +34,7 @@
 import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
 
-public class PropertiesImpl implements Properties
+public class PropertiesImpl extends Properties
 {
 	public static final String PROPERTIES_TAG = "Properties";
 

Modified: labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/message/Attachment.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/message/Attachment.java	2007-02-28 15:56:58 UTC (rev 9842)
+++ labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/message/Attachment.java	2007-02-28 16:07:13 UTC (rev 9843)
@@ -1,5 +1,14 @@
 package org.jboss.soa.esb.message;
 
+import java.net.URI;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+import org.jboss.soa.esb.addressing.Call;
+import org.jboss.soa.esb.addressing.EPR;
+import org.jboss.soa.esb.addressing.XMLUtil;
+
 /*
  * JBoss, Home of Professional Open Source
  * Copyright 2006, JBoss Inc., and others contributors as indicated 
@@ -29,15 +38,48 @@
  * @author Mark Little
  */
 
-public interface Attachment
+public abstract class Attachment
 {
 	/**
+	 * Populate the header.
+	 * 
+	 * @param contents the values to populate.
+	 */
+	
+	public void setContents (Map<String, Object> contents)
+	{
+		if (contents == null)
+			throw new IllegalArgumentException();
+		
+		Set<String> keys = contents.keySet();
+		
+		try
+		{
+			if (keys != null)
+			{
+				Iterator<String> iter = keys.iterator();
+				
+				while (iter.hasNext())
+				{
+					String value = iter.next();
+					
+					put(value, contents.get(value));
+				}
+			}
+		}
+		catch (ClassCastException ex)
+		{
+			throw new IllegalArgumentException(ex.toString());
+		}
+	}
+	
+	/**
 	 * Returns the attachment to which this object maps the specified key. 
 	 * Returns null if the there's no value mapped for this key.
 	 * @param name String - The name of the attachment to get
 	 * @return Object - the value mapped to arg0 or &lt;null&gt; if none
 	 */
-	Object get(String name);
+	public abstract Object get(String name);
 	/**
 	 * Associates the specified value with the specified name
 	 * If there was already a mapping for this name, the old value is replaced by 
@@ -47,17 +89,17 @@
 	 * @return Object - previous value associated with specified name,
 	 * or null  if there was none
 	 */
-	Object put(String name, Object value);
+	public abstract Object put(String name, Object value);
 	/**
 	 * Removes the mapping for this name if it was present
 	 * @param name String - the name of the object to be removed
 	 * @return the value previously associated the name, or null if there was none
 	 */
-	Object remove(String name);
+	public abstract Object remove(String name);
 	/**
 	 * @return String[] - the list of names of the named Objects
 	 */
-	String[] getNames();
+	public abstract String[] getNames();
 
 	/**
      * get the item at the specified position in the list of unnamed objects
@@ -65,7 +107,7 @@
      * @return Object the element at the specified position in the list of unnamed objects
      * @throws IndexOutOfBoundsException - if the index is out of range
      */
-	Object itemAt 		(int index) throws IndexOutOfBoundsException;
+	public abstract Object itemAt 		(int index) throws IndexOutOfBoundsException;
 	/**
 	 * Removes the element at the specified position in the list of unnamed objects
 	 * Shifts any subsequent elements to the left 
@@ -73,7 +115,7 @@
 	 * @return Object - the element that was removed from the list
 	 * @throws IndexOutOfBoundsException - if the index is out of range
 	 */
-	Object removeItemAt	(int index) throws IndexOutOfBoundsException;
+	public abstract Object removeItemAt	(int index) throws IndexOutOfBoundsException;
 	/**
 	 * Replaces the element at the specified position in the list of unnamed objects 
 	 * with the value supplied
@@ -82,13 +124,13 @@
 	 * @return Object - previous value at that index
 	 * @throws IndexOutOfBoundsException - if the index is out of range
 	 */
-	Object replaceItemAt(int index, Object value) throws IndexOutOfBoundsException;
+	public abstract Object replaceItemAt(int index, Object value) throws IndexOutOfBoundsException;
 	/**
 	 * Appends the specified element to the end of the list of unnamed objects
 	 * <br/>null values are allowed 
 	 * @param value Object - the object to be appended
 	 */
-	void addItem		(Object value);
+	public abstract void addItem		(Object value);
 	/**
 	 * Replaces the element at the specified position in the list of unnamed objects
 	 * <br/> allows null values
@@ -96,15 +138,15 @@
 	 * @param value Object - value to be stored at the specified position
 	 * @throws IndexOutOfBoundsException
 	 */
-	void addItemAt	(int index, Object value) throws IndexOutOfBoundsException;
+	public abstract void addItemAt	(int index, Object value) throws IndexOutOfBoundsException;
 	/**
 	 * getUnnamedCount()
 	 * @return the count of unnamed objects
 	 */
-	int	getUnnamedCount();
+	public abstract int	getUnnamedCount();
 	/**
 	 * getNamedCount()
 	 * @return the count of named objects
 	 */
-	public int getNamedCount(); 
+	public abstract int getNamedCount(); 
 }

Modified: labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/message/Body.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/message/Body.java	2007-02-28 15:56:58 UTC (rev 9842)
+++ labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/message/Body.java	2007-02-28 16:07:13 UTC (rev 9843)
@@ -1,5 +1,14 @@
 package org.jboss.soa.esb.message;
 
+import java.net.URI;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+import org.jboss.soa.esb.addressing.Call;
+import org.jboss.soa.esb.addressing.EPR;
+import org.jboss.soa.esb.addressing.XMLUtil;
+
 /*
  * JBoss, Home of Professional Open Source
  * Copyright 2006, JBoss Inc., and others contributors as indicated 
@@ -36,8 +45,50 @@
  * Currently we only support Serializable objects.
  */
 
-public interface Body
+public abstract class Body
 {
+	public static String BYTES = "bytes";
+	
+	/**
+	 * Populate the header.
+	 * 
+	 * @param contents the values to populate.
+	 */
+	
+	public void setContents (Map<String, Object> contents)
+	{
+		if (contents == null)
+			throw new IllegalArgumentException();
+		
+		Set<String> keys = contents.keySet();
+		
+		try
+		{
+			if (keys != null)
+			{
+				Iterator<String> iter = keys.iterator();
+
+				while (iter.hasNext())
+				{
+					String value = iter.next();
+					
+					if (value.equals(BYTES))
+					{
+						addBytes((byte[]) contents.get(value));
+					}
+					else
+					{
+						add(value, contents.get(value));
+					}
+				}
+			}
+		}
+		catch (ClassCastException ex)
+		{
+			throw new IllegalArgumentException(ex.toString());
+		}
+	}
+	
 	// TODO error handling exceptions
 	
 	/**
@@ -47,7 +98,7 @@
 	 * @param value the Object to add.
 	 */
 	
-	public void add (String name, Object value);
+	public abstract void add (String name, Object value);
 	
 	/**
 	 * Get the specified Object, or <code>null</code> if not present.
@@ -56,7 +107,7 @@
 	 * @return the Object.
 	 */
 	
-	public Object get (String name);
+	public abstract Object get (String name);
 	
 	/**
 	 * Remove the specified Object and return it, or <code>null</code> if not present.
@@ -65,7 +116,7 @@
 	 * @return the Object removed.
 	 */
 	
-	public Object remove (String name);
+	public abstract Object remove (String name);
 	
 	/**
 	 * Set the byte content of the body.
@@ -73,13 +124,13 @@
 	 * @param content the message bytes
 	 */
 	
-	public void addBytes (byte[] content);
+	public abstract void addBytes (byte[] content);
 	
 	/**
 	 * @return the byte content of the body.
 	 */
 	
-	public byte[] getBytes ();
+	public abstract byte[] getBytes ();
 
 	/**
 	 * Replace this body instance with the one given.
@@ -87,7 +138,7 @@
 	 * @param b the body to be replaced with.
 	 */
 	
-	public void replace (Body b);
+	public abstract void replace (Body b);
 	
 	/**
 	 * Merge two bodies.
@@ -95,13 +146,13 @@
 	 * @param b the body to be merged with.
 	 */
 	
-	public void merge (Body b);
+	public abstract void merge (Body b);
 	
 	/**
 	 * @return get the list of names in this instance.
 	 */
 	
-	public String[] getNames ();
+	public abstract String[] getNames ();
 	
 	// TODO replace an entry in the body
 

Modified: labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/message/Context.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/message/Context.java	2007-02-28 15:56:58 UTC (rev 9842)
+++ labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/message/Context.java	2007-02-28 16:07:13 UTC (rev 9843)
@@ -1,5 +1,7 @@
 package org.jboss.soa.esb.message;
 
+import java.util.Map;
+
 /*
  * JBoss, Home of Professional Open Source
  * Copyright 2006, JBoss Inc., and others contributors as indicated 
@@ -27,7 +29,18 @@
  * may be ordered.
  */
 
-public interface Context
+public abstract class Context
 {
 	// TODO add some methods!
+	
+	/**
+	 * Populate the header.
+	 * 
+	 * @param contents the values to populate.
+	 */
+	
+	public void setContents (Map<String, Object> contents)
+	{
+	}
+	
 }
\ No newline at end of file

Modified: labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/message/Header.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/message/Header.java	2007-02-28 15:56:58 UTC (rev 9842)
+++ labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/message/Header.java	2007-02-28 16:07:13 UTC (rev 9843)
@@ -21,19 +21,126 @@
  * @author mark.little at jboss.com
  */
 
+import java.net.URI;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
 import org.jboss.soa.esb.addressing.Call;
+import org.jboss.soa.esb.addressing.EPR;
+import org.jboss.soa.esb.addressing.XMLUtil;
 
 /**
  * The message header. Contains such things as routing information.
  */
 
-public interface Header
+public abstract class Header
 {
 	/**
+	 * Populate the header.
+	 * 
+	 * @param contents the values to populate.
+	 */
+	
+	/**
+	 * Populate the header.
+	 * 
+	 * @param contents the values to populate.
+	 */
+	
+	public void setContents (Map<String, Object> contents)
+	{
+		if (contents == null)
+			throw new IllegalArgumentException();
+		
+		Set<String> keys = contents.keySet();
+		
+		try
+		{
+			if (keys != null)
+			{
+				Iterator<String> iter = keys.iterator();
+				Call theCall = null;
+				
+				if (theCall == null)
+					theCall = new Call();
+				
+				while (iter.hasNext())
+				{
+					String value = iter.next();
+					boolean found = false;
+					
+					if (value.equals(XMLUtil.ACTION_TAG))
+					{
+						theCall.setAction((URI) contents.get(value));
+						found = true;
+					}
+					else
+					{
+						if (value.equals(XMLUtil.FAULT_TO_TAG))
+						{
+							theCall.setFaultTo((EPR) contents.get(value));
+							found = true;
+						}
+						else
+						{
+							if (value.equals(XMLUtil.TO_TAG))
+							{
+								theCall.setTo((EPR) contents.get(value));
+								found = true;
+							}
+							else
+							{
+								if (value.equals(XMLUtil.REPLY_TO_TAG))
+								{
+									theCall.setReplyTo((EPR) contents.get(value));
+									found = true;
+								}
+								else
+								{
+									if (value.equals(XMLUtil.FROM_TAG))
+									{
+										theCall.setFrom((EPR) contents.get(value));
+										found = true;
+									}
+									else
+									{
+										if (value.equals(XMLUtil.MESSAGE_IDENTIFIER_TAG))
+										{
+											theCall.setMessageID((URI) contents.get(value));
+											found = true;
+										}
+										else
+										{
+											if (value.equals(XMLUtil.RELATES_TO_TAG))
+											{
+												theCall.setRelatesTo((URI) contents.get(value));
+												found = true;
+											}
+										}
+									}
+								}
+							}
+						}
+					}
+					
+					
+					if (found)
+						setCall(theCall);
+				}
+			}
+		}
+		catch (ClassCastException ex)
+		{
+			throw new IllegalArgumentException(ex.toString());
+		}
+	}
+	
+	/**
 	 * @return get the Call information for this message.
 	 */
 	
-	public Call getCall ();
+	public abstract Call getCall ();
 	
 	/**
 	 * Set the call information for this message.
@@ -41,5 +148,5 @@
 	 * @param call the information.
 	 */
 	
-	public void setCall (Call call);
+	public abstract void setCall (Call call);
 }
\ No newline at end of file

Modified: labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/message/Properties.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/message/Properties.java	2007-02-28 15:56:58 UTC (rev 9842)
+++ labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/message/Properties.java	2007-02-28 16:07:13 UTC (rev 9843)
@@ -21,22 +21,59 @@
 
 package org.jboss.soa.esb.message;
 
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
 /**
  * The message properties hold arbitrary information in the form of
  * &lt;String,Object&gt; pairs
  * 
  */
 
-public interface Properties
+public abstract class Properties
 {
 	/**
+	 * Populate the header.
+	 * 
+	 * @param contents the values to populate.
+	 */
+	
+	public void setContents (Map<String, Object> contents)
+	{
+		if (contents == null)
+			throw new IllegalArgumentException();
+		
+		Set<String> keys = contents.keySet();
+		
+		try
+		{
+			if (keys != null)
+			{
+				Iterator<String> iter = keys.iterator();
+				
+				while (iter.hasNext())
+				{
+					String value = iter.next();
+
+					setProperty(value, contents.get(value));
+				}
+			}
+		}
+		catch (ClassCastException ex)
+		{
+			throw new IllegalArgumentException(ex.toString());
+		}
+	}
+	
+	/**
 	 * getProperty(name)
 	 * 
 	 * @param name
 	 *            String - name of property
 	 * @return Object - the value stored under the specified name
 	 */
-	public Object getProperty(String name);
+	public abstract Object getProperty(String name);
 
 	/**
 	 * getProperty(name,defaultVal)
@@ -47,7 +84,7 @@
 	 *            Object - value to return if no value found
 	 * @return Object - the value stored under the specified name
 	 */
-	public Object getProperty(String name, Object defaultVal);
+	public abstract Object getProperty(String name, Object defaultVal);
 
 	/**
 	 * setProperty(name,value)
@@ -59,7 +96,7 @@
 	 * @return Object - the previous value of the specified name, or null if it
 	 *         did not have one
 	 */
-	public Object setProperty(String name, Object value);
+	public abstract Object setProperty(String name, Object value);
 
 	/**
 	 * remove(name)
@@ -69,20 +106,20 @@
 	 * @return Object - the previous value of the specified name, or null if it
 	 *         did not have one
 	 */
-	public Object remove(String name);
+	public abstract Object remove(String name);
 
 	/**
 	 * size()
 	 * 
 	 * @return int - Returns the number of properties in this object
 	 */
-	public int size();
+	public abstract int size();
 
 	/**
 	 * getNames()
 	 * 
 	 * @return String[] - containing the names of all properties
 	 */
-	public String[] getNames();
+	public abstract String[] getNames();
 
 }




More information about the jboss-svn-commits mailing list