[jboss-svn-commits] JBL Code SVN: r9740 - in labs/jbossesb/workspace/rearch2/core: lib and 14 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Sun Feb 25 07:31:48 EST 2007


Author: mark.little at jboss.com
Date: 2007-02-25 07:31:48 -0500 (Sun, 25 Feb 2007)
New Revision: 9740

Added:
   labs/jbossesb/workspace/rearch2/core/lib/jboss-remoting-core.jar
   labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/api/
   labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/api/ClientPluginImpl.java
   labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/api/ServicePluginImpl.java
   labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/api/TwoWayClientPluginImpl.java
   labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/api/TwoWayServicePluginImpl.java
   labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/formant/
   labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/formant/xml/
   labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/formant/xml/remoting/
   labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/formant/xml/remoting/MarshalPlugin.java
   labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/formant/xml/remoting/UnMarshalPlugin.java
   labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/api/
   labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/api/ClientPlugin.java
   labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/api/ClientPluginFactory.java
   labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/api/ServicePlugin.java
   labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/api/ServicePluginFactory.java
   labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/remoting/
   labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/remoting/TcpClient.java
   labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/remoting/TcpService.java
Modified:
   labs/jbossesb/workspace/rearch2/core/pom.xml
   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/xml/BodyImpl.java
   labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/message/Body.java
   labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/message/tests/SerializedMessageUnitTest.java
   labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/message/tests/XMLMessageUnitTest.java
Log:
JBoss Remoting tests.

Added: labs/jbossesb/workspace/rearch2/core/lib/jboss-remoting-core.jar
===================================================================
(Binary files differ)


Property changes on: labs/jbossesb/workspace/rearch2/core/lib/jboss-remoting-core.jar
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Modified: labs/jbossesb/workspace/rearch2/core/pom.xml
===================================================================
--- labs/jbossesb/workspace/rearch2/core/pom.xml	2007-02-25 05:16:56 UTC (rev 9739)
+++ labs/jbossesb/workspace/rearch2/core/pom.xml	2007-02-25 12:31:48 UTC (rev 9740)
@@ -32,6 +32,13 @@
       <systemPath>${basedir}/lib/jbossts-common.jar</systemPath>
     </dependency>
     <dependency>
+      <groupId>jboss</groupId>
+      <artifactId>jboss-remoting-core</artifactId>
+      <version>2.0.0</version>
+      <scope>system</scope>
+      <systemPath>${basedir}/lib/jboss-remoting-core.jar</systemPath>
+    </dependency>
+    <dependency>
       <groupId>commons-logging</groupId>
       <artifactId>commons-logging-api</artifactId>
       <version>1.0.4</version>

Added: labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/api/ClientPluginImpl.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/api/ClientPluginImpl.java	                        (rev 0)
+++ labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/api/ClientPluginImpl.java	2007-02-25 12:31:48 UTC (rev 9740)
@@ -0,0 +1,98 @@
+package org.jboss.internal.soa.esb.api;
+
+/*
+ * 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 org.jboss.internal.soa.esb.message.formant.xml.remoting.MarshalPlugin;
+import org.jboss.internal.soa.esb.message.formant.xml.remoting.UnMarshalPlugin;
+import org.jboss.internal.soa.esb.message.format.xml.MessageImpl;
+import org.jboss.remoting.Client;
+import org.jboss.remoting.InvokerLocator;
+import org.jboss.remoting.marshal.MarshalFactory;
+import org.jboss.soa.esb.ProtocolNotSupportedException;
+import org.jboss.soa.esb.SendFailedException;
+import org.jboss.soa.esb.api.ClientPlugin;
+import org.jboss.soa.esb.message.Message;
+
+public class ClientPluginImpl implements ClientPlugin
+{
+	private static final String DATA_TYPE = "/?datatype=xml";
+
+	public ClientPluginImpl()
+	{
+		MarshalFactory.addMarshaller("xml", MarshalPlugin.getInstance(),
+				UnMarshalPlugin.getInstance());
+	}
+
+	/**
+	 * Start to assemble the ESBCore message that we will then pass down into
+	 * the Dispatcher hierarchy.
+	 */
+
+	public void send(Message msg) throws ProtocolNotSupportedException,
+			SendFailedException
+	{
+		if (msg == null)
+			throw new IllegalArgumentException("message is null!");
+
+		try
+		{
+			String locatorUri = msg.getHeader().getCall().getTo().getAddr().getAddress();
+			
+			if (msg instanceof MessageImpl)
+				locatorUri = locatorUri + DATA_TYPE;
+			
+			InvokerLocator locator = new InvokerLocator(locatorUri);
+			
+			System.out.println("Calling remoting server with locator uri of: "
+					+ locatorUri);
+
+			Client remotingClient = new Client(locator);
+			remotingClient.connect();
+
+			Object response = remotingClient.invoke(msg);
+
+			remotingClient.disconnect();
+			System.out.println("Invocation response: " + response);
+		}
+		catch (Throwable ex)
+		{
+			ex.printStackTrace();
+
+			throw new SendFailedException(ex);
+		}
+	}
+
+	public void sendAsync(Message msg) throws ProtocolNotSupportedException
+	{
+		throw new ProtocolNotSupportedException();
+	}
+
+	/*
+	 * public void sendAsync (EPR addr, Body msg, Callback cb) throws
+	 * ProtocolNotSupportedException { throw new
+	 * ProtocolNotSupportedException(); }
+	 */
+	public void sendReliable(Message msg) throws ProtocolNotSupportedException
+	{
+		throw new ProtocolNotSupportedException();
+	}
+}

