[jboss-svn-commits] JBL Code SVN: r14079 - in labs/jbossesb/trunk/product: rosetta/src/org/jboss/internal/soa/esb/message/format/serialized and 2 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Tue Aug 7 06:39:22 EDT 2007


Author: mark.little at jboss.com
Date: 2007-08-07 06:39:22 -0400 (Tue, 07 Aug 2007)
New Revision: 14079

Modified:
   labs/jbossesb/trunk/product/docs/ProgrammersGuide.odt
   labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/message/format/serialized/FaultImpl.java
   labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/message/format/serialized/MessageImpl.java
   labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/FaultImpl.java
   labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/MessageImpl.java
   labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/message/tests/FaultUnitTest.java
Log:
http://jira.jboss.com/jira/browse/JBESB-640 and http://jira.jboss.com/jira/browse/JBESB-772

Modified: labs/jbossesb/trunk/product/docs/ProgrammersGuide.odt
===================================================================
(Binary files differ)

Modified: labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/message/format/serialized/FaultImpl.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/message/format/serialized/FaultImpl.java	2007-08-07 06:26:53 UTC (rev 14078)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/message/format/serialized/FaultImpl.java	2007-08-07 10:39:22 UTC (rev 14079)
@@ -1,5 +1,9 @@
 package org.jboss.internal.soa.esb.message.format.serialized;
 
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
 import java.net.URI;
 
 import org.jboss.soa.esb.message.Fault;
@@ -25,36 +29,77 @@
  * @author mark.little at jboss.com
  */
 
-public class FaultImpl implements Fault, java.io.Serializable
+/**
+ * Since ESB 4.2 GA, Fault has simply been a convenience class to view the fault
+ * data within the Message body.
+ */
+
+public class FaultImpl implements Fault, Externalizable
 {
 	private static final long serialVersionUID = 0x0;
 	
+	public final static String FAULT_REASON = "org.jboss.soa.esb.message.fault.reason";
+	public final static String FAULT_CODE = "org.jboss.soa.esb.message.fault.code";
+	
+	public FaultImpl ()
+	{
+		_body = null;
+	}
+	
 	public URI getCode ()
 	{
-		return _code;
+		return (URI) _body.get(FAULT_CODE);
 	}
 	
 	public void setCode (URI code)
 	{
-		_code = code;
+		if (code == null)
+			throw new IllegalArgumentException();
+		
+		_body.add(FAULT_CODE, code);
 	}
 	
 	public String getReason ()
 	{
-		return _reason;
+		return (String) _body.get(FAULT_REASON);
 	}
 	
 	public void setReason (String reason)
 	{
-		_reason = reason;
+		if (reason == null)
+			throw new IllegalArgumentException();
+		
+		_body.add(FAULT_REASON, reason);
 	}
 	
 	public String toString ()
 	{
-		return "fault: [ "+((_code != null) ? _code : "null")+", "+((_reason != null) ? _reason : "null")+" ]";
+		URI code = getCode();
+		String reason = getReason();
+		
+		return "fault: [ "+((code != null) ? code : "null")+", "+((reason != null) ? reason : "null")+" ]";
 	}
 	
-	private URI _code = null;
-	private String _reason = null;
+	public void writeExternal (ObjectOutput out) throws IOException
+	{
+		// no need to do anything
+	}
 	
+	public void readExternal (ObjectInput in) throws IOException
+	{
+		// no need to do anything
+	}
+	
+	final void setBody (BodyImpl body)
+	{
+		_body = body;
+	}
+	
+	FaultImpl (BodyImpl body)
+	{
+		_body = body;
+	}
+	
+	private BodyImpl _body;
+	
 }
\ No newline at end of file

Modified: labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/message/format/serialized/MessageImpl.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/message/format/serialized/MessageImpl.java	2007-08-07 06:26:53 UTC (rev 14078)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/message/format/serialized/MessageImpl.java	2007-08-07 10:39:22 UTC (rev 14079)
@@ -20,6 +20,10 @@
  */
 package org.jboss.internal.soa.esb.message.format.serialized;
 
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
 import java.io.Serializable;
 import java.net.URI;
 
