[jboss-svn-commits] JBL Code SVN: r9743 - in labs/jbossesb/workspace/rearch2/core: src/main/java/org/jboss/internal/soa/esb/api and 5 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Sun Feb 25 14:54:23 EST 2007


Author: mark.little at jboss.com
Date: 2007-02-25 14:54:23 -0500 (Sun, 25 Feb 2007)
New Revision: 9743

Added:
   labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/format/xml/remoting/
   labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/remoting/OneWayTcpClient.java
   labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/remoting/OneWayTcpService.java
   labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/remoting/TwoWayTcpClient.java
   labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/remoting/TwoWayTcpService.java
Removed:
   labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/formant/xml/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/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/format/xml/remoting/MarshalPlugin.java
   labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/format/xml/remoting/UnMarshalPlugin.java
   labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/api/ServicePlugin.java
Log:
JBoss Remoting one-way testing.

Modified: labs/jbossesb/workspace/rearch2/core/pom.xml
===================================================================
--- labs/jbossesb/workspace/rearch2/core/pom.xml	2007-02-25 13:18:08 UTC (rev 9742)
+++ labs/jbossesb/workspace/rearch2/core/pom.xml	2007-02-25 19:54:23 UTC (rev 9743)
@@ -46,6 +46,27 @@
       <systemPath>${basedir}/lib/jboss-remoting-socket.jar</systemPath>
     </dependency>
     <dependency>
+      <groupId>jboss</groupId>
+      <artifactId>jboss-common</artifactId>
+      <version>1.2.3</version>
+      <scope>system</scope>
+      <systemPath>${basedir}/lib/jboss-common.jar</systemPath>
+    </dependency>
+    <dependency>
+      <groupId>jboss</groupId>
+      <artifactId>jboss-jmx</artifactId>
+      <version>1.2.3</version>
+      <scope>system</scope>
+      <systemPath>${basedir}/lib/jboss-jmx.jar</systemPath>
+    </dependency>
+    <dependency>
+      <groupId>oswego</groupId>
+      <artifactId>oswego-concurrent</artifactId>
+      <version>1.2.3</version>
+      <scope>system</scope>
+      <systemPath>${basedir}/lib/concurrent.jar</systemPath>
+    </dependency>
+    <dependency>
       <groupId>commons-logging</groupId>
       <artifactId>commons-logging-api</artifactId>
       <version>1.0.4</version>

Modified: 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	2007-02-25 13:18:08 UTC (rev 9742)
+++ labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/api/ClientPluginImpl.java	2007-02-25 19:54:23 UTC (rev 9743)
@@ -21,9 +21,9 @@
  * @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.internal.soa.esb.message.format.xml.remoting.MarshalPlugin;
+import org.jboss.internal.soa.esb.message.format.xml.remoting.UnMarshalPlugin;
 import org.jboss.remoting.Client;
 import org.jboss.remoting.InvokerLocator;
 import org.jboss.remoting.marshal.MarshalFactory;
@@ -68,10 +68,9 @@
 			Client remotingClient = new Client(locator);
 			remotingClient.connect();
 
-			Object response = remotingClient.invoke(msg);
+			remotingClient.invokeOneway(msg);
 
 			remotingClient.disconnect();