Added: labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/api/ServicePluginImpl.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/api/ServicePluginImpl.java	                        (rev 0)
+++ labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/api/ServicePluginImpl.java	2007-02-25 12:31:48 UTC (rev 9740)
@@ -0,0 +1,156 @@
+package org.jboss.internal.soa.esb.api;
+
+import javax.management.MBeanServer;
+
+import org.jboss.internal.soa.esb.message.formant.xml.remoting.MarshalPlugin;
+import org.jboss.internal.soa.esb.message.formant.xml.remoting.UnMarshalPlugin;
+import org.jboss.remoting.InvocationRequest;
+import org.jboss.remoting.InvokerLocator;
+import org.jboss.remoting.ServerInvocationHandler;
+import org.jboss.remoting.ServerInvoker;
+import org.jboss.remoting.callback.InvokerCallbackHandler;
+import org.jboss.remoting.marshal.MarshalFactory;
+import org.jboss.remoting.transport.Connector;
+import org.jboss.soa.esb.addressing.EPR;
+import org.jboss.soa.esb.api.ServicePlugin;
+import org.jboss.soa.esb.message.Body;
+import org.jboss.soa.esb.message.Message;
+
+/*
+ * 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
+ */
+
+public class ServicePluginImpl implements ServicePlugin
+{
+	public ServicePluginImpl (String locatorURI) throws Exception
+	{
+		MarshalFactory.addMarshaller("xml", MarshalPlugin.getInstance(), UnMarshalPlugin.getInstance());
+		
+		InvokerLocator locator = new InvokerLocator(locatorURI);
+		System.out.println("Starting remoting server with locator uri of: "
+				+ locatorURI);
+		Connector connector = new Connector(locator);
+		// creates all the connector's needed resources, such as the server
+		// invoker
+		connector.create();
+
+		// create the handler to receive the invocation request from the client
+		// for processing
+		SampleInvocationHandler invocationHandler = new SampleInvocationHandler();
+		// first parameter is sub-system name. can be any String value.
+		connector.addInvocationHandler("sample", invocationHandler);
+
+		// start with a new non daemon thread so
+		// server will wait for request and not exit
+		connector.start();
+	}
+
+	public Message receive ()
+	{
+		return null;
+		
+		/*
+		try
+		{
+			Message[] msg = _dispatcher.dispatch(null);
+
+			from.copy(msg[0].getHeader().getEPR());
+
+			return msg[0].getBody();
+		}
+		catch (Exception ex)
+		{
+			ex.printStackTrace();
+
+			return null;
+		}
+		*/
+	}
+
+	/**
+	 * Simple invocation handler implementation. This is the code that will be
+	 * called with the invocation payload from the client.
+	 */
+	public static class SampleInvocationHandler implements
+			ServerInvocationHandler
+	{
+		/**
+		 * called to handle a specific invocation
+		 * 
+		 * @param invocation
+		 * @return
+		 * @throws Throwable
+		 */
+		public Object invoke(InvocationRequest invocation) throws Throwable
+		{
+			System.err.println("**INVOKE CALLED**");
+			
+			// Print out the invocation request
+			System.out.println("Invocation request is: "
+					+ invocation.getParameter());
+
+			return "foo";
+		}
+
+		/**
+		 * Adds a callback handler that will listen for callbacks from the
+		 * server invoker handler.
+		 * 
+		 * @param callbackHandler
+		 */
+		public void addListener(InvokerCallbackHandler callbackHandler)
+		{
+			// NO OP as do not handling callback listeners in this example
+		}
+
+		/**
+		 * Removes the callback handler that was listening for callbacks from
+		 * the server invoker handler.
+		 * 
+		 * @param callbackHandler
+		 */
+		public void removeListener(InvokerCallbackHandler callbackHandler)
+		{
+			// NO OP as do not handling callback listeners in this example
+		}
+
+		/**
+		 * set the mbean server that the handler can reference
+		 * 
+		 * @param server
+		 */
+		public void setMBeanServer(MBeanServer server)
+		{
+			// NO OP as do not need reference to MBeanServer for this handler
+		}
+
+		/**
+		 * set the invoker that owns this handler
+		 * 
+		 * @param invoker
+		 */
+		public void setInvoker(ServerInvoker invoker)
+		{
+			// NO OP as do not need reference back to the server invoker
+		}
+
+	}
+
+}