@@ -53,10 +57,20 @@
  *
  */
 
-public class MessageImpl implements Message, Serializable
+public class MessageImpl implements Message, Externalizable
 {
 	private static final long serialVersionUID = 0x0;
 	
+	public MessageImpl ()
+	{
+		_theHeader = new HeaderImpl();
+		_theContext = new ContextImpl();
+		_theBody = new BodyImpl();
+		_theFault = new FaultImpl(_theBody);
+		_theAttachment = new AttachmentImpl();
+		_theProperties = new PropertiesImpl();
+	}
+	
 	/**
 	 * @return get the header component of the message.
 	 */
@@ -126,6 +140,35 @@
 		+"\n"+_theFault.toString()+"\n"+_theAttachment.toString()+"\n"+_theProperties.toString()+" ]";
 	}
 	
+	public void writeExternal (ObjectOutput out) throws IOException
+	{
+		out.writeObject(_theHeader);
+		out.writeObject(_theContext);
+		out.writeObject(_theBody);
+		out.writeObject(_theFault);
+		out.writeObject(_theAttachment);
+		out.writeObject(_theProperties);
+	}
+	
+	public void readExternal (ObjectInput in) throws IOException
+	{
+		try
+		{
+			_theHeader = (HeaderImpl) in.readObject();
+			_theContext = (ContextImpl) in.readObject();
+			_theBody = (BodyImpl) in.readObject();
+			_theFault = (FaultImpl) in.readObject();
+			_theAttachment = (AttachmentImpl) in.readObject();
+			_theProperties = (PropertiesImpl) in.readObject();
+			
+			_theFault.setBody(_theBody);
+		}
+		catch (Exception ex)
+		{
+			throw new IOException(ex.toString());
+		}
+	}
+	
 	// should be a capability on the base interface, but no changes for 4.2 ...
 	
 	void replaceBody (BodyImpl body)
@@ -136,10 +179,10 @@
 		_theBody = body;
 	}
 	
-	private HeaderImpl _theHeader = new HeaderImpl();
-	private ContextImpl _theContext = new ContextImpl();
-	private BodyImpl _theBody = new BodyImpl();
-	private FaultImpl _theFault = new FaultImpl();
-	private AttachmentImpl _theAttachment = new AttachmentImpl();
-	private Properties _theProperties = new PropertiesImpl();
+	private HeaderImpl _theHeader;
+	private ContextImpl _theContext;
+	private BodyImpl _theBody;
+	private FaultImpl _theFault;
+	private AttachmentImpl _theAttachment;
+	private Properties _theProperties;
 }

Modified: labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/FaultImpl.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/FaultImpl.java	2007-08-07 06:26:53 UTC (rev 14078)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/FaultImpl.java	2007-08-07 10:39:22 UTC (rev 14079)
@@ -5,11 +5,7 @@
 import org.jboss.soa.esb.MarshalException;
 import org.jboss.soa.esb.UnmarshalException;
 import org.jboss.soa.esb.message.Fault;
-import org.w3c.dom.Document;
 import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.w3c.dom.Text;
 
 /*
  * JBoss, Home of Professional Open Source
@@ -32,41 +28,55 @@
  * @author mark.little at jboss.com
  */
 
