[jboss-svn-commits] JBL Code SVN: r21315 - in labs/jbossesb/trunk/product/rosetta: src/org/jboss/internal/soa/esb/message/format and 12 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Thu Jul 31 11:48:48 EDT 2008
Author: tfennelly
Date: 2008-07-31 11:48:48 -0400 (Thu, 31 Jul 2008)
New Revision: 21315
Added:
labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/message/format/MessageSerializer.java
labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/message/format/serialized/JavaMessageSerializer.java
labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/XMLMessageSerializer.java
labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/message/format/
labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/message/format/MessageSerializerUnitTest.java
labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/message/format/serialized/
labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/message/format/serialized/JavaMessageSerializerUnitTest.java
labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/message/format/xml/
labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/message/format/xml/XMLMessageSerializerUnitTest.java
labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/in-listener-config-05.xml
Modified:
labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/couriers/InVMCourier.java
labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/addressing/eprs/InVMEpr.java
labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/config/ESBAwareGenerator.java
labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/util/Util.java
labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/couriers/tests/InVMCourierUnitTest.java
labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/addressing/helpers/tests/InVMUnitTest.java
labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/InVMListenerUnitTest.java
Log:
https://jira.jboss.org/jira/browse/JBESB-1892
https://jira.jboss.org/jira/browse/JBESB-1893
Modified: labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/couriers/InVMCourier.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/couriers/InVMCourier.java 2008-07-31 14:06:18 UTC (rev 21314)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/couriers/InVMCourier.java 2008-07-31 15:48:48 UTC (rev 21315)
@@ -24,6 +24,7 @@
import org.apache.log4j.Logger;
import org.jboss.internal.soa.esb.couriers.tx.InVMXAResource;
+import org.jboss.internal.soa.esb.message.format.MessageSerializer;
import org.jboss.soa.esb.addressing.eprs.InVMEpr;
import org.jboss.soa.esb.common.TransactionStrategy;
import org.jboss.soa.esb.common.TransactionStrategyException;
@@ -54,12 +55,12 @@
protected static Logger logger = Logger.getLogger(InVMCourier.class);
- private Queue<Message> messageQueue = new ConcurrentLinkedQueue<Message>();
+ private Queue<Object> messageQueue = new ConcurrentLinkedQueue<Object>();
private long deliveryTimeout = 0;
private boolean isActive = true;
- private boolean passByReference = true;
+ private boolean passByValue = true;
/**
* Objects of this class should only be instantiated by internal
@@ -88,7 +89,7 @@
deliveryTimeout = 0;
}
- passByReference = epr.getPassByReference();
+ passByValue = epr.getPassByValue();
}
/**
@@ -98,7 +99,7 @@
* the transaction outcome to determine the fate of the message. For example, register
* a Synchronization.
*
- * @param Message - the message to deliverAsync
+ * @param message - the message to deliverAsync
* @return boolean - the result of the delivery
* @throws CourierException -
* if problems were encountered
@@ -153,26 +154,10 @@
else
{
synchronized (messageQueue) {
- /*
- * If not pass-by-reference then use a copy of
- * the input message.
- */
-
- if (!passByReference)
- {
- try
- {
- messageQueue.add(message.copy());
- }
- catch (IOException ex)
- {
- logger.warn("Could not create a copy of message to pass by value: "+ex);
-
- return false;
- }
+
+ if (!addMessageToQueue(message)) {
+ return false;
}
- else
- messageQueue.add(message);
// Notify 1 waiting pickup thread of the delivery...
messageQueue.notify();
@@ -198,6 +183,21 @@
}
}
+ private boolean addMessageToQueue(Message message) {
+ if (passByValue) {
+ try {
+ messageQueue.add(MessageSerializer.serialize(message));
+ } catch (IOException ex) {
+ logger.warn("Could not serialize message to pass by value.", ex);
+ return false;
+ }
+ } else {
+ messageQueue.add(message);
+ }
+
+ return true;
+ }
+
/**
* Get a mesage from the queue or wait for the specified time in case one
* arrives.
@@ -207,7 +207,7 @@
* reasons it is not guaranteed that the message will go back at the same relative
* position.
*
- * @param long the time to wait if the queue is empty.
+ * @param millis The time to wait if the queue is empty.
* @return a Message or <code>null</code> if there is nothing on the queue.
*/
@@ -232,7 +232,13 @@
}
}
if (!messageQueue.isEmpty()) {
- message = messageQueue.remove();
+ Object messageObj = messageQueue.remove();
+
+ if(messageObj instanceof byte[]) {
+ message = MessageSerializer.deserialize((byte[]) messageObj);
+ } else {
+ message = (Message) messageObj;
+ }
}
// Notify 1 waiting delivery thread of the pickup...
@@ -310,26 +316,9 @@
{
synchronized (messageQueue)
{
- /*
- * If not pass-by-reference then use a copy of
- * the input message.
- */
-
- if (!passByReference)
- {
- try
- {
- messageQueue.add(message.copy());
- }
- catch (IOException ex)
- {
- logger.warn("Could not create a copy of message to pass by value: "+ex);
-
- return false;
- }
+ if (!addMessageToQueue(message)) {
+ return false;
}
- else
- messageQueue.add(message);
// Notify 1 waiting pickup thread of the delivery...
messageQueue.notify();
Added: labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/message/format/MessageSerializer.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/message/format/MessageSerializer.java (rev 0)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/message/format/MessageSerializer.java 2008-07-31 15:48:48 UTC (rev 21315)
@@ -0,0 +1,116 @@
+/*
+ * 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, JBoss Inc.
+ */
+package org.jboss.internal.soa.esb.message.format;
+
+import org.jboss.internal.soa.esb.message.format.serialized.JavaMessageSerializer;
+import org.jboss.internal.soa.esb.message.format.xml.XMLMessageSerializer;
+import org.jboss.internal.soa.esb.assertion.AssertArgument;
+import org.jboss.soa.esb.message.Message;
+
+import java.io.*;
+
+/**
+ * Message Serialization interface.
+ *
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ */
+public abstract class MessageSerializer {
+
+ /**
+ * XML message byte buffer preamble.
+ */
+ public static final byte PREAMBLE_XML = 0;
+ /**
+ * Java message byte buffer preamble.
+ */
+ public static final byte PREAMBLE_JAVA = 1;
+
+ private static XMLMessageSerializer xmlSerializer = new XMLMessageSerializer();
+ private static JavaMessageSerializer javaSerializer = new JavaMessageSerializer();
+
+ /**
+ * Serialize the supplied message to the supplied {@link OutputStream}.
+ *
+ * @param message The message to be serialized.
+ * @param outStream The target {@link OutputStream}.
+ */
+ public abstract void serialize(Message message, OutputStream outStream) throws IOException;
+
+ /**
+ * Deserialize the message supplied in the {@link InputStream}.
+ *
+ * @param inStream The message source {@link InputStream}.
+ */
+ public abstract Message deserialize(InputStream inStream) throws IOException;
+
+ public static byte[] serialize(Message message) throws IOException {
+ ByteArrayOutputStream bytesOutStream = new ByteArrayOutputStream();
+ MessageSerializer.serializeMessage(message, bytesOutStream);
+
+ return bytesOutStream.toByteArray();
+ }
+
+ public static Message deserialize(byte[] messageBytes) throws IOException {
+ ByteArrayInputStream bytesInStream = new ByteArrayInputStream(messageBytes);
+ return MessageSerializer.deserializeMessage(bytesInStream);
+ }
+
+ public static void serializeMessage(Message message, OutputStream outStream) throws IOException {
+ AssertArgument.isNotNull(message, "message");
+ AssertArgument.isNotNull(outStream, "outStream");
+
+ MessageSerializer serializer;
+
+ // Select the serializer...
+ if(XMLMessageSerializer.isXMLMessage(message)) {
+ serializer = xmlSerializer;
+ } else if(JavaMessageSerializer.isJavaMessage(message)) {
+ serializer = javaSerializer;
+ } else {
+ throw new IOException("Unsupported Message implementation type '" + message.getClass().getName() + "'.");
+ }
+
+ // Run the serialize...
+ serializer.serialize(message, outStream);
+ }
+
+ public static Message deserializeMessage(InputStream inStream) throws IOException {
+ AssertArgument.isNotNull(inStream, "inStream");
+
+ if(!inStream.markSupported()) {
+ throw new IOException("Cannot perform Message deserialization on supplied InputStream. The InputStream must support mark and reset!");
+ }
+ inStream.mark(1);
+
+ int preamble = inStream.read();
+ MessageSerializer serializer;
+
+ inStream.reset();
+ if(preamble == PREAMBLE_XML) {
+ serializer = xmlSerializer;
+ } else if(preamble == PREAMBLE_JAVA) {
+ serializer = javaSerializer;
+ } else {
+ throw new IOException("Unsupported serialized Message format. Unrecognized message preamble.");
+ }
+
+ return serializer.deserialize(inStream);
+ }
+}
Property changes on: labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/message/format/MessageSerializer.java
___________________________________________________________________
Name: svn:eol-style
+ native
Added: labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/message/format/serialized/JavaMessageSerializer.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/message/format/serialized/JavaMessageSerializer.java (rev 0)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/message/format/serialized/JavaMessageSerializer.java 2008-07-31 15:48:48 UTC (rev 21315)
@@ -0,0 +1,76 @@
+/*
+ * 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, JBoss Inc.
+ */
+package org.jboss.internal.soa.esb.message.format.serialized;
+
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.util.ContextObjectInputStream;
+import org.jboss.internal.soa.esb.message.format.MessageSerializer;
+
+import java.io.*;
+
+/**
+ * Java Message serializer.
+ *
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ */
+public class JavaMessageSerializer extends MessageSerializer {
+
+
+ public void serialize(Message message, OutputStream outStream) throws IOException {
+ assertMessageInstanceOK(message);
+
+ // Write the preamble....
+ outStream.write(MessageSerializer.PREAMBLE_JAVA);
+
+ // Write the message...
+ ObjectOutputStream output = new ObjectOutputStream(outStream);
+ try {
+ output.writeObject(message);
+ } finally {
+ output.close();
+ }
+ }
+
+ public Message deserialize(InputStream inStream) throws IOException {
+ // Read and test the preamble...
+ if(inStream.read() != MessageSerializer.PREAMBLE_JAVA) {
+ throw new IOException("Cannot deserialize message. Unrecognized message preamble.");
+ }
+
+ ObjectInputStream input = new ContextObjectInputStream(inStream);
+ try {
+ return (Message) input.readObject();
+ } catch (ClassNotFoundException e) {
+ throw (IOException) (new IOException("Unable to deserialize message instance.").initCause(e));
+ } finally {
+ input.close();
+ }
+ }
+
+ public static boolean isJavaMessage(Message message) {
+ return message instanceof MessageImpl;
+ }
+
+ private void assertMessageInstanceOK(Message message) throws IOException {
+ if (!(isJavaMessage(message))) {
+ throw new IOException("Invalid Message instance. Expecting instance of '" + MessageImpl.class.getName() + "'.");
+ }
+ }
+}
\ No newline at end of file
Property changes on: labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/message/format/serialized/JavaMessageSerializer.java
___________________________________________________________________
Name: svn:eol-style
+ native
Added: labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/XMLMessageSerializer.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/XMLMessageSerializer.java (rev 0)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/XMLMessageSerializer.java 2008-07-31 15:48:48 UTC (rev 21315)
@@ -0,0 +1,110 @@
+/*
+ * 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, JBoss Inc.
+ */
+package org.jboss.internal.soa.esb.message.format.xml;
+
+import org.jboss.internal.soa.esb.message.format.MessageSerializer;
+import org.jboss.internal.soa.esb.util.XMLHelper;
+import org.jboss.internal.soa.esb.util.stax.StreamHelper;
+import org.jboss.soa.esb.message.Message;
+
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+
+/**
+ * XML Message serializer.
+ *
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ */
+public class XMLMessageSerializer extends MessageSerializer {
+
+ public void serialize(Message message, OutputStream outStream) throws IOException {
+ assertMessageInstanceOK(message);
+
+ // Write the preamble....
+ outStream.write(MessageSerializer.PREAMBLE_XML);
+
+ // Write the message...
+ XMLStreamWriter streamWriter;
+ try {
+ streamWriter = XMLHelper.getXMLStreamWriter(outStream);
+ } catch (XMLStreamException e) {
+ throw (IOException) (new IOException("Unable to create XMLStreamWriter instance.").initCause(e));
+ }
+
+ try {
+ String origURI = StreamHelper.writeStartElement(streamWriter, XMLUtil.ESB_QNAME_ENVELOPE);
+ ((MessageImpl) message).writeContent(streamWriter) ;
+ StreamHelper.writeEndElement(streamWriter, XMLUtil.ESB_QNAME_ENVELOPE.getPrefix(), origURI) ;
+ streamWriter.flush();
+ } catch (XMLStreamException e) {
+ throw (IOException) (new IOException("Error writing message to output stream.").initCause(e));
+ } finally {
+ try {
+ streamWriter.close();
+ } catch (XMLStreamException e) {
+ throw (IOException) (new IOException("Error closing XMLStreamWriter instance.").initCause(e));
+ }
+ }
+ }
+
+ public Message deserialize(InputStream inStream) throws IOException {
+ XMLStreamReader streamReader;
+
+ // Read and test the preamble...
+ if(inStream.read() != MessageSerializer.PREAMBLE_XML) {
+ throw new IOException("Cannot deserialize message. Unrecognized message preamble.");
+ }
+
+ // Read the message...
+ try {
+ streamReader = XMLHelper.getXMLStreamReader(new InputStreamReader(inStream)) ;
+ } catch (XMLStreamException e) {
+ throw (IOException) (new IOException("Unable to create XMLStreamReader instance.").initCause(e));
+ }
+
+ try {
+ StreamHelper.checkNextStartTag(streamReader, XMLUtil.ESB_QNAME_ENVELOPE) ;
+ return new MessageImpl(streamReader);
+ } catch (XMLStreamException e) {
+ throw (IOException) (new IOException("Error reading message to from stream.").initCause(e));
+ } finally {
+ try {
+ streamReader.close();
+ } catch (XMLStreamException e) {
+ throw (IOException) (new IOException("Error closing XMLStreamReader instance.").initCause(e));
+ }
+ }
+ }
+
+ private void assertMessageInstanceOK(Message message) throws IOException {
+ if (!(isXMLMessage(message))) {
+ throw new IOException("Invalid Message instance. Expecting instance of '" + MessageImpl.class.getName() + "'.");
+ }
+ }
+
+ public static boolean isXMLMessage(Message message) {
+ return message instanceof MessageImpl;
+ }
+}
Property changes on: labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/message/format/xml/XMLMessageSerializer.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/addressing/eprs/InVMEpr.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/addressing/eprs/InVMEpr.java 2008-07-31 14:06:18 UTC (rev 21314)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/addressing/eprs/InVMEpr.java 2008-07-31 15:48:48 UTC (rev 21315)
@@ -38,7 +38,7 @@
/**
* A helper class for using in-VM communication.
*
- * EPR: invm://servicename[/pass-by-reference][?lockstep[#waittime]]
+ * EPR: invm://servicename[/pass-by-value][?lockstep[#waittime]]
*
* where lockstep can be either true or false and waittime is the lockstep wait
* time in milliseconds. If lockstep is false then any value specified for
@@ -47,8 +47,8 @@
* e.g.,
*
* invm://myservice?true#20000 invm://myservice invm://myservice?false (same as
- * invm://myservice) or invm://myservice/false?false (first false is pass-by-reference
- * value, which in this case means pass the message by value, i.e., copy it).
+ * invm://myservice) or invm://myservice/false?false (first false is pass-by-value
+ * value).
*
* You can have a lockstep service, where the sender thread is tied to the one
* that does the execution (equivalent to the sender thread doing the work
@@ -81,7 +81,7 @@
private boolean _lockstepTime = false;
- private boolean _passByReference = false;
+ private boolean _passByValue = false;
public InVMEpr(EPR epr)
{
@@ -116,11 +116,10 @@
getAddr().addExtension(LOCKSTEP_WAIT_TIME_TAG, nl.item(i).getTextContent());
_lockstepTime = true;
}
- if (tag.equals(PASS_BY_VALUE))
- {
- getAddr().addExtension(PASS_BY_VALUE, nl.item(i).getTextContent());
- _lockstepTime = true;
- }
+ if (tag.equals(PASS_BY_VALUE))
+ {
+ getAddr().addExtension(PASS_BY_VALUE, nl.item(i).getTextContent());
+ }
}
}
}
@@ -161,9 +160,12 @@
}
}
- if ("/false".equalsIgnoreCase(passByReference))
- setPassByReference(false);
- }
+ if ("/true".equalsIgnoreCase(passByReference)) {
+ setPassByValue(true);
+ } else {
+ setPassByValue(false);
+ }
+ }
public String getServiceId()
{
@@ -239,27 +241,27 @@
_lockstepTime = true;
}
- public boolean getPassByReference ()
+ public boolean getPassByValue()
{
- String passByReference = getAddr().getExtensionValue(PASS_BY_VALUE);
+ String passByValue = getAddr().getExtensionValue(PASS_BY_VALUE);
- if (passByReference == null) // default
- return true;
+ if (passByValue == null) // default
+ return false;
- if ("false".equalsIgnoreCase(passByReference))
+ if ("false".equalsIgnoreCase(passByValue))
return false;
else
return true;
}
- public void setPassByReference (boolean val)
+ public void setPassByValue(boolean val)
{
- if (_passByReference)
- throw new IllegalStateException("Pass by reference already set!");
+ if (_passByValue)
+ throw new IllegalStateException("Pass by value already set!");
getAddr().addExtension(PASS_BY_VALUE, "" + val);
- _passByReference = true;
+ _passByValue = true;
}
public String toString()
Modified: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/config/ESBAwareGenerator.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/config/ESBAwareGenerator.java 2008-07-31 14:06:18 UTC (rev 21314)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/listeners/config/ESBAwareGenerator.java 2008-07-31 15:48:48 UTC (rev 21315)
@@ -110,6 +110,7 @@
MapperUtil.mapProperties(service.getPropertyList(), properties);
eprNode.setAttribute(ListenerTagNames.URL_TAG, InVMEpr.INVM_PROTOCOL + "://"
+ InVMEpr.createEncodedServiceId(service.getCategory(), service.getName())
+ + "/" + YADOMUtil.getAttribute(properties, "inVMPassByValue", "false")
+ "?" + YADOMUtil.getAttribute(properties, "inVMLockStep", "false")
+ "#" + YADOMUtil.getAttribute(properties, "inVMLockStepTimeout", "10000"));
Modified: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/util/Util.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/util/Util.java 2008-07-31 14:06:18 UTC (rev 21314)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/util/Util.java 2008-07-31 15:48:48 UTC (rev 21315)
@@ -189,7 +189,6 @@
StreamHelper.writeEndElement(out, XMLUtil.ESB_QNAME_ENVELOPE.getPrefix(), origURI) ;
out.flush();
int size = baos.toByteArray().length;
- String outputString = baos.toString();
message.getProperties().setProperty(Environment.MESSAGE_BYTE_SIZE, "" + size);
return baos.toString();
}
Modified: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/couriers/tests/InVMCourierUnitTest.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/couriers/tests/InVMCourierUnitTest.java 2008-07-31 14:06:18 UTC (rev 21314)
+++ labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/couriers/tests/InVMCourierUnitTest.java 2008-07-31 15:48:48 UTC (rev 21315)
@@ -133,7 +133,7 @@
@Test
public void testPassByValueDeliver() throws Exception {
- InVMEpr epr = new InVMEpr(new URI("invm://serviceid5/false?true#2000"));
+ InVMEpr epr = new InVMEpr(new URI("invm://serviceid5/true?true#2000"));
InVMCourier courier = new InVMCourier(epr);
Producer producer = new Producer(courier);
Consumer consumer = new Consumer(courier);
Added: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/message/format/MessageSerializerUnitTest.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/message/format/MessageSerializerUnitTest.java (rev 0)
+++ labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/message/format/MessageSerializerUnitTest.java 2008-07-31 15:48:48 UTC (rev 21315)
@@ -0,0 +1,55 @@
+/*
+ * 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, JBoss Inc.
+ */
+package org.jboss.internal.soa.esb.message.format;
+
+import junit.framework.TestCase;
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.message.format.MessageType;
+
+import java.io.IOException;
+
+/**
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ */
+public class MessageSerializerUnitTest extends TestCase {
+
+ public void test_xml() throws IOException {
+ Message message = MessageFactoryImpl.getInstance().getMessage(MessageType.JBOSS_XML);
+ testMessage(message);
+ }
+
+ public void test_java() throws IOException {
+ Message message = MessageFactoryImpl.getInstance().getMessage(MessageType.JAVA_SERIALIZED);
+ testMessage(message);
+ }
+
+ private void testMessage(Message originalMessage) throws IOException {
+ originalMessage.getBody().add("This is an Message!");
+
+ // Serialize...
+ byte[] messageBytes = MessageSerializer.serialize(originalMessage);
+
+ // Deserialize...
+ Message deserializedMessage = MessageSerializer.deserialize(messageBytes);
+
+ // Test...
+ assertEquals("This is an Message!", deserializedMessage.getBody().get());
+ }
+}
Property changes on: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/message/format/MessageSerializerUnitTest.java
___________________________________________________________________
Name: svn:eol-style
+ native
Added: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/message/format/serialized/JavaMessageSerializerUnitTest.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/message/format/serialized/JavaMessageSerializerUnitTest.java (rev 0)
+++ labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/message/format/serialized/JavaMessageSerializerUnitTest.java 2008-07-31 15:48:48 UTC (rev 21315)
@@ -0,0 +1,74 @@
+/*
+ * 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, JBoss Inc.
+ */
+package org.jboss.internal.soa.esb.message.format.serialized;
+
+import junit.framework.TestCase;
+import org.jboss.internal.soa.esb.message.format.MessageFactoryImpl;
+import org.jboss.internal.soa.esb.message.format.MessageSerializer;
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.message.format.MessageType;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+
+/**
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ */
+public class JavaMessageSerializerUnitTest extends TestCase {
+
+ public void test_all_ok() throws IOException {
+ Message originalMessage = MessageFactoryImpl.getInstance().getMessage(MessageType.JAVA_SERIALIZED);
+ JavaMessageSerializer serializer = new JavaMessageSerializer();
+
+ originalMessage.getBody().add("This is an Java Message!");
+
+ // serialize the message to bytes...
+ ByteArrayOutputStream bytesOutStream = new ByteArrayOutputStream();
+ serializer.serialize(originalMessage, bytesOutStream);
+
+ // deserialize the message from bytes....
+ ByteArrayInputStream bytesInStream = new ByteArrayInputStream(bytesOutStream.toByteArray());
+ Message deserMessage = serializer.deserialize(bytesInStream);
+
+ // Make sure they're the same message...
+ assertEquals("This is an Java Message!", deserMessage.getBody().get());
+ }
+
+ public void test_invalid_preamble() throws IOException {
+ Message originalMessage = MessageFactoryImpl.getInstance().getMessage(MessageType.JAVA_SERIALIZED);
+ JavaMessageSerializer serializer = new JavaMessageSerializer();
+
+ // serialize the message to bytes...
+ ByteArrayOutputStream bytesOutStream = new ByteArrayOutputStream();
+ serializer.serialize(originalMessage, bytesOutStream);
+
+ // deserialize the message from bytes, corrupt it and then try deserialize....
+ byte[] messageBytes = bytesOutStream.toByteArray();
+ messageBytes[0] = MessageSerializer.PREAMBLE_XML;
+ ByteArrayInputStream bytesInStream = new ByteArrayInputStream(messageBytes);
+ try {
+ serializer.deserialize(bytesInStream);
+ fail("Expected IOException.");
+ } catch(IOException e) {
+ assertEquals("Cannot deserialize message. Unrecognized message preamble.", e.getMessage());
+ }
+ }
+}
\ No newline at end of file
Property changes on: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/message/format/serialized/JavaMessageSerializerUnitTest.java
___________________________________________________________________
Name: svn:eol-style
+ native
Added: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/message/format/xml/XMLMessageSerializerUnitTest.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/message/format/xml/XMLMessageSerializerUnitTest.java (rev 0)
+++ labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/message/format/xml/XMLMessageSerializerUnitTest.java 2008-07-31 15:48:48 UTC (rev 21315)
@@ -0,0 +1,74 @@
+/*
+ * 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, JBoss Inc.
+ */
+package org.jboss.internal.soa.esb.message.format.xml;
+
+import junit.framework.TestCase;
+import org.jboss.internal.soa.esb.message.format.MessageFactoryImpl;
+import org.jboss.internal.soa.esb.message.format.MessageSerializer;
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.message.format.MessageType;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+
+/**
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ */
+public class XMLMessageSerializerUnitTest extends TestCase {
+
+ public void test_all_ok() throws IOException {
+ Message originalMessage = MessageFactoryImpl.getInstance().getMessage(MessageType.JBOSS_XML);
+ XMLMessageSerializer serializer = new XMLMessageSerializer();
+
+ originalMessage.getBody().add("This is an XML Message!");
+
+ // serialize the message to bytes...
+ ByteArrayOutputStream bytesOutStream = new ByteArrayOutputStream();
+ serializer.serialize(originalMessage, bytesOutStream);
+
+ // deserialize the message from bytes....
+ ByteArrayInputStream bytesInStream = new ByteArrayInputStream(bytesOutStream.toByteArray());
+ Message deserMessage = serializer.deserialize(bytesInStream);
+
+ // Make sure they're the same message...
+ assertEquals("This is an XML Message!", deserMessage.getBody().get());
+ }
+
+ public void test_invalid_preamble() throws IOException {
+ Message originalMessage = MessageFactoryImpl.getInstance().getMessage(MessageType.JBOSS_XML);
+ XMLMessageSerializer serializer = new XMLMessageSerializer();
+
+ // serialize the message to bytes...
+ ByteArrayOutputStream bytesOutStream = new ByteArrayOutputStream();
+ serializer.serialize(originalMessage, bytesOutStream);
+
+ // deserialize the message from bytes, corrupt it and then try deserialize....
+ byte[] messageBytes = bytesOutStream.toByteArray();
+ messageBytes[0] = MessageSerializer.PREAMBLE_JAVA;
+ ByteArrayInputStream bytesInStream = new ByteArrayInputStream(messageBytes);
+ try {
+ serializer.deserialize(bytesInStream);
+ fail("Expected IOException.");
+ } catch(IOException e) {
+ assertEquals("Cannot deserialize message. Unrecognized message preamble.", e.getMessage());
+ }
+ }
+}
Property changes on: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/message/format/xml/XMLMessageSerializerUnitTest.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/addressing/helpers/tests/InVMUnitTest.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/addressing/helpers/tests/InVMUnitTest.java 2008-07-31 14:06:18 UTC (rev 21314)
+++ labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/addressing/helpers/tests/InVMUnitTest.java 2008-07-31 15:48:48 UTC (rev 21315)
@@ -50,13 +50,13 @@
}
}
- public void testPassByReference ()
+ public void testPassByValue()
{
try
{
- InVMEpr epr = new InVMEpr(new URI("invm://myservice/false?true#1234"));
+ InVMEpr epr = new InVMEpr(new URI("invm://myservice/true?true#1234"));
- assertEquals(epr.getPassByReference(), false);
+ assertEquals(epr.getPassByValue(), true);
}
catch (Exception ex)
{
Modified: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/InVMListenerUnitTest.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/InVMListenerUnitTest.java 2008-07-31 14:06:18 UTC (rev 21314)
+++ labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/InVMListenerUnitTest.java 2008-07-31 15:48:48 UTC (rev 21315)
@@ -139,6 +139,23 @@
assertEquals("10", maxThreads);
}
+ public void test_passByValue() throws Exception {
+ AbstractTestRunner testRunner = new AbstractTestRunner() {
+ public void test() throws Exception {
+ ServiceInvoker invoker = new ServiceInvoker("ServiceCat", "ServiceName");
+ Message message = MessageFactory.getInstance().getMessage();
+
+ message.getBody().add("This message was passed by value!");
+ invoker.deliverSync(message, 2000);
+
+ assertTrue(message != MockAction.message);
+ assertEquals("This message was passed by value!", MockAction.message.getBody().get());
+ }
+ }.setServiceConfig("in-listener-config-05.xml");
+
+ testRunner.run();
+ }
+
public void test_sync_multithreaded() throws Exception {
AbstractTestRunner testRunner = new AbstractTestRunner() {
public void test() throws Exception {
Copied: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/in-listener-config-05.xml (from rev 21309, labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/in-listener-config-01.xml)
===================================================================
--- labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/in-listener-config-05.xml (rev 0)
+++ labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/in-listener-config-05.xml 2008-07-31 15:48:48 UTC (rev 21315)
@@ -0,0 +1,13 @@
+<?xml version = "1.0" encoding = "UTF-8"?>
+<jbossesb xmlns="http://anonsvn.labs.jboss.com/labs/jbossesb/trunk/product/etc/schemas/xml/jbossesb-1.0.1.xsd">
+
+ <services>
+ <service category="ServiceCat" name="ServiceName" description="Test Service">
+ <property name="inVMPassByValue" value="true" />
+ <actions mep="RequestResponse">
+ <action name="action" class="org.jboss.soa.esb.mock.MockAction" />
+ </actions>
+ </service>
+ </services>
+
+</jbossesb>
\ No newline at end of file
More information about the jboss-svn-commits
mailing list