Added: labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/api/TwoWayClientPluginImpl.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/api/TwoWayClientPluginImpl.java	                        (rev 0)
+++ labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/api/TwoWayClientPluginImpl.java	2007-02-25 12:31:48 UTC (rev 9740)
@@ -0,0 +1,101 @@
+package org.jboss.internal.soa.esb.api;
+
+/*
+ * 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 org.jboss.internal.soa.esb.message.formant.xml.remoting.MarshalPlugin;
+import org.jboss.internal.soa.esb.message.formant.xml.remoting.UnMarshalPlugin;
+import org.jboss.internal.soa.esb.message.format.xml.MessageImpl;
+import org.jboss.remoting.Client;
+import org.jboss.remoting.InvokerLocator;
+import org.jboss.remoting.marshal.MarshalFactory;
+import org.jboss.soa.esb.ProtocolNotSupportedException;
+import org.jboss.soa.esb.SendFailedException;
+import org.jboss.soa.esb.api.ClientPlugin;
+import org.jboss.soa.esb.message.Message;
+
+public class TwoWayClientPluginImpl //implements ClientPlugin
+{
+	private static final String DATA_TYPE = "/?datatype=xml";
+
+	public TwoWayClientPluginImpl()
+	{
+		MarshalFactory.addMarshaller("xml", MarshalPlugin.getInstance(),
+				UnMarshalPlugin.getInstance());
+	}
+
+	/**
+	 * Start to assemble the ESBCore message that we will then pass down into
+	 * the Dispatcher hierarchy.
+	 */
+
+	public Message invoke (Message msg) throws ProtocolNotSupportedException,
+			SendFailedException
+	{
+		if (msg == null)
+			throw new IllegalArgumentException("message is null!");
+
+		try
+		{
+			String locatorUri = msg.getHeader().getCall().getTo().getAddr().getAddress();
+			
+			if (msg instanceof MessageImpl)
+				locatorUri = locatorUri + DATA_TYPE;
+			
+			InvokerLocator locator = new InvokerLocator(locatorUri);
+			
+			System.out.println("Calling remoting server with locator uri of: "
+					+ locatorUri);
+
+			Client remotingClient = new Client(locator);
+			remotingClient.connect();
+
+			Object response = remotingClient.invoke(msg);
+
+			remotingClient.disconnect();
+			
+			System.err.println("**response is "+response);
+			
+			return (Message) response;
+		}
+		catch (Throwable ex)
+		{
+			ex.printStackTrace();
+
+			throw new SendFailedException(ex);
+		}
+	}
+
+	public void sendAsync(Message msg) throws ProtocolNotSupportedException
+	{
+		throw new ProtocolNotSupportedException();
+	}
+
+	/*
+	 * public void sendAsync (EPR addr, Body msg, Callback cb) throws
+	 * ProtocolNotSupportedException { throw new
+	 * ProtocolNotSupportedException(); }
+	 */
+	public void sendReliable(Message msg) throws ProtocolNotSupportedException
+	{
+		throw new ProtocolNotSupportedException();
+	}
+}