+/**
+ * Since ESB 4.2 GA, Fault has simply been a convenience class to view the fault
+ * data within the Message body.
+ */
+
 public class FaultImpl implements Fault
 {
-	public static final String FAULT_TAG = "Fault";
-
-	public static final String CODE_TAG = "Code";
-
-	public static final String REASON_TAG = "Reason";
-
+	public final static String FAULT_REASON = "org.jboss.soa.esb.message.fault.reason";
+	public final static String FAULT_CODE = "org.jboss.soa.esb.message.fault.code";
+	
 	public URI getCode()
 	{
-		return _code;
+		return (URI) _body.get(FAULT_CODE);
 	}
 
 	public void setCode(URI code)
 	{
-		_code = code;
+		if (code == null)
+			throw new IllegalArgumentException();
+		
+		_body.add(FAULT_CODE, code);
 	}
 
 	public String getReason()
 	{
-		return _reason;
+		return (String) _body.get(FAULT_REASON);
 	}
 
 	public void setReason(String reason)
 	{
-		_reason = reason;
+		if (reason == null)
+			throw new IllegalArgumentException();
+		
+		_body.add(FAULT_REASON, reason);
 	}
 
 	public String toString ()
 	{
-		return "fault: [ "+((_code != null) ? _code : "null")+", "+((_reason != null) ? _reason : "null")+" ]";
+		URI code = getCode();
+		String reason = getReason();
+		
+		return "fault: [ "+((code != null) ? code : "null")+", "+((reason != null) ? reason : "null")+" ]";
 	}
 	
 	public Element toXML(Element envelope) throws MarshalException
 	{
+		return envelope;
+		
+		/*
 		Document doc = envelope.getOwnerDocument();
 		Element faultElement = doc.createElement(FAULT_TAG);
 
@@ -98,10 +108,12 @@
 		}
 		else
 			return envelope;
+			*/
 	}
 
 	public void fromXML (Element envelope) throws UnmarshalException
 	{
+		/*
 		NodeList nl = envelope.getChildNodes();
 
 		_code = null;
@@ -138,9 +150,14 @@
 				}
 			}
 		}
+		*/
 	}
 
-	private URI _code = null;
-	private String _reason = null;
+	FaultImpl (BodyImpl body)
+	{
+		_body = body;
+	}
+	
+	private BodyImpl _body;
 
 }
\ No newline at end of file

Modified: labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/MessageImpl.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/MessageImpl.java	2007-08-07 06:26:53 UTC (rev 14078)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/MessageImpl.java	2007-08-07 10:39:22 UTC (rev 14079)
@@ -63,12 +63,22 @@
  *
  */
 
-public class MessageImpl implements Message, Serializable
+public class MessageImpl implements Message//, Serializable
 {
     private static final long serialVersionUID = 0x0;
     
     public static final String ENVELOPE_TAG = "Envelope";
     
+    public MessageImpl ()
+    {
+    	_theHeader = new HeaderImpl();
+    	_theContext = new ContextImpl();
+    	_theBody = new BodyImpl();
+    	_theFault = new FaultImpl(_theBody);
+    	_theAttachment = new AttachmentImpl();
+    	_theProperties = new PropertiesImpl();
+    }
+    
 	/**
 	 * @return get the header component of the message.
 	 */
@@ -242,12 +252,12 @@
 	
 	// TODO add equality operator(s)
 	
-	private HeaderImpl _theHeader = new HeaderImpl();
-	private ContextImpl _theContext = new ContextImpl();
-	private BodyImpl _theBody = new BodyImpl();
-	private FaultImpl _theFault = new FaultImpl();
-	private AttachmentImpl _theAttachment = new AttachmentImpl();
-	private PropertiesImpl _theProperties = new PropertiesImpl();
+	private HeaderImpl _theHeader;
+	private ContextImpl _theContext;
+	private BodyImpl _theBody;
+	private FaultImpl _theFault;
+	private AttachmentImpl _theAttachment;
+	private PropertiesImpl _theProperties;
 	
 	/**
 	 * The logger for this class.

Modified: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/message/tests/FaultUnitTest.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/message/tests/FaultUnitTest.java	2007-08-07 06:26:53 UTC (rev 14078)
+++ labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/message/tests/FaultUnitTest.java	2007-08-07 10:39:22 UTC (rev 14079)
@@ -88,6 +88,8 @@
 		}
 		catch (Exception ex)
 		{
+			ex.printStackTrace();
+			
 			fail(ex.toString());
 		}
 	}




More information about the jboss-svn-commits mailing list