[jboss-cvs] JBoss Messaging SVN: r3360 - in branches/Branch_JBMESSAGING-544: src/main/org/jboss/jms/server/endpoint/advised and 4 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri Nov 23 08:41:11 EST 2007
Author: jmesnil
Date: 2007-11-23 08:41:10 -0500 (Fri, 23 Nov 2007)
New Revision: 3360
Added:
branches/Branch_JBMESSAGING-544/src/main/org/jboss/messaging/core/remoting/codec/BrowserNextMessageBlockRequestCodec.java
branches/Branch_JBMESSAGING-544/src/main/org/jboss/messaging/core/remoting/codec/BrowserNextMessageBlockResponseCodec.java
branches/Branch_JBMESSAGING-544/src/main/org/jboss/messaging/core/remoting/codec/GetClientAOPStackResponseCodec.java
branches/Branch_JBMESSAGING-544/src/main/org/jboss/messaging/core/remoting/codec/GetPreparedTransactionsResponseCodec.java
branches/Branch_JBMESSAGING-544/src/main/org/jboss/messaging/core/remoting/codec/GetTopologyResponseCodec.java
branches/Branch_JBMESSAGING-544/src/main/org/jboss/messaging/core/remoting/wireformat/BrowserNextMessageBlockRequest.java
branches/Branch_JBMESSAGING-544/src/main/org/jboss/messaging/core/remoting/wireformat/BrowserNextMessageBlockResponse.java
branches/Branch_JBMESSAGING-544/src/main/org/jboss/messaging/core/remoting/wireformat/GetClientAOPStackRequest.java
branches/Branch_JBMESSAGING-544/src/main/org/jboss/messaging/core/remoting/wireformat/GetClientAOPStackResponse.java
branches/Branch_JBMESSAGING-544/src/main/org/jboss/messaging/core/remoting/wireformat/GetPreparedTransactionsRequest.java
branches/Branch_JBMESSAGING-544/src/main/org/jboss/messaging/core/remoting/wireformat/GetPreparedTransactionsResponse.java
branches/Branch_JBMESSAGING-544/src/main/org/jboss/messaging/core/remoting/wireformat/GetTopologyRequest.java
branches/Branch_JBMESSAGING-544/src/main/org/jboss/messaging/core/remoting/wireformat/GetTopologyResponse.java
Modified:
branches/Branch_JBMESSAGING-544/src/main/org/jboss/jms/client/delegate/ClientBrowserDelegate.java
branches/Branch_JBMESSAGING-544/src/main/org/jboss/jms/client/delegate/ClientClusteredConnectionFactoryDelegate.java
branches/Branch_JBMESSAGING-544/src/main/org/jboss/jms/client/delegate/ClientConnectionDelegate.java
branches/Branch_JBMESSAGING-544/src/main/org/jboss/jms/client/delegate/ClientConnectionFactoryDelegate.java
branches/Branch_JBMESSAGING-544/src/main/org/jboss/jms/client/delegate/DelegateSupport.java
branches/Branch_JBMESSAGING-544/src/main/org/jboss/jms/server/endpoint/advised/ConnectionAdvised.java
branches/Branch_JBMESSAGING-544/src/main/org/jboss/jms/server/endpoint/advised/ConnectionFactoryAdvised.java
branches/Branch_JBMESSAGING-544/src/main/org/jboss/messaging/core/remoting/Constants.java
branches/Branch_JBMESSAGING-544/src/main/org/jboss/messaging/core/remoting/codec/PacketCodecFactory.java
branches/Branch_JBMESSAGING-544/src/main/org/jboss/messaging/core/remoting/wireformat/PacketType.java
branches/Branch_JBMESSAGING-544/tests/src/org/jboss/test/messaging/core/remoting/wireformat/PacketTypeTest.java
Log:
http://jira.jboss.org/jira/browse/JBMESSAGING-544: Replace client-server transport with NIO based transport
Modified: branches/Branch_JBMESSAGING-544/src/main/org/jboss/jms/client/delegate/ClientBrowserDelegate.java
===================================================================
--- branches/Branch_JBMESSAGING-544/src/main/org/jboss/jms/client/delegate/ClientBrowserDelegate.java 2007-11-22 16:49:46 UTC (rev 3359)
+++ branches/Branch_JBMESSAGING-544/src/main/org/jboss/jms/client/delegate/ClientBrowserDelegate.java 2007-11-23 13:41:10 UTC (rev 3360)
@@ -30,14 +30,14 @@
import org.jboss.jms.client.state.HierarchicalState;
import org.jboss.jms.delegate.BrowserDelegate;
import org.jboss.jms.message.JBossMessage;
-import org.jboss.jms.wireformat.BrowserNextMessageBlockRequest;
-import org.jboss.jms.wireformat.CloseRequest;
-import org.jboss.jms.wireformat.ClosingRequest;
-import org.jboss.jms.wireformat.RequestSupport;
import org.jboss.messaging.core.remoting.wireformat.BrowserHasNextMessageRequest;
import org.jboss.messaging.core.remoting.wireformat.BrowserHasNextMessageResponse;
+import org.jboss.messaging.core.remoting.wireformat.BrowserNextMessageBlockRequest;
+import org.jboss.messaging.core.remoting.wireformat.BrowserNextMessageBlockResponse;
import org.jboss.messaging.core.remoting.wireformat.BrowserNextMessageResponse;
import org.jboss.messaging.core.remoting.wireformat.BrowserResetMessage;
+import org.jboss.messaging.core.remoting.wireformat.CloseMessage;
+import org.jboss.messaging.core.remoting.wireformat.ClosingResponse;
/**
* The client-side Browser delegate class.
@@ -107,16 +107,21 @@
public void close() throws JMSException
{
- RequestSupport req = new CloseRequest(id, version);
-
- doInvoke(client, req);
+ sendBlocking(new CloseMessage());
+
+// RequestSupport req = new CloseRequest(id, version);
+//
+// doInvoke(client, req);
}
public long closing(long sequence) throws JMSException
{
- RequestSupport req = new ClosingRequest(sequence, id, version);
-
- return ((Long)doInvoke(client, req)).longValue();
+ ClosingResponse response = (ClosingResponse) sendBlocking(new org.jboss.messaging.core.remoting.wireformat.ClosingRequest(sequence));
+ return response.getID();
+
+// RequestSupport req = new ClosingRequest(sequence, id, version);
+//
+// return ((Long)doInvoke(client, req)).longValue();
}
// BrowserDelegate implementation ---------------------------------------------------------------
@@ -144,9 +149,13 @@
public JBossMessage[] nextMessageBlock(int maxMessages) throws JMSException
{
- RequestSupport req = new BrowserNextMessageBlockRequest(id, version, maxMessages);
- return (JBossMessage[])doInvoke(client, req);
+ BrowserNextMessageBlockResponse response = (BrowserNextMessageBlockResponse) sendBlocking(new BrowserNextMessageBlockRequest(maxMessages));
+ return response.getMessages();
+
+ // RequestSupport req = new BrowserNextMessageBlockRequest(id, version, maxMessages);
+//
+// return (JBossMessage[])doInvoke(client, req);
}
// Streamable implementation ----------------------------------------------------------
Modified: branches/Branch_JBMESSAGING-544/src/main/org/jboss/jms/client/delegate/ClientClusteredConnectionFactoryDelegate.java
===================================================================
--- branches/Branch_JBMESSAGING-544/src/main/org/jboss/jms/client/delegate/ClientClusteredConnectionFactoryDelegate.java 2007-11-22 16:49:46 UTC (rev 3359)
+++ branches/Branch_JBMESSAGING-544/src/main/org/jboss/jms/client/delegate/ClientClusteredConnectionFactoryDelegate.java 2007-11-23 13:41:10 UTC (rev 3360)
@@ -22,26 +22,26 @@
package org.jboss.jms.client.delegate;
import java.io.Serializable;
+import java.util.Collections;
import java.util.Map;
import java.util.Set;
-import java.util.Collections;
import javax.jms.JMSException;
+import org.jboss.jms.client.container.JMSClientVMIdentifier;
import org.jboss.jms.client.plugin.LoadBalancingPolicy;
+import org.jboss.jms.client.remoting.ConnectionFactoryCallbackHandler;
import org.jboss.jms.client.remoting.JMSRemotingConnection;
-import org.jboss.jms.client.remoting.ConnectionFactoryCallbackHandler;
-import org.jboss.jms.client.container.JMSClientVMIdentifier;
import org.jboss.jms.delegate.ConnectionFactoryDelegate;
import org.jboss.jms.delegate.CreateConnectionResult;
import org.jboss.jms.delegate.IDBlock;
import org.jboss.jms.delegate.TopologyResult;
import org.jboss.jms.exception.MessagingNetworkFailureException;
import org.jboss.jms.wireformat.ConnectionFactoryAddCallbackRequest;
-import org.jboss.jms.wireformat.ConnectionFactoryGetTopologyRequest;
-import org.jboss.jms.wireformat.ConnectionFactoryGetTopologyResponse;
import org.jboss.jms.wireformat.ConnectionFactoryRemoveCallbackRequest;
import org.jboss.logging.Logger;
+import org.jboss.messaging.core.remoting.wireformat.GetTopologyRequest;
+import org.jboss.messaging.core.remoting.wireformat.GetTopologyResponse;
import org.jboss.messaging.util.Version;
import org.jboss.messaging.util.WeakHashSet;
@@ -311,24 +311,31 @@
public TopologyResult getTopology() throws JMSException
{
- try
- {
- ConnectionFactoryGetTopologyRequest request =
- new ConnectionFactoryGetTopologyRequest(currentDelegate.getID());
+// try
+// {
+// ConnectionFactoryGetTopologyRequest request =
+// new ConnectionFactoryGetTopologyRequest(currentDelegate.getID());
+//
+// ConnectionFactoryGetTopologyResponse response = (ConnectionFactoryGetTopologyResponse)remoting.getRemotingClient().invoke(request, null);
+//
+//
+// TopologyResult topology = (TopologyResult)response.getResponse();
+//
+// updateFailoverInfo(topology.getDelegates(), topology.getFailoverMap());
+//
+// return topology;
+// }
+// catch (Throwable e)
+// {
+// throw handleThrowable(e);
+// }
+
+ GetTopologyResponse response = (GetTopologyResponse) sendBlocking(remoting.getNewRemotingClient(), currentDelegate.getID(), new GetTopologyRequest());
+ TopologyResult topology = response.getTopology();
- ConnectionFactoryGetTopologyResponse response = (ConnectionFactoryGetTopologyResponse)remoting.getRemotingClient().invoke(request, null);
+ updateFailoverInfo(topology.getDelegates(), topology.getFailoverMap());
-
- TopologyResult topology = (TopologyResult)response.getResponse();
-
- updateFailoverInfo(topology.getDelegates(), topology.getFailoverMap());
-
- return topology;
- }
- catch (Throwable e)
- {
- throw handleThrowable(e);
- }
+ return topology;
}
//Only used in testing
Modified: branches/Branch_JBMESSAGING-544/src/main/org/jboss/jms/client/delegate/ClientConnectionDelegate.java
===================================================================
--- branches/Branch_JBMESSAGING-544/src/main/org/jboss/jms/client/delegate/ClientConnectionDelegate.java 2007-11-22 16:49:46 UTC (rev 3359)
+++ branches/Branch_JBMESSAGING-544/src/main/org/jboss/jms/client/delegate/ClientConnectionDelegate.java 2007-11-23 13:41:10 UTC (rev 3360)
@@ -41,7 +41,6 @@
import org.jboss.jms.tx.MessagingXid;
import org.jboss.jms.tx.ResourceManagerFactory;
import org.jboss.jms.tx.TransactionRequest;
-import org.jboss.jms.wireformat.ConnectionGetPreparedTransactionsRequest;
import org.jboss.jms.wireformat.ConnectionStartRequest;
import org.jboss.jms.wireformat.RequestSupport;
import org.jboss.logging.Logger;
@@ -51,6 +50,8 @@
import org.jboss.messaging.core.remoting.wireformat.CreateSessionResponse;
import org.jboss.messaging.core.remoting.wireformat.GetClientIDRequest;
import org.jboss.messaging.core.remoting.wireformat.GetClientIDResponse;
+import org.jboss.messaging.core.remoting.wireformat.GetPreparedTransactionsRequest;
+import org.jboss.messaging.core.remoting.wireformat.GetPreparedTransactionsResponse;
import org.jboss.messaging.core.remoting.wireformat.IDBlockRequest;
import org.jboss.messaging.core.remoting.wireformat.IDBlockResponse;
import org.jboss.messaging.core.remoting.wireformat.SendTransactionMessage;
@@ -270,9 +271,15 @@
public void startAfterFailover() throws JMSException
{
- RequestSupport req = new ConnectionStartRequest(id, version);
+ assert newClient != null;
- doInvoke(client, req);
+ StartConnectionMessage message = new StartConnectionMessage();
+ message.setTargetID(id);
+ newClient.sendOneWay(message);
+
+// RequestSupport req = new ConnectionStartRequest(id, version);
+//
+// doInvoke(client, req);
}
public void stop() throws JMSException
@@ -286,9 +293,13 @@
public MessagingXid[] getPreparedTransactions() throws JMSException
{
- RequestSupport req = new ConnectionGetPreparedTransactionsRequest(id, version);
-
- return (MessagingXid[])doInvoke(client, req);
+ GetPreparedTransactionsResponse response = (GetPreparedTransactionsResponse) sendBlocking(new GetPreparedTransactionsRequest());
+
+ return response.getXids();
+
+// RequestSupport req = new ConnectionGetPreparedTransactionsRequest(id, version);
+//
+// return (MessagingXid[])doInvoke(client, req);
}
/**
Modified: branches/Branch_JBMESSAGING-544/src/main/org/jboss/jms/client/delegate/ClientConnectionFactoryDelegate.java
===================================================================
--- branches/Branch_JBMESSAGING-544/src/main/org/jboss/jms/client/delegate/ClientConnectionFactoryDelegate.java 2007-11-22 16:49:46 UTC (rev 3359)
+++ branches/Branch_JBMESSAGING-544/src/main/org/jboss/jms/client/delegate/ClientConnectionFactoryDelegate.java 2007-11-23 13:41:10 UTC (rev 3360)
@@ -21,6 +21,8 @@
*/
package org.jboss.jms.client.delegate;
+import static org.jboss.messaging.core.remoting.TransportType.TCP;
+
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.Serializable;
@@ -36,10 +38,12 @@
import org.jboss.jms.delegate.TopologyResult;
import org.jboss.jms.exception.MessagingNetworkFailureException;
import org.jboss.jms.server.ServerPeer;
-import org.jboss.jms.wireformat.ConnectionFactoryGetClientAOPStackRequest;
import org.jboss.jms.wireformat.JMSWireFormat;
+import org.jboss.messaging.core.remoting.Constants;
import org.jboss.messaging.core.remoting.wireformat.CreateConnectionRequest;
import org.jboss.messaging.core.remoting.wireformat.CreateConnectionResponse;
+import org.jboss.messaging.core.remoting.wireformat.GetClientAOPStackRequest;
+import org.jboss.messaging.core.remoting.wireformat.GetClientAOPStackResponse;
import org.jboss.messaging.util.Version;
import org.jboss.remoting.Client;
import org.jboss.remoting.InvokerLocator;
@@ -243,20 +247,28 @@
byte v = version.getProviderIncrementingVersion();
- // Create a client - make sure pinging is off
-
- Map configuration = new HashMap();
-
- configuration.put(Client.ENABLE_LEASE, String.valueOf(false));
-
- //We execute this on its own client
+// // Create a client - make sure pinging is off
+//
+// Map configuration = new HashMap();
+//
+// configuration.put(Client.ENABLE_LEASE, String.valueOf(false));
+//
+// //We execute this on its own client
+//
+// Client theClient = createClient();
+//
+// ConnectionFactoryGetClientAOPStackRequest req =
+// new ConnectionFactoryGetClientAOPStackRequest(id, v);
+//
+// byte[] stack = (byte[])doInvoke(theClient, req);
+//
+// theClient.disconnect();
+//
- Client theClient = createClient();
+ org.jboss.messaging.core.remoting.Client client = createNewClient();
- ConnectionFactoryGetClientAOPStackRequest req =
- new ConnectionFactoryGetClientAOPStackRequest(id, v);
-
- return (byte[])doInvoke(theClient, req);
+ GetClientAOPStackResponse response = (GetClientAOPStackResponse) sendBlocking(client, id, new GetClientAOPStackRequest());
+ return response.getStack();
}
public TopologyResult getTopology() throws JMSException
@@ -336,6 +348,25 @@
return client;
}
+ private org.jboss.messaging.core.remoting.Client createNewClient() throws JMSException
+ {
+ //We execute this on it's own client
+ org.jboss.messaging.core.remoting.Client client;
+
+ try
+ {
+ InvokerLocator locator = new InvokerLocator(serverLocatorURI);
+ client = new org.jboss.messaging.core.remoting.Client();
+ client.connect(locator.getHost(), Constants.PORT, TCP);
+ }
+ catch (Exception e)
+ {
+ throw new MessagingNetworkFailureException("Failed to connect client", e);
+ }
+
+ return client;
+ }
+
// Streamable implementation --------------------------------------------
public void read(DataInputStream in) throws Exception
Modified: branches/Branch_JBMESSAGING-544/src/main/org/jboss/jms/client/delegate/DelegateSupport.java
===================================================================
--- branches/Branch_JBMESSAGING-544/src/main/org/jboss/jms/client/delegate/DelegateSupport.java 2007-11-22 16:49:46 UTC (rev 3359)
+++ branches/Branch_JBMESSAGING-544/src/main/org/jboss/jms/client/delegate/DelegateSupport.java 2007-11-23 13:41:10 UTC (rev 3360)
@@ -21,6 +21,8 @@
*/
package org.jboss.jms.client.delegate;
+import static org.jboss.messaging.core.remoting.Assert.assertValidID;
+
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
@@ -170,13 +172,19 @@
protected AbstractPacket sendBlocking(AbstractPacket request) throws JMSException
{
- assert newClient != null;
+ return sendBlocking(newClient, id, request);
+ }
+
+ protected static AbstractPacket sendBlocking(org.jboss.messaging.core.remoting.Client client, String targetID, AbstractPacket request) throws JMSException
+ {
+ assert client != null;
+ assertValidID(targetID);
assert request != null;
- request.setTargetID(id);
+ request.setTargetID(targetID);
try
{
- AbstractPacket response = (AbstractPacket) newClient.sendBlocking(request);
+ AbstractPacket response = (AbstractPacket) client.sendBlocking(request);
if (response instanceof JMSExceptionMessage)
{
JMSExceptionMessage message = (JMSExceptionMessage) response;
@@ -231,7 +239,7 @@
}
}
- public JMSException handleThrowable(Throwable t)
+ public static JMSException handleThrowable(Throwable t)
{
// ConnectionFailedException could happen during ConnectionFactory.createConnection.
// IOException could happen during an interrupted exception.
Modified: branches/Branch_JBMESSAGING-544/src/main/org/jboss/jms/server/endpoint/advised/ConnectionAdvised.java
===================================================================
--- branches/Branch_JBMESSAGING-544/src/main/org/jboss/jms/server/endpoint/advised/ConnectionAdvised.java 2007-11-22 16:49:46 UTC (rev 3359)
+++ branches/Branch_JBMESSAGING-544/src/main/org/jboss/jms/server/endpoint/advised/ConnectionAdvised.java 2007-11-23 13:41:10 UTC (rev 3360)
@@ -29,6 +29,7 @@
import static org.jboss.messaging.core.remoting.wireformat.PacketType.REQ_CLOSING;
import static org.jboss.messaging.core.remoting.wireformat.PacketType.REQ_CREATESESSION;
import static org.jboss.messaging.core.remoting.wireformat.PacketType.REQ_GETCLIENTID;
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.REQ_GETPREPAREDTRANSACTIONS;
import static org.jboss.messaging.core.remoting.wireformat.PacketType.REQ_IDBLOCK;
import javax.jms.JMSException;
@@ -46,6 +47,7 @@
import org.jboss.messaging.core.remoting.wireformat.CreateSessionRequest;
import org.jboss.messaging.core.remoting.wireformat.CreateSessionResponse;
import org.jboss.messaging.core.remoting.wireformat.GetClientIDResponse;
+import org.jboss.messaging.core.remoting.wireformat.GetPreparedTransactionsResponse;
import org.jboss.messaging.core.remoting.wireformat.IDBlockRequest;
import org.jboss.messaging.core.remoting.wireformat.IDBlockResponse;
import org.jboss.messaging.core.remoting.wireformat.JMSExceptionMessage;
@@ -221,6 +223,12 @@
NullPacket response = new NullPacket();
response.normalize(message);
session.write(response);
+ } else if (type == REQ_GETPREPAREDTRANSACTIONS)
+ {
+ MessagingXid[] xids = getPreparedTransactions();
+ GetPreparedTransactionsResponse response = new GetPreparedTransactionsResponse(xids);
+ response.normalize(packet);
+ session.write(response);
} else if (type == REQ_GETCLIENTID)
{
GetClientIDResponse response = new GetClientIDResponse(getClientID());
Modified: branches/Branch_JBMESSAGING-544/src/main/org/jboss/jms/server/endpoint/advised/ConnectionFactoryAdvised.java
===================================================================
--- branches/Branch_JBMESSAGING-544/src/main/org/jboss/jms/server/endpoint/advised/ConnectionFactoryAdvised.java 2007-11-22 16:49:46 UTC (rev 3359)
+++ branches/Branch_JBMESSAGING-544/src/main/org/jboss/jms/server/endpoint/advised/ConnectionFactoryAdvised.java 2007-11-23 13:41:10 UTC (rev 3360)
@@ -22,6 +22,8 @@
package org.jboss.jms.server.endpoint.advised;
import static org.jboss.messaging.core.remoting.wireformat.PacketType.REQ_CREATECONNECTION;
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.REQ_GETCLIENTAOPSTACK;
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.REQ_GETTOPOLOGY;
import javax.jms.JMSException;
@@ -36,6 +38,8 @@
import org.jboss.messaging.core.remoting.wireformat.AbstractPacket;
import org.jboss.messaging.core.remoting.wireformat.CreateConnectionRequest;
import org.jboss.messaging.core.remoting.wireformat.CreateConnectionResponse;
+import org.jboss.messaging.core.remoting.wireformat.GetClientAOPStackResponse;
+import org.jboss.messaging.core.remoting.wireformat.GetTopologyResponse;
import org.jboss.messaging.core.remoting.wireformat.JMSExceptionMessage;
import org.jboss.messaging.core.remoting.wireformat.PacketType;
import org.jboss.remoting.callback.ServerInvokerCallbackHandler;
@@ -171,10 +175,24 @@
CreateConnectionRequest request = (CreateConnectionRequest) packet;
CreateConnectionResult del =
createConnectionDelegate(request.getUsername(), request.getPassword(), request.getFailedNodeID(), null, request.getClientVMID(), request.getVersion(), null);
+
CreateConnectionResponse response = new CreateConnectionResponse(del.getDelegate().getID(), del.getDelegate().getServerID());
response.normalize(request);
session.write(response);
+ } else if (type == REQ_GETCLIENTAOPSTACK)
+ {
+ byte[] stack = getClientAOPStack();
+ GetClientAOPStackResponse response = new GetClientAOPStackResponse(stack);
+ response.normalize(packet);
+ session.write(response);
+ } else if (type == REQ_GETTOPOLOGY)
+ {
+ TopologyResult topology = getTopology();
+
+ GetTopologyResponse response = new GetTopologyResponse(topology);
+ response.normalize(packet);
+ session.write(response);
} else
{
System.err.println("unhandled packet:" + packet);
Modified: branches/Branch_JBMESSAGING-544/src/main/org/jboss/messaging/core/remoting/Constants.java
===================================================================
--- branches/Branch_JBMESSAGING-544/src/main/org/jboss/messaging/core/remoting/Constants.java 2007-11-22 16:49:46 UTC (rev 3359)
+++ branches/Branch_JBMESSAGING-544/src/main/org/jboss/messaging/core/remoting/Constants.java 2007-11-23 13:41:10 UTC (rev 3360)
@@ -21,7 +21,7 @@
public static final String NO_ID_SET = "NO_ID_SET";
- public static final int PORT = 8080;
+ public static final int PORT = 9090;
public static final String PACKET_TYPE_HEADER = "PACKET_TYPE";
Added: branches/Branch_JBMESSAGING-544/src/main/org/jboss/messaging/core/remoting/codec/BrowserNextMessageBlockRequestCodec.java
===================================================================
--- branches/Branch_JBMESSAGING-544/src/main/org/jboss/messaging/core/remoting/codec/BrowserNextMessageBlockRequestCodec.java (rev 0)
+++ branches/Branch_JBMESSAGING-544/src/main/org/jboss/messaging/core/remoting/codec/BrowserNextMessageBlockRequestCodec.java 2007-11-23 13:41:10 UTC (rev 3360)
@@ -0,0 +1,67 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.messaging.core.remoting.codec;
+
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.REQ_BROWSER_NEXTMESSAGEBLOCK;
+
+import org.apache.mina.common.IoBuffer;
+import org.apache.mina.common.IoSession;
+import org.jboss.messaging.core.remoting.wireformat.BrowserNextMessageBlockRequest;
+
+/**
+ * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>.
+ */
+public class BrowserNextMessageBlockRequestCodec extends AbstractPacketCodec<BrowserNextMessageBlockRequest>
+{
+ // Constants -----------------------------------------------------
+
+ // Attributes ----------------------------------------------------
+
+ // Static --------------------------------------------------------
+
+ // Constructors --------------------------------------------------
+
+ public BrowserNextMessageBlockRequestCodec()
+ {
+ super(REQ_BROWSER_NEXTMESSAGEBLOCK);
+ }
+
+ // Public --------------------------------------------------------
+
+ // AbstractPacketCodec overrides ---------------------------------
+
+ @Override
+ protected void encodeBody(IoSession session, BrowserNextMessageBlockRequest request,
+ IoBuffer out) throws Exception
+ {
+ out.putInt(LONG_LENGTH);
+ out.putLong(request.getMaxMessages());
+ }
+
+ @Override
+ protected BrowserNextMessageBlockRequest decodeBody(IoSession session, IoBuffer in)
+ throws Exception
+ {
+ int bodyLength = in.getInt();
+ if (in.remaining() < bodyLength)
+ {
+ return null;
+ }
+
+ long maxMessages = in.getLong();
+
+ return new BrowserNextMessageBlockRequest(maxMessages);
+ }
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ // Private ----------------------------------------------------
+
+ // Inner classes -------------------------------------------------
+}
Added: branches/Branch_JBMESSAGING-544/src/main/org/jboss/messaging/core/remoting/codec/BrowserNextMessageBlockResponseCodec.java
===================================================================
--- branches/Branch_JBMESSAGING-544/src/main/org/jboss/messaging/core/remoting/codec/BrowserNextMessageBlockResponseCodec.java (rev 0)
+++ branches/Branch_JBMESSAGING-544/src/main/org/jboss/messaging/core/remoting/codec/BrowserNextMessageBlockResponseCodec.java 2007-11-23 13:41:10 UTC (rev 3360)
@@ -0,0 +1,117 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.messaging.core.remoting.codec;
+
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.RESP_BROWSER_NEXTMESSAGEBLOCK;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+
+import org.apache.mina.common.IoBuffer;
+import org.apache.mina.common.IoSession;
+import org.jboss.jms.message.JBossMessage;
+import org.jboss.messaging.core.impl.message.MessageFactory;
+import org.jboss.messaging.core.remoting.wireformat.BrowserNextMessageBlockResponse;
+
+/**
+ * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>.
+ */
+public class BrowserNextMessageBlockResponseCodec extends AbstractPacketCodec<BrowserNextMessageBlockResponse>
+{
+ // Constants -----------------------------------------------------
+
+ // Attributes ----------------------------------------------------
+
+ // Static --------------------------------------------------------
+
+ // Constructors --------------------------------------------------
+
+ public BrowserNextMessageBlockResponseCodec()
+ {
+ super(RESP_BROWSER_NEXTMESSAGEBLOCK);
+ }
+
+ // Public --------------------------------------------------------
+
+ // AbstractPacketCodec overrides ---------------------------------
+
+ @Override
+ protected void encodeBody(IoSession session, BrowserNextMessageBlockResponse response,
+ IoBuffer out) throws Exception
+ {
+ JBossMessage[] messages = response.getMessages();
+
+ byte[] encodedMessages = encode(messages);
+
+ int bodyLength = INT_LENGTH + INT_LENGTH + encodedMessages.length;
+
+ out.putInt(bodyLength);
+ out.putInt(messages.length);
+ out.putInt(encodedMessages.length);
+ out.put(encodedMessages);
+ }
+
+ @Override
+ protected BrowserNextMessageBlockResponse decodeBody(IoSession session, IoBuffer in)
+ throws Exception
+ {
+ int bodyLength = in.getInt();
+ if (in.remaining() < bodyLength)
+ {
+ return null;
+ }
+
+ int numOfMessages = in.getInt();
+ int encodedMessagesLength = in.getInt();
+ byte[] encodedMessages = new byte[encodedMessagesLength];
+ in.get(encodedMessages);
+ JBossMessage[] messages = decode(numOfMessages, encodedMessages);
+
+ return new BrowserNextMessageBlockResponse(messages);
+ }
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ // Private ----------------------------------------------------
+
+ private byte[] encode(JBossMessage[] messages) throws Exception
+ {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ DataOutputStream daos = new DataOutputStream(baos);
+
+ for (int i = 0; i < messages.length; i++)
+ {
+ JBossMessage message = messages[i];
+ daos.writeByte(message.getType());
+ message.write(daos);
+ }
+ return baos.toByteArray();
+ }
+
+ private JBossMessage[] decode(int numOfMessages, byte[] encodedMessages) throws Exception
+ {
+ JBossMessage[] messages = new JBossMessage[numOfMessages];
+ ByteArrayInputStream bais = new ByteArrayInputStream(encodedMessages);
+ DataInputStream dais = new DataInputStream(bais);
+
+ for (int i = 0; i < messages.length; i++)
+ {
+ byte type = (byte) dais.readByte();
+ JBossMessage message = (JBossMessage)MessageFactory.createMessage(type);
+ message.read(dais);
+ messages[i] = message;
+ }
+
+ return messages;
+ }
+
+ // Inner classes -------------------------------------------------
+}
Added: branches/Branch_JBMESSAGING-544/src/main/org/jboss/messaging/core/remoting/codec/GetClientAOPStackResponseCodec.java
===================================================================
--- branches/Branch_JBMESSAGING-544/src/main/org/jboss/messaging/core/remoting/codec/GetClientAOPStackResponseCodec.java (rev 0)
+++ branches/Branch_JBMESSAGING-544/src/main/org/jboss/messaging/core/remoting/codec/GetClientAOPStackResponseCodec.java 2007-11-23 13:41:10 UTC (rev 3360)
@@ -0,0 +1,76 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.messaging.core.remoting.codec;
+
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.RESP_GETCLIENTAOPSTACK;
+
+import org.apache.mina.common.IoBuffer;
+import org.apache.mina.common.IoSession;
+import org.jboss.messaging.core.remoting.wireformat.GetClientAOPStackResponse;
+
+/**
+ * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>.
+ */
+public class GetClientAOPStackResponseCodec extends
+ AbstractPacketCodec<GetClientAOPStackResponse>
+{
+ // Constants -----------------------------------------------------
+
+ // Attributes ----------------------------------------------------
+
+ // Static --------------------------------------------------------
+
+ // Constructors --------------------------------------------------
+
+ public GetClientAOPStackResponseCodec()
+ {
+ super(RESP_GETCLIENTAOPSTACK);
+ }
+
+ // Public --------------------------------------------------------
+
+ // AbstractPacketCodec overrides ---------------------------------
+
+ @Override
+ protected void encodeBody(IoSession session,
+ GetClientAOPStackResponse response, IoBuffer out) throws Exception
+ {
+
+ byte[] stack = response.getStack();
+
+ int bodyLength = INT_LENGTH + stack.length;
+
+ out.putInt(bodyLength);
+ out.putInt(stack.length);
+ out.put(stack);
+ }
+
+ @Override
+ protected GetClientAOPStackResponse decodeBody(IoSession session,
+ IoBuffer in) throws Exception
+ {
+ int bodyLength = in.getInt();
+ if (in.remaining() < bodyLength)
+ {
+ return null;
+ }
+
+ int stackLength = in.getInt();
+ byte[] stack = new byte[stackLength];
+ in.get(stack);
+
+ return new GetClientAOPStackResponse(stack);
+ }
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
+}
Added: branches/Branch_JBMESSAGING-544/src/main/org/jboss/messaging/core/remoting/codec/GetPreparedTransactionsResponseCodec.java
===================================================================
--- branches/Branch_JBMESSAGING-544/src/main/org/jboss/messaging/core/remoting/codec/GetPreparedTransactionsResponseCodec.java (rev 0)
+++ branches/Branch_JBMESSAGING-544/src/main/org/jboss/messaging/core/remoting/codec/GetPreparedTransactionsResponseCodec.java 2007-11-23 13:41:10 UTC (rev 3360)
@@ -0,0 +1,113 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.messaging.core.remoting.codec;
+
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.RESP_GETPREPAREDTRANSACTIONS;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+
+import org.apache.mina.common.IoBuffer;
+import org.apache.mina.common.IoSession;
+import org.jboss.jms.tx.MessagingXid;
+import org.jboss.messaging.core.remoting.wireformat.GetPreparedTransactionsResponse;
+
+/**
+ * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>.
+ */
+public class GetPreparedTransactionsResponseCodec extends
+ AbstractPacketCodec<GetPreparedTransactionsResponse>
+{
+ // Constants -----------------------------------------------------
+
+ // Attributes ----------------------------------------------------
+
+ // Static --------------------------------------------------------
+
+ // Constructors --------------------------------------------------
+
+ public GetPreparedTransactionsResponseCodec()
+ {
+ super(RESP_GETPREPAREDTRANSACTIONS);
+ }
+
+ // Public --------------------------------------------------------
+
+ // AbstractPacketCodec overrides ---------------------------------
+
+ @Override
+ protected void encodeBody(IoSession session,
+ GetPreparedTransactionsResponse response, IoBuffer out) throws Exception
+ {
+
+ MessagingXid[] xids = response.getXids();
+
+ byte[] encodedXids = convert(xids);
+
+ int bodyLength = INT_LENGTH + INT_LENGTH + encodedXids.length;
+
+ out.putInt(bodyLength);
+ out.putInt(xids.length);
+ out.putInt(encodedXids.length);
+ out.put(encodedXids);
+ }
+
+ @Override
+ protected GetPreparedTransactionsResponse decodeBody(IoSession session,
+ IoBuffer in) throws Exception
+ {
+ int bodyLength = in.getInt();
+ if (in.remaining() < bodyLength)
+ {
+ return null;
+ }
+
+ int numOfXids = in.getInt();
+ int encodedXidsLength = in.getInt();
+ byte[] b = new byte[encodedXidsLength];
+ in.get(b);
+ MessagingXid[] xids = convert(numOfXids, b);
+
+ return new GetPreparedTransactionsResponse(xids);
+ }
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ // Private -------------------------------------------------------
+
+ private static byte[] convert(MessagingXid[] xids) throws Exception
+ {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ DataOutputStream dos = new DataOutputStream(baos);
+ for (int i = 0; i < xids.length; i++)
+ {
+ MessagingXid xid = xids[i];
+ xid.write(dos);
+ }
+ return baos.toByteArray();
+ }
+
+ private MessagingXid[] convert(int numOfXids, byte[] encodedXids) throws Exception
+ {
+ MessagingXid[] xids = new MessagingXid[numOfXids];
+ ByteArrayInputStream bais = new ByteArrayInputStream(encodedXids);
+ DataInputStream dis = new DataInputStream(bais);
+ for (int i = 0; i < xids.length; i++)
+ {
+ MessagingXid xid = new MessagingXid();
+ xid.read(dis);
+ xids[i] = xid;
+ }
+ return xids;
+ }
+
+ // Inner classes -------------------------------------------------
+}
Added: branches/Branch_JBMESSAGING-544/src/main/org/jboss/messaging/core/remoting/codec/GetTopologyResponseCodec.java
===================================================================
--- branches/Branch_JBMESSAGING-544/src/main/org/jboss/messaging/core/remoting/codec/GetTopologyResponseCodec.java (rev 0)
+++ branches/Branch_JBMESSAGING-544/src/main/org/jboss/messaging/core/remoting/codec/GetTopologyResponseCodec.java 2007-11-23 13:41:10 UTC (rev 3360)
@@ -0,0 +1,100 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.messaging.core.remoting.codec;
+
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.RESP_GETTOPOLOGY;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+
+import org.apache.mina.common.IoBuffer;
+import org.apache.mina.common.IoSession;
+import org.jboss.jms.delegate.TopologyResult;
+import org.jboss.messaging.core.remoting.wireformat.GetTopologyResponse;
+
+/**
+ * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>.
+ */
+public class GetTopologyResponseCodec extends
+ AbstractPacketCodec<GetTopologyResponse>
+{
+ // Constants -----------------------------------------------------
+
+ // Attributes ----------------------------------------------------
+
+ // Static --------------------------------------------------------
+
+ // Constructors --------------------------------------------------
+
+ public GetTopologyResponseCodec()
+ {
+ super(RESP_GETTOPOLOGY);
+ }
+
+ // Public --------------------------------------------------------
+
+ // AbstractPacketCodec overrides ---------------------------------
+
+ @Override
+ protected void encodeBody(IoSession session, GetTopologyResponse response,
+ IoBuffer out) throws Exception
+ {
+ byte[] encodedTopology = encode(response.getTopology());
+
+ int bodyLength = INT_LENGTH + encodedTopology.length;
+
+ out.putInt(bodyLength);
+ out.putInt(encodedTopology.length);
+ out.put(encodedTopology);
+ }
+
+ @Override
+ protected GetTopologyResponse decodeBody(IoSession session, IoBuffer in)
+ throws Exception
+ {
+ int bodyLength = in.getInt();
+ if (in.remaining() < bodyLength)
+ {
+ return null;
+ }
+
+ int encodedTopologyLength = in.getInt();
+ byte[] encodedTopology = new byte[encodedTopologyLength];
+ in.get(encodedTopology);
+ TopologyResult topology = decodeTopology(encodedTopology);
+
+ return new GetTopologyResponse(topology);
+ }
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ // Private ----------------------------------------------------
+
+ private byte[] encode(TopologyResult topology) throws Exception
+ {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ DataOutputStream dos = new DataOutputStream(baos);
+ topology.write(dos);
+ return baos.toByteArray();
+ }
+
+ private TopologyResult decodeTopology(byte[] encodedTopology)
+ throws Exception
+ {
+ ByteArrayInputStream bais = new ByteArrayInputStream(encodedTopology);
+ DataInputStream dis = new DataInputStream(bais);
+ TopologyResult topology = new TopologyResult();
+ topology.read(dis);
+ return topology;
+ }
+
+ // Inner classes -------------------------------------------------
+}
Modified: branches/Branch_JBMESSAGING-544/src/main/org/jboss/messaging/core/remoting/codec/PacketCodecFactory.java
===================================================================
--- branches/Branch_JBMESSAGING-544/src/main/org/jboss/messaging/core/remoting/codec/PacketCodecFactory.java 2007-11-22 16:49:46 UTC (rev 3359)
+++ branches/Branch_JBMESSAGING-544/src/main/org/jboss/messaging/core/remoting/codec/PacketCodecFactory.java 2007-11-23 13:41:10 UTC (rev 3360)
@@ -13,7 +13,10 @@
import static org.jboss.messaging.core.remoting.wireformat.PacketType.NULL;
import static org.jboss.messaging.core.remoting.wireformat.PacketType.REQ_BROWSER_HASNEXTMESSAGE;
import static org.jboss.messaging.core.remoting.wireformat.PacketType.REQ_BROWSER_NEXTMESSAGE;
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.REQ_GETCLIENTAOPSTACK;
import static org.jboss.messaging.core.remoting.wireformat.PacketType.REQ_GETCLIENTID;
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.REQ_GETPREPAREDTRANSACTIONS;
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.REQ_GETTOPOLOGY;
import org.apache.mina.common.IoBuffer;
import org.apache.mina.common.IoSession;
@@ -25,6 +28,8 @@
import org.jboss.messaging.core.remoting.wireformat.AddTemporaryDestinationMessage;
import org.jboss.messaging.core.remoting.wireformat.BrowserHasNextMessageRequest;
import org.jboss.messaging.core.remoting.wireformat.BrowserHasNextMessageResponse;
+import org.jboss.messaging.core.remoting.wireformat.BrowserNextMessageBlockRequest;
+import org.jboss.messaging.core.remoting.wireformat.BrowserNextMessageBlockResponse;
import org.jboss.messaging.core.remoting.wireformat.BrowserNextMessageRequest;
import org.jboss.messaging.core.remoting.wireformat.BrowserNextMessageResponse;
import org.jboss.messaging.core.remoting.wireformat.BrowserResetMessage;
@@ -46,8 +51,14 @@
import org.jboss.messaging.core.remoting.wireformat.CreateSessionResponse;
import org.jboss.messaging.core.remoting.wireformat.DeleteTemporaryDestinationMessage;
import org.jboss.messaging.core.remoting.wireformat.DeliverMessage;
+import org.jboss.messaging.core.remoting.wireformat.GetClientAOPStackRequest;
+import org.jboss.messaging.core.remoting.wireformat.GetClientAOPStackResponse;
import org.jboss.messaging.core.remoting.wireformat.GetClientIDRequest;
import org.jboss.messaging.core.remoting.wireformat.GetClientIDResponse;
+import org.jboss.messaging.core.remoting.wireformat.GetPreparedTransactionsRequest;
+import org.jboss.messaging.core.remoting.wireformat.GetPreparedTransactionsResponse;
+import org.jboss.messaging.core.remoting.wireformat.GetTopologyRequest;
+import org.jboss.messaging.core.remoting.wireformat.GetTopologyResponse;
import org.jboss.messaging.core.remoting.wireformat.IDBlockRequest;
import org.jboss.messaging.core.remoting.wireformat.IDBlockResponse;
import org.jboss.messaging.core.remoting.wireformat.JMSExceptionMessage;
@@ -91,6 +102,15 @@
addCodec(CreateConnectionResponse.class,
ConnectionFactoryCreateConnectionResponseCodec.class);
+ addCodecForEmptyPacket(REQ_GETCLIENTAOPSTACK, GetClientAOPStackRequest.class);
+
+ addCodec(GetClientAOPStackResponse.class,
+ GetClientAOPStackResponseCodec.class);
+
+ addCodecForEmptyPacket(REQ_GETTOPOLOGY, GetTopologyRequest.class);
+
+ addCodec(GetTopologyResponse.class, GetTopologyResponseCodec.class);
+
addCodec(CreateSessionRequest.class, CreateSessionRequestCodec.class);
addCodec(CreateSessionResponse.class, CreateSessionResponseCodec.class);
@@ -154,6 +174,12 @@
addCodec(SendTransactionMessage.class, SendTransactionRequestCodec.class);
+ addCodecForEmptyPacket(REQ_GETPREPAREDTRANSACTIONS,
+ GetPreparedTransactionsRequest.class);
+
+ addCodec(GetPreparedTransactionsResponse.class,
+ GetPreparedTransactionsResponseCodec.class);
+
addCodecForEmptyPacket(MSG_BROWSER_RESET, BrowserResetMessage.class);
addCodecForEmptyPacket(REQ_BROWSER_HASNEXTMESSAGE,
@@ -168,6 +194,12 @@
addCodec(BrowserNextMessageResponse.class,
BrowserNextMessageResponseCodec.class);
+ addCodec(BrowserNextMessageBlockRequest.class,
+ BrowserNextMessageBlockRequestCodec.class);
+
+ addCodec(BrowserNextMessageBlockResponse.class,
+ BrowserNextMessageBlockResponseCodec.class);
+
addCodec(UnsubscribeMessage.class, UnsubscribeMessageCodec.class);
addCodec(AddTemporaryDestinationMessage.class,
@@ -175,7 +207,7 @@
addCodec(DeleteTemporaryDestinationMessage.class,
DeleteTemporaryDestinationMessageCodec.class);
-}
+ }
// Public --------------------------------------------------------
Added: branches/Branch_JBMESSAGING-544/src/main/org/jboss/messaging/core/remoting/wireformat/BrowserNextMessageBlockRequest.java
===================================================================
--- branches/Branch_JBMESSAGING-544/src/main/org/jboss/messaging/core/remoting/wireformat/BrowserNextMessageBlockRequest.java (rev 0)
+++ branches/Branch_JBMESSAGING-544/src/main/org/jboss/messaging/core/remoting/wireformat/BrowserNextMessageBlockRequest.java 2007-11-23 13:41:10 UTC (rev 3360)
@@ -0,0 +1,57 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.messaging.core.remoting.wireformat;
+
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.REQ_BROWSER_NEXTMESSAGEBLOCK;
+
+/**
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
+ *
+ * @version <tt>$Revision$</tt>
+ *
+ */
+public class BrowserNextMessageBlockRequest extends AbstractPacket
+{
+ // Constants -----------------------------------------------------
+
+ // Attributes ----------------------------------------------------
+
+ private final long maxMessages;
+
+ // Static --------------------------------------------------------
+
+ // Constructors --------------------------------------------------
+
+ public BrowserNextMessageBlockRequest(long maxMessages)
+ {
+ super(REQ_BROWSER_NEXTMESSAGEBLOCK);
+
+ this.maxMessages = maxMessages;
+ }
+
+ // Public --------------------------------------------------------
+
+ public long getMaxMessages()
+ {
+ return maxMessages;
+ }
+
+ @Override
+ public String toString()
+ {
+ return getParentString() + ", maxMessages=" + maxMessages + "]";
+ }
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
+}
Added: branches/Branch_JBMESSAGING-544/src/main/org/jboss/messaging/core/remoting/wireformat/BrowserNextMessageBlockResponse.java
===================================================================
--- branches/Branch_JBMESSAGING-544/src/main/org/jboss/messaging/core/remoting/wireformat/BrowserNextMessageBlockResponse.java (rev 0)
+++ branches/Branch_JBMESSAGING-544/src/main/org/jboss/messaging/core/remoting/wireformat/BrowserNextMessageBlockResponse.java 2007-11-23 13:41:10 UTC (rev 3360)
@@ -0,0 +1,62 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.messaging.core.remoting.wireformat;
+
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.RESP_BROWSER_NEXTMESSAGEBLOCK;
+
+import java.util.Arrays;
+
+import org.jboss.jms.message.JBossMessage;
+
+/**
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
+ *
+ * @version <tt>$Revision$</tt>
+ */
+public class BrowserNextMessageBlockResponse extends AbstractPacket
+{
+ // Constants -----------------------------------------------------
+
+ // Attributes ----------------------------------------------------
+
+ private final JBossMessage[] messages;
+
+ // Static --------------------------------------------------------
+
+ // Constructors --------------------------------------------------
+
+ public BrowserNextMessageBlockResponse(JBossMessage[] messages)
+ {
+ super(RESP_BROWSER_NEXTMESSAGEBLOCK);
+
+ assert messages != null;
+
+ this.messages = messages;
+ }
+
+ // Public --------------------------------------------------------
+
+ public JBossMessage[] getMessages()
+ {
+ return messages;
+ }
+
+ @Override
+ public String toString()
+ {
+ return getParentString() + ", messages=" + Arrays.asList(messages) + "]";
+ }
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
+}
Added: branches/Branch_JBMESSAGING-544/src/main/org/jboss/messaging/core/remoting/wireformat/GetClientAOPStackRequest.java
===================================================================
--- branches/Branch_JBMESSAGING-544/src/main/org/jboss/messaging/core/remoting/wireformat/GetClientAOPStackRequest.java (rev 0)
+++ branches/Branch_JBMESSAGING-544/src/main/org/jboss/messaging/core/remoting/wireformat/GetClientAOPStackRequest.java 2007-11-23 13:41:10 UTC (rev 3360)
@@ -0,0 +1,42 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.messaging.core.remoting.wireformat;
+
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.REQ_GETCLIENTAOPSTACK;
+
+/**
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
+ *
+ * @version <tt>$Revision$</tt>
+ *
+ */
+public class GetClientAOPStackRequest extends AbstractPacket
+{
+ // Constants -----------------------------------------------------
+
+ // Attributes ----------------------------------------------------
+
+ // Static --------------------------------------------------------
+
+ // Constructors --------------------------------------------------
+
+ public GetClientAOPStackRequest()
+ {
+ super(REQ_GETCLIENTAOPSTACK);
+ }
+
+ // Public --------------------------------------------------------
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
+}
Added: branches/Branch_JBMESSAGING-544/src/main/org/jboss/messaging/core/remoting/wireformat/GetClientAOPStackResponse.java
===================================================================
--- branches/Branch_JBMESSAGING-544/src/main/org/jboss/messaging/core/remoting/wireformat/GetClientAOPStackResponse.java (rev 0)
+++ branches/Branch_JBMESSAGING-544/src/main/org/jboss/messaging/core/remoting/wireformat/GetClientAOPStackResponse.java 2007-11-23 13:41:10 UTC (rev 3360)
@@ -0,0 +1,59 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.messaging.core.remoting.wireformat;
+
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.RESP_GETCLIENTAOPSTACK;
+
+/**
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
+ *
+ * @version <tt>$Revision$</tt>
+ *
+ */
+public class GetClientAOPStackResponse extends AbstractPacket
+{
+ // Constants -----------------------------------------------------
+
+ // Attributes ----------------------------------------------------
+
+ private final byte[] stack;
+
+ // Static --------------------------------------------------------
+
+ // Constructors --------------------------------------------------
+
+ public GetClientAOPStackResponse(byte[] stack)
+ {
+ super(RESP_GETCLIENTAOPSTACK);
+
+ assert stack != null;
+
+ this.stack = stack;
+ }
+
+ // Public --------------------------------------------------------
+
+ public byte[] getStack()
+ {
+ return stack;
+ }
+
+ @Override
+ public String toString()
+ {
+ return getParentString() + ", stack=" + stack + "]";
+ }
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
+}
Added: branches/Branch_JBMESSAGING-544/src/main/org/jboss/messaging/core/remoting/wireformat/GetPreparedTransactionsRequest.java
===================================================================
--- branches/Branch_JBMESSAGING-544/src/main/org/jboss/messaging/core/remoting/wireformat/GetPreparedTransactionsRequest.java (rev 0)
+++ branches/Branch_JBMESSAGING-544/src/main/org/jboss/messaging/core/remoting/wireformat/GetPreparedTransactionsRequest.java 2007-11-23 13:41:10 UTC (rev 3360)
@@ -0,0 +1,42 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.messaging.core.remoting.wireformat;
+
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.REQ_GETPREPAREDTRANSACTIONS;
+
+/**
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
+ *
+ * @version <tt>$Revision$</tt>
+ *
+ */
+public class GetPreparedTransactionsRequest extends AbstractPacket
+{
+ // Constants -----------------------------------------------------
+
+ // Attributes ----------------------------------------------------
+
+ // Static --------------------------------------------------------
+
+ // Constructors --------------------------------------------------
+
+ public GetPreparedTransactionsRequest()
+ {
+ super(REQ_GETPREPAREDTRANSACTIONS);
+ }
+
+ // Public --------------------------------------------------------
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
+}
Added: branches/Branch_JBMESSAGING-544/src/main/org/jboss/messaging/core/remoting/wireformat/GetPreparedTransactionsResponse.java
===================================================================
--- branches/Branch_JBMESSAGING-544/src/main/org/jboss/messaging/core/remoting/wireformat/GetPreparedTransactionsResponse.java (rev 0)
+++ branches/Branch_JBMESSAGING-544/src/main/org/jboss/messaging/core/remoting/wireformat/GetPreparedTransactionsResponse.java 2007-11-23 13:41:10 UTC (rev 3360)
@@ -0,0 +1,63 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.messaging.core.remoting.wireformat;
+
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.RESP_GETPREPAREDTRANSACTIONS;
+
+import java.util.Arrays;
+
+import org.jboss.jms.tx.MessagingXid;
+
+/**
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
+ *
+ * @version <tt>$Revision$</tt>
+ *
+ */
+public class GetPreparedTransactionsResponse extends AbstractPacket
+{
+ // Constants -----------------------------------------------------
+
+ // Attributes ----------------------------------------------------
+
+ private final MessagingXid[] xids;
+
+ // Static --------------------------------------------------------
+
+ // Constructors --------------------------------------------------
+
+ public GetPreparedTransactionsResponse(MessagingXid[] xids)
+ {
+ super(RESP_GETPREPAREDTRANSACTIONS);
+
+ assert xids != null;
+
+ this.xids = xids;
+ }
+
+ // Public --------------------------------------------------------
+
+ public MessagingXid[] getXids()
+ {
+ return xids;
+ }
+
+ @Override
+ public String toString()
+ {
+ return getParentString() + ", xids=" + Arrays.asList(xids) + "]";
+ }
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
+}
Added: branches/Branch_JBMESSAGING-544/src/main/org/jboss/messaging/core/remoting/wireformat/GetTopologyRequest.java
===================================================================
--- branches/Branch_JBMESSAGING-544/src/main/org/jboss/messaging/core/remoting/wireformat/GetTopologyRequest.java (rev 0)
+++ branches/Branch_JBMESSAGING-544/src/main/org/jboss/messaging/core/remoting/wireformat/GetTopologyRequest.java 2007-11-23 13:41:10 UTC (rev 3360)
@@ -0,0 +1,41 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.messaging.core.remoting.wireformat;
+
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.REQ_GETTOPOLOGY;
+
+/**
+ * @author <a href="mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
+ * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>.
+ *
+ * @version <tt>$Revision$</tt>
+ */
+public class GetTopologyRequest extends AbstractPacket
+{
+ // Constants -----------------------------------------------------
+
+ // Attributes ----------------------------------------------------
+
+ // Static --------------------------------------------------------
+
+ // Constructors --------------------------------------------------
+
+ public GetTopologyRequest()
+ {
+ super(REQ_GETTOPOLOGY);
+ }
+
+ // Public --------------------------------------------------------
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
+}
Added: branches/Branch_JBMESSAGING-544/src/main/org/jboss/messaging/core/remoting/wireformat/GetTopologyResponse.java
===================================================================
--- branches/Branch_JBMESSAGING-544/src/main/org/jboss/messaging/core/remoting/wireformat/GetTopologyResponse.java (rev 0)
+++ branches/Branch_JBMESSAGING-544/src/main/org/jboss/messaging/core/remoting/wireformat/GetTopologyResponse.java 2007-11-23 13:41:10 UTC (rev 3360)
@@ -0,0 +1,60 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.messaging.core.remoting.wireformat;
+
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.RESP_GETTOPOLOGY;
+
+import org.jboss.jms.delegate.TopologyResult;
+
+/**
+ * @author <a href="mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
+ * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>.
+ *
+ * @version <tt>$Revision$</tt>
+ */
+public class GetTopologyResponse extends AbstractPacket
+{
+ // Constants -----------------------------------------------------
+
+ // Attributes ----------------------------------------------------
+
+ private final TopologyResult topology;
+
+ // Static --------------------------------------------------------
+
+ // Constructors --------------------------------------------------
+
+ public GetTopologyResponse(TopologyResult topology)
+ {
+ super(RESP_GETTOPOLOGY);
+
+ assert topology != null;
+
+ this.topology = topology;
+ }
+
+ // Public --------------------------------------------------------
+
+ public TopologyResult getTopology()
+ {
+ return topology;
+ }
+
+ @Override
+ public String toString()
+ {
+ return getParentString() + ", topology=" + topology + "]";
+ }
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
+}
Modified: branches/Branch_JBMESSAGING-544/src/main/org/jboss/messaging/core/remoting/wireformat/PacketType.java
===================================================================
--- branches/Branch_JBMESSAGING-544/src/main/org/jboss/messaging/core/remoting/wireformat/PacketType.java 2007-11-22 16:49:46 UTC (rev 3359)
+++ branches/Branch_JBMESSAGING-544/src/main/org/jboss/messaging/core/remoting/wireformat/PacketType.java 2007-11-23 13:41:10 UTC (rev 3360)
@@ -13,59 +13,63 @@
*/
public enum PacketType
{
- // FIXME better choice of byte value...
-
- NULL ((byte) 1),
- MSG_JMSEXCEPTION ((byte) 2),
- TEXT ((byte) 3),
+ NULL ((byte) 1),
+ MSG_JMSEXCEPTION ((byte) 2),
+ TEXT ((byte) 3),
// Connection factory
- REQ_CREATECONNECTION ((byte)10),
- RESP_CREATECONNECTION ((byte)11),
+ REQ_CREATECONNECTION ((byte)10),
+ RESP_CREATECONNECTION ((byte)11),
+ REQ_GETCLIENTAOPSTACK ((byte)12),
+ RESP_GETCLIENTAOPSTACK ((byte)13),
+ REQ_GETTOPOLOGY ((byte)14),
+ RESP_GETTOPOLOGY ((byte)15),
// Connection
- REQ_IDBLOCK ((byte)20),
- RESP_IDBLOCK ((byte)21),
- REQ_CREATESESSION ((byte)22),
- RESP_CREATESESSION ((byte)23),
- MSG_STARTCONNECTION ((byte)24),
- MSG_STOPCONNECTION ((byte)25),
- MSG_SENDTRANSACTION ((byte)26),
- RESP_SENDTRANSACTION ((byte)27),
- REQ_GETCLIENTID ((byte)28),
- RESP_GETCLIENTID ((byte)29),
- MSG_SETCLIENTID ((byte)30),
+ REQ_IDBLOCK ((byte)20),
+ RESP_IDBLOCK ((byte)21),
+ REQ_CREATESESSION ((byte)22),
+ RESP_CREATESESSION ((byte)23),
+ MSG_STARTCONNECTION ((byte)24),
+ MSG_STOPCONNECTION ((byte)25),
+ MSG_SENDTRANSACTION ((byte)26),
+ RESP_SENDTRANSACTION ((byte)27),
+ REQ_GETPREPAREDTRANSACTIONS ((byte)28),
+ RESP_GETPREPAREDTRANSACTIONS ((byte)29),
+ REQ_GETCLIENTID ((byte)30),
+ RESP_GETCLIENTID ((byte)31),
+ MSG_SETCLIENTID ((byte)32),
// Session
- REQ_CREATECONSUMER ((byte)40),
- RESP_CREATECONSUMER ((byte)41),
- REQ_CREATEDESTINATION ((byte)42),
- RESP_CREATEDESTINATION ((byte)43),
- MSG_ADDTEMPORARYDESTINATION ((byte)44),
- MSG_DELETETEMPORARYDESTINATION((byte)45),
- REQ_CREATEBROWSER ((byte)46),
- RESP_CREATEBROWSER ((byte)47),
- MSG_SENDMESSAGE ((byte)48),
- MSG_DELIVERMESSAGE ((byte)49),
- REQ_ACKDELIVERY ((byte)50),
- RESP_ACKDELIVERY ((byte)51),
- MSG_ACKDELIVERIES ((byte)52),
- RESP_ACKDELIVERIES ((byte)53),
- MSG_RECOVERDELIVERIES ((byte)54),
- MSG_CANCELDELIVERY ((byte)55),
- MSG_CANCELDELIVERIES ((byte)56),
- MSG_UNSUBSCRIBE ((byte)57),
- // Consumer
- MSG_CHANGERATE ((byte)70),
+ REQ_CREATECONSUMER ((byte)40),
+ RESP_CREATECONSUMER ((byte)41),
+ REQ_CREATEDESTINATION ((byte)42),
+ RESP_CREATEDESTINATION ((byte)43),
+ MSG_ADDTEMPORARYDESTINATION ((byte)44),
+ MSG_DELETETEMPORARYDESTINATION ((byte)45),
+ REQ_CREATEBROWSER ((byte)46),
+ RESP_CREATEBROWSER ((byte)47),
+ MSG_SENDMESSAGE ((byte)48),
+ MSG_DELIVERMESSAGE ((byte)49),
+ REQ_ACKDELIVERY ((byte)50),
+ RESP_ACKDELIVERY ((byte)51),
+ MSG_ACKDELIVERIES ((byte)52),
+ RESP_ACKDELIVERIES ((byte)53),
+ MSG_RECOVERDELIVERIES ((byte)54),
+ MSG_CANCELDELIVERY ((byte)55),
+ MSG_CANCELDELIVERIES ((byte)56),
+ MSG_UNSUBSCRIBE ((byte)57),
+ // Consumer
+ MSG_CHANGERATE ((byte)70),
// Browse
- MSG_BROWSER_RESET ((byte)80),
- REQ_BROWSER_HASNEXTMESSAGE ((byte)81),
- RESP_BROWSER_HASNEXTMESSAGE ((byte)82),
- REQ_BROWSER_NEXTMESSAGEBLOCK ((byte)83),
- RESP_BROWSER_NEXTMESSAGEBLOCK ((byte)84),
- REQ_BROWSER_NEXTMESSAGE ((byte)85),
- RESP_BROWSER_NEXTMESSAGE ((byte)86),
+ MSG_BROWSER_RESET ((byte)80),
+ REQ_BROWSER_HASNEXTMESSAGE ((byte)81),
+ RESP_BROWSER_HASNEXTMESSAGE ((byte)82),
+ REQ_BROWSER_NEXTMESSAGEBLOCK ((byte)83),
+ RESP_BROWSER_NEXTMESSAGEBLOCK ((byte)84),
+ REQ_BROWSER_NEXTMESSAGE ((byte)85),
+ RESP_BROWSER_NEXTMESSAGE ((byte)86),
// Misc
- REQ_CLOSING ((byte)90),
- RESP_CLOSING ((byte)91),
- MSG_CLOSE ((byte)92);
+ REQ_CLOSING ((byte)90),
+ RESP_CLOSING ((byte)91),
+ MSG_CLOSE ((byte)92);
public final byte type;
Modified: branches/Branch_JBMESSAGING-544/tests/src/org/jboss/test/messaging/core/remoting/wireformat/PacketTypeTest.java
===================================================================
--- branches/Branch_JBMESSAGING-544/tests/src/org/jboss/test/messaging/core/remoting/wireformat/PacketTypeTest.java 2007-11-22 16:49:46 UTC (rev 3359)
+++ branches/Branch_JBMESSAGING-544/tests/src/org/jboss/test/messaging/core/remoting/wireformat/PacketTypeTest.java 2007-11-23 13:41:10 UTC (rev 3360)
@@ -6,8 +6,6 @@
*/
package org.jboss.test.messaging.core.remoting.wireformat;
-import static java.lang.System.currentTimeMillis;
-import static java.util.UUID.randomUUID;
import static org.jboss.messaging.core.remoting.wireformat.PacketType.MSG_ADDTEMPORARYDESTINATION;
import static org.jboss.messaging.core.remoting.wireformat.PacketType.MSG_BROWSER_RESET;
import static org.jboss.messaging.core.remoting.wireformat.PacketType.MSG_CANCELDELIVERIES;
@@ -28,28 +26,38 @@
import static org.jboss.messaging.core.remoting.wireformat.PacketType.REQ_ACKDELIVERY;
import static org.jboss.messaging.core.remoting.wireformat.PacketType.REQ_BROWSER_HASNEXTMESSAGE;
import static org.jboss.messaging.core.remoting.wireformat.PacketType.REQ_BROWSER_NEXTMESSAGE;
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.REQ_BROWSER_NEXTMESSAGEBLOCK;
import static org.jboss.messaging.core.remoting.wireformat.PacketType.REQ_CLOSING;
import static org.jboss.messaging.core.remoting.wireformat.PacketType.REQ_CREATEBROWSER;
import static org.jboss.messaging.core.remoting.wireformat.PacketType.REQ_CREATECONNECTION;
import static org.jboss.messaging.core.remoting.wireformat.PacketType.REQ_CREATECONSUMER;
import static org.jboss.messaging.core.remoting.wireformat.PacketType.REQ_CREATEDESTINATION;
import static org.jboss.messaging.core.remoting.wireformat.PacketType.REQ_CREATESESSION;
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.REQ_GETCLIENTAOPSTACK;
import static org.jboss.messaging.core.remoting.wireformat.PacketType.REQ_GETCLIENTID;
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.REQ_GETPREPAREDTRANSACTIONS;
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.REQ_GETTOPOLOGY;
import static org.jboss.messaging.core.remoting.wireformat.PacketType.REQ_IDBLOCK;
import static org.jboss.messaging.core.remoting.wireformat.PacketType.RESP_ACKDELIVERY;
import static org.jboss.messaging.core.remoting.wireformat.PacketType.RESP_BROWSER_HASNEXTMESSAGE;
import static org.jboss.messaging.core.remoting.wireformat.PacketType.RESP_BROWSER_NEXTMESSAGE;
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.RESP_BROWSER_NEXTMESSAGEBLOCK;
import static org.jboss.messaging.core.remoting.wireformat.PacketType.RESP_CLOSING;
import static org.jboss.messaging.core.remoting.wireformat.PacketType.RESP_CREATEBROWSER;
import static org.jboss.messaging.core.remoting.wireformat.PacketType.RESP_CREATECONNECTION;
import static org.jboss.messaging.core.remoting.wireformat.PacketType.RESP_CREATECONSUMER;
import static org.jboss.messaging.core.remoting.wireformat.PacketType.RESP_CREATESESSION;
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.RESP_GETCLIENTAOPSTACK;
import static org.jboss.messaging.core.remoting.wireformat.PacketType.RESP_GETCLIENTID;
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.RESP_GETPREPAREDTRANSACTIONS;
+import static org.jboss.messaging.core.remoting.wireformat.PacketType.RESP_GETTOPOLOGY;
import static org.jboss.messaging.core.remoting.wireformat.PacketType.RESP_IDBLOCK;
import static org.jboss.messaging.core.remoting.wireformat.PacketType.TEXT;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
+import java.util.UUID;
import javax.jms.InvalidDestinationException;
import javax.jms.JMSException;
@@ -60,16 +68,19 @@
import org.apache.mina.filter.codec.ProtocolCodecSession;
import org.apache.mina.filter.codec.ProtocolDecoder;
import org.apache.mina.filter.codec.ProtocolEncoder;
+import org.jboss.jms.client.delegate.ClientConnectionFactoryDelegate;
import org.jboss.jms.delegate.Ack;
import org.jboss.jms.delegate.Cancel;
import org.jboss.jms.delegate.DefaultAck;
import org.jboss.jms.delegate.DefaultCancel;
import org.jboss.jms.delegate.DeliveryRecovery;
+import org.jboss.jms.delegate.TopologyResult;
import org.jboss.jms.destination.JBossDestination;
import org.jboss.jms.destination.JBossQueue;
import org.jboss.jms.destination.JBossTopic;
import org.jboss.jms.message.JBossMessage;
import org.jboss.jms.tx.ClientTransaction;
+import org.jboss.jms.tx.MessagingXid;
import org.jboss.jms.tx.TransactionRequest;
import org.jboss.messaging.core.contract.Message;
import org.jboss.messaging.core.remoting.codec.PacketCodecFactory;
@@ -80,6 +91,8 @@
import org.jboss.messaging.core.remoting.wireformat.AddTemporaryDestinationMessage;
import org.jboss.messaging.core.remoting.wireformat.BrowserHasNextMessageRequest;
import org.jboss.messaging.core.remoting.wireformat.BrowserHasNextMessageResponse;
+import org.jboss.messaging.core.remoting.wireformat.BrowserNextMessageBlockRequest;
+import org.jboss.messaging.core.remoting.wireformat.BrowserNextMessageBlockResponse;
import org.jboss.messaging.core.remoting.wireformat.BrowserNextMessageRequest;
import org.jboss.messaging.core.remoting.wireformat.BrowserNextMessageResponse;
import org.jboss.messaging.core.remoting.wireformat.BrowserResetMessage;
@@ -101,8 +114,14 @@
import org.jboss.messaging.core.remoting.wireformat.CreateSessionResponse;
import org.jboss.messaging.core.remoting.wireformat.DeleteTemporaryDestinationMessage;
import org.jboss.messaging.core.remoting.wireformat.DeliverMessage;
+import org.jboss.messaging.core.remoting.wireformat.GetClientAOPStackRequest;
+import org.jboss.messaging.core.remoting.wireformat.GetClientAOPStackResponse;
import org.jboss.messaging.core.remoting.wireformat.GetClientIDRequest;
import org.jboss.messaging.core.remoting.wireformat.GetClientIDResponse;
+import org.jboss.messaging.core.remoting.wireformat.GetPreparedTransactionsRequest;
+import org.jboss.messaging.core.remoting.wireformat.GetPreparedTransactionsResponse;
+import org.jboss.messaging.core.remoting.wireformat.GetTopologyRequest;
+import org.jboss.messaging.core.remoting.wireformat.GetTopologyResponse;
import org.jboss.messaging.core.remoting.wireformat.IDBlockRequest;
import org.jboss.messaging.core.remoting.wireformat.IDBlockResponse;
import org.jboss.messaging.core.remoting.wireformat.JMSExceptionMessage;
@@ -116,6 +135,7 @@
import org.jboss.messaging.core.remoting.wireformat.StopConnectionMessage;
import org.jboss.messaging.core.remoting.wireformat.TextPacket;
import org.jboss.messaging.core.remoting.wireformat.UnsubscribeMessage;
+import org.jboss.messaging.util.Version;
/**
* @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>.
@@ -131,8 +151,18 @@
// Static --------------------------------------------------------
- private static void assertSameAcks(List<Ack> expected, List<Ack> actual)
+ private static String randomString()
{
+ return UUID.randomUUID().toString();
+ }
+
+ private static long randomLong()
+ {
+ return System.currentTimeMillis();
+ }
+
+ private static void assertEqualsAcks(List<Ack> expected, List<Ack> actual)
+ {
assertEquals(expected.size(), actual.size());
for (int i = 0; i < expected.size(); i++)
{
@@ -141,7 +171,7 @@
}
}
- private static void assertSameDeliveries(List<DeliveryRecovery> expected,
+ private static void assertEqualsDeliveries(List<DeliveryRecovery> expected,
List<DeliveryRecovery> actual)
{
assertEquals(expected.size(), actual.size());
@@ -158,7 +188,7 @@
}
}
- private static void assertSameCancels(List<Cancel> expected,
+ private static void assertEqualsCancels(List<Cancel> expected,
List<Cancel> actual)
{
assertEquals(expected.size(), actual.size());
@@ -176,6 +206,52 @@
}
}
+ private static void assertSameXids(MessagingXid[] expected,
+ MessagingXid[] actual)
+ {
+ assertEquals(expected.length, actual.length);
+ for (int i = 0; i < expected.length; i++)
+ {
+ MessagingXid expectedXid = expected[i];
+ MessagingXid actualXid = actual[i];
+ assertEqualsByteArrays(expectedXid.getBranchQualifier(), actualXid
+ .getBranchQualifier());
+ assertEquals(expectedXid.getFormatId(), actualXid.getFormatId());
+ assertEqualsByteArrays(expectedXid.getGlobalTransactionId(), actualXid
+ .getGlobalTransactionId());
+ }
+ }
+
+ private static void assertEqualsByteArrays(byte[] expected, byte[] actual)
+ {
+ assertEquals(expected.length, actual.length);
+ for (int i = 0; i < expected.length; i++)
+ {
+ assertEquals(expected[i], actual[i]);
+ }
+ }
+
+ private static void assertSameTopology(TopologyResult expected,
+ TopologyResult actual)
+ {
+ assertEquals(expected.getUniqueName(), actual.getUniqueName());
+ assertEquals(expected.getFailoverMap(), actual.getFailoverMap());
+
+ ClientConnectionFactoryDelegate[] expectedDelegates = expected.getDelegates();
+ ClientConnectionFactoryDelegate[] actualDelegates = actual.getDelegates();
+
+ assertEquals(expectedDelegates.length, actualDelegates.length);
+
+ for (int i = 0; i < expectedDelegates.length; i++)
+ {
+ ClientConnectionFactoryDelegate expectedDelegate = expectedDelegates[i];
+ ClientConnectionFactoryDelegate actualDelegate = actualDelegates[i];
+
+ assertEquals(expectedDelegate.getID(), actualDelegate.getID());
+ assertEquals(expectedDelegate.getName(), actualDelegate.getName());
+ }
+ }
+
// Constructors --------------------------------------------------
// Public --------------------------------------------------------
@@ -183,9 +259,9 @@
public void testNullPacket() throws Exception
{
NullPacket packet = new NullPacket();
- packet.setCallbackID(randomUUID().toString());
- packet.setCorrelationID(currentTimeMillis());
- packet.setTargetID(randomUUID().toString());
+ packet.setCallbackID(randomString());
+ packet.setCorrelationID(randomLong());
+ packet.setTargetID(randomString());
AbstractPacket decodedPacket = encodeAndDecode(packet);
@@ -230,7 +306,7 @@
public void testCreateConnectionRequest() throws Exception
{
byte version = (byte) 4;
- String clientVMID = randomUUID().toString();
+ String clientVMID = randomString();
int failedNodeID = 0;
String username = null;
String password = null;
@@ -254,7 +330,7 @@
public void testCreateConnectionResponse() throws Exception
{
CreateConnectionResponse response = new CreateConnectionResponse(
- randomUUID().toString(), 1234);
+ randomString(), 1234);
AbstractPacket decodedPacket = encodeAndDecode(response);
@@ -267,6 +343,61 @@
assertEquals(response.getServerID(), decodedResponse.getServerID());
}
+ public void testGetClientAOPStackRequest() throws Exception
+ {
+ GetClientAOPStackRequest request = new GetClientAOPStackRequest();
+
+ AbstractPacket decodedPacket = encodeAndDecode(request);
+
+ assertTrue(decodedPacket instanceof GetClientAOPStackRequest);
+ assertEquals(REQ_GETCLIENTAOPSTACK, decodedPacket.getType());
+ }
+
+ public void testGetClientAOPStackResponse() throws Exception
+ {
+ byte[] stack = randomString().getBytes();
+
+ GetClientAOPStackResponse response = new GetClientAOPStackResponse(stack);
+
+ AbstractPacket decodedPacket = encodeAndDecode(response);
+
+ assertTrue(decodedPacket instanceof GetClientAOPStackResponse);
+ GetClientAOPStackResponse decodedResponse = (GetClientAOPStackResponse) decodedPacket;
+ assertEquals(RESP_GETCLIENTAOPSTACK, decodedResponse.getType());
+ assertEqualsByteArrays(response.getStack(), decodedResponse.getStack());
+ }
+
+ public void testGetTopologyRequest() throws Exception
+ {
+ GetTopologyRequest request = new GetTopologyRequest();
+
+ AbstractPacket decodedPacket = encodeAndDecode(request);
+
+ assertTrue(decodedPacket instanceof GetTopologyRequest);
+ assertEquals(REQ_GETTOPOLOGY, decodedPacket.getType());
+ }
+
+ @SuppressWarnings("unchecked")
+ public void testGetTopologyResponse() throws Exception
+ {
+ // FIXME should use mock objects with a correct interface
+ ClientConnectionFactoryDelegate[] delegates = new ClientConnectionFactoryDelegate[] {
+ new ClientConnectionFactoryDelegate(randomString(), randomString(),
+ 23, randomString(), Version.instance(), false, true),
+ new ClientConnectionFactoryDelegate(randomString(), randomString(),
+ 33, randomString(), Version.instance(), true, false) };
+ TopologyResult topology = new TopologyResult(randomString(), delegates,
+ new HashMap());
+ GetTopologyResponse response = new GetTopologyResponse(topology);
+
+ AbstractPacket decodedPacket = encodeAndDecode(response);
+
+ assertTrue(decodedPacket instanceof GetTopologyResponse);
+ GetTopologyResponse decodedResponse = (GetTopologyResponse) decodedPacket;
+ assertEquals(RESP_GETTOPOLOGY, decodedPacket.getType());
+ assertSameTopology(response.getTopology(), decodedResponse.getTopology());
+ }
+
public void testCreateSessionRequest() throws Exception
{
CreateSessionRequest request = new CreateSessionRequest(true, 0, false);
@@ -285,8 +416,8 @@
public void testCreateSessionResponse() throws Exception
{
- CreateSessionResponse response = new CreateSessionResponse(randomUUID()
- .toString(), 23, false);
+ CreateSessionResponse response = new CreateSessionResponse(
+ randomString(), 23, false);
AbstractPacket decodedPacket = encodeAndDecode(response);
@@ -315,8 +446,8 @@
public void testIDBlockResponse() throws Exception
{
- IDBlockResponse response = new IDBlockResponse(currentTimeMillis(),
- currentTimeMillis() * 2);
+ IDBlockResponse response = new IDBlockResponse(randomLong(),
+ randomLong() * 2);
AbstractPacket decodedPacket = encodeAndDecode(response);
@@ -331,7 +462,7 @@
public void testSendMessage() throws Exception
{
SendMessage packet = new SendMessage(new JBossMessage(System
- .currentTimeMillis()), true, currentTimeMillis());
+ .currentTimeMillis()), true, randomLong());
AbstractPacket p = encodeAndDecode(packet);
@@ -422,8 +553,8 @@
public void testCreateConsumerResponse() throws Exception
{
- CreateConsumerResponse response = new CreateConsumerResponse(randomUUID()
- .toString(), 23, 42, currentTimeMillis());
+ CreateConsumerResponse response = new CreateConsumerResponse(
+ randomString(), 23, 42, randomLong());
AbstractPacket decodedPacket = encodeAndDecode(response);
@@ -472,9 +603,9 @@
public void testDeliverMessage() throws Exception
{
- Message msg = new JBossMessage(currentTimeMillis());
- DeliverMessage message = new DeliverMessage(msg, randomUUID().toString(),
- currentTimeMillis(), 23);
+ Message msg = new JBossMessage(randomLong());
+ DeliverMessage message = new DeliverMessage(msg, randomString(),
+ randomLong(), 23);
AbstractPacket decodedPacket = encodeAndDecode(message);
@@ -492,7 +623,7 @@
public void testAcknowledgeDeliveryRequest() throws Exception
{
AcknowledgeDeliveryRequest request = new AcknowledgeDeliveryRequest(
- currentTimeMillis());
+ randomLong());
AbstractPacket decodedPacket = encodeAndDecode(request);
@@ -517,7 +648,7 @@
assertTrue(decodedPacket instanceof AcknowledgeDeliveriesMessage);
AcknowledgeDeliveriesMessage decodedRequest = (AcknowledgeDeliveriesMessage) decodedPacket;
assertEquals(PacketType.MSG_ACKDELIVERIES, decodedRequest.getType());
- assertSameAcks(request.getAcks(), decodedRequest.getAcks());
+ assertEqualsAcks(request.getAcks(), decodedRequest.getAcks());
}
public void testAcknowledgeDeliveryResponse() throws Exception
@@ -536,7 +667,7 @@
public void testClosingRequest() throws Exception
{
- ClosingRequest request = new ClosingRequest(currentTimeMillis());
+ ClosingRequest request = new ClosingRequest(randomLong());
AbstractPacket decodedPacket = encodeAndDecode(request);
@@ -588,6 +719,36 @@
.checkForDuplicates());
}
+ public void testGetPreparedTransactionsRequest() throws Exception
+ {
+ GetPreparedTransactionsRequest request = new GetPreparedTransactionsRequest();
+
+ AbstractPacket decodedPacket = encodeAndDecode(request);
+
+ assertTrue(decodedPacket instanceof GetPreparedTransactionsRequest);
+ assertEquals(REQ_GETPREPAREDTRANSACTIONS, decodedPacket.getType());
+ }
+
+ public void testGetPreparedTransactionsResponse() throws Exception
+ {
+ MessagingXid[] xids = new MessagingXid[] {
+ new MessagingXid(randomString().getBytes(), 23, randomString()
+ .getBytes()),
+ new MessagingXid(randomString().getBytes(), 33, randomString()
+ .getBytes()),
+ new MessagingXid(randomString().getBytes(), 91, randomString()
+ .getBytes()) };
+ GetPreparedTransactionsResponse response = new GetPreparedTransactionsResponse(
+ xids);
+
+ AbstractPacket decodedPacket = encodeAndDecode(response);
+
+ assertTrue(decodedPacket instanceof GetPreparedTransactionsResponse);
+ GetPreparedTransactionsResponse decodedResponse = (GetPreparedTransactionsResponse) decodedPacket;
+ assertEquals(RESP_GETPREPAREDTRANSACTIONS, decodedResponse.getType());
+ assertSameXids(response.getXids(), decodedResponse.getXids());
+ }
+
public void testGetClientIDRequest() throws Exception
{
GetClientIDRequest request = new GetClientIDRequest();
@@ -600,8 +761,7 @@
public void testGetClientIDResponse() throws Exception
{
- GetClientIDResponse response = new GetClientIDResponse(randomUUID()
- .toString());
+ GetClientIDResponse response = new GetClientIDResponse(randomString());
AbstractPacket decodedPacket = encodeAndDecode(response);
@@ -613,8 +773,7 @@
public void testSetClientIDMessage() throws Exception
{
- SetClientIDMessage message = new SetClientIDMessage(randomUUID()
- .toString());
+ SetClientIDMessage message = new SetClientIDMessage(randomString());
AbstractPacket decodedPacket = encodeAndDecode(message);
@@ -627,29 +786,29 @@
public void testRecoverDeliveriesMessage() throws Exception
{
List<DeliveryRecovery> deliveries = new ArrayList<DeliveryRecovery>();
- deliveries.add(new DeliveryRecovery(currentTimeMillis(),
- currentTimeMillis(), randomUUID().toString()));
- deliveries.add(new DeliveryRecovery(currentTimeMillis(),
- currentTimeMillis(), randomUUID().toString()));
- deliveries.add(new DeliveryRecovery(currentTimeMillis(),
- currentTimeMillis(), randomUUID().toString()));
+ deliveries.add(new DeliveryRecovery(randomLong(), randomLong(),
+ randomString()));
+ deliveries.add(new DeliveryRecovery(randomLong(), randomLong(),
+ randomString()));
+ deliveries.add(new DeliveryRecovery(randomLong(), randomLong(),
+ randomString()));
RecoverDeliveriesMessage message = new RecoverDeliveriesMessage(
- deliveries, randomUUID().toString());
+ deliveries, randomString());
AbstractPacket decodedPacket = encodeAndDecode(message);
assertTrue(decodedPacket instanceof RecoverDeliveriesMessage);
RecoverDeliveriesMessage decodedMessage = (RecoverDeliveriesMessage) decodedPacket;
assertEquals(MSG_RECOVERDELIVERIES, decodedMessage.getType());
- assertSameDeliveries(message.getDeliveries(), decodedMessage
+ assertEqualsDeliveries(message.getDeliveries(), decodedMessage
.getDeliveries());
assertEquals(message.getSessionID(), decodedMessage.getSessionID());
}
public void testCancelDeliveryMessage() throws Exception
{
- Cancel cancel = new DefaultCancel(currentTimeMillis(), 23, true, false);
+ Cancel cancel = new DefaultCancel(randomLong(), 23, true, false);
CancelDeliveryMessage message = new CancelDeliveryMessage(cancel);
AbstractPacket decodedPacket = encodeAndDecode(message);
@@ -669,8 +828,8 @@
public void testCancelDeliveriesMessage() throws Exception
{
List<Cancel> cancels = new ArrayList<Cancel>();
- cancels.add(new DefaultCancel(currentTimeMillis(), 23, true, false));
- cancels.add(new DefaultCancel(currentTimeMillis(), 33, false, true));
+ cancels.add(new DefaultCancel(randomLong(), 23, true, false));
+ cancels.add(new DefaultCancel(randomLong(), 33, false, true));
CancelDeliveriesMessage message = new CancelDeliveriesMessage(cancels);
@@ -679,7 +838,7 @@
assertTrue(decodedPacket instanceof CancelDeliveriesMessage);
CancelDeliveriesMessage decodedMessage = (CancelDeliveriesMessage) decodedPacket;
assertEquals(MSG_CANCELDELIVERIES, decodedMessage.getType());
- assertSameCancels(message.getCancels(), decodedMessage.getCancels());
+ assertEqualsCancels(message.getCancels(), decodedMessage.getCancels());
}
public void testCreateBrowserRequest() throws Exception
@@ -701,8 +860,7 @@
public void testCreateBrowserResponse() throws Exception
{
- CreateBrowserResponse response = new CreateBrowserResponse(randomUUID()
- .toString());
+ CreateBrowserResponse response = new CreateBrowserResponse(randomString());
AbstractPacket decodedPacket = encodeAndDecode(response);
@@ -759,7 +917,7 @@
public void testBrowserNextMessageResponse() throws Exception
{
- JBossMessage msg = new JBossMessage(currentTimeMillis());
+ JBossMessage msg = new JBossMessage(randomLong());
BrowserNextMessageResponse response = new BrowserNextMessageResponse(msg);
AbstractPacket decodedPacket = encodeAndDecode(response);
@@ -771,6 +929,38 @@
.getMessage().getMessageID());
}
+ public void testBrowserNextMessageBlockRequest() throws Exception
+ {
+ BrowserNextMessageBlockRequest request = new BrowserNextMessageBlockRequest(
+ randomLong());
+
+ AbstractPacket decodedPacket = encodeAndDecode(request);
+
+ assertTrue(decodedPacket instanceof BrowserNextMessageBlockRequest);
+ BrowserNextMessageBlockRequest decodedRequest = (BrowserNextMessageBlockRequest) decodedPacket;
+ assertEquals(REQ_BROWSER_NEXTMESSAGEBLOCK, decodedPacket.getType());
+ assertEquals(request.getMaxMessages(), decodedRequest.getMaxMessages());
+ }
+
+ public void testBrowserNextMessageBlockResponse() throws Exception
+ {
+ JBossMessage[] messages = new JBossMessage[] {
+ new JBossMessage(randomLong()), new JBossMessage(randomLong()) };
+
+ BrowserNextMessageBlockResponse response = new BrowserNextMessageBlockResponse(
+ messages);
+
+ AbstractPacket decodedPacket = encodeAndDecode(response);
+
+ assertTrue(decodedPacket instanceof BrowserNextMessageBlockResponse);
+ BrowserNextMessageBlockResponse decodedResponse = (BrowserNextMessageBlockResponse) decodedPacket;
+ assertEquals(RESP_BROWSER_NEXTMESSAGEBLOCK, decodedResponse.getType());
+ assertEquals(response.getMessages()[0].getMessageID(), decodedResponse
+ .getMessages()[0].getMessageID());
+ assertEquals(response.getMessages()[1].getMessageID(), decodedResponse
+ .getMessages()[1].getMessageID());
+ }
+
public void testUnsubscribeMessage() throws Exception
{
UnsubscribeMessage message = new UnsubscribeMessage(
@@ -784,11 +974,11 @@
assertEquals(decodedMessage.getSubscriptionName(), message
.getSubscriptionName());
}
-
+
public void testAddTemporaryDestinationMessage() throws Exception
{
- JBossDestination destination = new JBossQueue("testAddTemporaryDestinationMessage",
- true);
+ JBossDestination destination = new JBossQueue(
+ "testAddTemporaryDestinationMessage", true);
AddTemporaryDestinationMessage message = new AddTemporaryDestinationMessage(
destination);
@@ -803,8 +993,8 @@
public void testDeleteTemporaryDestinationMessage() throws Exception
{
- JBossDestination destination = new JBossQueue("testDeleteTemporaryDestinationMessage",
- true);
+ JBossDestination destination = new JBossQueue(
+ "testDeleteTemporaryDestinationMessage", true);
DeleteTemporaryDestinationMessage message = new DeleteTemporaryDestinationMessage(
destination);
@@ -816,7 +1006,7 @@
assertEquals(MSG_DELETETEMPORARYDESTINATION, decodedMessage.getType());
assertEquals(message.getDestination(), decodedMessage.getDestination());
}
-
+
// Package protected ---------------------------------------------
// Protected -----------------------------------------------------
More information about the jboss-cvs-commits
mailing list