Added: labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/api/TwoWayServicePluginImpl.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/api/TwoWayServicePluginImpl.java	                        (rev 0)
+++ labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/api/TwoWayServicePluginImpl.java	2007-02-25 12:31:48 UTC (rev 9740)
@@ -0,0 +1,159 @@
+package org.jboss.internal.soa.esb.api;
+
+import javax.management.MBeanServer;
+
+import org.jboss.internal.soa.esb.message.formant.xml.remoting.MarshalPlugin;
+import org.jboss.internal.soa.esb.message.formant.xml.remoting.UnMarshalPlugin;
+import org.jboss.remoting.InvocationRequest;
+import org.jboss.remoting.InvokerLocator;
+import org.jboss.remoting.ServerInvocationHandler;
+import org.jboss.remoting.ServerInvoker;
+import org.jboss.remoting.callback.InvokerCallbackHandler;
+import org.jboss.remoting.marshal.MarshalFactory;
+import org.jboss.remoting.transport.Connector;
+import org.jboss.soa.esb.addressing.EPR;
+import org.jboss.soa.esb.api.ServicePlugin;
+import org.jboss.soa.esb.message.Body;
+import org.jboss.soa.esb.message.Message;
+
+/*
+ * 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
+ */
+
+public class TwoWayServicePluginImpl //implements ServicePlugin
+{
+	public interface Worker
+	{
+		public Message doWork (Message msg);
+	}
+	
+	public TwoWayServicePluginImpl (String locatorURI, Worker work) throws Exception
+	{
+		if ((locatorURI == null) || (work == null))
+			throw new IllegalArgumentException();
+		
+		MarshalFactory.addMarshaller("xml", MarshalPlugin.getInstance(), UnMarshalPlugin.getInstance());
+		
+		InvokerLocator locator = new InvokerLocator(locatorURI);
+		System.out.println("Starting remoting server with locator uri of: "
+				+ locatorURI);
+		Connector connector = new Connector(locator);
+		// creates all the connector's needed resources, such as the server
+		// invoker
+		connector.create();
+
+		// create the handler to receive the invocation request from the client
+		// for processing
+		RosettaInvocationHandler invocationHandler = new RosettaInvocationHandler(work);
+		// first parameter is sub-system name. can be any String value.
+		connector.addInvocationHandler("rosetta", invocationHandler);
+
+		// start with a new non daemon thread so
+		// server will wait for request and not exit
+		connector.start();
+	}
+	
+	public void listen ()
+	{
+		while (!_terminate)
+		{
+		}
+	}
+
+	private boolean _terminate = false;
+	
+	/**
+	 * Simple invocation handler implementation. This is the code that will be
+	 * called with the invocation payload from the client.
+	 */
+	
+	public static class RosettaInvocationHandler implements
+			ServerInvocationHandler
+	{
+		public RosettaInvocationHandler (Worker work)
+		{
+			_worker = work;
+		}
+		
+		/**
+		 * called to handle a specific invocation
+		 * 
+		 * @param invocation
+		 * @return
+		 * @throws Throwable
+		 */
+		
+		public Object invoke(InvocationRequest invocation) throws Throwable
+		{
+			Message msg = (Message) invocation.getParameter();
+			
+			// could check msg to see if it's for the service (e.g., shutdown).
+			
+			Message response = _worker.doWork(msg);
+			
+			return response;
+		}
+
+		/**
+		 * Adds a callback handler that will listen for callbacks from the
+		 * server invoker handler.
+		 * 
+		 * @param callbackHandler
+		 */
+		public void addListener(InvokerCallbackHandler callbackHandler)
+		{
+			// NO OP as do not handling callback listeners in this example
+		}
+
+		/**
+		 * Removes the callback handler that was listening for callbacks from
+		 * the server invoker handler.
+		 * 
+		 * @param callbackHandler
+		 */
+		public void removeListener(InvokerCallbackHandler callbackHandler)
+		{
+			// NO OP as do not handling callback listeners in this example
+		}
+
+		/**
+		 * set the mbean server that the handler can reference
+		 * 
+		 * @param server
+		 */
+		public void setMBeanServer(MBeanServer server)
+		{
+			// NO OP as do not need reference to MBeanServer for this handler
+		}
+
+		/**
+		 * set the invoker that owns this handler
+		 * 
+		 * @param invoker
+		 */
+		public void setInvoker(ServerInvoker invoker)
+		{
+			// NO OP as do not need reference back to the server invoker
+		}
+
+		private Worker _worker;
+	}
+
+}