-			System.out.println("Invocation response: " + response);
 		}
 		catch (Throwable ex)
 		{

Modified: 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	2007-02-25 13:18:08 UTC (rev 9742)
+++ labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/api/ServicePluginImpl.java	2007-02-25 19:54:23 UTC (rev 9743)
@@ -2,8 +2,8 @@
 
 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.internal.soa.esb.message.format.xml.remoting.MarshalPlugin;
+import org.jboss.internal.soa.esb.message.format.xml.remoting.UnMarshalPlugin;
 import org.jboss.remoting.InvocationRequest;
 import org.jboss.remoting.InvokerLocator;
 import org.jboss.remoting.ServerInvocationHandler;
@@ -39,8 +39,13 @@
 
 public class ServicePluginImpl implements ServicePlugin
 {
-	public ServicePluginImpl (String locatorURI) throws Exception
+	public interface Receiver
 	{
+		public void receive (Message msg);
+	}
+	
+	public ServicePluginImpl (String locatorURI, Receiver receiver) throws Exception
+	{
 		MarshalFactory.addMarshaller("xml", MarshalPlugin.getInstance(), UnMarshalPlugin.getInstance());
 		
 		InvokerLocator locator = new InvokerLocator(locatorURI);
@@ -53,44 +58,32 @@
 
 		// create the handler to receive the invocation request from the client
 		// for processing
-		SampleInvocationHandler invocationHandler = new SampleInvocationHandler();
+		RosettaInvocationHandler invocationHandler = new RosettaInvocationHandler(receiver);
 		// first parameter is sub-system name. can be any String value.
-		connector.addInvocationHandler("sample", invocationHandler);
+		connector.addInvocationHandler("rosetta", invocationHandler);
 
 		// start with a new non daemon thread so
 		// server will wait for request and not exit
 		connector.start();
 	}
 
-	public Message receive ()
+	public void listen ()
 	{
-		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;
-		}
-		*/
+		for (;;);
 	}
-
+	
 	/**
 	 * Simple invocation handler implementation. This is the code that will be
 	 * called with the invocation payload from the client.
 	 */
-	public static class SampleInvocationHandler implements
+	public static class RosettaInvocationHandler implements
 			ServerInvocationHandler
 	{
+		public RosettaInvocationHandler (Receiver receiver)
+		{
+			_receiver = receiver;
+		}
+		
 		/**
 		 * called to handle a specific invocation
 		 * 
@@ -100,13 +93,14 @@
 		 */
 		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";
+			if (_receiver != null)
+				_receiver.receive((Message) invocation.getParameter());
+			
+			return null;
 		}
 
 		/**
@@ -151,6 +145,7 @@
 			// NO OP as do not need reference back to the server invoker
 		}
 
+		private Receiver _receiver;
 	}
 
 }

Modified: 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	2007-02-25 13:18:08 UTC (rev 9742)
+++ labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/api/TwoWayClientPluginImpl.java	2007-02-25 19:54:23 UTC (rev 9743)
@@ -21,9 +21,9 @@
  * @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.internal.soa.esb.message.format.xml.remoting.MarshalPlugin;
+import org.jboss.internal.soa.esb.message.format.xml.remoting.UnMarshalPlugin;
 import org.jboss.remoting.Client;
 import org.jboss.remoting.InvokerLocator;
 import org.jboss.remoting.marshal.MarshalFactory;
@@ -72,8 +72,6 @@
 
 			remotingClient.disconnect();
 			
-			System.err.println("**response is "+response);
-			
 			return (Message) response;
 		}
 		catch (Throwable ex)

Modified: 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	2007-02-25 13:18:08 UTC (rev 9742)
+++ labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/api/TwoWayServicePluginImpl.java	2007-02-25 19:54:23 UTC (rev 9743)
@@ -2,8 +2,8 @@
 
 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.internal.soa.esb.message.format.xml.remoting.MarshalPlugin;
+import org.jboss.internal.soa.esb.message.format.xml.remoting.UnMarshalPlugin;
 import org.jboss.remoting.InvocationRequest;
 import org.jboss.remoting.InvokerLocator;
 import org.jboss.remoting.ServerInvocationHandler;

Copied: labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/format/xml/remoting (from rev 9740, labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/formant/xml/remoting)

Modified: labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/format/xml/remoting/MarshalPlugin.java
===================================================================
--- 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)
+++ labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/format/xml/remoting/MarshalPlugin.java	2007-02-25 19:54:23 UTC (rev 9743)
@@ -1,4 +1,4 @@
-package org.jboss.internal.soa.esb.message.formant.xml.remoting;
+package org.jboss.internal.soa.esb.message.format.xml.remoting;
 
 import java.io.IOException;
 import java.io.StringWriter;
@@ -8,6 +8,7 @@
 
 import org.jboss.remoting.InvocationRequest;
 import org.jboss.remoting.InvocationResponse;
+import org.jboss.remoting.invocation.OnewayInvocation;
 import org.jboss.remoting.marshal.Marshaller;
 import org.jboss.remoting.marshal.serializable.SerializableMarshaller;
 import org.jboss.soa.esb.MarshalException;
@@ -87,6 +88,13 @@
 			else
 				invocationMsg = ((InvocationResponse) dataObject).getResult();
 
+			if (invocationMsg instanceof OnewayInvocation)
+			{
+				OnewayInvocation oneWay = (OnewayInvocation) invocationMsg;
+				
+				invocationMsg = oneWay.getParameters()[0];
+			}
+		
 			if (invocationMsg instanceof org.jboss.internal.soa.esb.message.format.xml.MessageImpl)
 			{	
 				try

Modified: labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/format/xml/remoting/UnMarshalPlugin.java
===================================================================
--- 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)
+++ labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/internal/soa/esb/message/format/xml/remoting/UnMarshalPlugin.java	2007-02-25 19:54:23 UTC (rev 9743)
@@ -1,4 +1,4 @@
-package org.jboss.internal.soa.esb.message.formant.xml.remoting;
+package org.jboss.internal.soa.esb.message.format.xml.remoting;
 
 import java.io.ByteArrayInputStream;
 import java.io.IOException;
@@ -106,6 +106,9 @@
 					serial = (String) response.getResult();
 				}
 				
+				if (serial == null) // probably a one-way
+					return null;
+				
 				// MessageType.JBOSS_XML
 				InputStream inStream = new ByteArrayInputStream((serial).getBytes());
 				DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();

Modified: 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	2007-02-25 13:18:08 UTC (rev 9742)
+++ labs/jbossesb/workspace/rearch2/core/src/main/java/org/jboss/soa/esb/api/ServicePlugin.java	2007-02-25 19:54:23 UTC (rev 9743)
@@ -25,5 +25,5 @@
 
 public interface ServicePlugin
 {
-	public Message receive ();
+	//public Message receive ();
 }

Copied: labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/remoting/OneWayTcpClient.java (from rev 9740, 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/OneWayTcpClient.java	                        (rev 0)
+++ labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/remoting/OneWayTcpClient.java	2007-02-25 19:54:23 UTC (rev 9743)
@@ -0,0 +1,154 @@
+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.ClientPluginImpl;
+import org.jboss.internal.soa.esb.api.ServicePluginImpl;
+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 OneWayTcpClient
+{
+	public static class Receiver implements ServicePluginImpl.Receiver
+	{
+		public void receive (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 one-way response message: "+sWriter.toString());
+			}
+			catch (Throwable ex)
+			{
+			}
+		}
+	}
+	
+	public static void main (String[] args) throws Exception
+	{
+		URI destination = new URI("socket://localhost:5555");
+		URI response = new URI("socket://localhost:8080");
+		
+		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.
+		 */
+		
+		ClientPluginImpl tcpClientPlugin = new ClientPluginImpl();
+		
+		/*
+		 * 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));
+	    msg.getHeader().getCall().setReplyTo(new EPR(response));
+	      
+		/*
+		 * Send the message payload.
+		 */
+		
+		try
+		{
+			ServicePluginImpl tcpServicePlugin = new ServicePluginImpl(response.toString()+"/?datatype=xml", new Receiver());
+			
+			tcpClientPlugin.send(msg);
+
+			tcpServicePlugin.listen();
+		}
+		catch (Exception ex)
+		{
+			ex.printStackTrace();
+		}
+	}
+	
+}
\ No newline at end of file