Added: labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/formant/xml/remoting/MarshalPlugin.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/formant/xml/remoting/MarshalPlugin.java	                        (rev 0)
+++ labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/formant/xml/remoting/MarshalPlugin.java	2007-02-25 12:31:48 UTC (rev 9740)
@@ -0,0 +1,142 @@
+package org.jboss.internal.soa.esb.message.formant.xml.remoting;
+
+import java.io.IOException;
+import java.io.StringWriter;
+
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.jboss.remoting.InvocationRequest;
+import org.jboss.remoting.InvocationResponse;
+import org.jboss.remoting.marshal.Marshaller;
+import org.jboss.remoting.marshal.serializable.SerializableMarshaller;
+import org.jboss.soa.esb.MarshalException;
+import org.w3c.dom.Document;
+
+import com.sun.org.apache.xml.internal.serialize.OutputFormat;
+import com.sun.org.apache.xml.internal.serialize.XMLSerializer;
+
+/*
+ * 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 MarshalPlugin extends SerializableMarshaller //implements Marshaller
+{
+	private static final long serialVersionUID = 0xdeadbeef;
+
+	public static final MarshalPlugin getInstance ()
+	{
+		return _instance;
+	}
+	
+	public Marshaller cloneMarshaller ()
+	{
+		return getInstance();
+	}
+
+	/**
+	 * 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 void write (Object dataObject, java.io.OutputStream output) throws IOException
+	{
+		if ((dataObject instanceof InvocationRequest) || (dataObject instanceof InvocationResponse))
+		{
+			Object invocationMsg = null;
+			
+			if (dataObject instanceof InvocationRequest)
+				invocationMsg = ((InvocationRequest) dataObject).getParameter();
+			else
+				invocationMsg = ((InvocationResponse) dataObject).getResult();
+
+			if (invocationMsg instanceof org.jboss.internal.soa.esb.message.format.xml.MessageImpl)
+			{	
+				try
+				{
+					DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+					
+					factory.setNamespaceAware(true);
+					
+					Document doc = factory.newDocumentBuilder().newDocument();
+					((org.jboss.internal.soa.esb.message.format.xml.MessageImpl) invocationMsg).toXML(doc);
+					StringWriter sWriter = new StringWriter();
+					OutputFormat format = new OutputFormat();
+					format.setIndenting(true);
+					XMLSerializer xmlS = new XMLSerializer(sWriter, format);
+					xmlS.asDOMSerializer();
+					xmlS.serialize(doc);
+
+					if (dataObject instanceof InvocationRequest)
+						((InvocationRequest) dataObject).setParameter(sWriter.toString());
+					else
+					{
+						InvocationResponse response = (InvocationResponse) dataObject;
+					
+						InvocationResponse modifiedResponse = new InvocationResponse(response.getSessionId(), sWriter.toString(),
+																	response.isException(), response.getPayload());
+						
+						dataObject = modifiedResponse;
+					}
+					
+					super.write(dataObject, output);
+				}
+				catch (ParserConfigurationException ex)
+				{
+					throw new IOException(ex.toString());
+				}
+				catch (MarshalException ex)
+				{
+					throw new IOException(ex.toString());
+				}
+			}
+			else
+				super.write(dataObject, output);
+		}
+		else
+			super.write(dataObject, output);
+	}
+	
+	private MarshalPlugin ()
+	{	
+	}
+	
+	private static final MarshalPlugin _instance = new MarshalPlugin();
+}

Added: labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/formant/xml/remoting/UnMarshalPlugin.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/formant/xml/remoting/UnMarshalPlugin.java	                        (rev 0)
+++ labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/formant/xml/remoting/UnMarshalPlugin.java	2007-02-25 12:31:48 UTC (rev 9740)
@@ -0,0 +1,157 @@
+package org.jboss.internal.soa.esb.message.formant.xml.remoting;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.jboss.remoting.InvocationRequest;
+import org.jboss.remoting.InvocationResponse;
+import org.jboss.remoting.marshal.UnMarshaller;
+import org.jboss.remoting.marshal.serializable.SerializableUnMarshaller;
+import org.jboss.soa.esb.MarshalException;
+import org.jboss.soa.esb.UnmarshalException;
+import org.w3c.dom.Document;
+import org.xml.sax.SAXException;
+
+/*
+ * 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 UnMarshalPlugin extends SerializableUnMarshaller //implements UnMarshaller
+{
+	private static final long serialVersionUID = 0xdeadbeef;
+
+	public static final UnMarshalPlugin getInstance ()
+	{
+		return _instance;
+	}
+	
+	public UnMarshaller cloneUnMarshaller ()
+	{
+		return getInstance();
+	}
+
+	public void setClassLoader (java.lang.ClassLoader classloader)
+	{
+		super.setClassLoader(classloader);
+	}
+
+	/**
+	 * 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 Object read (java.io.InputStream inputStream, java.util.Map metadata) throws IOException, ClassNotFoundException
+	{
+		try
+		{
+			Object invocationMsg = super.read(inputStream, metadata);
+			
+			if ((invocationMsg instanceof InvocationRequest) || (invocationMsg instanceof InvocationResponse))
+			{
+				String serial;
+				InvocationRequest request = null;
+				InvocationResponse response = null;
+				
+				if (invocationMsg instanceof InvocationRequest)
+				{
+					request = (InvocationRequest) invocationMsg;
+					serial = (String) request.getParameter();
+				}
+				else
+				{
+					response = (InvocationResponse) invocationMsg;
+					
+					serial = (String) response.getResult();
+				}
+				
+				// MessageType.JBOSS_XML
+				InputStream inStream = new ByteArrayInputStream((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);
+				
+				if (request != null)
+				{
+					request.setParameter(message);
+				
+					return request;
+				}
+				else
+				{
+					InvocationResponse modifiedResponse = new InvocationResponse(response.getSessionId(), message,
+															response.isException(), response.getPayload());
+					
+					return modifiedResponse;
+				}
+			}
+			else
+				return invocationMsg;
+		}
+		catch (SAXException ex)
+		{
+			throw new IOException(ex.toString());
+		}
+		catch (ParserConfigurationException ex)
+		{
+			throw new IOException(ex.toString());
+		}
+		catch (UnmarshalException ex)
+		{
+			throw new IOException(ex.toString());
+		}
+	}
+	
+	private UnMarshalPlugin ()
+	{
+	}
+	
+	private static final UnMarshalPlugin _instance = new UnMarshalPlugin();
+	
+}

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-25 05:16:56 UTC (rev 9739)
+++ labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/format/serialized/BodyImpl.java	2007-02-25 12:31:48 UTC (rev 9740)
@@ -41,12 +41,12 @@
 		_objects = new Hashtable<String, Serializable>();
 	}
 	
-	public void setContents (byte[] content)
+	public void addBytes (byte[] content)
 	{
 		_content = content;
 	}
 
-	public byte[] getContents ()
+	public byte[] getBytes ()
 	{
 		return _content;
 	}
@@ -102,7 +102,7 @@
 		if (b == null)
 			throw new IllegalArgumentException();
 		
-		setContents(b.getContents());
+		addBytes(b.getBytes());
 		
 		_objects = ((BodyImpl) b)._objects;
 	}
@@ -112,7 +112,7 @@
 		if (b == null)
 			throw new IllegalArgumentException();
 		
-		byte[] toAdd = b.getContents();
+		byte[] toAdd = b.getBytes();
 		
 		if ((toAdd != null) && (toAdd.length > 0))
 		{

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-25 05:16:56 UTC (rev 9739)
+++ labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/format/xml/BodyImpl.java	2007-02-25 12:31:48 UTC (rev 9740)
@@ -229,12 +229,12 @@
 		}
 	}
 
-	public void setContents(byte[] content)
+	public void addBytes(byte[] content)
 	{
 		_content = content;
 	}
 
-	public byte[] getContents()
+	public byte[] getBytes()
 	{
 		return _content;
 	}
@@ -244,7 +244,7 @@
 		if (b == null)
 			throw new IllegalArgumentException();
 
-		setContents(b.getContents());
+		addBytes(b.getBytes());
 
 		_objects = ((BodyImpl) b)._objects;
 	}
@@ -254,7 +254,7 @@
 		if (b == null)
 			throw new IllegalArgumentException();
 
-		byte[] toAdd = b.getContents();
+		byte[] toAdd = b.getBytes();
 
 		if ((toAdd != null) && (toAdd.length > 0))
 		{

Added: labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/api/ClientPlugin.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/api/ClientPlugin.java	                        (rev 0)
+++ labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/api/ClientPlugin.java	2007-02-25 12:31:48 UTC (rev 9740)
@@ -0,0 +1,35 @@
+package org.jboss.soa.esb.api;
+
+import org.jboss.soa.esb.ProtocolNotSupportedException;
+import org.jboss.soa.esb.SendFailedException;
+import org.jboss.soa.esb.message.Message;
+
+/*
+ * 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
+ */
+
+
+public interface ClientPlugin
+{
+	public void send (Message msg) throws ProtocolNotSupportedException, SendFailedException;
+	public void sendAsync (Message msg) throws ProtocolNotSupportedException, SendFailedException;
+//	public void sendAsync (EPR addr, Body msg, Callback cb) throws ProtocolNotSupportedException, SendFailedException;
+	public void sendReliable (Message msg) throws ProtocolNotSupportedException, SendFailedException;
+}

Added: labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/api/ClientPluginFactory.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/api/ClientPluginFactory.java	                        (rev 0)
+++ labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/api/ClientPluginFactory.java	2007-02-25 12:31:48 UTC (rev 9740)
@@ -0,0 +1,27 @@
+package org.jboss.soa.esb.api;
+
+/*
+ * 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
+ */
+
+public interface ClientPluginFactory
+{
+	public ClientPlugin getPlugin ();
+}

Added: labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/api/ServicePlugin.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/api/ServicePlugin.java	                        (rev 0)
+++ labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/api/ServicePlugin.java	2007-02-25 12:31:48 UTC (rev 9740)
@@ -0,0 +1,29 @@
+package org.jboss.soa.esb.api;
+
+import org.jboss.soa.esb.message.Message;
+
+/*
+ * 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
+ */
+
+public interface ServicePlugin
+{
+	public Message receive ();
+}

Added: labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/api/ServicePluginFactory.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/api/ServicePluginFactory.java	                        (rev 0)
+++ labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/api/ServicePluginFactory.java	2007-02-25 12:31:48 UTC (rev 9740)
@@ -0,0 +1,27 @@
+package org.jboss.soa.esb.api;
+
+/*
+ * 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
+ */
+
+public interface ServicePluginFactory
+{
+	public ServicePlugin getPlugin ();
+}

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-25 05:16:56 UTC (rev 9739)
+++ labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/message/Body.java	2007-02-25 12:31:48 UTC (rev 9740)
@@ -73,13 +73,13 @@
 	 * @param content the message bytes
 	 */
 	
-	public void setContents (byte[] content);
+	public void addBytes (byte[] content);
 	
 	/**
 	 * @return the byte content of the body.
 	 */
 	