Copied: labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/remoting/OneWayTcpService.java (from rev 9740, 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/OneWayTcpService.java	                        (rev 0)
+++ labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/remoting/OneWayTcpService.java	2007-02-25 19:54:23 UTC (rev 9743)
@@ -0,0 +1,135 @@
+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.ClientPluginImpl;
+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 OneWayTcpService
+{
+	public static class Receiver implements ServicePluginImpl.Receiver
+	{
+		public void receive (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)
+			{
+			}
+			
+			ClientPluginImpl tcpClientPlugin = new ClientPluginImpl();
+			
+			Message response = MessageFactory.getInstance().getMessage();
+			response.getHeader().setCall(new Call(msg.getHeader().getCall().getReplyTo()));
+			
+			Body payload = response.getBody();
+			
+			String message = "Echo echo echo echo";
+			
+			payload.addBytes(message.getBytes());
+		    
+			try
+			{
+				tcpClientPlugin.send(response);
+				
+				System.err.println("Sent response to "+response.getHeader().getCall().getTo());
+			}
+			catch (Exception ex)
+			{
+				ex.printStackTrace();
+			}
+		}
+	}
+	
+	public static void main (String[] args) throws Exception
+	{
+		URI listener = new URI("socket://localhost:5555/?datatype=xml");
+		
+		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.
+			 */
+			
+			ServicePluginImpl tcpServicePlugin = new ServicePluginImpl(listener.toString(), new Receiver());
+			
+			tcpServicePlugin.listen();
+		}
+		catch (Exception ex)
+		{
+			ex.printStackTrace();
+		}
+	}
+	
+}
\ No newline at end of file

Deleted: 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	2007-02-25 13:18:08 UTC (rev 9742)
+++ labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/remoting/TcpClient.java	2007-02-25 19:54:23 UTC (rev 9743)
@@ -1,140 +0,0 @@
-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

Deleted: 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	2007-02-25 13:18:08 UTC (rev 9742)
+++ labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/remoting/TcpService.java	2007-02-25 19:54:23 UTC (rev 9743)
@@ -1,126 +0,0 @@
-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

Added: labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/remoting/TwoWayTcpClient.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/remoting/TwoWayTcpClient.java	                        (rev 0)
+++ labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/remoting/TwoWayTcpClient.java	2007-02-25 19:54:23 UTC (rev 9743)
@@ -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 TwoWayTcpClient
+{
+	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/TwoWayTcpService.java
===================================================================
--- labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/remoting/TwoWayTcpService.java	                        (rev 0)
+++ labs/jbossesb/workspace/rearch2/core/src/test/java/org/jboss/soa/esb/remoting/TwoWayTcpService.java	2007-02-25 19:54:23 UTC (rev 9743)
@@ -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 TwoWayTcpService
+{
+	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 TwoWayTcpService.Worker());
+			
+			tcpServicePlugin.listen();
+		}
+		catch (Exception ex)
+		{
+			ex.printStackTrace();
+		}
+	}
+	
+}
\ No newline at end of file




More information about the jboss-svn-commits mailing list