-	public byte[] getContents ();
+	public byte[] getBytes ();
 
 	/**
 	 * Replace this body instance with the one given.

Modified: labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/message/tests/SerializedMessageUnitTest.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/message/tests/SerializedMessageUnitTest.java	2007-02-25 05:16:56 UTC (rev 9739)
+++ labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/message/tests/SerializedMessageUnitTest.java	2007-02-25 12:31:48 UTC (rev 9740)
@@ -167,7 +167,7 @@
 		
 		String testString = "test";
 		
-		msg.getBody().setContents(testString.getBytes());
+		msg.getBody().addBytes(testString.getBytes());
 		
 		try
 		{
@@ -184,7 +184,7 @@
 			
 			o.close();
 			
-			String val = new String(nImpl.getBody().getContents());
+			String val = new String(nImpl.getBody().getBytes());
 			
 			assertEquals(val, testString);
 		}
@@ -210,12 +210,12 @@
 		
 		String bar = "bar";
 		
-		msg1.getBody().setContents(foo.getBytes());
-		msg2.getBody().setContents(bar.getBytes());
+		msg1.getBody().addBytes(foo.getBytes());
+		msg2.getBody().addBytes(bar.getBytes());
 		
 		msg1.getBody().replace(msg2.getBody());
 		
-		String foobar = new String(msg1.getBody().getContents());
+		String foobar = new String(msg1.getBody().getBytes());
 		
 		assertEquals(foobar.equals("bar"), true);
 	}
@@ -236,12 +236,12 @@
 		
 		String bar = "bar";
 		
-		msg1.getBody().setContents(foo.getBytes());
-		msg2.getBody().setContents(bar.getBytes());
+		msg1.getBody().addBytes(foo.getBytes());
+		msg2.getBody().addBytes(bar.getBytes());
 		
 		msg1.getBody().merge(msg2.getBody());
 		
-		String foobar = new String(msg1.getBody().getContents());
+		String foobar = new String(msg1.getBody().getBytes());
 		
 		assertEquals(foobar, "foobar");
 	}

Modified: labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/message/tests/XMLMessageUnitTest.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/message/tests/XMLMessageUnitTest.java	2007-02-25 05:16:56 UTC (rev 9739)
+++ labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/message/tests/XMLMessageUnitTest.java	2007-02-25 12:31:48 UTC (rev 9740)
@@ -162,7 +162,7 @@
 		
 		String testString = "test";
 		
-		msg.getBody().setContents(testString.getBytes());
+		msg.getBody().addBytes(testString.getBytes());
 		
 		try
 		{
@@ -171,7 +171,7 @@
 			
 			final MessageImpl nImpl = msgFromXML(xmlRepresentation) ;
 			
-			String val = new String(nImpl.getBody().getContents());
+			String val = new String(nImpl.getBody().getBytes());
 			
 			assertEquals(val, testString);
 		}
@@ -197,12 +197,12 @@
 		
 		String bar = "bar";
 		
-		msg1.getBody().setContents(foo.getBytes());
-		msg2.getBody().setContents(bar.getBytes());
+		msg1.getBody().addBytes(foo.getBytes());
+		msg2.getBody().addBytes(bar.getBytes());
 		
 		msg1.getBody().replace(msg2.getBody());
 		
-		String foobar = new String(msg1.getBody().getContents());
+		String foobar = new String(msg1.getBody().getBytes());
 		
 		assertEquals(foobar, "bar");
 	}
@@ -223,12 +223,12 @@
 		
 		String bar = "bar";
 		
-		msg1.getBody().setContents(foo.getBytes());
-		msg2.getBody().setContents(bar.getBytes());
+		msg1.getBody().addBytes(foo.getBytes());
+		msg2.getBody().addBytes(bar.getBytes());
 		
 		msg1.getBody().merge(msg2.getBody());
 		
-		String foobar = new String(msg1.getBody().getContents());
+		String foobar = new String(msg1.getBody().getBytes());
 		
 		assertEquals(foobar, "foobar");
 	}

Added: labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/remoting/TcpClient.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/remoting/TcpClient.java	                        (rev 0)
+++ labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/remoting/TcpClient.java	2007-02-25 12:31:48 UTC (rev 9740)
@@ -0,0 +1,140 @@
+package org.jboss.soa.esb.remoting;
+
+import java.io.StringWriter;
+import java.net.URI;
+
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.jboss.internal.soa.esb.api.TwoWayClientPluginImpl;
+import org.jboss.soa.esb.addressing.Call;
+import org.jboss.soa.esb.addressing.EPR;
+import org.jboss.soa.esb.message.Body;
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.message.format.MessageFactory;
+import org.w3c.dom.Document;
+
+import com.sun.org.apache.xml.internal.serialize.OutputFormat;
+import com.sun.org.apache.xml.internal.serialize.XMLSerializer;
+
+/*
+ * 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
+ */
+
+public class TcpClient
+{
+	public static void main (String[] args) throws Exception
+	{
+		URI destination = new URI("socket://localhost:5555");
+		
+		for (int i = 0; i < args.length; i++)
+		{
+			if (args[i].equals("-url"))
+			{
+				try
+				{
+					destination = new URI(args[i+1]);
+				}
+				catch (Exception ex)
+				{
+					ex.printStackTrace();
+					
+					System.exit(0);
+				}
+			}
+			if (args[i].equals("-help"))
+			{
+				System.err.println("Usage: -url <url> [-help]");
+				System.exit(0);
+			}
+		}
+		
+		if (destination == null)
+		{
+			System.err.println("Error - no destination URL specified!");
+			
+			System.exit(0);
+		}
+		
+		/*
+		 * Most (or all) of the following would be automated via interactions with other
+		 * services, such as a registry/repository.
+		 */
+		
+		/*
+		 * Create a reference to the endpoint service we want to talk to.
+		 */
+		
+		EPR epr = new EPR(destination);
+		
+		/*
+		 * Now create a binding to the right aspect of the ESB.
+		 */
+		
+		TwoWayClientPluginImpl httpClientPlugin = new TwoWayClientPluginImpl();
+		
+		/*
+		 * Create the message payload.
+		 */
+		
+		Message msg = MessageFactory.getInstance().getMessage();
+		Body payload = msg.getBody();
+		
+		String message = "Hello World";
+		
+		payload.addBytes(message.getBytes());
+		
+	    msg.getHeader().setCall(new Call(epr));  
+	      
+		/*
+		 * Send the message payload.
+		 */
+		
+		try
+		{
+			Message response = httpClientPlugin.invoke(msg);
+			
+			try
+			{
+				DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+				
+				factory.setNamespaceAware(true);
+				
+				Document doc = factory.newDocumentBuilder().newDocument();
+				((org.jboss.internal.soa.esb.message.format.xml.MessageImpl) response).toXML(doc);
+				StringWriter sWriter = new StringWriter();
+				OutputFormat format = new OutputFormat();
+				format.setIndenting(true);
+				XMLSerializer xmlS = new XMLSerializer(sWriter, format);
+				xmlS.asDOMSerializer();
+				xmlS.serialize(doc);
+				
+				System.err.println("Received response message: "+sWriter.toString());
+			}
+			catch (Throwable ex)
+			{
+			}
+		}
+		catch (Exception ex)
+		{
+			ex.printStackTrace();
+		}
+	}
+	
+}
\ No newline at end of file

Added: labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/remoting/TcpService.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/remoting/TcpService.java	                        (rev 0)
+++ labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/remoting/TcpService.java	2007-02-25 12:31:48 UTC (rev 9740)
@@ -0,0 +1,126 @@
+package org.jboss.soa.esb.remoting;
+
+import java.io.StringWriter;
+import java.net.URI;
+
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.jboss.internal.soa.esb.api.ServicePluginImpl;
+import org.jboss.internal.soa.esb.api.TwoWayServicePluginImpl;
+import org.jboss.soa.esb.addressing.Call;
+import org.jboss.soa.esb.addressing.EPR;
+import org.jboss.soa.esb.message.Body;
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.message.format.MessageFactory;
+import org.w3c.dom.Document;
+
+import com.sun.org.apache.xml.internal.serialize.OutputFormat;
+import com.sun.org.apache.xml.internal.serialize.XMLSerializer;
+
+/*
+ * 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
+ */
+
+public class TcpService
+{
+	public static class Worker implements TwoWayServicePluginImpl.Worker
+	{
+		public Message doWork (Message msg)
+		{
+			try
+			{
+				DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+				
+				factory.setNamespaceAware(true);
+				
+				Document doc = factory.newDocumentBuilder().newDocument();
+				((org.jboss.internal.soa.esb.message.format.xml.MessageImpl) msg).toXML(doc);
+				StringWriter sWriter = new StringWriter();
+				OutputFormat format = new OutputFormat();
+				format.setIndenting(true);
+				XMLSerializer xmlS = new XMLSerializer(sWriter, format);
+				xmlS.asDOMSerializer();
+				xmlS.serialize(doc);
+				
+				System.err.println("Received request message: "+sWriter.toString());
+			}
+			catch (Throwable ex)
+			{
+			}
+			
+			/*
+			 * How do we get the implicit ReplyTo address?
+			 */
+			
+			Message response = MessageFactory.getInstance().getMessage();
+			Body payload = response.getBody();
+			
+			String message = "Echo echo echo echo";
+			
+			payload.addBytes(message.getBytes());
+		    
+			return response;
+		}
+	}
+	
+	public static void main (String[] args) throws Exception
+	{
+		URI listener = new URI("socket://localhost:5555/?datatype=xml");
+		//URI listener = new URI("socket://localhost:5555");
+		
+		for (int i = 0; i < args.length; i++)
+		{
+			if (args[i].equals("-url"))
+			{
+				try
+				{
+					listener = new URI(args[i+1]);
+				}
+				catch (Exception ex)
+				{
+					ex.printStackTrace();
+					
+					System.exit(0);
+				}
+			}
+			if (args[i].equals("-help"))
+			{
+				System.err.println("Usage: -url <url> [-help]");
+				System.exit(0);
+			}
+		}
+		
+		try
+		{
+			/*
+			 * Now create a binding to the right aspect of the ESB.
+			 */
+			
+			TwoWayServicePluginImpl tcpServicePlugin = new TwoWayServicePluginImpl(listener.toString(), new TcpService.Worker());
+			
+			tcpServicePlugin.listen();
+		}
+		catch (Exception ex)
+		{
+			ex.printStackTrace();
+		}
+	}
+	
+}
\ No newline at end of file




More information about the jboss-svn-commits mailing list