[jboss-cvs] JBoss Messaging SVN: r2119 - in trunk: src/etc and 30 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Jan 31 19:10:21 EST 2007


Author: timfox
Date: 2007-01-31 19:10:20 -0500 (Wed, 31 Jan 2007)
New Revision: 2119

Added:
   trunk/src/main/org/jboss/jms/wireformat/
   trunk/src/main/org/jboss/jms/wireformat/BrowserHasNextMessageRequest.java
   trunk/src/main/org/jboss/jms/wireformat/BrowserHasNextMessageResponse.java
   trunk/src/main/org/jboss/jms/wireformat/BrowserNextMessageBlockRequest.java
   trunk/src/main/org/jboss/jms/wireformat/BrowserNextMessageBlockResponse.java
   trunk/src/main/org/jboss/jms/wireformat/BrowserNextMessageRequest.java
   trunk/src/main/org/jboss/jms/wireformat/BrowserNextMessageResponse.java
   trunk/src/main/org/jboss/jms/wireformat/CallbackSupport.java
   trunk/src/main/org/jboss/jms/wireformat/ClientDelivery.java
   trunk/src/main/org/jboss/jms/wireformat/CloseRequest.java
   trunk/src/main/org/jboss/jms/wireformat/ClosingRequest.java
   trunk/src/main/org/jboss/jms/wireformat/ConnectionCreateSessionDelegateRequest.java
   trunk/src/main/org/jboss/jms/wireformat/ConnectionCreateSessionDelegateResponse.java
   trunk/src/main/org/jboss/jms/wireformat/ConnectionFactoryCreateConnectionDelegateRequest.java
   trunk/src/main/org/jboss/jms/wireformat/ConnectionFactoryCreateConnectionDelegateResponse.java
   trunk/src/main/org/jboss/jms/wireformat/ConnectionFactoryGetClientAOPStackRequest.java
   trunk/src/main/org/jboss/jms/wireformat/ConnectionFactoryGetClientAOPStackResponse.java
   trunk/src/main/org/jboss/jms/wireformat/ConnectionFactoryGetIDBlockRequest.java
   trunk/src/main/org/jboss/jms/wireformat/ConnectionFactoryGetIDBlockResponse.java
   trunk/src/main/org/jboss/jms/wireformat/ConnectionFactoryUpdate.java
   trunk/src/main/org/jboss/jms/wireformat/ConnectionGetClientIDRequest.java
   trunk/src/main/org/jboss/jms/wireformat/ConnectionGetClientIDResponse.java
   trunk/src/main/org/jboss/jms/wireformat/ConnectionGetPreparedTransactionsRequest.java
   trunk/src/main/org/jboss/jms/wireformat/ConnectionGetPreparedTransactionsResponse.java
   trunk/src/main/org/jboss/jms/wireformat/ConnectionSendTransactionRequest.java
   trunk/src/main/org/jboss/jms/wireformat/ConnectionSetClientIDRequest.java
   trunk/src/main/org/jboss/jms/wireformat/ConnectionStartRequest.java
   trunk/src/main/org/jboss/jms/wireformat/ConnectionStopRequest.java
   trunk/src/main/org/jboss/jms/wireformat/ConsumerCancelInflightMessagesRequest.java
   trunk/src/main/org/jboss/jms/wireformat/ConsumerChangeRateRequest.java
   trunk/src/main/org/jboss/jms/wireformat/Dispatcher.java
   trunk/src/main/org/jboss/jms/wireformat/NullResponse.java
   trunk/src/main/org/jboss/jms/wireformat/PacketSupport.java
   trunk/src/main/org/jboss/jms/wireformat/PolledCallbacksDelivery.java
   trunk/src/main/org/jboss/jms/wireformat/RequestSupport.java
   trunk/src/main/org/jboss/jms/wireformat/ResponseSupport.java
   trunk/src/main/org/jboss/jms/wireformat/SerializedPacket.java
   trunk/src/main/org/jboss/jms/wireformat/SessionAcknowledgeDeliveriesRequest.java
   trunk/src/main/org/jboss/jms/wireformat/SessionAcknowledgeDeliveryRequest.java
   trunk/src/main/org/jboss/jms/wireformat/SessionAddTemporaryDestinationRequest.java
   trunk/src/main/org/jboss/jms/wireformat/SessionCancelDeliveriesRequest.java
   trunk/src/main/org/jboss/jms/wireformat/SessionCancelDeliveryRequest.java
   trunk/src/main/org/jboss/jms/wireformat/SessionCreateBrowserDelegateRequest.java
   trunk/src/main/org/jboss/jms/wireformat/SessionCreateBrowserDelegateResponse.java
   trunk/src/main/org/jboss/jms/wireformat/SessionCreateConsumerDelegateRequest.java
   trunk/src/main/org/jboss/jms/wireformat/SessionCreateConsumerDelegateResponse.java
   trunk/src/main/org/jboss/jms/wireformat/SessionCreateQueueRequest.java
   trunk/src/main/org/jboss/jms/wireformat/SessionCreateQueueResponse.java
   trunk/src/main/org/jboss/jms/wireformat/SessionCreateTopicRequest.java
   trunk/src/main/org/jboss/jms/wireformat/SessionCreateTopicResponse.java
   trunk/src/main/org/jboss/jms/wireformat/SessionDeleteTemporaryDestinationRequest.java
   trunk/src/main/org/jboss/jms/wireformat/SessionRecoverDeliveriesRequest.java
   trunk/src/main/org/jboss/jms/wireformat/SessionSendRequest.java
   trunk/src/main/org/jboss/jms/wireformat/SessionUnsubscribeRequest.java
   trunk/src/main/org/jboss/messaging/core/tx/MessagingXid.java
   trunk/tests/src/org/jboss/test/messaging/graveyard/
   trunk/tests/src/org/jboss/test/messaging/graveyard/GraveyardTest.java
   trunk/tests/src/org/jboss/test/messaging/graveyard/MultipleServerInvocationHandlersTest.java
Removed:
   trunk/src/main/org/jboss/jms/client/delegate/Initializable.java
   trunk/src/main/org/jboss/jms/server/container/InjectionAspect.java
   trunk/src/main/org/jboss/jms/server/endpoint/ClientDelivery.java
   trunk/src/main/org/jboss/jms/server/endpoint/ConnectionFactoryUpdateMessage.java
   trunk/src/main/org/jboss/jms/server/remoting/JMSDispatcher.java
   trunk/src/main/org/jboss/jms/server/remoting/MessagingMarshallable.java
   trunk/src/main/org/jboss/jms/server/remoting/MetaDataConstants.java
   trunk/src/main/org/jboss/messaging/core/tx/XidImpl.java
   trunk/tests/src/org/jboss/test/messaging/jms/MultipleServerInvocationHandlersTest.java
Modified:
   trunk/lib/jboss-remoting.jar
   trunk/src/etc/aop-messaging-server.xml
   trunk/src/main/org/jboss/jms/client/Closeable.java
   trunk/src/main/org/jboss/jms/client/JBossConnectionConsumer.java
   trunk/src/main/org/jboss/jms/client/JBossConnectionFactory.java
   trunk/src/main/org/jboss/jms/client/JBossSession.java
   trunk/src/main/org/jboss/jms/client/container/ClosedInterceptor.java
   trunk/src/main/org/jboss/jms/client/container/ClusteringAspect.java
   trunk/src/main/org/jboss/jms/client/container/StateCreationAspect.java
   trunk/src/main/org/jboss/jms/client/delegate/ClientBrowserDelegate.java
   trunk/src/main/org/jboss/jms/client/delegate/ClientClusteredConnectionFactoryDelegate.java
   trunk/src/main/org/jboss/jms/client/delegate/ClientConnectionDelegate.java
   trunk/src/main/org/jboss/jms/client/delegate/ClientConnectionFactoryDelegate.java
   trunk/src/main/org/jboss/jms/client/delegate/ClientConsumerDelegate.java
   trunk/src/main/org/jboss/jms/client/delegate/ClientProducerDelegate.java
   trunk/src/main/org/jboss/jms/client/delegate/ClientSessionDelegate.java
   trunk/src/main/org/jboss/jms/client/delegate/DelegateSupport.java
   trunk/src/main/org/jboss/jms/client/remoting/CallbackManager.java
   trunk/src/main/org/jboss/jms/client/remoting/ConnectionFactoryCallbackHandler.java
   trunk/src/main/org/jboss/jms/client/remoting/MessageCallbackHandler.java
   trunk/src/main/org/jboss/jms/client/state/SessionState.java
   trunk/src/main/org/jboss/jms/destination/JBossDestination.java
   trunk/src/main/org/jboss/jms/message/JBossMessage.java
   trunk/src/main/org/jboss/jms/server/Version.java
   trunk/src/main/org/jboss/jms/server/connectionfactory/ConnectionFactoryJNDIMapper.java
   trunk/src/main/org/jboss/jms/server/endpoint/BrowserEndpoint.java
   trunk/src/main/org/jboss/jms/server/endpoint/ConnectionEndpoint.java
   trunk/src/main/org/jboss/jms/server/endpoint/CreateConnectionResult.java
   trunk/src/main/org/jboss/jms/server/endpoint/ServerBrowserEndpoint.java
   trunk/src/main/org/jboss/jms/server/endpoint/ServerConnectionEndpoint.java
   trunk/src/main/org/jboss/jms/server/endpoint/ServerConnectionFactoryEndpoint.java
   trunk/src/main/org/jboss/jms/server/endpoint/ServerConsumerEndpoint.java
   trunk/src/main/org/jboss/jms/server/endpoint/ServerSessionEndpoint.java
   trunk/src/main/org/jboss/jms/server/endpoint/SessionEndpoint.java
   trunk/src/main/org/jboss/jms/server/endpoint/advised/BrowserAdvised.java
   trunk/src/main/org/jboss/jms/server/endpoint/advised/ConnectionAdvised.java
   trunk/src/main/org/jboss/jms/server/endpoint/advised/ConsumerAdvised.java
   trunk/src/main/org/jboss/jms/server/endpoint/advised/SessionAdvised.java
   trunk/src/main/org/jboss/jms/server/remoting/JMSServerInvocationHandler.java
   trunk/src/main/org/jboss/jms/server/remoting/JMSWireFormat.java
   trunk/src/main/org/jboss/jms/tx/MessagingXAResource.java
   trunk/src/main/org/jboss/jms/tx/ResourceManager.java
   trunk/src/main/org/jboss/jms/tx/ResourceManagerFactory.java
   trunk/src/main/org/jboss/jms/tx/TransactionRequest.java
   trunk/src/main/org/jboss/messaging/core/plugin/JDBCPersistenceManager.java
   trunk/tests/build.xml
   trunk/tests/etc/log4j.xml
   trunk/tests/src/org/jboss/test/messaging/core/paging/base/PagingStateTestBase.java
   trunk/tests/src/org/jboss/test/messaging/jms/BrowserTest.java
   trunk/tests/src/org/jboss/test/messaging/jms/ConnectionClosedTest.java
   trunk/tests/src/org/jboss/test/messaging/jms/ConnectionTest.java
   trunk/tests/src/org/jboss/test/messaging/jms/WireFormatTest.java
   trunk/tests/src/org/jboss/test/messaging/jms/XARecoveryTest.java
   trunk/tests/src/org/jboss/test/messaging/jms/clustering/base/ClusteringTestBase.java
   trunk/tests/src/org/jboss/test/messaging/jms/server/ServerPeerTest.java
   trunk/tests/src/org/jboss/test/messaging/jms/server/connectionmanager/SimpleConnectionManagerTest.java
   trunk/tests/src/org/jboss/test/messaging/jms/stress/Transactional2PCReceiver.java
   trunk/tests/src/org/jboss/test/messaging/jms/stress/Transactional2PCSender.java
   trunk/tests/src/org/jboss/test/messaging/tools/ServerManagement.java
   trunk/tests/src/org/jboss/test/messaging/tools/jmx/ServiceContainer.java
Log:
Mainly new wireformat



Modified: trunk/lib/jboss-remoting.jar
===================================================================
(Binary files differ)

Modified: trunk/src/etc/aop-messaging-server.xml
===================================================================
--- trunk/src/etc/aop-messaging-server.xml	2007-01-31 20:11:51 UTC (rev 2118)
+++ trunk/src/etc/aop-messaging-server.xml	2007-02-01 00:10:20 UTC (rev 2119)
@@ -7,12 +7,6 @@
    <interceptor class="org.jboss.jms.server.container.ServerLogInterceptor" scope="PER_VM"/>
    <interceptor class="org.jboss.jms.server.container.CachingInterceptor" scope="PER_VM"/>      
    <aspect class="org.jboss.jms.server.container.SecurityAspect" scope="PER_INSTANCE"/>
-   <aspect class="org.jboss.jms.server.container.InjectionAspect" scope="PER_VM"/>
-
-   <!-- ConnectionFactory -->
-   <bind pointcut="execution(* org.jboss.jms.server.endpoint.advised.ConnectionFactoryAdvised->createConnectionDelegate(..))">
-      <advice name="handleCreateConnectionDelegate" aspect="org.jboss.jms.server.container.InjectionAspect"/>
-   </bind>
    
    <!-- Connection -->
    <bind pointcut="execution(* org.jboss.jms.server.endpoint.advised.ConnectionAdvised->$implementing{org.jboss.jms.server.endpoint.ConnectionEndpoint}(..))">

Modified: trunk/src/main/org/jboss/jms/client/Closeable.java
===================================================================
--- trunk/src/main/org/jboss/jms/client/Closeable.java	2007-01-31 20:11:51 UTC (rev 2118)
+++ trunk/src/main/org/jboss/jms/client/Closeable.java	2007-02-01 00:10:20 UTC (rev 2119)
@@ -47,6 +47,4 @@
     * @throws JMSException
     */
    void closing() throws JMSException;
-   
-   boolean isClosed() throws JMSException;
 }

Modified: trunk/src/main/org/jboss/jms/client/JBossConnectionConsumer.java
===================================================================
--- trunk/src/main/org/jboss/jms/client/JBossConnectionConsumer.java	2007-01-31 20:11:51 UTC (rev 2118)
+++ trunk/src/main/org/jboss/jms/client/JBossConnectionConsumer.java	2007-02-01 00:10:20 UTC (rev 2119)
@@ -126,7 +126,7 @@
          // not call pre or postDeliver so messages won't be acked, or stored in session/tx.
          sess = conn.createSessionDelegate(false, Session.CLIENT_ACKNOWLEDGE, false);
 
-         cons = sess.createConsumerDelegate(dest, messageSelector, false, subName, true, null);
+         cons = sess.createConsumerDelegate(dest, messageSelector, false, subName, true, -1);
       }
       finally
       {

Modified: trunk/src/main/org/jboss/jms/client/JBossConnectionFactory.java
===================================================================
--- trunk/src/main/org/jboss/jms/client/JBossConnectionFactory.java	2007-01-31 20:11:51 UTC (rev 2118)
+++ trunk/src/main/org/jboss/jms/client/JBossConnectionFactory.java	2007-02-01 00:10:20 UTC (rev 2119)
@@ -43,7 +43,6 @@
 import org.jboss.jms.referenceable.SerializableObjectRefAddr;
 import org.jboss.jms.server.endpoint.CreateConnectionResult;
 import org.jboss.jms.util.ThreadContextClassLoaderChanger;
-import org.jboss.jms.client.delegate.Initializable;
 import org.jboss.logging.Logger;
 
 /**
@@ -206,9 +205,7 @@
             log.error(msg, e);
             throw new RuntimeException(msg, e);
          }
-
-         ((Initializable)delegate).init();
-
+   
          // The version used by the connection is the minimum of the server version for the
          // connection factory and the client code version
          

Modified: trunk/src/main/org/jboss/jms/client/JBossSession.java
===================================================================
--- trunk/src/main/org/jboss/jms/client/JBossSession.java	2007-01-31 20:11:51 UTC (rev 2118)
+++ trunk/src/main/org/jboss/jms/client/JBossSession.java	2007-02-01 00:10:20 UTC (rev 2119)
@@ -252,7 +252,7 @@
          tccc.set(getClass().getClassLoader());
 
          ConsumerDelegate cd = delegate.
-            createConsumerDelegate((JBossDestination)d, messageSelector, noLocal, null, false, null);
+            createConsumerDelegate((JBossDestination)d, messageSelector, noLocal, null, false, -1);
          
          return new JBossMessageConsumer(cd);
       }
@@ -305,7 +305,7 @@
          tccc.set(getClass().getClassLoader());
 
          ConsumerDelegate cd =
-            delegate.createConsumerDelegate((JBossTopic)topic, null, false, name, false, null);
+            delegate.createConsumerDelegate((JBossTopic)topic, null, false, name, false, -1);
 
          return new JBossMessageConsumer(cd);
       }
@@ -340,7 +340,7 @@
       }
 
       ConsumerDelegate cd = delegate.
-         createConsumerDelegate((JBossTopic)topic, messageSelector, noLocal, name, false, null);
+         createConsumerDelegate((JBossTopic)topic, messageSelector, noLocal, name, false, -1);
 
       return new JBossMessageConsumer(cd);
    }
@@ -377,7 +377,7 @@
          tccc.set(getClass().getClassLoader());
 
          BrowserDelegate del =
-            delegate.createBrowserDelegate((JBossQueue)queue, messageSelector, null);
+            delegate.createBrowserDelegate((JBossQueue)queue, messageSelector, -1);
          
          return new JBossQueueBrowser(queue, messageSelector, del);
       }

Modified: trunk/src/main/org/jboss/jms/client/container/ClosedInterceptor.java
===================================================================
--- trunk/src/main/org/jboss/jms/client/container/ClosedInterceptor.java	2007-01-31 20:11:51 UTC (rev 2118)
+++ trunk/src/main/org/jboss/jms/client/container/ClosedInterceptor.java	2007-02-01 00:10:20 UTC (rev 2119)
@@ -125,15 +125,9 @@
       {
          id = DelegateIdentity.getIdentity(invocation);
       }
-
+      
       String methodName = ((MethodInvocation)invocation).getMethod().getName();
-
-      if ("isClosed".equals(methodName))
-      {
-         //Actually this is badly named, it returns true if it's closing as well as closed
-         return new Boolean(isClosed());
-      }
-
+        
       boolean isClosing = methodName.equals("closing");
       boolean isClose = methodName.equals("close");
       
@@ -315,11 +309,6 @@
    // Package Private ------------------------------------------------
 
    // Private --------------------------------------------------------
-   
-   private boolean isClosed()
-   {
-      return state == IN_CLOSE || state == CLOSED;
-   }
 
    // Inner Classes --------------------------------------------------
 

Modified: trunk/src/main/org/jboss/jms/client/container/ClusteringAspect.java
===================================================================
--- trunk/src/main/org/jboss/jms/client/container/ClusteringAspect.java	2007-01-31 20:11:51 UTC (rev 2118)
+++ trunk/src/main/org/jboss/jms/client/container/ClusteringAspect.java	2007-02-01 00:10:20 UTC (rev 2119)
@@ -46,6 +46,8 @@
    // Constants ------------------------------------------------------------------------------------
 
    private static final Logger log = Logger.getLogger(ClusteringAspect.class);
+   
+   private boolean trace = log.isTraceEnabled();
 
    public static final int MAX_RECONNECT_HOP_COUNT = 10;
 
@@ -67,6 +69,11 @@
    public CreateConnectionResult handleCreateConnectionDelegate(Invocation invocation)
       throws Throwable
    {
+      if (trace)
+      {
+         log.trace(this + " handleCreateConnectionDelegate");
+      }
+      
       // initalize this PER_INSTANCE aspect by getting a hold of its corresponding clustered
       // delegate and maintaining a reference to it
       if (clusteredDelegate == null)

Modified: trunk/src/main/org/jboss/jms/client/container/StateCreationAspect.java
===================================================================
--- trunk/src/main/org/jboss/jms/client/container/StateCreationAspect.java	2007-01-31 20:11:51 UTC (rev 2118)
+++ trunk/src/main/org/jboss/jms/client/container/StateCreationAspect.java	2007-02-01 00:10:20 UTC (rev 2119)
@@ -93,8 +93,6 @@
 
          if(trace) { log.trace(connectionDelegate + " not configured, configuring ..."); }
 
-         connectionDelegate.init();
-
          int serverID = connectionDelegate.getServerID();
          Version versionToUse = connectionDelegate.getVersionToUse();
          JMSRemotingConnection remotingConnection = connectionDelegate.getRemotingConnection();
@@ -132,8 +130,6 @@
       ClientSessionDelegate sessionDelegate = (ClientSessionDelegate)invocation.invokeNext();
       DelegateSupport delegate = (DelegateSupport)sessionDelegate;
 
-      delegate.init();
-
       ConnectionState connectionState = (ConnectionState)getState(invocation);
 
       MethodInvocation mi = (MethodInvocation)invocation;
@@ -153,8 +149,6 @@
       ClientConsumerDelegate consumerDelegate = (ClientConsumerDelegate)invocation.invokeNext();
       DelegateSupport delegate = (DelegateSupport)consumerDelegate;
 
-      delegate.init();
-
       SessionState sessionState = (SessionState)getState(invocation);
 
       MethodInvocation mi = (MethodInvocation)invocation;
@@ -209,8 +203,6 @@
       ClientBrowserDelegate browserDelegate = (ClientBrowserDelegate)invocation.invokeNext();
       DelegateSupport delegate = (DelegateSupport)browserDelegate;
 
-      delegate.init();
-
       SessionState sessionState = (SessionState)getState(invocation);
 
       JBossDestination destination = (JBossDestination)mi.getArguments()[0];

Modified: trunk/src/main/org/jboss/jms/client/delegate/ClientBrowserDelegate.java
===================================================================
--- trunk/src/main/org/jboss/jms/client/delegate/ClientBrowserDelegate.java	2007-01-31 20:11:51 UTC (rev 2118)
+++ trunk/src/main/org/jboss/jms/client/delegate/ClientBrowserDelegate.java	2007-02-01 00:10:20 UTC (rev 2119)
@@ -21,12 +21,21 @@
   */
 package org.jboss.jms.client.delegate;
 
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+
 import javax.jms.JMSException;
-import javax.jms.Message;
 
 import org.jboss.jms.client.state.ConnectionState;
+import org.jboss.jms.client.state.HierarchicalState;
 import org.jboss.jms.delegate.BrowserDelegate;
-import org.jboss.remoting.Client;
+import org.jboss.jms.message.JBossMessage;
+import org.jboss.jms.wireformat.BrowserHasNextMessageRequest;
+import org.jboss.jms.wireformat.BrowserNextMessageBlockRequest;
+import org.jboss.jms.wireformat.BrowserNextMessageRequest;
+import org.jboss.jms.wireformat.CloseRequest;
+import org.jboss.jms.wireformat.ClosingRequest;
+import org.jboss.jms.wireformat.RequestSupport;
 
 /**
  * The client-side Browser delegate class.
@@ -42,8 +51,6 @@
 {
    // Constants ------------------------------------------------------------------------------------
 
-   private static final long serialVersionUID = 8293543769773757409L;
-
    // Attributes -----------------------------------------------------------------------------------
 
    private long channelID;
@@ -75,65 +82,69 @@
       // synchronize (recursively) the client-side state
 
       state.synchronizeWith(newDelegate.getState());
-
-      // synchronize the delegates
-
    }
-
-   // BrowserDelegate implementation ---------------------------------------------------------------
-
-   /**
-    * This invocation should either be handled by the client-side interceptor chain or by the
-    * server-side endpoint.
-    */
+   
+   public void setState(HierarchicalState state)
+   {
+      super.setState(state);
+      
+      client = ((ConnectionState)state.getParent().getParent()).getRemotingConnection().
+                  getRemotingClient();
+   }
+   
+   // Closeable implementation ---------------------------------------------------------------------
+   
    public void close() throws JMSException
    {
-      throw new IllegalStateException("This invocation should not be handled here!");
+      RequestSupport req = new CloseRequest(id, version);
+      
+      doInvoke(client, req);
    }
-
-   /**
-    * This invocation should either be handled by the client-side interceptor chain or by the
-    * server-side endpoint.
-    */
+   
    public void closing() throws JMSException
    {
-      throw new IllegalStateException("This invocation should not be handled here!");
+      RequestSupport req = new ClosingRequest(id, version);
+      
+      doInvoke(client, req);
    }
 
-   /**
-    * This invocation should either be handled by the client-side interceptor chain or by the
-    * server-side endpoint.
-    */
-   public boolean isClosed()
+   // BrowserDelegate implementation ---------------------------------------------------------------
+
+   public boolean hasNextMessage() throws JMSException
    {
-      throw new IllegalStateException("This invocation should not be handled here!");
+      RequestSupport req = new BrowserHasNextMessageRequest(id, version);
+      
+      return ((Boolean)doInvoke(client, req)).booleanValue();      
    }
 
-   /**
-    * This invocation should either be handled by the client-side interceptor chain or by the
-    * server-side endpoint.
-    */
-   public boolean hasNextMessage() throws JMSException
+   public JBossMessage nextMessage() throws JMSException
    {
-      throw new IllegalStateException("This invocation should not be handled here!");
+      RequestSupport req = new BrowserNextMessageRequest(id, version);
+      
+      return (JBossMessage)doInvoke(client, req);      
    }
 
-   /**
-    * This invocation should either be handled by the client-side interceptor chain or by the
-    * server-side endpoint.
-    */
-   public Message nextMessage() throws JMSException
+   public JBossMessage[] nextMessageBlock(int maxMessages) throws JMSException
    {
-      throw new IllegalStateException("This invocation should not be handled here!");
+      RequestSupport req = new BrowserNextMessageBlockRequest(id, version, maxMessages);
+      
+      return (JBossMessage[])doInvoke(client, req);
    }
+   
+   // Streamable implementation ----------------------------------------------------------
+   
+   public void read(DataInputStream in) throws Exception
+   {
+      super.read(in);
+      
+      channelID = in.readLong();
+   }
 
-   /**
-    * This invocation should either be handled by the client-side interceptor chain or by the
-    * server-side endpoint.
-    */
-   public Message[] nextMessageBlock(int maxMessages) throws JMSException
+   public void write(DataOutputStream out) throws Exception
    {
-      throw new IllegalStateException("This invocation should not be handled here!");
+      super.write(out);
+      
+      out.writeLong(channelID);
    }
 
    // Public ---------------------------------------------------------------------------------------
@@ -154,13 +165,6 @@
    }
 
    // Protected ------------------------------------------------------------------------------------
-   
-   protected Client getClient()
-   {
-      // Use the Client in the Connection's state
-      return ((ConnectionState)state.getParent().getParent()).getRemotingConnection().
-         getRemotingClient();
-   }
 
    // Package Private ------------------------------------------------------------------------------
 

Modified: trunk/src/main/org/jboss/jms/client/delegate/ClientClusteredConnectionFactoryDelegate.java
===================================================================
--- trunk/src/main/org/jboss/jms/client/delegate/ClientClusteredConnectionFactoryDelegate.java	2007-01-31 20:11:51 UTC (rev 2118)
+++ trunk/src/main/org/jboss/jms/client/delegate/ClientClusteredConnectionFactoryDelegate.java	2007-02-01 00:10:20 UTC (rev 2119)
@@ -48,7 +48,7 @@
  * $Id$
  */
 public class ClientClusteredConnectionFactoryDelegate
-   implements Serializable, Initializable, ConnectionFactoryDelegate
+   implements Serializable, ConnectionFactoryDelegate
 {
    // Constants ------------------------------------------------------------------------------------
 
@@ -112,16 +112,6 @@
       throw new IllegalStateException("This invocation should not be handled here!");
    }
 
-   // Initializable implemenation ------------------------------------------------------------------
-
-   public void init()
-   {
-      for (int i = 0; i < delegates.length; i++)
-      {
-         delegates[i].init();
-      }
-   }
-
    // Public ---------------------------------------------------------------------------------------
 
    public ClientConnectionFactoryDelegate[] getDelegates()
@@ -157,8 +147,6 @@
       this.delegates = delegates;
       this.failoverMap = failoverMap;
 
-      init();
-
       loadBalancingPolicy.updateView(delegates);
    }
 

Modified: trunk/src/main/org/jboss/jms/client/delegate/ClientConnectionDelegate.java
===================================================================
--- trunk/src/main/org/jboss/jms/client/delegate/ClientConnectionDelegate.java	2007-01-31 20:11:51 UTC (rev 2118)
+++ trunk/src/main/org/jboss/jms/client/delegate/ClientConnectionDelegate.java	2007-02-01 00:10:20 UTC (rev 2119)
@@ -21,23 +21,36 @@
   */
 package org.jboss.jms.client.delegate;
 
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+
 import javax.jms.ConnectionMetaData;
 import javax.jms.Destination;
 import javax.jms.ExceptionListener;
 import javax.jms.JMSException;
 import javax.jms.ServerSessionPool;
-import javax.transaction.xa.Xid;
 
+import org.jboss.jms.client.FailoverListener;
 import org.jboss.jms.client.JBossConnectionConsumer;
-import org.jboss.jms.client.FailoverListener;
 import org.jboss.jms.client.remoting.JMSRemotingConnection;
 import org.jboss.jms.client.state.ConnectionState;
+import org.jboss.jms.client.state.HierarchicalState;
 import org.jboss.jms.delegate.ConnectionDelegate;
 import org.jboss.jms.delegate.SessionDelegate;
 import org.jboss.jms.server.Version;
+import org.jboss.jms.tx.ResourceManagerFactory;
 import org.jboss.jms.tx.TransactionRequest;
-import org.jboss.jms.tx.ResourceManagerFactory;
-import org.jboss.remoting.Client;
+import org.jboss.jms.wireformat.CloseRequest;
+import org.jboss.jms.wireformat.ClosingRequest;
+import org.jboss.jms.wireformat.ConnectionCreateSessionDelegateRequest;
+import org.jboss.jms.wireformat.ConnectionGetClientIDRequest;
+import org.jboss.jms.wireformat.ConnectionGetPreparedTransactionsRequest;
+import org.jboss.jms.wireformat.ConnectionSendTransactionRequest;
+import org.jboss.jms.wireformat.ConnectionSetClientIDRequest;
+import org.jboss.jms.wireformat.ConnectionStartRequest;
+import org.jboss.jms.wireformat.ConnectionStopRequest;
+import org.jboss.jms.wireformat.RequestSupport;
+import org.jboss.messaging.core.tx.MessagingXid;
 
 /**
  * The client-side Connection delegate class.
@@ -54,14 +67,14 @@
 {
    // Constants ------------------------------------------------------------------------------------
 
-   private static final long serialVersionUID = 6680015509555859038L;
-
    // Attributes -----------------------------------------------------------------------------------
 
    private int serverID;
+   
    private transient JMSRemotingConnection remotingConnection;
-   private Version versionToUse;
    
+   private transient Version versionToUse;
+   
    // Static ---------------------------------------------------------------------------------------
 
    // Constructors ---------------------------------------------------------------------------------
@@ -69,6 +82,7 @@
    public ClientConnectionDelegate(int objectID, int serverID)
    {
       super(objectID);
+      
       this.serverID = serverID;
    }
 
@@ -115,39 +129,35 @@
          this.start();
       }
    }
+   
+   public void setState(HierarchicalState state)
+   {
+      super.setState(state);
+      
+      client = ((ConnectionState)state).getRemotingConnection(). getRemotingClient();
+   }
 
-   // ConnectionDelegate implementation ------------------------------------------------------------
-
-   /**
-    * This invocation should either be handled by the client-side interceptor chain or by the
-    * server-side endpoint.
-    */
+   // Closeable implementation ---------------------------------------------------------------------
+   
    public void close() throws JMSException
    {
-      throw new IllegalStateException("This invocation should not be handled here!");
+      RequestSupport req = new CloseRequest(id, version);
+      
+      doInvoke(client, req);
    }
-
-   /**
-    * This invocation should either be handled by the client-side interceptor chain or by the
-    * server-side endpoint.
-    */
+   
    public void closing() throws JMSException
    {
-      throw new IllegalStateException("This invocation should not be handled here!");
+      RequestSupport req = new ClosingRequest(id, version);
+      
+      doInvoke(client, req);
    }
+   
+   // ConnectionDelegate implementation ------------------------------------------------------------
 
    /**
     * This invocation should either be handled by the client-side interceptor chain or by the
     * server-side endpoint.
-    */
-   public boolean isClosed()
-   {
-      throw new IllegalStateException("This invocation should not be handled here!");
-   }
-
-   /**
-    * This invocation should either be handled by the client-side interceptor chain or by the
-    * server-side endpoint.
     * @see org.jboss.jms.client.container.AsfAspect#handleCreateConnectionConsumer(org.jboss.aop.joinpoint.Invocation)
     */
    public JBossConnectionConsumer createConnectionConsumer(Destination dest,
@@ -159,25 +169,21 @@
       throw new IllegalStateException("This invocation should not be handled here!");
    }
 
-   /**
-    * This invocation should either be handled by the client-side interceptor chain or by the
-    * server-side endpoint.
-    * @see org.jboss.jms.server.endpoint.advised.ConnectionAdvised#createSessionDelegate(boolean, int, boolean)
-    */
    public SessionDelegate createSessionDelegate(boolean transacted,
                                                 int acknowledgmentMode,
                                                 boolean isXA) throws JMSException
    {
-      throw new IllegalStateException("This invocation should not be handled here!");
+      RequestSupport req = new ConnectionCreateSessionDelegateRequest(id, version,
+                                                                      transacted, acknowledgmentMode, isXA);      
+      return (SessionDelegate)doInvoke(client, req);     
    }
+  
 
-   /**
-    * This invocation should either be handled by the client-side interceptor chain or by the
-    * server-side endpoint.
-    */
    public String getClientID() throws JMSException
    {
-      throw new IllegalStateException("This invocation should not be handled here!");
+      RequestSupport req = new ConnectionGetClientIDRequest(id, version);
+                     
+      return (String)doInvoke(client, req);      
    }
 
    /**
@@ -198,22 +204,18 @@
       throw new IllegalStateException("This invocation should not be handled here!");
    }
 
-   /**
-    * This invocation should either be handled by the client-side interceptor chain or by the
-    * server-side endpoint.
-    */
    public void sendTransaction(TransactionRequest request) throws JMSException
    {
-      throw new IllegalStateException("This invocation should not be handled here!");
+      RequestSupport req = new ConnectionSendTransactionRequest(id, version, request);
+      
+      doInvoke(client, req);
    }
 
-   /**
-    * This invocation should either be handled by the client-side interceptor chain or by the
-    * server-side endpoint.
-    */
-   public void setClientID(String id) throws JMSException
+   public void setClientID(String clientID) throws JMSException
    {
-      throw new IllegalStateException("This invocation should not be handled here!");
+      RequestSupport req = new ConnectionSetClientIDRequest(id, version, clientID);
+      
+      doInvoke(client, req);
    }
 
    /**
@@ -225,31 +227,25 @@
       throw new IllegalStateException("This invocation should not be handled here!");
    }
 
-   /**
-    * This invocation should either be handled by the client-side interceptor chain or by the
-    * server-side endpoint.
-    */
    public void start() throws JMSException
    {
-      throw new IllegalStateException("This invocation should not be handled here!");
+      RequestSupport req = new ConnectionStartRequest(id, version);
+      
+      doInvoke(client, req);
    }
 
-   /**
-    * This invocation should either be handled by the client-side interceptor chain or by the
-    * server-side endpoint.
-    */
    public void stop() throws JMSException
    {
-      throw new IllegalStateException("This invocation should not be handled here!");
+      RequestSupport req = new ConnectionStopRequest(id, version);
+      
+      doInvoke(client, req);
    }
 
-   /**
-    * This invocation should either be handled by the client-side interceptor chain or by the
-    * server-side endpoint.
-    */
-   public Xid[] getPreparedTransactions()
+   public MessagingXid[] getPreparedTransactions() throws JMSException
    {
-      throw new IllegalStateException("This invocation should not be handled here!");
+      RequestSupport req = new ConnectionGetPreparedTransactionsRequest(id, version);
+      
+      return (MessagingXid[])doInvoke(client, req);    
    }
 
    /**
@@ -270,11 +266,6 @@
 
    // Public ---------------------------------------------------------------------------------------
 
-   public void init()
-   {
-      super.init();
-   }
-
    public void setRemotingConnection(JMSRemotingConnection conn)
    {
       this.remotingConnection = conn;
@@ -307,11 +298,22 @@
 
    // Protected ------------------------------------------------------------------------------------
 
-   protected Client getClient()
+   // Streamable implementation -------------------------------------------------------------------
+   
+   public void read(DataInputStream in) throws Exception
    {
-      return ((ConnectionState)state).getRemotingConnection().getRemotingClient();
+      super.read(in);
+      
+      serverID = in.readInt();
    }
 
+   public void write(DataOutputStream out) throws Exception
+   {
+      super.write(out);
+      
+      out.writeInt(serverID);
+   }
+
    // Package Private ------------------------------------------------------------------------------
 
    // Private --------------------------------------------------------------------------------------

Modified: trunk/src/main/org/jboss/jms/client/delegate/ClientConnectionFactoryDelegate.java
===================================================================
--- trunk/src/main/org/jboss/jms/client/delegate/ClientConnectionFactoryDelegate.java	2007-01-31 20:11:51 UTC (rev 2118)
+++ trunk/src/main/org/jboss/jms/client/delegate/ClientConnectionFactoryDelegate.java	2007-02-01 00:10:20 UTC (rev 2119)
@@ -21,17 +21,14 @@
  */
 package org.jboss.jms.client.delegate;
 
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.Serializable;
 import java.util.HashMap;
 import java.util.Map;
 
 import javax.jms.JMSException;
 
-import org.jboss.aop.Dispatcher;
-import org.jboss.aop.Advised;
-import org.jboss.aop.joinpoint.Invocation;
-import org.jboss.aop.joinpoint.MethodInvocation;
-import org.jboss.aop.metadata.SimpleMetaData;
-import org.jboss.aop.util.PayloadKey;
 import org.jboss.jms.client.container.JMSClientVMIdentifier;
 import org.jboss.jms.client.remoting.JMSRemotingConnection;
 import org.jboss.jms.delegate.ConnectionFactoryDelegate;
@@ -39,8 +36,11 @@
 import org.jboss.jms.server.Version;
 import org.jboss.jms.server.endpoint.CreateConnectionResult;
 import org.jboss.jms.server.remoting.JMSWireFormat;
-import org.jboss.jms.server.remoting.MessagingMarshallable;
-import org.jboss.jms.server.remoting.MetaDataConstants;
+import org.jboss.jms.util.MessagingJMSException;
+import org.jboss.jms.wireformat.ConnectionFactoryCreateConnectionDelegateRequest;
+import org.jboss.jms.wireformat.ConnectionFactoryGetClientAOPStackRequest;
+import org.jboss.jms.wireformat.ConnectionFactoryGetIDBlockRequest;
+import org.jboss.jms.wireformat.ResponseSupport;
 import org.jboss.logging.Logger;
 import org.jboss.messaging.core.plugin.IDBlock;
 import org.jboss.remoting.Client;
@@ -49,6 +49,7 @@
 /**
  * The client-side ConnectionFactory delegate class.
  * 
+ * 
  * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
  * @author <a href="mailto:ovidiu at jboss.org">Ovidiu Feodorov</a>
  *
@@ -57,7 +58,7 @@
  * $Id$
  */
 public class ClientConnectionFactoryDelegate
-   extends DelegateSupport implements ConnectionFactoryDelegate
+   extends DelegateSupport implements ConnectionFactoryDelegate, Serializable
 {
    // Constants ------------------------------------------------------------------------------------
 
@@ -76,7 +77,7 @@
    
    private boolean clientPing;
    
-   private transient boolean trace;
+   private transient boolean trace = log.isTraceEnabled();
 
    // Static ---------------------------------------------------------------------------------------
    
@@ -110,74 +111,25 @@
                                           Version serverVersion, boolean clientPing)
    {
       super(objectID);
-
+      
       this.serverID = serverID;
       this.serverLocatorURI = serverLocatorURI;
       this.serverVersion = serverVersion;
       this.clientPing = clientPing;
       trace = log.isTraceEnabled();
+   }   
+   
+   public ClientConnectionFactoryDelegate()
+   {      
    }
 
-   // ClientAOPStackProvider implementation --------------------------------------------------------
-
-   public byte[] getClientAOPStack()
-   {
-      // When the invocation lands here the first time, the AOP stack hasn't been initialized yet,
-      // so we "manually" add this delegate at the end of its empty stack and re-send the invocation
-      // down the stack; it will eventually end up on the server.
-
-      ((Advised)this)._getInstanceAdvisor().appendInterceptor(this);
-
-      byte[] clientAOPStack = this.getClientAOPStack();
-
-      // remove ourselves from the end of our own AOP stack now that we have the "real" AOP
-      // configuration that we can use.
-
-      ((Advised)this)._getInstanceAdvisor().removeInterceptor(this.getName());
-
-      return clientAOPStack;
-   }
-
    // ConnectionFactoryDelegate implementation -----------------------------------------------------
  
-   /**
-    * This invocation should either be handled by the client-side interceptor chain or by the
-    * server-side endpoint.
-    */
    public CreateConnectionResult createConnectionDelegate(String username,
                                                           String password,
                                                           int failedNodeID)
       throws JMSException
    {
-      throw new IllegalStateException("This invocation should not be handled here!");
-   }
-
-   /**
-    * This invocation should either be handled by the client-side interceptor chain or by the
-    * server-side endpoint.
-    * @see org.jboss.jms.server.endpoint.ServerConnectionFactoryEndpoint#getIdBlock(int)  
-    */
-   public IDBlock getIdBlock(int size)
-   {
-      throw new IllegalStateException("This invocation should not be handled here!");
-   }
-
-   // Public ---------------------------------------------------------------------------------------
-
-   public synchronized Object invoke(Invocation invocation) throws Throwable
-   {
-      MethodInvocation mi = (MethodInvocation)invocation;
-      String methodName = mi.getMethod().getName();
-
-      if (trace) { log.trace("invoking " + methodName + " on server"); }
-
-      SimpleMetaData md = mi.getMetaData();
-
-      md.addMetaData(Dispatcher.DISPATCHER,
-                     Dispatcher.OID,
-                     new Integer(id),
-                     PayloadKey.AS_IS);
-
       // If the method being invoked is createConnectionDelegate() then we must invoke it on the
       // same remoting client subsequently used by the connection. This is because we need to pass
       // in the remoting session id in the call to createConnection. All other invocations can be
@@ -187,63 +139,39 @@
       // create the client since it will use the already existing invoker. This prevents us from
       // having to maintain a Client instance per connection factory, which gives difficulties in
       // knowing when to close it.
-
-      Client client;
-
+      
+      Version version = getVersionToUse(serverVersion);
+      
+      byte v = version.getProviderIncrementingVersion();
+                       
       JMSRemotingConnection remotingConnection = null;
-
-      if ("createConnectionDelegate".equals(methodName))
-      {
-         // Create a new connection
-
+      
+      CreateConnectionResult res;
+      
+      try
+      {         
          remotingConnection = new JMSRemotingConnection(serverLocatorURI, clientPing);
+         
          remotingConnection.start();
-
-         client = remotingConnection.getRemotingClient();
-
-         md.addMetaData(MetaDataConstants.JMS,
-                        MetaDataConstants.REMOTING_SESSION_ID,
-                        client.getSessionId(),
-                        PayloadKey.AS_IS);
-
-         md.addMetaData(MetaDataConstants.JMS,
-                        MetaDataConstants.JMS_CLIENT_VM_ID,
-                        JMSClientVMIdentifier.instance,
-                        PayloadKey.AS_IS);
+   
+         Client client = remotingConnection.getRemotingClient();
+         
+         String remotingSessionId = client.getSessionId();
+         
+         String clientVMId = JMSClientVMIdentifier.instance;
+            
+         ConnectionFactoryCreateConnectionDelegateRequest req = 
+            new ConnectionFactoryCreateConnectionDelegateRequest(id, v,
+                                                                 remotingSessionId, clientVMId,
+                                                                 username, password, failedNodeID);
+           
+         ResponseSupport rs = (ResponseSupport)client.invoke(req, null);
+         
+         res = (CreateConnectionResult)rs.getResponse();
       }
-      else
-      {
-         // Create a client - make sure pinging is off
-
-         Map configuration = new HashMap();
-
-         configuration.put(Client.ENABLE_LEASE, String.valueOf(false));
-
-         client = new Client(new InvokerLocator(serverLocatorURI), configuration);
-         client.setSubsystem(ServerPeer.REMOTING_JMS_SUBSYSTEM);
-         client.connect();
-
-         client.setMarshaller(new JMSWireFormat());
-         client.setUnMarshaller(new JMSWireFormat());
-      }
-
-      // What version should we use for invocations on this connection factory?
-      Version version = getVersionToUse(serverVersion);
-      byte v = version.getProviderIncrementingVersion();
-
-      MessagingMarshallable request = new MessagingMarshallable(v, mi);
-
-      MessagingMarshallable response;
-
-      try
-      {
-         response = (MessagingMarshallable)client.invoke(request, null);
-
-         if (trace) { log.trace("got server response for " + methodName); }
-      }
       catch (Throwable t)
       {
-         // If we were invoking createConnectionDelegate and failure occurs then we need to clear
+         //If we were invoking createConnectionDelegate and failure occurs then we need to clear
          // up the JMSRemotingConnection
 
          if (remotingConnection != null)
@@ -256,54 +184,74 @@
             {
             }
          }
-
-         throw t;
+         
+         throw handleThrowable(t);
       }
-      finally
+         
+      ClientConnectionDelegate connectionDelegate = (ClientConnectionDelegate)res.getDelegate();
+      
+      if (connectionDelegate != null)
       {
-         if (remotingConnection == null)
-         {
-            // Not a call to createConnectionDelegate - disconnect the client
+         connectionDelegate.setRemotingConnection(remotingConnection);
+         
+         connectionDelegate.setVersionToUse(version);
 
-            // client.disconnect();
-         }
+         remotingConnection.getCallbackManager().setConnectionDelegate(connectionDelegate);
       }
-
-      Object ret = response.getLoad();
-
-      if (remotingConnection != null)
+      else
       {
-         // It was a call to createConnectionDelegate - set the remoting connection to use
-         
-         CreateConnectionResult res = (CreateConnectionResult)ret;
-         
-         ClientConnectionDelegate connectionDelegate = (ClientConnectionDelegate)res.getDelegate();
-         
-         if (connectionDelegate != null)
+         //Wrong server redirect on failure
+         //close the remoting connection
+         try
          {
-            connectionDelegate.setRemotingConnection(remotingConnection);
-            
-            connectionDelegate.setVersionToUse(version);
-
-            remotingConnection.getCallbackManager().setConnectionDelegate(connectionDelegate);
+            remotingConnection.stop();
          }
-         else
+         catch (Throwable ignore)
          {
-            //Wrong server redirect on failure
-            //close the remoting connection
-            try
-            {
-               remotingConnection.stop();
-            }
-            catch (Throwable ignore)
-            {
-            }
          }
       }
 
-      return ret;
+      return res;
    }
+   
+   public IDBlock getIdBlock(int size) throws JMSException
+   {
+      Version version = getVersionToUse(serverVersion);
+      
+      byte v = version.getProviderIncrementingVersion();
+      
+      Client theClient = createClient();
+      
+      ConnectionFactoryGetIDBlockRequest req =
+         new ConnectionFactoryGetIDBlockRequest(id, v, size);
+      
+      return (IDBlock)doInvoke(theClient, req);    
+   }
+   
+   public byte[] getClientAOPStack() throws JMSException
+   {
+      Version version = getVersionToUse(serverVersion);
+      
+      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
+      
+      Client theClient = createClient();
+      
+      ConnectionFactoryGetClientAOPStackRequest req =
+         new ConnectionFactoryGetClientAOPStackRequest(id, v);
+      
+      return (byte[])doInvoke(theClient, req); 
+   }
+      
+   // Public ---------------------------------------------------------------------------------------
+
    public String toString()
    {
       return "ConnectionFactoryDelegate[" + id + ", SID=" + serverID + "]";
@@ -333,17 +281,71 @@
    {
       super.synchronizeWith(newDelegate);
    }
+   
 
    // Protected ------------------------------------------------------------------------------------
 
-   protected Client getClient()
+   // Package Private ------------------------------------------------------------------------------
+
+   // Private --------------------------------------------------------------------------------------
+   
+   private Client createClient() throws JMSException
    {
-      return null;
+      // Create a client - make sure pinging is off
+
+      Map configuration = new HashMap();
+
+      configuration.put(Client.ENABLE_LEASE, String.valueOf(false));
+
+      //We execute this on it's own client
+      Client client;
+      
+      try
+      {
+         client = new Client(new InvokerLocator(serverLocatorURI), configuration);
+         client.setSubsystem(ServerPeer.REMOTING_JMS_SUBSYSTEM);
+         client.connect();
+      }
+      catch (Exception e)
+      {
+         throw new MessagingJMSException("Failed to connect client", e);
+      }
+
+      client.setMarshaller(new JMSWireFormat());
+      client.setUnMarshaller(new JMSWireFormat());
+      
+      return client;
    }
+   
+   // Streamable implementation --------------------------------------------
 
-   // Package Private ------------------------------------------------------------------------------
+   public void read(DataInputStream in) throws Exception
+   {      
+      super.read(in);
+      
+      serverLocatorURI = in.readUTF();
+      
+      serverVersion = new Version();
+      
+      serverVersion.read(in);
+      
+      serverID = in.readInt();
+      
+      clientPing = in.readBoolean();
+   }
 
-   // Private --------------------------------------------------------------------------------------
+   public void write(DataOutputStream out) throws Exception
+   {
+      super.write(out);
+      
+      out.writeUTF(serverLocatorURI);
+      
+      serverVersion.write(out);
+      
+      out.writeInt(serverID);
+      
+      out.writeBoolean(clientPing);
+   }
 
    // Inner Classes --------------------------------------------------------------------------------
 

Modified: trunk/src/main/org/jboss/jms/client/delegate/ClientConsumerDelegate.java
===================================================================
--- trunk/src/main/org/jboss/jms/client/delegate/ClientConsumerDelegate.java	2007-01-31 20:11:51 UTC (rev 2118)
+++ trunk/src/main/org/jboss/jms/client/delegate/ClientConsumerDelegate.java	2007-02-01 00:10:20 UTC (rev 2119)
@@ -21,13 +21,22 @@
   */
 package org.jboss.jms.client.delegate;
 
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+
 import javax.jms.JMSException;
 import javax.jms.Message;
 import javax.jms.MessageListener;
 
 import org.jboss.jms.client.state.ConnectionState;
+import org.jboss.jms.client.state.HierarchicalState;
 import org.jboss.jms.delegate.ConsumerDelegate;
 import org.jboss.jms.destination.JBossDestination;
+import org.jboss.jms.wireformat.CloseRequest;
+import org.jboss.jms.wireformat.ClosingRequest;
+import org.jboss.jms.wireformat.ConsumerCancelInflightMessagesRequest;
+import org.jboss.jms.wireformat.ConsumerChangeRateRequest;
+import org.jboss.jms.wireformat.RequestSupport;
 import org.jboss.remoting.Client;
 
 /**
@@ -44,8 +53,6 @@
 {
    // Constants ------------------------------------------------------------------------------------
 
-   private static final long serialVersionUID = -2578195153435251519L;
-
    // Attributes -----------------------------------------------------------------------------------
    
    private int bufferSize;
@@ -89,53 +96,46 @@
       channelID = newDelegate.getChannelID();
 
    }
-
-   // ConsumerDelegate implementation --------------------------------------------------------------
    
-   /**
-    * This invocation should either be handled by the client-side interceptor chain or by the
-    * server-side endpoint.
-    */
-   public void cancelInflightMessages(long lastDeliveryId) throws JMSException
+   public void setState(HierarchicalState state)
    {
-      throw new IllegalStateException("This invocation should not be handled here!");
+      super.setState(state);
+      
+      client = ((ConnectionState)state.getParent().getParent()).getRemotingConnection().
+                  getRemotingClient();
    }
+
+   // Closeable implementation ---------------------------------------------------------------------
    
-   /**
-    * This invocation should either be handled by the client-side interceptor chain or by the
-    * server-side endpoint.
-    */
-   public void changeRate(float newRate)
-   {
-      throw new IllegalStateException("This invocation should not be handled here!");
-   }
-
-   /**
-    * This invocation should either be handled by the client-side interceptor chain or by the
-    * server-side endpoint.
-    */
    public void close() throws JMSException
    {
-      throw new IllegalStateException("This invocation should not be handled here!");
+      RequestSupport req = new CloseRequest(id, version);
+      
+      doInvoke(client, req);
    }
-
-   /**
-    * This invocation should either be handled by the client-side interceptor chain or by the
-    * server-side endpoint.
-    */
+   
    public void closing() throws JMSException
    {
-      throw new IllegalStateException("This invocation should not be handled here!");
+      RequestSupport req = new ClosingRequest(id, version);
+      
+      doInvoke(client, req);
    }
-
-   /**
-    * This invocation should either be handled by the client-side interceptor chain or by the
-    * server-side endpoint.
-    */
-   public boolean isClosed()
+   
+   // ConsumerDelegate implementation --------------------------------------------------------------
+   
+   public void cancelInflightMessages(long lastDeliveryId) throws JMSException
    {
-      throw new IllegalStateException("This invocation should not be handled here!");
+      RequestSupport req = new ConsumerCancelInflightMessagesRequest(id, version, lastDeliveryId);
+      
+      doInvoke(client, req);
    }
+   
+   public void changeRate(float newRate) throws JMSException
+   {
+      RequestSupport req = new ConsumerChangeRateRequest(id, version, newRate);
+      
+      doInvokeOneway(client, req);
+   }
 
    /**
     * This invocation should either be handled by the client-side interceptor chain or by the
@@ -190,7 +190,31 @@
    {
       throw new IllegalStateException("This invocation should not be handled here!");
    }
+   
+   // Streamable implementation ----------------------------------------------------------
 
+   public void read(DataInputStream in) throws Exception
+   {
+      super.read(in);
+      
+      bufferSize = in.readInt();
+      
+      maxDeliveries = in.readInt();
+      
+      channelID = in.readLong();
+   }
+
+   public void write(DataOutputStream out) throws Exception
+   {
+      super.write(out);
+      
+      out.writeInt(bufferSize);
+      
+      out.writeInt(maxDeliveries);
+      
+      out.writeLong(channelID);
+   }
+
    // Public ---------------------------------------------------------------------------------------
 
    public String toString()
@@ -215,14 +239,6 @@
 
    // Protected ------------------------------------------------------------------------------------
 
-   protected Client getClient()
-   {
-      // Use the Client in the Connection's state
-      return ((ConnectionState)state.getParent().getParent()).getRemotingConnection().
-         getRemotingClient();
-   }
-
-
    // Package Private ------------------------------------------------------------------------------
 
    // Private --------------------------------------------------------------------------------------

Modified: trunk/src/main/org/jboss/jms/client/delegate/ClientProducerDelegate.java
===================================================================
--- trunk/src/main/org/jboss/jms/client/delegate/ClientProducerDelegate.java	2007-01-31 20:11:51 UTC (rev 2118)
+++ trunk/src/main/org/jboss/jms/client/delegate/ClientProducerDelegate.java	2007-02-01 00:10:20 UTC (rev 2119)
@@ -69,9 +69,6 @@
       // synchronize (recursively) the client-side state
 
       state.synchronizeWith(newDelegate.getState());
-
-      // synchronize the delegates
-
    }
 
    // ProducerDelegate implementation --------------------------------------------------------------
@@ -98,15 +95,6 @@
     * This invocation should either be handled by the client-side interceptor chain or by the
     * server-side endpoint.
     */
-   public boolean isClosed()
-   {
-      throw new IllegalStateException("This invocation should not be handled here!");
-   }
-
-   /**
-    * This invocation should either be handled by the client-side interceptor chain or by the
-    * server-side endpoint.
-    */
    public int getDeliveryMode() throws JMSException
    {
       throw new IllegalStateException("This invocation should not be handled here!");
@@ -239,11 +227,6 @@
 
    // Protected ------------------------------------------------------------------------------------
    
-   protected Client getClient()
-   {
-      throw new UnsupportedOperationException("Producers only exist on the client");
-   }
-
    // Package Private ------------------------------------------------------------------------------
 
    // Private --------------------------------------------------------------------------------------

Modified: trunk/src/main/org/jboss/jms/client/delegate/ClientSessionDelegate.java
===================================================================
--- trunk/src/main/org/jboss/jms/client/delegate/ClientSessionDelegate.java	2007-01-31 20:11:51 UTC (rev 2118)
+++ trunk/src/main/org/jboss/jms/client/delegate/ClientSessionDelegate.java	2007-02-01 00:10:20 UTC (rev 2119)
@@ -29,6 +29,7 @@
 import javax.transaction.xa.XAResource;
 
 import org.jboss.jms.client.state.ConnectionState;
+import org.jboss.jms.client.state.HierarchicalState;
 import org.jboss.jms.delegate.BrowserDelegate;
 import org.jboss.jms.delegate.ConsumerDelegate;
 import org.jboss.jms.delegate.ProducerDelegate;
@@ -46,7 +47,23 @@
 import org.jboss.jms.server.endpoint.Ack;
 import org.jboss.jms.server.endpoint.Cancel;
 import org.jboss.jms.server.endpoint.DeliveryInfo;
-import org.jboss.remoting.Client;
+import org.jboss.jms.wireformat.CloseRequest;
+import org.jboss.jms.wireformat.ClosingRequest;
+import org.jboss.jms.wireformat.RequestSupport;
+import org.jboss.jms.wireformat.SessionAcknowledgeDeliveriesRequest;
+import org.jboss.jms.wireformat.SessionAcknowledgeDeliveryRequest;
+import org.jboss.jms.wireformat.SessionAddTemporaryDestinationRequest;
+import org.jboss.jms.wireformat.SessionCancelDeliveriesRequest;
+import org.jboss.jms.wireformat.SessionCancelDeliveryRequest;
+import org.jboss.jms.wireformat.SessionCreateBrowserDelegateRequest;
+import org.jboss.jms.wireformat.SessionCreateConsumerDelegateRequest;
+import org.jboss.jms.wireformat.SessionCreateQueueRequest;
+import org.jboss.jms.wireformat.SessionCreateTopicRequest;
+import org.jboss.jms.wireformat.SessionDeleteTemporaryDestinationRequest;
+import org.jboss.jms.wireformat.SessionRecoverDeliveriesRequest;
+import org.jboss.jms.wireformat.SessionSendRequest;
+import org.jboss.jms.wireformat.SessionUnsubscribeRequest;
+import org.jboss.logging.Logger;
 
 /**
  * The client-side Session delegate class.
@@ -64,7 +81,9 @@
    // Constants ------------------------------------------------------------------------------------
 
    private static final long serialVersionUID = -8096852898620279131L;
-   
+
+   private static final Logger log = Logger.getLogger(ClientSessionDelegate.class);
+
    // Attributes -----------------------------------------------------------------------------------
 
    // Static ---------------------------------------------------------------------------------------
@@ -75,9 +94,9 @@
    {
       super(objectID);
    }
-   
+
    public ClientSessionDelegate()
-   {      
+   {
    }
 
    // DelegateSupport overrides --------------------------------------------------------------------
@@ -93,57 +112,48 @@
       // synchronize (recursively) the client-side state
 
       state.synchronizeWith(newDelegate.getState());
-
-      // synchronize the delegates
    }
 
-   // SessionDelegate implementation ---------------------------------------------------------------
+   public void setState(HierarchicalState state)
+   {
+      super.setState(state);
 
-   /**
-    * This invocation should either be handled by the client-side interceptor chain or by the
-    * server-side endpoint.
-    */
+      client = ((ConnectionState)state.getParent()).getRemotingConnection().
+                  getRemotingClient();
+   }
+   
+   // Closeable implementation ---------------------------------------------------------------------
+   
    public void close() throws JMSException
    {
-      throw new IllegalStateException("This invocation should not be handled here!");
+      RequestSupport req = new CloseRequest(id, version);
+      
+      doInvoke(client, req);
    }
-
-   /**
-    * This invocation should either be handled by the client-side interceptor chain or by the
-    * server-side endpoint.
-    */
+   
    public void closing() throws JMSException
    {
-      throw new IllegalStateException("This invocation should not be handled here!");
+      RequestSupport req = new ClosingRequest(id, version);
+      
+      doInvoke(client, req);
    }
 
-   /**
-    * This invocation should either be handled by the client-side interceptor chain or by the
-    * server-side endpoint.
-    */
-   public boolean isClosed()
-   {
-      throw new IllegalStateException("This invocation should not be handled here!");
-   }
+   // SessionDelegate implementation ---------------------------------------------------------------
 
-   /**
-    * This invocation should either be handled by the client-side interceptor chain or by the
-    * server-side endpoint.
-    */
    public void acknowledgeDelivery(Ack ack) throws JMSException
    {
-      throw new IllegalStateException("This invocation should not be handled here!");
+      RequestSupport req = new SessionAcknowledgeDeliveryRequest(id, version, ack);
+
+      doInvoke(client, req);
    }
-   
-   /**
-    * This invocation should either be handled by the client-side interceptor chain or by the
-    * server-side endpoint.
-    */
+
    public void acknowledgeDeliveries(List acks) throws JMSException
    {
-      throw new IllegalStateException("This invocation should not be handled here!");
+      RequestSupport req = new SessionAcknowledgeDeliveriesRequest(id, version, acks);
+
+      doInvoke(client, req);
    }
-   
+
    /**
     * This invocation should either be handled by the client-side interceptor chain or by the
     * server-side endpoint.
@@ -153,13 +163,11 @@
       throw new IllegalStateException("This invocation should not be handled here!");
    }
 
-   /**
-    * This invocation should either be handled by the client-side interceptor chain or by the
-    * server-side endpoint.
-    */
    public void addTemporaryDestination(JBossDestination destination) throws JMSException
    {
-      throw new IllegalStateException("This invocation should not be handled here!");
+      RequestSupport req = new SessionAddTemporaryDestinationRequest(id, version, destination);
+
+      doInvoke(client, req);
    }
 
    /**
@@ -180,14 +188,15 @@
       throw new IllegalStateException("This invocation should not be handled here!");
    }
 
-   /**
-    * This invocation should either be handled by the client-side interceptor chain or by the
-    * server-side endpoint.
-    */
    public BrowserDelegate createBrowserDelegate(JBossDestination queue, String messageSelector,
-                                                Long failoverChannelID) throws JMSException
+                                                long failoverChannelID) throws JMSException
    {
-      throw new IllegalStateException("This invocation should not be handled here!");
+      RequestSupport req = new SessionCreateBrowserDelegateRequest(id, version, queue,
+                                                  messageSelector, failoverChannelID);
+
+      Object res = doInvoke(client, req);
+      
+      return (BrowserDelegate)res;
    }
 
    /**
@@ -199,17 +208,16 @@
       throw new IllegalStateException("This invocation should not be handled here!");
    }
 
-   /**
-    * This invocation should either be handled by the client-side interceptor chain or by the
-    * server-side endpoint.
-    * @see org.jboss.jms.client.container.ConsumerAspect#handleCreateConsumerDelegate(org.jboss.aop.joinpoint.Invocation)
-    */
+
    public ConsumerDelegate createConsumerDelegate(JBossDestination destination, String selector,
-                                                  boolean noLocal, String subscriptionName,
-                                                  boolean connectionConsumer,
-                                                  Long failoverChannelID) throws JMSException
+            boolean noLocal, String subscriptionName,
+            boolean connectionConsumer,
+            long failoverChannelID) throws JMSException
    {
-      throw new IllegalStateException("This invocation should not be handled here!");
+      RequestSupport req = new SessionCreateConsumerDelegateRequest(id, version, destination,
+               selector, noLocal, subscriptionName, connectionConsumer, failoverChannelID);
+
+      return (ConsumerDelegate)doInvoke(client, req);
    }
 
    /**
@@ -257,13 +265,11 @@
       throw new IllegalStateException("This invocation should not be handled here!");
    }
 
-   /**
-    * This invocation should either be handled by the client-side interceptor chain or by the
-    * server-side endpoint.
-    */
    public JBossQueue createQueue(String queueName) throws JMSException
    {
-      throw new IllegalStateException("This invocation should not be handled here!");
+      RequestSupport req = new SessionCreateQueueRequest(id, version, queueName);
+
+      return (JBossQueue)doInvoke(client, req);
    }
 
    /**
@@ -293,22 +299,18 @@
       throw new IllegalStateException("This invocation should not be handled here!");
    }
 
-   /**
-    * This invocation should either be handled by the client-side interceptor chain or by the
-    * server-side endpoint.
-    */
    public JBossTopic createTopic(String topicName) throws JMSException
    {
-      throw new IllegalStateException("This invocation should not be handled here!");
+      RequestSupport req = new SessionCreateTopicRequest(id, version, topicName);
+
+      return (JBossTopic)doInvoke(client, req);
    }
 
-   /**
-    * This invocation should either be handled by the client-side interceptor chain or by the
-    * server-side endpoint.
-    */
    public void deleteTemporaryDestination(JBossDestination destination) throws JMSException
    {
-      throw new IllegalStateException("This invocation should not be handled here!");
+      RequestSupport req = new SessionDeleteTemporaryDestinationRequest(id, version, destination);
+
+      doInvoke(client, req);
    }
 
    /**
@@ -346,7 +348,7 @@
    {
       throw new IllegalStateException("This invocation should not be handled here!");
    }
-   
+
    /**
     * This invocation should either be handled by the client-side interceptor chain or by the
     * server-side endpoint.
@@ -355,7 +357,7 @@
    {
       throw new IllegalStateException("This invocation should not be handled here!");
    }
-   
+
    /**
     * This invocation should either be handled by the client-side interceptor chain or by the
     * server-side endpoint.
@@ -377,22 +379,20 @@
    /**
     * This invocation should either be handled by the client-side interceptor chain or by the
     * server-side endpoint.
-    * @see org.jboss.jms.client.container.AsfAspect#handleSetMessageListener(org.jboss.aop.joinpoint.Invocation) 
+    * @see org.jboss.jms.client.container.AsfAspect#handleSetMessageListener(org.jboss.aop.joinpoint.Invocation)
     */
    public void setMessageListener(MessageListener listener) throws JMSException
    {
       throw new IllegalStateException("This invocation should not be handled here!");
    }
 
-   /**
-    * This invocation should either be handled by the client-side interceptor chain or by the
-    * server-side endpoint.
-    */
    public void unsubscribe(String subscriptionName) throws JMSException
    {
-      throw new IllegalStateException("This invocation should not be handled here!");
+      RequestSupport req = new SessionUnsubscribeRequest(id, version, subscriptionName);
+
+      doInvoke(client, req);
    }
-   
+
    /**
     * This invocation should either be handled by the client-side interceptor chain or by the
     * server-side endpoint.
@@ -401,7 +401,7 @@
    {
       throw new IllegalStateException("This invocation should not be handled here!");
    }
-   
+
    /**
     * This invocation should either be handled by the client-side interceptor chain or by the
     * server-side endpoint.
@@ -410,7 +410,7 @@
    {
       throw new IllegalStateException("This invocation should not be handled here!");
    }
-      
+
    /**
     * This invocation should either be handled by the client-side interceptor chain or by the
     * server-side endpoint.
@@ -419,7 +419,7 @@
    {
       throw new IllegalStateException("This invocation should not be handled here!");
    }
-   
+
    /**
     * This invocation should either be handled by the client-side interceptor chain or by the
     * server-side endpoint.
@@ -429,41 +429,33 @@
    {
       throw new IllegalStateException("This invocation should not be handled here!");
    }
-   
-   /**
-    * This invocation should either be handled by the client-side interceptor chain or by the
-    * server-side endpoint.
-    */
-   public void send(JBossMessage m)
+
+   public void send(JBossMessage m) throws JMSException
    {
-      throw new IllegalStateException("This invocation should not be handled here!");
+      RequestSupport req = new SessionSendRequest(id, version, m);
+
+      doInvoke(client, req);
    }
-   
-   /**
-    * This invocation should either be handled by the client-side interceptor chain or by the
-    * server-side endpoint.
-    */
-   public void cancelDeliveries(List cancels)
+
+   public void cancelDeliveries(List cancels) throws JMSException
    {
-      throw new IllegalStateException("This invocation should not be handled here!");
+      RequestSupport req = new SessionCancelDeliveriesRequest(id, version, cancels);
+
+      doInvoke(client, req);
    }
-   
-   /**
-    * This invocation should either be handled by the client-side interceptor chain or by the
-    * server-side endpoint.
-    */
-   public void cancelDelivery(Cancel cancel)
+
+   public void cancelDelivery(Cancel cancel) throws JMSException
    {
-      throw new IllegalStateException("This invocation should not be handled here!");
+      RequestSupport req = new SessionCancelDeliveryRequest(id, version, cancel);
+
+      doInvoke(client, req);
    }
-   
-   /**
-    * This invocation should either be handled by the client-side interceptor chain or by the
-    * server-side endpoint.
-    */
-   public void recoverDeliveries(List ackInfos) throws JMSException
+
+   public void recoverDeliveries(List acks) throws JMSException
    {
-      throw new IllegalStateException("This invocation should not be handled here!");
+      RequestSupport req = new SessionRecoverDeliveriesRequest(id, version, acks);
+
+      doInvoke(client, req);
    }
 
    // Public ---------------------------------------------------------------------------------------
@@ -474,12 +466,6 @@
    }
 
    // Protected ------------------------------------------------------------------------------------
-   
-   protected Client getClient()
-   {
-      //Use the Client in the Connection's state
-      return ((ConnectionState)state.getParent()).getRemotingConnection().getRemotingClient();
-   }
 
    // Package Private ------------------------------------------------------------------------------
 

Modified: trunk/src/main/org/jboss/jms/client/delegate/DelegateSupport.java
===================================================================
--- trunk/src/main/org/jboss/jms/client/delegate/DelegateSupport.java	2007-01-31 20:11:51 UTC (rev 2118)
+++ trunk/src/main/org/jboss/jms/client/delegate/DelegateSupport.java	2007-02-01 00:10:20 UTC (rev 2119)
@@ -21,18 +21,18 @@
   */
 package org.jboss.jms.client.delegate;
 
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
 import java.io.Serializable;
 
-import org.jboss.aop.Advised;
-import org.jboss.aop.Dispatcher;
-import org.jboss.aop.advice.Interceptor;
-import org.jboss.aop.joinpoint.Invocation;
-import org.jboss.aop.joinpoint.MethodInvocation;
-import org.jboss.aop.metadata.SimpleMetaData;
-import org.jboss.aop.util.PayloadKey;
+import javax.jms.JMSException;
+
 import org.jboss.jms.client.state.HierarchicalState;
-import org.jboss.jms.server.remoting.MessagingMarshallable;
+import org.jboss.jms.util.MessagingJMSException;
+import org.jboss.jms.wireformat.RequestSupport;
+import org.jboss.jms.wireformat.ResponseSupport;
 import org.jboss.logging.Logger;
+import org.jboss.messaging.util.Streamable;
 import org.jboss.remoting.Client;
 
 /**
@@ -54,16 +54,14 @@
  *
  * $Id$
  */
-public abstract class DelegateSupport implements Interceptor, Serializable, Initializable
+public abstract class DelegateSupport implements Streamable, Serializable
 {
    // Constants ------------------------------------------------------------------------------------
-
-   private static final long serialVersionUID = 8005108339439737469L;
-
+      
    private static final Logger log = Logger.getLogger(DelegateSupport.class);
 
    private static boolean trace = log.isTraceEnabled();
-
+   
    // Attributes -----------------------------------------------------------------------------------
 
    // This is set on the server.
@@ -74,6 +72,10 @@
    // extra HashMap lookup that would entail. This can be significant since the state could be
    // queried for many aspects in an a single invocation.
    protected transient HierarchicalState state;
+   
+   protected transient byte version;
+   
+   protected transient Client client;
 
    // Static ---------------------------------------------------------------------------------------
 
@@ -97,55 +99,17 @@
       // Neede a meaninful name to change the aop stack programatically (HA uses that)
       return this.getClass().getName();
    }
-
-   /**
-    * DelegateSupport also acts as an interceptor - the last interceptor in the chain which invokes
-    * on the server.
-    */
-   public Object invoke(Invocation invocation) throws Throwable
+   
+   // Streamable implementation --------------------------------------------------------------------
+   
+   public void read(DataInputStream in) throws Exception
    {
-      String methodName = ((MethodInvocation)invocation).getMethod().getName();
-
-      invocation.getMetaData().addMetaData(Dispatcher.DISPATCHER,
-                                           Dispatcher.OID,
-                                           new Integer(id),
-                                           PayloadKey.AS_IS);
-
-      Client client = getClient();
-      byte version = getState().getVersionToUse().getProviderIncrementingVersion();
-      MessagingMarshallable request = new MessagingMarshallable(version, invocation);
-
-      // select invocations ought to be sent "one way" for increased performance
-      
-      //TODO polymorphism: shouldn't this be ClientSessionDelegate::invoke rather than the super class?? 
-      if ("changeRate".equals(methodName))
-      {
-         if (trace) { log.trace(this + " invoking " + methodName + "(..) asynchronously on server"); }
-
-         client.invokeOneway(request);
-
-         if (trace) { log.trace(this + " asynchronously invoked " + methodName + "(..) on server, no response expected"); }
-
-         return null;
-      }
-      else
-      {
-         if (trace) { log.trace(this + " invoking " + methodName + "(..) synchronously on server"); }
-
-         Object o = client.invoke(request, null);
-
-         if (trace) { log.trace(this + " got server response for " + methodName + "(..): " + o); }
-
-         MessagingMarshallable response = (MessagingMarshallable)o;
-         return response.getLoad();
-      }
+      id = in.readInt();
    }
 
-   // Initializable implemenation ------------------------------------------------------------------
-
-   public void init()
+   public void write(DataOutputStream out) throws Exception
    {
-      ((Advised)this)._getInstanceAdvisor().appendInterceptor(this);
+      out.writeInt(id);
    }
 
    // Public ---------------------------------------------------------------------------------------
@@ -154,17 +118,19 @@
    {
       return state;
    }
-
+   
    public void setState(HierarchicalState state)
    {
       this.state = state;
+      
+      this.version = state.getVersionToUse().getProviderIncrementingVersion();
    }
 
    public int getID()
    {
       return id;
    }
-
+   
    /**
     * During HA events, delegates corresponding to new enpoints on the new server are created and
     * the state of those delegates has to be transfered to the "failed" delegates. For example, a
@@ -178,18 +144,62 @@
 
    // Package protected ----------------------------------------------------------------------------
 
-   // Protected ------------------------------------------------------------------------------------
-
-   protected SimpleMetaData getMetaData()
+   // Protected ------------------------------------------------------------------------------------     
+   
+   protected Object doInvoke(Client client, RequestSupport req) throws JMSException
    {
-      return ((Advised)this)._getInstanceAdvisor().getMetaData();
+      return doInvoke(client, req, false);
    }
+   
+   protected Object doInvokeOneway(Client client, RequestSupport req) throws JMSException
+   {
+      return doInvoke(client, req, true);
+   }
 
-   protected abstract Client getClient() throws Exception;
-
-
    // Private --------------------------------------------------------------------------------------
 
+   private Object doInvoke(Client client, RequestSupport req, boolean oneWay) throws JMSException
+   {
+      try
+      {
+         Object resp = null;
+         
+         if (oneWay)
+         {
+            client.invokeOneway(req);
+         }
+         else
+         {
+            resp = client.invoke(req);
+         }
+           
+         Object res = null;
+         
+         if (resp instanceof ResponseSupport)
+         {
+            res = ((ResponseSupport)resp).getResponse();
+         }
+         
+         return res;     
+      }
+      catch (Throwable t)
+      {
+         throw handleThrowable(t);
+      }
+   }
+   
+   public JMSException handleThrowable(Throwable t)
+   {
+      if (t instanceof JMSException)
+      {
+         return (JMSException)t;
+      }
+      else
+      {
+         log.error("Failed", t);
+         return new MessagingJMSException("Failed to invoke", t);
+      }
+   }
+   
    // Inner classes --------------------------------------------------------------------------------
-
 }

Deleted: trunk/src/main/org/jboss/jms/client/delegate/Initializable.java
===================================================================
--- trunk/src/main/org/jboss/jms/client/delegate/Initializable.java	2007-01-31 20:11:51 UTC (rev 2118)
+++ trunk/src/main/org/jboss/jms/client/delegate/Initializable.java	2007-02-01 00:10:20 UTC (rev 2119)
@@ -1,24 +0,0 @@
-/**
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package org.jboss.jms.client.delegate;
-
-/**
- * Applies to delegates.
- *
- * @author <a href="mailto:ovidiu at jboss.org">Ovidiu Feodorov</a>
- * @version <tt>$Revision$</tt>
- *
- * $Id$
- */
-public interface Initializable
-{
-   /**
-    * Usually add the delegate itself as the last invoking interceptor in the stack, and prepare
-    * the stack for invocations.
-    */
-   void init();
-}

Modified: trunk/src/main/org/jboss/jms/client/remoting/CallbackManager.java
===================================================================
--- trunk/src/main/org/jboss/jms/client/remoting/CallbackManager.java	2007-01-31 20:11:51 UTC (rev 2118)
+++ trunk/src/main/org/jboss/jms/client/remoting/CallbackManager.java	2007-02-01 00:10:20 UTC (rev 2119)
@@ -23,11 +23,10 @@
 
 import java.util.Map;
 
-import org.jboss.jms.message.MessageProxy;
-import org.jboss.jms.server.endpoint.ClientDelivery;
-import org.jboss.jms.server.endpoint.ConnectionFactoryUpdateMessage;
-import org.jboss.jms.server.remoting.MessagingMarshallable;
 import org.jboss.jms.client.delegate.ClientConnectionDelegate;
+import org.jboss.jms.message.MessageProxy;
+import org.jboss.jms.wireformat.ClientDelivery;
+import org.jboss.jms.wireformat.ConnectionFactoryUpdate;
 import org.jboss.logging.Logger;
 import org.jboss.remoting.callback.Callback;
 import org.jboss.remoting.callback.HandleCallbackException;
@@ -84,10 +83,9 @@
    {
       Object parameter = callback.getParameter();
 
-      if (parameter instanceof MessagingMarshallable)
+      if (parameter instanceof ClientDelivery)
       {
-         MessagingMarshallable mm = (MessagingMarshallable)parameter;
-         ClientDelivery dr = (ClientDelivery)mm.getLoad();
+         ClientDelivery dr = (ClientDelivery)parameter;
          MessageProxy msg = dr.getMessage();
 
          MessageCallbackHandler handler =
@@ -100,6 +98,7 @@
             // safe to ignore the message.
 
             if (trace) { log.trace(this + " callback handler not found, message arrived after consumer is closed"); }
+            
             return;
          }
 
@@ -113,9 +112,9 @@
             throw new HandleCallbackException(e.getMessage(), e);
          }
       }
-      else if (parameter instanceof ConnectionFactoryUpdateMessage)
+      else if (parameter instanceof ConnectionFactoryUpdate)
       {
-         ConnectionFactoryUpdateMessage viewChange = (ConnectionFactoryUpdateMessage)parameter;
+         ConnectionFactoryUpdate viewChange = (ConnectionFactoryUpdate)parameter;
 
          if (trace) { log.trace(this + " receiving cluster view change " + viewChange); }
 

Modified: trunk/src/main/org/jboss/jms/client/remoting/ConnectionFactoryCallbackHandler.java
===================================================================
--- trunk/src/main/org/jboss/jms/client/remoting/ConnectionFactoryCallbackHandler.java	2007-01-31 20:11:51 UTC (rev 2118)
+++ trunk/src/main/org/jboss/jms/client/remoting/ConnectionFactoryCallbackHandler.java	2007-02-01 00:10:20 UTC (rev 2119)
@@ -25,7 +25,7 @@
 import org.jboss.jms.client.delegate.ClientClusteredConnectionFactoryDelegate;
 import org.jboss.jms.client.delegate.ClientConnectionDelegate;
 import org.jboss.jms.client.state.ConnectionState;
-import org.jboss.jms.server.endpoint.ConnectionFactoryUpdateMessage;
+import org.jboss.jms.wireformat.ConnectionFactoryUpdate;
 import org.jboss.logging.Logger;
 
 /**
@@ -63,7 +63,7 @@
    {
       if (trace) { log.trace(this + " handling " + message); }
 
-      ConnectionFactoryUpdateMessage viewChange = (ConnectionFactoryUpdateMessage)message;
+      ConnectionFactoryUpdate viewChange = (ConnectionFactoryUpdate)message;
 
       Object d = getState().getClusteredConnectionFactoryDelegate();
 

Modified: trunk/src/main/org/jboss/jms/client/remoting/MessageCallbackHandler.java
===================================================================
--- trunk/src/main/org/jboss/jms/client/remoting/MessageCallbackHandler.java	2007-01-31 20:11:51 UTC (rev 2118)
+++ trunk/src/main/org/jboss/jms/client/remoting/MessageCallbackHandler.java	2007-02-01 00:10:20 UTC (rev 2119)
@@ -165,17 +165,12 @@
          }
       }   
 
-      if (!sess.isClosed())
+      // If this is the callback-handler for a connection consumer we don't want to acknowledge
+      // or add anything to the tx for this session
+      if (!isConnectionConsumer)
       {
-         // postDeliver only if the session is not closed
-               
-         // If this is the callback-handler for a connection consumer we don't want to acknowledge
-         // or add anything to the tx for this session
-         if (!isConnectionConsumer)
-         {
-            sess.postDeliver();
-         }   
-      }
+         sess.postDeliver();
+      }   
    }
    
    // Attributes -----------------------------------------------------------------------------------

Modified: trunk/src/main/org/jboss/jms/client/state/SessionState.java
===================================================================
--- trunk/src/main/org/jboss/jms/client/state/SessionState.java	2007-01-31 20:11:51 UTC (rev 2118)
+++ trunk/src/main/org/jboss/jms/client/state/SessionState.java	2007-02-01 00:10:20 UTC (rev 2119)
@@ -89,9 +89,6 @@
    // List<DeliveryInfo>
    private List clientAckList;
 
-   // List<DeliveryInfo>
-   //private List clientCancelList;
-   
    private DeliveryInfo autoAckInfo;
    private Map callbackHandlers;
 
@@ -129,8 +126,6 @@
 
       clientAckList = new ArrayList();
 
-     // clientCancelList = new ArrayList();
-      
       // TODO could optimise this to use the same map of callbackmanagers (which holds refs
       // to callbackhandlers) in the connection, instead of maintaining another map
       callbackHandlers = new HashMap();
@@ -190,7 +185,7 @@
                                       consState.isNoLocal(),
                                       consState.getSubscriptionName(),
                                       consState.isConnectionConsumer(),
-                                      new Long(consState.getChannelID()));
+                                      consState.getChannelID());
             log.debug(this + " created new consumer " + newConsDelegate);
 
             consDelegate.synchronizeWith(newConsDelegate);
@@ -219,7 +214,7 @@
             ClientBrowserDelegate newBrowserDelegate = (ClientBrowserDelegate)newDelegate.
                createBrowserDelegate(browserState.getJmsDestination(),
                                      browserState.getMessageSelector(),
-                                     new Long(browserState.getChannelID()));
+                                     browserState.getChannelID());
             log.debug(this + " created new browser " + newBrowserDelegate);
 
             browserDelegate.synchronizeWith(newBrowserDelegate);

Modified: trunk/src/main/org/jboss/jms/destination/JBossDestination.java
===================================================================
--- trunk/src/main/org/jboss/jms/destination/JBossDestination.java	2007-01-31 20:11:51 UTC (rev 2118)
+++ trunk/src/main/org/jboss/jms/destination/JBossDestination.java	2007-02-01 00:10:20 UTC (rev 2119)
@@ -21,6 +21,9 @@
   */
 package org.jboss.jms.destination;
 
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
 import java.io.Serializable;
 
 import javax.jms.Destination;
@@ -41,9 +44,95 @@
    // Constants -----------------------------------------------------
 
    private final static long serialVersionUID = -3483274922186827576L;
+   
+   private static final byte NULL = 0;
+   
+   private static final byte QUEUE = 1;
+   
+   private static final byte TOPIC = 2;
+   
+   private static final byte TEMP_QUEUE = 3;
+   
+   private static final byte TEMP_TOPIC = 4;
 
    // Static --------------------------------------------------------
    
+   public static void writeDestination(DataOutputStream out, Destination dest) throws IOException
+   {
+      JBossDestination jb = (JBossDestination)dest;
+            
+      if (dest == null)
+      {
+         out.writeByte(NULL);
+      }
+      else
+      {
+         if (!jb.isTemporary())
+         {
+            if (jb.isQueue())
+            {
+               out.writeByte(QUEUE);
+            }
+            else 
+            {
+               out.writeByte(TOPIC);
+            }
+         }
+         else
+         {
+            if (jb.isQueue())
+            {
+               out.writeByte(TEMP_QUEUE);
+            }
+            else 
+            {
+               out.writeByte(TEMP_TOPIC);
+            }
+         }
+         out.writeUTF(jb.getName());
+      }
+   }
+   
+   public static JBossDestination readDestination(DataInputStream in) throws IOException
+   {
+      byte b = in.readByte();
+      
+      if (b == NULL)
+      {
+         return null;
+      }
+      else
+      {
+         String name = in.readUTF();
+
+         JBossDestination dest;
+         
+         if (b == QUEUE)
+         {
+            dest = new JBossQueue(name);
+         }
+         else if (b == TOPIC)
+         {
+            dest = new JBossTopic(name);
+         }
+         else if (b == TEMP_QUEUE)
+         {
+            dest = new JBossTemporaryQueue(name);
+         }
+         else if (b == TEMP_TOPIC)
+         {
+            dest = new JBossTemporaryTopic(name);
+         }
+         else
+         {
+            throw new IllegalStateException("Invalid value:" + b);
+         }
+         
+         return dest;
+      }
+   }
+
+   
    // Attributes ----------------------------------------------------
 
    protected String name;

Modified: trunk/src/main/org/jboss/jms/message/JBossMessage.java
===================================================================
--- trunk/src/main/org/jboss/jms/message/JBossMessage.java	2007-01-31 20:11:51 UTC (rev 2118)
+++ trunk/src/main/org/jboss/jms/message/JBossMessage.java	2007-02-01 00:10:20 UTC (rev 2119)
@@ -87,13 +87,9 @@
    private static final byte NULL = 0;
    
    private static final byte STRING = 1;
+   
    private static final byte BYTES = 2;
-   private static final byte QUEUE = 3;
-   private static final byte TOPIC = 4;
-   private static final byte TEMP_QUEUE = 5;
    
-   private static final byte TEMP_TOPIC = 6;
-   
    private static final String JMSX_DELIVERY_COUNT_PROP_NAME = "JMSXDeliveryCount";   
    
    public static final String JMS_JBOSS_SCHEDULED_DELIVERY_PROP_NAME = "JMS_JBOSS_SCHEDULED_DELIVERY";
@@ -970,10 +966,10 @@
    {
       super.write(out);
       
-      writeDestination(out, destination);
-
-      writeDestination(out, replyToDestination);
+      JBossDestination.writeDestination(out, destination);
       
+      JBossDestination.writeDestination(out, replyToDestination);
+      
       if (jmsType == null)
       {
          out.writeByte(NULL);
@@ -1012,9 +1008,9 @@
    {
       super.read(in);
 
-      destination = readDestination(in);
+      destination = JBossDestination.readDestination(in);
 
-      replyToDestination = readDestination(in);
+      replyToDestination = JBossDestination.readDestination(in);
  
       byte b = in.readByte();
       if (b == NULL)
@@ -1109,80 +1105,5 @@
 
    // Protected -----------------------------------------------------
    
-   protected void writeDestination(DataOutputStream out, Destination dest) throws IOException
-   {
-      JBossDestination jb = (JBossDestination)dest;
-            
-      if (dest == null)
-      {
-         out.writeByte(NULL);
-      }
-      else
-      {
-         if (!jb.isTemporary())
-         {
-            if (jb.isQueue())
-            {
-               out.writeByte(QUEUE);
-            }
-            else 
-            {
-               out.writeByte(TOPIC);
-            }
-         }
-         else
-         {
-            if (jb.isQueue())
-            {
-               out.writeByte(TEMP_QUEUE);
-            }
-            else 
-            {
-               out.writeByte(TEMP_TOPIC);
-            }
-         }
-         out.writeUTF(jb.getName());
-      }
-   }
-   
-   protected JBossDestination readDestination(DataInputStream in) throws IOException
-   {
-      byte b = in.readByte();
-      
-      if (b == NULL)
-      {
-         return null;
-      }
-      else
-      {
-         String name = in.readUTF();
-
-         JBossDestination dest;
-         
-         if (b == QUEUE)
-         {
-            dest = new JBossQueue(name);
-         }
-         else if (b == TOPIC)
-         {
-            dest = new JBossTopic(name);
-         }
-         else if (b == TEMP_QUEUE)
-         {
-            dest = new JBossTemporaryQueue(name);
-         }
-         else if (b == TEMP_TOPIC)
-         {
-            dest = new JBossTemporaryTopic(name);
-         }
-         else
-         {
-            throw new IllegalStateException("Invalid value:" + b);
-         }
-         
-         return dest;
-      }
-   }
-
    // Inner classes -------------------------------------------------
 }

Modified: trunk/src/main/org/jboss/jms/server/Version.java
===================================================================
--- trunk/src/main/org/jboss/jms/server/Version.java	2007-01-31 20:11:51 UTC (rev 2118)
+++ trunk/src/main/org/jboss/jms/server/Version.java	2007-02-01 00:10:20 UTC (rev 2119)
@@ -6,12 +6,15 @@
  */
 package org.jboss.jms.server;
 
-import org.jboss.logging.Logger;
-
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
 import java.io.InputStream;
 import java.io.Serializable;
 import java.util.Properties;
 
+import org.jboss.logging.Logger;
+import org.jboss.messaging.util.Streamable;
+
 /**
  * @author <a href="mailto:ovidiu at jboss.org">Ovidiu Feodorov</a>
  * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
@@ -19,14 +22,14 @@
  *
  * $Id$
  */
-public class Version implements Serializable
+public class Version implements Streamable, Serializable
 {
    // Constants -----------------------------------------------------
 
+   private static final long serialVersionUID = 3605477218138273630L;
+
    private static final Logger log = Logger.getLogger(Version.class);
 
-   private static final long serialVersionUID = 549375395739573409L;
-
    // Static --------------------------------------------------------
    
    // Attributes ----------------------------------------------------
@@ -56,6 +59,10 @@
 
    // Public -------------------------------------------------------
    
+   public Version()
+   {      
+   }
+   
    public static synchronized Version instance()
    {
       if (singleton == null)
@@ -227,6 +234,44 @@
          }
       }
    }
+   
+   public void read(DataInputStream in) throws Exception
+   {
+      jmsVersion = in.readUTF();
+      
+      jmsMajorVersion = in.readInt();
+      
+      jmsMinorVersion = in.readInt();
+      
+      jmsProviderName = in.readUTF();
+      
+      providerVersion = in.readUTF();
+      
+      providerMajorVersion = in.readInt();
+      
+      providerMinorVersion = in.readInt();
+      
+      providerIncrementingVersion = in.readByte();      
+   }
 
+   public void write(DataOutputStream out) throws Exception
+   {
+      out.writeUTF(jmsVersion);
+      
+      out.writeInt(jmsMajorVersion);
+      
+      out.writeInt(jmsMinorVersion);
+      
+      out.writeUTF(jmsProviderName);
+      
+      out.writeUTF(providerVersion);
+      
+      out.writeInt(providerMajorVersion);
+      
+      out.writeInt(providerMinorVersion);
+      
+      out.writeByte(providerIncrementingVersion);
+   }
+
    // Inner classes -------------------------------------------------
 }

Modified: trunk/src/main/org/jboss/jms/server/connectionfactory/ConnectionFactoryJNDIMapper.java
===================================================================
--- trunk/src/main/org/jboss/jms/server/connectionfactory/ConnectionFactoryJNDIMapper.java	2007-01-31 20:11:51 UTC (rev 2118)
+++ trunk/src/main/org/jboss/jms/server/connectionfactory/ConnectionFactoryJNDIMapper.java	2007-02-01 00:10:20 UTC (rev 2119)
@@ -37,22 +37,22 @@
 import javax.naming.NamingException;
 
 import org.jboss.jms.client.JBossConnectionFactory;
+import org.jboss.jms.client.delegate.ClientClusteredConnectionFactoryDelegate;
+import org.jboss.jms.client.delegate.ClientConnectionFactoryDelegate;
 import org.jboss.jms.client.plugin.LoadBalancingFactory;
 import org.jboss.jms.client.plugin.LoadBalancingPolicy;
-import org.jboss.jms.client.delegate.ClientConnectionFactoryDelegate;
-import org.jboss.jms.client.delegate.ClientClusteredConnectionFactoryDelegate;
+import org.jboss.jms.delegate.ConnectionFactoryDelegate;
 import org.jboss.jms.server.ConnectionFactoryManager;
 import org.jboss.jms.server.ServerPeer;
 import org.jboss.jms.server.Version;
 import org.jboss.jms.server.endpoint.ServerConnectionFactoryEndpoint;
 import org.jboss.jms.server.endpoint.advised.ConnectionFactoryAdvised;
-import org.jboss.jms.server.remoting.JMSDispatcher;
 import org.jboss.jms.util.JNDIUtil;
-import org.jboss.jms.delegate.ConnectionFactoryDelegate;
+import org.jboss.jms.wireformat.Dispatcher;
 import org.jboss.logging.Logger;
+import org.jboss.messaging.core.plugin.contract.FailoverMapper;
 import org.jboss.messaging.core.plugin.contract.ReplicationListener;
 import org.jboss.messaging.core.plugin.contract.Replicator;
-import org.jboss.messaging.core.plugin.contract.FailoverMapper;
 import org.jboss.messaging.core.plugin.postoffice.cluster.DefaultClusteredPostOffice;
 
 /**
@@ -191,8 +191,8 @@
 
       // Registering with the dispatcher should always be the last thing otherwise a client could
       // use a partially initialised object
-      JMSDispatcher.instance.
-         registerTarget(new Integer(id), new ConnectionFactoryAdvised(endpoint));
+      Dispatcher.instance.
+         registerTarget(id, new ConnectionFactoryAdvised(endpoint));
    }
 
    public synchronized void unregisterConnectionFactory(String uniqueName, boolean clustered)
@@ -246,7 +246,7 @@
 
       }
 
-      JMSDispatcher.instance.unregisterTarget(new Integer(endpoint.getID()));
+      Dispatcher.instance.unregisterTarget(endpoint.getID());
    }
 
    // MessagingComponent implementation ------------------------------------------------------------

Deleted: trunk/src/main/org/jboss/jms/server/container/InjectionAspect.java
===================================================================
--- trunk/src/main/org/jboss/jms/server/container/InjectionAspect.java	2007-01-31 20:11:51 UTC (rev 2118)
+++ trunk/src/main/org/jboss/jms/server/container/InjectionAspect.java	2007-02-01 00:10:20 UTC (rev 2119)
@@ -1,125 +0,0 @@
-/*
-  * JBoss, Home of Professional Open Source
-  * Copyright 2005, JBoss Inc., and individual contributors as indicated
-  * by the @authors tag. See the copyright.txt in the distribution for a
-  * full listing of individual contributors.
-  *
-  * This is free software; you can redistribute it and/or modify it
-  * under the terms of the GNU Lesser General Public License as
-  * published by the Free Software Foundation; either version 2.1 of
-  * the License, or (at your option) any later version.
-  *
-  * This software is distributed in the hope that it will be useful,
-  * but WITHOUT ANY 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 along with this software; if not, write to the Free
-  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-  */
-package org.jboss.jms.server.container;
-
-import org.jboss.aop.joinpoint.Invocation;
-import org.jboss.aop.joinpoint.MethodInvocation;
-import org.jboss.jms.client.delegate.ClientConnectionDelegate;
-import org.jboss.jms.server.endpoint.CreateConnectionResult;
-import org.jboss.jms.server.endpoint.ServerConnectionEndpoint;
-import org.jboss.jms.server.endpoint.advised.ConnectionAdvised;
-import org.jboss.jms.server.remoting.JMSDispatcher;
-import org.jboss.jms.server.remoting.MetaDataConstants;
-import org.jboss.remoting.callback.ServerInvokerCallbackHandler;
-
-/**
- * Server-side injection aspect.
- *
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- *
- * $Id$
- */
-public class InjectionAspect
-{
-    // Constants -----------------------------------------------------------------------------------
-   
-    // Static --------------------------------------------------------------------------------------
-
-    // Attributes ----------------------------------------------------------------------------------
-
-    // Constructors --------------------------------------------------------------------------------
-
-    // Public --------------------------------------------------------------------------------------
-
-    public Object handleCreateConnectionDelegate(Invocation invocation) throws Throwable
-    {
-       MethodInvocation mi = (MethodInvocation)invocation;
-       
-       // First we inject the callback handler for the connection
-       
-       ServerInvokerCallbackHandler handler =
-          (ServerInvokerCallbackHandler)mi.getMetaData(MetaDataConstants.JMS,
-                                                       MetaDataConstants.CALLBACK_HANDLER);
-       
-       if (handler == null)
-       {
-          throw new IllegalStateException("Can't find handler");
-       }
-       
-       CreateConnectionResult res = (CreateConnectionResult)invocation.invokeNext();
-       ClientConnectionDelegate del = (ClientConnectionDelegate)res.getDelegate();
-       
-       if (del != null)
-       {          
-          ConnectionAdvised advised = 
-             (ConnectionAdvised)JMSDispatcher.instance.getRegistered(new Integer(del.getID()));
-          
-          ServerConnectionEndpoint endpoint = (ServerConnectionEndpoint)advised.getEndpoint();
-          
-          endpoint.setCallbackHandler(handler);
-          
-          // Then we inject the remoting session id of the client
-          String sessionId = (String)mi.getMetaData(MetaDataConstants.JMS,
-                                                    MetaDataConstants.REMOTING_SESSION_ID);
-          if (sessionId == null)
-          {
-             throw new IllegalStateException("Can't find remoting session ID");
-          }
-          
-          // Then we inject the unique ID of the client VM
-          String jmsClientVMID = (String)mi.getMetaData(MetaDataConstants.JMS,
-                                                        MetaDataConstants.JMS_CLIENT_VM_ID);
-          
-          if (jmsClientVMID == null)
-          {
-             throw new IllegalStateException("Can't find jms client ID");
-          }
-          
-          endpoint.setRemotingInformation(jmsClientVMID, sessionId);       
-          
-          // Then we inject the version number from to be used
-          
-          Byte ver = (Byte)mi.getMetaData(MetaDataConstants.JMS,
-                                          MetaDataConstants.VERSION_NUMBER);
-          if (ver == null)
-          {
-             throw new IllegalStateException("Can't find version");
-          }
-          
-          endpoint.setUsingVersion(ver.byteValue());
-       }
-       
-       return res;
-    }
-    
-    // Package protected ---------------------------------------------
-
-    // Protected -----------------------------------------------------
-
-    // Private -------------------------------------------------------
-
-    // Inner classes -------------------------------------------------
-}
-
-
-
-

Modified: trunk/src/main/org/jboss/jms/server/endpoint/BrowserEndpoint.java
===================================================================
--- trunk/src/main/org/jboss/jms/server/endpoint/BrowserEndpoint.java	2007-01-31 20:11:51 UTC (rev 2118)
+++ trunk/src/main/org/jboss/jms/server/endpoint/BrowserEndpoint.java	2007-02-01 00:10:20 UTC (rev 2119)
@@ -22,9 +22,9 @@
 package org.jboss.jms.server.endpoint;
 
 import javax.jms.JMSException;
-import javax.jms.Message;
 
 import org.jboss.jms.client.Closeable;
+import org.jboss.jms.message.JBossMessage;
 
 /**
  * Represents the set of methods from the BrowserDelegate that are handled on the server. The rest
@@ -37,9 +37,9 @@
  */
 public interface BrowserEndpoint extends Closeable
 {   
-   Message nextMessage() throws JMSException;
+   JBossMessage nextMessage() throws JMSException;
    
    boolean hasNextMessage() throws JMSException;
       
-   Message[] nextMessageBlock(int maxMessages) throws JMSException;
+   JBossMessage[] nextMessageBlock(int maxMessages) throws JMSException;
 }

Deleted: trunk/src/main/org/jboss/jms/server/endpoint/ClientDelivery.java
===================================================================
--- trunk/src/main/org/jboss/jms/server/endpoint/ClientDelivery.java	2007-01-31 20:11:51 UTC (rev 2118)
+++ trunk/src/main/org/jboss/jms/server/endpoint/ClientDelivery.java	2007-02-01 00:10:20 UTC (rev 2119)
@@ -1,128 +0,0 @@
-/*
-  * JBoss, Home of Professional Open Source
-  * Copyright 2005, JBoss Inc., and individual contributors as indicated
-  * by the @authors tag. See the copyright.txt in the distribution for a
-  * full listing of individual contributors.
-  *
-  * This is free software; you can redistribute it and/or modify it
-  * under the terms of the GNU Lesser General Public License as
-  * published by the Free Software Foundation; either version 2.1 of
-  * the License, or (at your option) any later version.
-  *
-  * This software is distributed in the hope that it will be useful,
-  * but WITHOUT ANY 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 along with this software; if not, write to the Free
-  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-  */
-package org.jboss.jms.server.endpoint;
-
-import java.io.DataInputStream;
-import java.io.DataOutputStream;
-
-import org.jboss.jms.message.JBossMessage;
-import org.jboss.jms.message.MessageProxy;
-import org.jboss.messaging.core.message.MessageFactory;
-import org.jboss.messaging.util.Streamable;
-
-/**
- * 
- * A ClientDelivery
- * Encapsulates a delivery of a messages to a client consumer
- * 
- * There is no need to specify the server id since the client side CallbackManager is
- * unique to the remoting connection
- * 
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- * @version <tt>$Revision$</tt>
- *
- * $Id$
- *
- */
-public class ClientDelivery implements Streamable
-{
-   // Constants -----------------------------------------------------
-   
-   // Static --------------------------------------------------------
-   
-   // Attributes ----------------------------------------------------
-   
-   private MessageProxy msg;
-         
-   private int consumerId;
-    
-   // Constructors --------------------------------------------------
-   
-   public ClientDelivery()
-   {      
-   }
-
-   public ClientDelivery(MessageProxy msg, int consumerId)
-   {
-      this.msg = msg;
-      
-      this.consumerId = consumerId;
-   }
-  
-   // Streamable implementation
-   // ---------------------------------------------------------------
-   
-   public void write(DataOutputStream out) throws Exception
-   {
-      out.writeInt(consumerId);
-      
-      out.writeByte(msg.getMessage().getType());
-
-      out.writeInt(msg.getDeliveryCount());
-      
-      out.writeLong(msg.getDeliveryId());
-
-      msg.getMessage().write(out);          
-   }
-
-   public void read(DataInputStream in) throws Exception
-   {
-      consumerId = in.readInt();
-      
-      byte type = in.readByte();
-      
-      int deliveryCount = in.readInt();
-      
-      long deliveryId = in.readLong();
-      
-      JBossMessage m = (JBossMessage)MessageFactory.createMessage(type);
-
-      m.read(in);
-
-      msg = JBossMessage.createThinDelegate(deliveryId, m, deliveryCount); 
-   }
-
-   // Public --------------------------------------------------------
-   
-   public MessageProxy getMessage()
-   {
-      return msg;
-   }
-   
-   public int getConsumerId()
-   {
-      return consumerId;
-   }
-
-   public String toString()
-   {
-      return "ClientDelivery[" + msg + "]";
-   }
-
-   // Package protected ---------------------------------------------
-   
-   // Protected -----------------------------------------------------
-   
-   // Private -------------------------------------------------------
-   
-   // Inner classes -------------------------------------------------   
-}

Modified: trunk/src/main/org/jboss/jms/server/endpoint/ConnectionEndpoint.java
===================================================================
--- trunk/src/main/org/jboss/jms/server/endpoint/ConnectionEndpoint.java	2007-01-31 20:11:51 UTC (rev 2118)
+++ trunk/src/main/org/jboss/jms/server/endpoint/ConnectionEndpoint.java	2007-02-01 00:10:20 UTC (rev 2119)
@@ -22,12 +22,13 @@
 package org.jboss.jms.server.endpoint;
 
 import javax.jms.JMSException;
-import javax.transaction.xa.Xid;
 
 import org.jboss.jms.client.Closeable;
 import org.jboss.jms.delegate.SessionDelegate;
 import org.jboss.jms.tx.TransactionRequest;
+import org.jboss.messaging.core.tx.MessagingXid;
 
+
 /**
  * 
  * Represents the set of methods from the ConnectionDelegate that are handled on the server.
@@ -54,6 +55,6 @@
 
    void sendTransaction(TransactionRequest request) throws JMSException;
 
-   Xid[] getPreparedTransactions() throws JMSException; 
+   MessagingXid[] getPreparedTransactions() throws JMSException; 
 }
 

Deleted: trunk/src/main/org/jboss/jms/server/endpoint/ConnectionFactoryUpdateMessage.java
===================================================================
--- trunk/src/main/org/jboss/jms/server/endpoint/ConnectionFactoryUpdateMessage.java	2007-01-31 20:11:51 UTC (rev 2118)
+++ trunk/src/main/org/jboss/jms/server/endpoint/ConnectionFactoryUpdateMessage.java	2007-02-01 00:10:20 UTC (rev 2119)
@@ -1,109 +0,0 @@
-/*
-   * JBoss, Home of Professional Open Source
-   * Copyright 2005, JBoss Inc., and individual contributors as indicated
-   * by the @authors tag. See the copyright.txt in the distribution for a
-   * full listing of individual contributors.
-   *
-   * This is free software; you can redistribute it and/or modify it
-   * under the terms of the GNU Lesser General Public License as
-   * published by the Free Software Foundation; either version 2.1 of
-   * the License, or (at your option) any later version.
-   *
-   * This software is distributed in the hope that it will be useful,
-   * but WITHOUT ANY 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 along with this software; if not, write to the Free
-   * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-   * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-   */
-
-package org.jboss.jms.server.endpoint;
-
-import org.jboss.jms.client.delegate.ClientConnectionFactoryDelegate;
-import java.util.Map;
-import java.io.Serializable;
-
-/**
- * This class holds the update cluster view sent by the server to client-side clustered connection
- * factories.
- *
- * @author <a href="mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
- * @version <tt>$Revision$</tt>
- *
- * $Id$
- */
-public class ConnectionFactoryUpdateMessage implements Serializable
-{
-
-   // Constants ------------------------------------------------------------------------------------
-
-   static final long serialVersionUID = 7978093036163402989L;
-
-   // Attributes -----------------------------------------------------------------------------------
-
-   private ClientConnectionFactoryDelegate[] delegates;
-   private Map failoverMap;
-
-   // Static ---------------------------------------------------------------------------------------
-
-   // Constructors ---------------------------------------------------------------------------------
-
-   public ConnectionFactoryUpdateMessage(ClientConnectionFactoryDelegate[] delegates,
-                                         Map failoverMap)
-   {
-      this.delegates = delegates;
-      this.failoverMap = failoverMap;
-   }
-
-   // Public ---------------------------------------------------------------------------------------
-
-   public ClientConnectionFactoryDelegate[] getDelegates()
-   {
-      return delegates;
-   }
-
-   public void setDelegates(ClientConnectionFactoryDelegate[] delegates)
-   {
-      this.delegates = delegates;
-   }
-
-   public Map getFailoverMap()
-   {
-      return failoverMap;
-   }
-
-   public void setFailoverMap(Map failoverMap)
-   {
-      this.failoverMap = failoverMap;
-   }
-
-   public String toString()
-   {
-      StringBuffer sb = new StringBuffer("ConnectionFactoryUpdateMessage[");
-
-      for(int i = 0; i < delegates.length; i++)
-      {
-         sb.append(delegates[i]);
-         if (i < delegates.length - 1)
-         {
-            sb.append(',');
-         }
-      }
-
-      sb.append("]");
-
-      return sb.toString();
-   }
-
-   // Package protected ----------------------------------------------------------------------------
-
-   // Protected ------------------------------------------------------------------------------------
-
-   // Private --------------------------------------------------------------------------------------
-
-   // Inner classes --------------------------------------------------------------------------------
-
-}

Modified: trunk/src/main/org/jboss/jms/server/endpoint/CreateConnectionResult.java
===================================================================
--- trunk/src/main/org/jboss/jms/server/endpoint/CreateConnectionResult.java	2007-01-31 20:11:51 UTC (rev 2118)
+++ trunk/src/main/org/jboss/jms/server/endpoint/CreateConnectionResult.java	2007-02-01 00:10:20 UTC (rev 2119)
@@ -21,9 +21,11 @@
  */
 package org.jboss.jms.server.endpoint;
 
-import java.io.Serializable;
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
 
-import org.jboss.jms.delegate.ConnectionDelegate;
+import org.jboss.jms.client.delegate.ClientConnectionDelegate;
+import org.jboss.messaging.util.Streamable;
 
 /**
  * 
@@ -35,23 +37,29 @@
  * $Id$
  *
  */
-public class CreateConnectionResult implements Serializable
+public class CreateConnectionResult implements Streamable
 {
    // Constants -----------------------------------------------------
 
-   private static final long serialVersionUID = 4311863642735135167L;
-
    // Static --------------------------------------------------------
+   
+   private static final int NULL = 0;
+   
+   private static final int NOT_NULL = 1;
 
    // Attributes ----------------------------------------------------
 
-   private ConnectionDelegate delegate;
+   private ClientConnectionDelegate delegate;
 
    private int actualFailoverNodeID;
 
    // Constructors --------------------------------------------------
+   
+   public CreateConnectionResult()
+   {      
+   }
 
-   public CreateConnectionResult(ConnectionDelegate delegate)
+   public CreateConnectionResult(ClientConnectionDelegate delegate)
    {
       this(delegate, Integer.MIN_VALUE);
    }
@@ -61,7 +69,7 @@
       this(null, actualFailoverNodeID);
    }
 
-   private CreateConnectionResult(ConnectionDelegate delegate,
+   private CreateConnectionResult(ClientConnectionDelegate delegate,
                                   int actualFailoverNodeId)
    {
       this.delegate = delegate;
@@ -70,7 +78,7 @@
 
    // Public --------------------------------------------------------
 
-   public ConnectionDelegate getDelegate()
+   public ClientConnectionDelegate getDelegate()
    {
       return delegate;
    }
@@ -84,7 +92,39 @@
    {
       return "CreateConnectionResult[" + delegate + ", failover node " + actualFailoverNodeID + "]";
    }
+   
+   // Streamable implementation ------------------------------------
 
+   public void read(DataInputStream in) throws Exception
+   {
+      actualFailoverNodeID = in.readInt();
+      
+      int b = in.readByte();
+      
+      if (b == NOT_NULL)
+      {
+         delegate = new ClientConnectionDelegate();
+         
+         delegate.read(in);
+      }
+   }
+
+   public void write(DataOutputStream out) throws Exception
+   {
+      out.writeInt(actualFailoverNodeID);
+      
+      if (delegate == null)
+      {
+         out.writeByte(NULL);
+      }
+      else
+      {
+         out.writeByte(NOT_NULL);
+         
+         delegate.write(out);
+      }         
+   }
+
    // Package protected ---------------------------------------------
 
    // Protected -----------------------------------------------------

Modified: trunk/src/main/org/jboss/jms/server/endpoint/ServerBrowserEndpoint.java
===================================================================
--- trunk/src/main/org/jboss/jms/server/endpoint/ServerBrowserEndpoint.java	2007-01-31 20:11:51 UTC (rev 2118)
+++ trunk/src/main/org/jboss/jms/server/endpoint/ServerBrowserEndpoint.java	2007-02-01 00:10:20 UTC (rev 2119)
@@ -28,9 +28,10 @@
 import javax.jms.JMSException;
 import javax.jms.Message;
 
+import org.jboss.jms.message.JBossMessage;
 import org.jboss.jms.selector.Selector;
-import org.jboss.jms.server.remoting.JMSDispatcher;
 import org.jboss.jms.util.ExceptionUtil;
+import org.jboss.jms.wireformat.Dispatcher;
 import org.jboss.logging.Logger;
 import org.jboss.messaging.core.Channel;
 import org.jboss.messaging.core.Filter;
@@ -68,6 +69,7 @@
       throws JMSException
    {     
       this.session = session;
+      
       this.id = id;
       
 		Filter filter = null;
@@ -101,7 +103,7 @@
       }
    }
    
-   public Message nextMessage() throws JMSException
+   public JBossMessage nextMessage() throws JMSException
    {
       try
       {
@@ -114,7 +116,7 @@
    
          if (trace) { log.trace(this + " returning " + r); }
          
-         return (Message)r.getMessage();
+         return (JBossMessage)r.getMessage();
       }   
       catch (Throwable t)
       {
@@ -122,7 +124,7 @@
       }
    }
 
-   public Message[] nextMessageBlock(int maxMessages) throws JMSException
+   public JBossMessage[] nextMessageBlock(int maxMessages) throws JMSException
    {
 
       if (trace) { log.trace(this + " returning next message block of " + maxMessages); }
@@ -151,7 +153,7 @@
             }
             else break;
          }		
-   		return (Message[])messages.toArray(new Message[messages.size()]);	
+   		return (JBossMessage[])messages.toArray(new JBossMessage[messages.size()]);	
       }   
       catch (Throwable t)
       {
@@ -178,11 +180,6 @@
       // Do nothing
    }
    
-   public boolean isClosed() throws JMSException
-   {
-      throw new IllegalStateException("isClosed should never be handled on the server side");
-   }
-
    // Public ---------------------------------------------------------------------------------------
 
    public String toString()
@@ -201,7 +198,7 @@
       
       iterator = null;
       
-      JMSDispatcher.instance.unregisterTarget(new Integer(id));
+      Dispatcher.instance.unregisterTarget(id);
       
       closed = true;
    }

Modified: trunk/src/main/org/jboss/jms/server/endpoint/ServerConnectionEndpoint.java
===================================================================
--- trunk/src/main/org/jboss/jms/server/endpoint/ServerConnectionEndpoint.java	2007-01-31 20:11:51 UTC (rev 2118)
+++ trunk/src/main/org/jboss/jms/server/endpoint/ServerConnectionEndpoint.java	2007-02-01 00:10:20 UTC (rev 2119)
@@ -31,7 +31,6 @@
 import javax.jms.Destination;
 import javax.jms.IllegalStateException;
 import javax.jms.JMSException;
-import javax.transaction.xa.Xid;
 
 import org.jboss.jms.client.delegate.ClientSessionDelegate;
 import org.jboss.jms.client.remoting.CallbackManager;
@@ -44,18 +43,19 @@
 import org.jboss.jms.server.ServerPeer;
 import org.jboss.jms.server.endpoint.advised.SessionAdvised;
 import org.jboss.jms.server.messagecounter.MessageCounter;
-import org.jboss.jms.server.remoting.JMSDispatcher;
 import org.jboss.jms.server.remoting.JMSWireFormat;
 import org.jboss.jms.tx.ClientTransaction;
 import org.jboss.jms.tx.TransactionRequest;
 import org.jboss.jms.tx.ClientTransaction.SessionTxState;
 import org.jboss.jms.util.ExceptionUtil;
 import org.jboss.jms.util.ToString;
+import org.jboss.jms.wireformat.Dispatcher;
 import org.jboss.logging.Logger;
 import org.jboss.messaging.core.MessageReference;
 import org.jboss.messaging.core.Routable;
 import org.jboss.messaging.core.plugin.contract.MessageStore;
 import org.jboss.messaging.core.plugin.contract.PostOffice;
+import org.jboss.messaging.core.tx.MessagingXid;
 import org.jboss.messaging.core.tx.Transaction;
 import org.jboss.messaging.core.tx.TransactionRepository;
 import org.jboss.remoting.Client;
@@ -128,12 +128,16 @@
     *        failover. Negative values are ignored (mean regular connection creation attempt).
     */
    public ServerConnectionEndpoint(ServerPeer serverPeer, String clientID,
-                                      String username, String password, int prefetchSize,
-                                      int defaultTempQueueFullSize,
-                                      int defaultTempQueuePageSize,
-                                      int defaultTempQueueDownCacheSize,
-                                      int failedNodeID,
-                                      ServerConnectionFactoryEndpoint cfendpoint) throws Exception
+                                   String username, String password, int prefetchSize,
+                                   int defaultTempQueueFullSize,
+                                   int defaultTempQueuePageSize,
+                                   int defaultTempQueueDownCacheSize,
+                                   int failedNodeID,
+                                   ServerConnectionFactoryEndpoint cfendpoint,
+                                   String remotingSessionID,
+                                   String clientVMID,
+                                   byte versionToUse,
+                                   ServerInvokerCallbackHandler callbackHandler) throws Exception
    {
       this.serverPeer = serverPeer;
 
@@ -165,6 +169,38 @@
       {
          this.failedNodeID = new Integer(failedNodeID);
       }
+      
+      this.remotingClientSessionID = remotingSessionID;
+      
+      this.jmsClientVMID = clientVMID;
+      
+      this.serverPeer.getConnectionManager().
+         registerConnection(jmsClientVMID, remotingClientSessionID, this);
+      
+      this.callbackHandler = callbackHandler;
+      
+      Client callbackClient = callbackHandler.getCallbackClient();
+      
+      if (callbackClient != null)
+      {
+         // TODO not sure if this is the best way to do this, but the callbackClient needs to have
+         //      its "subsystem" set, otherwise remoting cannot find the associated
+         //      ServerInvocationHandler on the callback server
+         callbackClient.setSubsystem(CallbackManager.JMS_CALLBACK_SUBSYSTEM);
+         
+         // We explictly set the Marshaller since otherwise remoting tries to resolve the marshaller
+         // every time which is very slow - see org.jboss.remoting.transport.socket.ProcessInvocation
+         // This can make a massive difference on performance. We also do this in
+         // JMSRemotingConnection.setupConnection
+         
+         callbackClient.setMarshaller(new JMSWireFormat());
+         callbackClient.setUnMarshaller(new JMSWireFormat());
+      }
+      else
+      {
+         log.debug("ServerInvokerCallbackHandler callback Client is not available: " +
+                   "must be using pull callbacks");
+      }
    }
 
    // ConnectionDelegate implementation ------------------------------------------------------------
@@ -202,7 +238,7 @@
          
          serverPeer.addSession(iSessionID, ep);
 
-         JMSDispatcher.instance.registerTarget(iSessionID, sessionAdvised);
+         Dispatcher.instance.registerTarget(iSessionID, sessionAdvised);
 
          log.debug("created and registered " + ep);
 
@@ -350,7 +386,7 @@
    
          cm.unregisterConnection(jmsClientVMID, remotingClientSessionID);
    
-         JMSDispatcher.instance.unregisterTarget(new Integer(id));
+         Dispatcher.instance.unregisterTarget(id);
 
          closed = true;
       }
@@ -425,13 +461,13 @@
     * This would be used by the transaction manager in recovery or by a tool to apply
     * heuristic decisions to commit or rollback particular transactions
     */
-   public Xid[] getPreparedTransactions() throws JMSException
+   public MessagingXid[] getPreparedTransactions() throws JMSException
    {
       try
       {
          List xids = tr.recoverPreparedTransactions();
          
-         return (Xid[])xids.toArray(new Xid[xids.size()]);
+         return (MessagingXid[])xids.toArray(new MessagingXid[xids.size()]);
       }
       catch (Throwable t)
       {
@@ -439,11 +475,6 @@
       }
    }
    
-   public boolean isClosed() throws JMSException
-   {
-      throw new IllegalStateException("isClosed should never be handled on the server side");
-   }
-  
    // Public ---------------------------------------------------------------------------------------
    
    public String getUsername()
@@ -461,58 +492,11 @@
       return sm;
    }
 
-   /**
-    * IOC
-    */
-   public void setCallbackHandler(ServerInvokerCallbackHandler handler)
-   {
-      callbackHandler = handler;
-      Client callbackClient = callbackHandler.getCallbackClient();
-      
-      if (callbackClient != null)
-      {
-         // TODO not sure if this is the best way to do this, but the callbackClient needs to have
-         //      its "subsystem" set, otherwise remoting cannot find the associated
-         //      ServerInvocationHandler on the callback server
-         callbackClient.setSubsystem(CallbackManager.JMS_CALLBACK_SUBSYSTEM);
-         
-         // We explictly set the Marshaller since otherwise remoting tries to resolve the marshaller
-         // every time which is very slow - see org.jboss.remoting.transport.socket.ProcessInvocation
-         // This can make a massive difference on performance. We also do this in
-         // JMSRemotingConnection.setupConnection
-         
-         callbackClient.setMarshaller(new JMSWireFormat());
-         callbackClient.setUnMarshaller(new JMSWireFormat());
-      }
-      else
-      {
-         log.debug("ServerInvokerCallbackHandler callback Client is not available: " +
-                   "must be using pull callbacks");
-      }
-   }
-
    public ServerInvokerCallbackHandler getCallbackHandler()
    {
       return callbackHandler;
    }
 
-   /**
-    * IOC
-    */
-   public void setRemotingInformation(String jmsClientVMID, String remotingClientSessionID)
-   {
-      this.remotingClientSessionID = remotingClientSessionID;
-      this.jmsClientVMID = jmsClientVMID;
-      
-      this.serverPeer.getConnectionManager().
-         registerConnection(jmsClientVMID, remotingClientSessionID, this);
-   }
-   
-   public void setUsingVersion(byte version)
-   {
-      this.usingVersion = version;
-   }
-   
    public ServerPeer getServerPeer()
    {
       return serverPeer;

Modified: trunk/src/main/org/jboss/jms/server/endpoint/ServerConnectionFactoryEndpoint.java
===================================================================
--- trunk/src/main/org/jboss/jms/server/endpoint/ServerConnectionFactoryEndpoint.java	2007-01-31 20:11:51 UTC (rev 2118)
+++ trunk/src/main/org/jboss/jms/server/endpoint/ServerConnectionFactoryEndpoint.java	2007-02-01 00:10:20 UTC (rev 2119)
@@ -21,21 +21,24 @@
   */
 package org.jboss.jms.server.endpoint;
 
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
 import javax.jms.JMSException;
+
 import org.jboss.jms.client.delegate.ClientConnectionDelegate;
 import org.jboss.jms.client.delegate.ClientConnectionFactoryDelegate;
-import org.jboss.jms.delegate.ConnectionDelegate;
 import org.jboss.jms.server.ServerPeer;
 import org.jboss.jms.server.connectionfactory.JNDIBindings;
 import org.jboss.jms.server.endpoint.advised.ConnectionAdvised;
-import org.jboss.jms.server.remoting.JMSDispatcher;
 import org.jboss.jms.util.ExceptionUtil;
+import org.jboss.jms.wireformat.ConnectionFactoryUpdate;
+import org.jboss.jms.wireformat.Dispatcher;
 import org.jboss.logging.Logger;
 import org.jboss.messaging.core.plugin.IDBlock;
 import org.jboss.remoting.callback.Callback;
-import java.util.List;
-import java.util.Map;
-import java.util.Iterator;
+import org.jboss.remoting.callback.ServerInvokerCallbackHandler;
 
 /**
  * Concrete implementation of ConnectionFactoryEndpoint
@@ -99,22 +102,38 @@
 
    // ConnectionFactoryDelegate implementation -----------------------------------------------------
 
+   public CreateConnectionResult createConnectionDelegate(String username,
+                                                         String password,
+                                                         int failedNodeID)
+                                                        
+      throws JMSException      
+   {
+      //This is never called directly
+      throw new IllegalStateException("createConnectionDelegate should never be called directly");
+   }
+   
    /**
     * @param failedNodeID - zero or positive values mean connection creation attempt is result of
-    *        failover. Negative values are ignored (mean regular connection creation attempt).
+    *        failover. -1 are ignored (mean regular connection creation attempt).
     */
    public CreateConnectionResult createConnectionDelegate(String username,
                                                           String password,
-                                                          int failedNodeID)
+                                                          int failedNodeID,
+                                                          String remotingSessionID, String clientVMID,
+                                                          byte versionToUse,
+                                                          ServerInvokerCallbackHandler callbackHandler)
       throws JMSException      
    {
       try
       {
-         if (failedNodeID < 0)
+         if (failedNodeID == -1)
          {
             // Just a standard createConnection
-            ConnectionDelegate cd =
-               createConnectionDelegateInternal(username, password, failedNodeID);
+            ClientConnectionDelegate cd =
+               createConnectionDelegateInternal(username, password, failedNodeID,
+                                                remotingSessionID, clientVMID,
+                                                versionToUse,
+                                                callbackHandler);
             return new CreateConnectionResult(cd);
          }
          else
@@ -134,8 +153,11 @@
             {
                log.debug(this + " received notification that server-side failover completed, " +
                   "creating connection delegate ...");
-               ConnectionDelegate cd =
-                  createConnectionDelegateInternal(username, password, failedNodeID);
+               ClientConnectionDelegate cd =
+                  createConnectionDelegateInternal(username, password, failedNodeID,
+                                                   remotingSessionID, clientVMID,
+                                                   versionToUse,
+                                                   callbackHandler);
                return new CreateConnectionResult(cd);
             }
          }
@@ -151,9 +173,13 @@
     * @param failedNodeID - zero or positive values mean connection creation attempt is result of
     *        failover. Negative values are ignored (mean regular connection creation attempt).
     */
-   private ConnectionDelegate createConnectionDelegateInternal(String username,
-                                                               String password,
-                                                               int failedNodeID)
+   private ClientConnectionDelegate
+      createConnectionDelegateInternal(String username,
+                                       String password,
+                                       int failedNodeID,
+                                       String remotingSessionID, String clientVMID,
+                                       byte versionToUse,
+                                       ServerInvokerCallbackHandler callbackHandler)
       throws Exception
    {
       log.debug("creating a new connection for user " + username);
@@ -178,13 +204,16 @@
       ServerConnectionEndpoint endpoint =
          new ServerConnectionEndpoint(serverPeer, clientID, username, password, prefetchSize,
                                       defaultTempQueueFullSize, defaultTempQueuePageSize,
-                                      defaultTempQueueDownCacheSize, failedNodeID, this);
+                                      defaultTempQueueDownCacheSize, failedNodeID, this,
+                                      remotingSessionID, clientVMID, versionToUse,
+                                      callbackHandler);
 
       int connectionID = endpoint.getConnectionID();
 
       ConnectionAdvised connAdvised = new ConnectionAdvised(endpoint);
-      JMSDispatcher.instance.registerTarget(new Integer(connectionID), connAdvised);
 
+      Dispatcher.instance.registerTarget(connectionID, connAdvised);
+
       log.debug("created and registered " + endpoint);
 
       return new ClientConnectionDelegate(connectionID, serverPeer.getServerPeerID());
@@ -239,8 +268,8 @@
 
       List activeConnections = serverPeer.getConnectionManager().getActiveConnections();
 
-      ConnectionFactoryUpdateMessage message =
-         new ConnectionFactoryUpdateMessage(delegates, failoverMap);
+      ConnectionFactoryUpdate message =
+         new ConnectionFactoryUpdate(delegates, failoverMap);
 
       Callback callback = new Callback(message);
 

Modified: trunk/src/main/org/jboss/jms/server/endpoint/ServerConsumerEndpoint.java
===================================================================
--- trunk/src/main/org/jboss/jms/server/endpoint/ServerConsumerEndpoint.java	2007-01-31 20:11:51 UTC (rev 2118)
+++ trunk/src/main/org/jboss/jms/server/endpoint/ServerConsumerEndpoint.java	2007-02-01 00:10:20 UTC (rev 2119)
@@ -32,9 +32,9 @@
 import org.jboss.jms.server.ConnectionManager;
 import org.jboss.jms.server.destination.TopicService;
 import org.jboss.jms.server.messagecounter.MessageCounter;
-import org.jboss.jms.server.remoting.JMSDispatcher;
-import org.jboss.jms.server.remoting.MessagingMarshallable;
 import org.jboss.jms.util.ExceptionUtil;
+import org.jboss.jms.wireformat.ClientDelivery;
+import org.jboss.jms.wireformat.Dispatcher;
 import org.jboss.logging.Logger;
 import org.jboss.messaging.core.Channel;
 import org.jboss.messaging.core.Delivery;
@@ -87,8 +87,6 @@
    
    private ServerInvokerCallbackHandler callbackHandler;
    
-   private byte versionToUse;
-
    private boolean noLocal;
 
    private Selector messageSelector;
@@ -129,8 +127,6 @@
       
       this.callbackHandler = sessionEndpoint.getConnectionEndpoint().getCallbackHandler();
       
-      this.versionToUse = sessionEndpoint.getConnectionEndpoint().getUsingVersion();
-            
       this.noLocal = noLocal;
       
       this.destination = dest;
@@ -235,14 +231,11 @@
          // We send the message to the client on the current thread. The message is written onto the
          // transport and then the thread returns immediately without waiting for a response.
          
-         // FIXME - how can we ensure that a later send doesn't overtake an earlier send - this
-         // might happen if they are using different underlying TCP connections (e.g. from pool)
+         Client callbackClient = callbackHandler.getCallbackClient();
          
          ClientDelivery del = new ClientDelivery(mp, id);
          
-         MessagingMarshallable mm = new MessagingMarshallable(versionToUse, del);
-         
-         Callback callback = new Callback(mm);
+         Callback callback = new Callback(del);
            
          try
          {
@@ -254,13 +247,12 @@
             // all access so that only the first connection in the pool is ever used - bit this is
             // far from ideal!!!
             // See http://jira.jboss.com/jira/browse/JBMESSAGING-789
-
-            Client clientInvoker = callbackHandler.getCallbackClient();
+            
             Object invoker = null;
 
-            if (clientInvoker != null)
+            if (callbackClient != null)
             {
-               invoker = clientInvoker.getInvoker();
+               invoker = callbackClient.getInvoker();
             }
             else
             {
@@ -428,12 +420,6 @@
       }            
    }
    
-   
-   public boolean isClosed() throws JMSException
-   {
-      throw new IllegalStateException("isClosed should never be handled on the server side");
-   }
-
    // Public ---------------------------------------------------------------------------------------
    
    public String toString()
@@ -474,7 +460,7 @@
 
       messageQueue.remove(this); 
       
-      JMSDispatcher.instance.unregisterTarget(new Integer(id));
+      Dispatcher.instance.unregisterTarget(id);
       
       // If this is a consumer of a non durable subscription then we want to unbind the
       // subscription and delete all its data.

Modified: trunk/src/main/org/jboss/jms/server/endpoint/ServerSessionEndpoint.java
===================================================================
--- trunk/src/main/org/jboss/jms/server/endpoint/ServerSessionEndpoint.java	2007-01-31 20:11:51 UTC (rev 2118)
+++ trunk/src/main/org/jboss/jms/server/endpoint/ServerSessionEndpoint.java	2007-02-01 00:10:20 UTC (rev 2119)
@@ -58,9 +58,9 @@
 import org.jboss.jms.server.endpoint.advised.BrowserAdvised;
 import org.jboss.jms.server.endpoint.advised.ConsumerAdvised;
 import org.jboss.jms.server.messagecounter.MessageCounter;
-import org.jboss.jms.server.remoting.JMSDispatcher;
 import org.jboss.jms.util.ExceptionUtil;
 import org.jboss.jms.util.MessageQueueNameHelper;
+import org.jboss.jms.wireformat.Dispatcher;
 import org.jboss.logging.Logger;
 import org.jboss.messaging.core.Channel;
 import org.jboss.messaging.core.Delivery;
@@ -196,7 +196,7 @@
                                                   boolean noLocal,
                                                   String subscriptionName,
                                                   boolean isCC,
-                                                  Long failoverChannelID) throws JMSException
+                                                  long failoverChannelID) throws JMSException
    {
       try
       {
@@ -220,7 +220,7 @@
    }
       
 	public BrowserDelegate createBrowserDelegate(JBossDestination jmsDestination,
-                                                String selector, Long failoverChannelID)
+                                                String selector, long failoverChannelID)
       throws JMSException
 	{
       try
@@ -715,11 +715,6 @@
       }
    }
    
-   public boolean isClosed() throws JMSException
-   {
-      throw new IllegalStateException("isClosed should never be handled on the server side");
-   }
-    
    // Public ---------------------------------------------------------------------------------------
    
    public ServerConnectionEndpoint getConnectionEndpoint()
@@ -883,7 +878,7 @@
       
       sp.removeSession(new Integer(id));
             
-      JMSDispatcher.instance.unregisterTarget(new Integer(id));
+      Dispatcher.instance.unregisterTarget(id);
       
       closed = true;
    }            
@@ -1133,7 +1128,7 @@
                                                                    String selectorString,
                                                                    boolean noLocal,
                                                                    String subscriptionName,
-                                                                   Long oldChannelID)
+                                                                   long oldChannelID)
       throws Exception
    {
       log.debug(this + " creating FAILOVER consumer for failed channel " +
@@ -1150,9 +1145,9 @@
 
       Binding binding = null;
 
-      if (oldChannelID != null)
+      if (oldChannelID != -1)
       {
-         binding = postOffice.getBindingforChannelId(oldChannelID.longValue());
+         binding = postOffice.getBindingforChannelId(oldChannelID);
       }
       else
       {
@@ -1174,7 +1169,7 @@
       if (binding == null)
       {
          throw new IllegalStateException("Can't find failed over " +
-            (oldChannelID != null ?
+            (oldChannelID != -1 ?
                "channel " +  oldChannelID : "queue " + jmsDestination.getName()));
       }
 
@@ -1211,7 +1206,7 @@
                                     binding.getQueue().getName(), this, selectorString, noLocal,
                                     jmsDestination, dlqToUse, expiryQueueToUse, redeliveryDelay);
 
-      JMSDispatcher.instance.registerTarget(new Integer(consumerID), new ConsumerAdvised(ep));
+      Dispatcher.instance.registerTarget(consumerID, new ConsumerAdvised(ep));
 
       ClientConsumerDelegate stub =
          new ClientConsumerDelegate(consumerID, newChannelID, prefetchSize, maxDeliveryAttempts);
@@ -1527,7 +1522,7 @@
                   binding.getQueue().getName(), this, selectorString, noLocal,
                   jmsDestination, dlqToUse, expiryQueueToUse, redeliveryDelay);
       
-      JMSDispatcher.instance.registerTarget(new Integer(consumerID), new ConsumerAdvised(ep));
+      Dispatcher.instance.registerTarget(consumerID, new ConsumerAdvised(ep));
       
       ClientConsumerDelegate stub =
          new ClientConsumerDelegate(consumerID, binding.getQueue().getChannelID(),
@@ -1545,7 +1540,7 @@
 
    private BrowserDelegate createFailoverBrowserDelegateInternal(JBossDestination jmsDestination,
                                                                  String selector,
-                                                                 Long oldChannelID) throws Throwable
+                                                                 long oldChannelID) throws Throwable
    {
       log.debug(this + " creating FAILOVER browser for failed channel " + oldChannelID + " for " +
          jmsDestination + (selector == null ? "" : ", selector '" + selector + "'"));
@@ -1557,9 +1552,9 @@
 
       Binding binding = null;
 
-      if (oldChannelID != null)
+      if (oldChannelID != -1)
       {
-         binding = postOffice.getBindingforChannelId(oldChannelID.longValue());
+         binding = postOffice.getBindingforChannelId(oldChannelID);
       }
       else
       {
@@ -1581,7 +1576,7 @@
       if (binding == null)
       {
          throw new IllegalStateException("Can't find failed over " +
-            (oldChannelID != null ?
+            (oldChannelID != -1 ?
                "channel " +  oldChannelID : "queue " + jmsDestination.getName()));
       }
 
@@ -1590,7 +1585,7 @@
       int browserID = connectionEndpoint.getServerPeer().getNextObjectID();
 
       ServerBrowserEndpoint ep = new ServerBrowserEndpoint(this, browserID, newChannel, selector);
-      JMSDispatcher.instance.registerTarget(new Integer(browserID), new BrowserAdvised(ep));
+      Dispatcher.instance.registerTarget(browserID, new BrowserAdvised(ep));
 
       // still need to synchronized since close() can come in on a different thread
       synchronized (browsers)
@@ -1640,7 +1635,7 @@
          browsers.put(new Integer(browserID), ep);
       }
 
-      JMSDispatcher.instance.registerTarget(new Integer(browserID), new BrowserAdvised(ep));
+      Dispatcher.instance.registerTarget(browserID, new BrowserAdvised(ep));
 
       ClientBrowserDelegate stub =
          new ClientBrowserDelegate(browserID, binding.getQueue().getChannelID());

Modified: trunk/src/main/org/jboss/jms/server/endpoint/SessionEndpoint.java
===================================================================
--- trunk/src/main/org/jboss/jms/server/endpoint/SessionEndpoint.java	2007-01-31 20:11:51 UTC (rev 2118)
+++ trunk/src/main/org/jboss/jms/server/endpoint/SessionEndpoint.java	2007-02-01 00:10:20 UTC (rev 2119)
@@ -47,19 +47,19 @@
 {
    /**
     * @param failoverChannelID - the ID of the channel for which there is a failover process in
-    *        progress. Null means regular (non-failover) consumer delegate creation.
+    *        progress. -1 means regular (non-failover) consumer delegate creation.
     */
    ConsumerDelegate createConsumerDelegate(JBossDestination destination, String selector,
                                            boolean noLocal, String subscriptionName,
                                            boolean connectionConsumer,
-                                           Long failoverChannelID) throws JMSException;
+                                           long failoverChannelID) throws JMSException;
 
    /**
     * @param failoverChannelID - the ID of the channel for which there is a failover process in
-    *        progress. Null means regular (non-failover) browser delegate creation.
+    *        progress. -1 means regular (non-failover) browser delegate creation.
     */
    BrowserDelegate createBrowserDelegate(JBossDestination queue, String messageSelector,
-                                         Long failoverChannelID) throws JMSException;
+                                         long failoverChannelID) throws JMSException;
 
    /**
     * Creates a queue identity given a Queue name. Does NOT create the physical queue. The physical
@@ -79,7 +79,7 @@
     * Acknowledge a list of deliveries
     * @throws JMSException
     */
-   void acknowledgeDeliveries(List deliveryIds) throws JMSException;
+   void acknowledgeDeliveries(List acks) throws JMSException;
    
    /**
     * Acknowledge a delivery
@@ -90,7 +90,7 @@
    /**
     * Cancel a list of deliveries.
     */
-   void cancelDeliveries(List cancelInfos) throws JMSException;
+   void cancelDeliveries(List cancels) throws JMSException;
          
    /**
     * Cancel a delivery

Modified: trunk/src/main/org/jboss/jms/server/endpoint/advised/BrowserAdvised.java
===================================================================
--- trunk/src/main/org/jboss/jms/server/endpoint/advised/BrowserAdvised.java	2007-01-31 20:11:51 UTC (rev 2118)
+++ trunk/src/main/org/jboss/jms/server/endpoint/advised/BrowserAdvised.java	2007-02-01 00:10:20 UTC (rev 2119)
@@ -22,8 +22,8 @@
 package org.jboss.jms.server.endpoint.advised;
 
 import javax.jms.JMSException;
-import javax.jms.Message;
 
+import org.jboss.jms.message.JBossMessage;
 import org.jboss.jms.server.endpoint.BrowserEndpoint;
 
 /**
@@ -70,20 +70,15 @@
       return endpoint.hasNextMessage();
    }
 
-   public Message nextMessage() throws JMSException
+   public JBossMessage nextMessage() throws JMSException
    {
       return endpoint.nextMessage();
    }
 
-   public Message[] nextMessageBlock(int maxMessages) throws JMSException
+   public JBossMessage[] nextMessageBlock(int maxMessages) throws JMSException
    {
       return endpoint.nextMessageBlock(maxMessages);
    }
-   
-   public boolean isClosed() throws JMSException
-   {
-      return endpoint.isClosed();
-   }
 
    // AdvisedSupport overrides --------------------------------------
    

Modified: trunk/src/main/org/jboss/jms/server/endpoint/advised/ConnectionAdvised.java
===================================================================
--- trunk/src/main/org/jboss/jms/server/endpoint/advised/ConnectionAdvised.java	2007-01-31 20:11:51 UTC (rev 2118)
+++ trunk/src/main/org/jboss/jms/server/endpoint/advised/ConnectionAdvised.java	2007-02-01 00:10:20 UTC (rev 2119)
@@ -22,11 +22,11 @@
 package org.jboss.jms.server.endpoint.advised;
 
 import javax.jms.JMSException;
-import javax.transaction.xa.Xid;
 
 import org.jboss.jms.delegate.SessionDelegate;
 import org.jboss.jms.server.endpoint.ConnectionEndpoint;
 import org.jboss.jms.tx.TransactionRequest;
+import org.jboss.messaging.core.tx.MessagingXid;
 
 /**
  * The server-side advised instance corresponding to a Connection. It is bound to the AOP
@@ -99,16 +99,11 @@
       endpoint.sendTransaction(request);
    }
 
-   public Xid[] getPreparedTransactions() throws JMSException
+   public MessagingXid[] getPreparedTransactions() throws JMSException
    {
       return endpoint.getPreparedTransactions();
    }
    
-   public boolean isClosed() throws JMSException
-   {
-      return endpoint.isClosed();
-   }
-
    // Public --------------------------------------------------------
 
    public Object getEndpoint()

Modified: trunk/src/main/org/jboss/jms/server/endpoint/advised/ConsumerAdvised.java
===================================================================
--- trunk/src/main/org/jboss/jms/server/endpoint/advised/ConsumerAdvised.java	2007-01-31 20:11:51 UTC (rev 2118)
+++ trunk/src/main/org/jboss/jms/server/endpoint/advised/ConsumerAdvised.java	2007-02-01 00:10:20 UTC (rev 2119)
@@ -74,12 +74,6 @@
       endpoint.cancelInflightMessages(lastDeliveryId);
    }
 
-   public boolean isClosed() throws JMSException
-   {
-      return endpoint.isClosed();
-   }
-
-  
    // AdvisedSupport overrides --------------------------------------
 
    public Object getEndpoint()

Modified: trunk/src/main/org/jboss/jms/server/endpoint/advised/SessionAdvised.java
===================================================================
--- trunk/src/main/org/jboss/jms/server/endpoint/advised/SessionAdvised.java	2007-01-31 20:11:51 UTC (rev 2118)
+++ trunk/src/main/org/jboss/jms/server/endpoint/advised/SessionAdvised.java	2007-02-01 00:10:20 UTC (rev 2119)
@@ -83,14 +83,14 @@
    public ConsumerDelegate createConsumerDelegate(JBossDestination destination, String selector,
                                                   boolean noLocal, String subscriptionName,
                                                   boolean connectionConsumer,
-                                                  Long failoverChannelID) throws JMSException
+                                                  long failoverChannelID) throws JMSException
    {
       return endpoint.createConsumerDelegate(destination, selector, noLocal, subscriptionName,
                                              connectionConsumer, failoverChannelID);
    }
    
    public BrowserDelegate createBrowserDelegate(JBossDestination queue, String messageSelector,
-                                                Long failoverChannelID) throws JMSException                                                 
+                                                long failoverChannelID) throws JMSException                                                 
    {
       return endpoint.createBrowserDelegate(queue, messageSelector, failoverChannelID);
    }
@@ -145,11 +145,6 @@
       endpoint.recoverDeliveries(ackInfos);
    }
 
-   public boolean isClosed() throws JMSException
-   {
-      return endpoint.isClosed();
-   }
-
    // AdvisedSupport overrides --------------------------------------
 
    public Object getEndpoint()

Deleted: trunk/src/main/org/jboss/jms/server/remoting/JMSDispatcher.java
===================================================================
--- trunk/src/main/org/jboss/jms/server/remoting/JMSDispatcher.java	2007-01-31 20:11:51 UTC (rev 2118)
+++ trunk/src/main/org/jboss/jms/server/remoting/JMSDispatcher.java	2007-02-01 00:10:20 UTC (rev 2119)
@@ -1,40 +0,0 @@
-/*
-  * JBoss, Home of Professional Open Source
-  * Copyright 2005, JBoss Inc., and individual contributors as indicated
-  * by the @authors tag. See the copyright.txt in the distribution for a
-  * full listing of individual contributors.
-  *
-  * This is free software; you can redistribute it and/or modify it
-  * under the terms of the GNU Lesser General Public License as
-  * published by the Free Software Foundation; either version 2.1 of
-  * the License, or (at your option) any later version.
-  *
-  * This software is distributed in the hope that it will be useful,
-  * but WITHOUT ANY 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 along with this software; if not, write to the Free
-  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-  */
-package org.jboss.jms.server.remoting;
-
-import org.jboss.aop.Dispatcher;
-
-/**
- * 
- * We have our own Dispatcher so we don't have the possibility with conflicts with other systems
- * using the same object ids.
- * 
- * @author <a href="tim.fox at jboss.com">Tim Fox</a>
- * @version <tt>$Revision$</tt>
- *
- * $Id$
- */
-public class JMSDispatcher extends Dispatcher
-{
-   public static final JMSDispatcher instance = new JMSDispatcher();
-
-}

Modified: trunk/src/main/org/jboss/jms/server/remoting/JMSServerInvocationHandler.java
===================================================================
--- trunk/src/main/org/jboss/jms/server/remoting/JMSServerInvocationHandler.java	2007-01-31 20:11:51 UTC (rev 2118)
+++ trunk/src/main/org/jboss/jms/server/remoting/JMSServerInvocationHandler.java	2007-02-01 00:10:20 UTC (rev 2119)
@@ -28,9 +28,9 @@
 
 import javax.management.MBeanServer;
 
-import org.jboss.aop.joinpoint.InvocationResponse;
-import org.jboss.aop.joinpoint.MethodInvocation;
-import org.jboss.aop.util.PayloadKey;
+import org.jboss.jms.wireformat.ConnectionFactoryCreateConnectionDelegateRequest;
+import org.jboss.jms.wireformat.RequestSupport;
+import org.jboss.jms.wireformat.ResponseSupport;
 import org.jboss.logging.Logger;
 import org.jboss.messaging.util.Util;
 import org.jboss.remoting.InvocationRequest;
@@ -93,66 +93,59 @@
    public Object invoke(InvocationRequest invocation) throws Throwable
    {      
       if (trace) { log.trace("invoking " + invocation); }
+        
+      RequestSupport request = (RequestSupport)invocation.getParameter();
       
-      MessagingMarshallable mm = (MessagingMarshallable)invocation.getParameter();
-      
-      MethodInvocation i = (MethodInvocation)mm.getLoad();
-            
-      // put the version number into meta data for use in the InjectionInterceptor
-      i.getMetaData().addMetaData(MetaDataConstants.JMS,
-                                  MetaDataConstants.VERSION_NUMBER,
-                                  new Byte(mm.getVersion()),
-                                  PayloadKey.TRANSIENT);
-            
-      String s =
-         (String)i.getMetaData(MetaDataConstants.JMS, MetaDataConstants.REMOTING_SESSION_ID);
-      
-      if (s != null)
+      if (request instanceof ConnectionFactoryCreateConnectionDelegateRequest)
       {
-         Object callbackHandler = null;
+         //Create connection request
+         
+         ConnectionFactoryCreateConnectionDelegateRequest cReq = 
+            (ConnectionFactoryCreateConnectionDelegateRequest)request;
+         
+         String remotingSessionId = cReq.getRemotingSessionID();
+         
+         ServerInvokerCallbackHandler callbackHandler = null;
          synchronized(callbackHandlers)
          {
-            callbackHandler = callbackHandlers.get(s);
+            callbackHandler = (ServerInvokerCallbackHandler)callbackHandlers.get(remotingSessionId);
          }
          if (callbackHandler != null)
          {
-            log.debug("found calllback handler for remoting session " + Util.guidToString(s));
+            log.debug("found calllback handler for remoting session " + Util.guidToString(remotingSessionId));
             
-            i.getMetaData().addMetaData(MetaDataConstants.JMS,
-                                        MetaDataConstants.CALLBACK_HANDLER,
-                                        callbackHandler, PayloadKey.TRANSIENT);
+            cReq.setCallbackHandler(callbackHandler);
          }
          else
          {
-            throw new javax.jms.IllegalStateException("Cannot find callback handler " +
-                                                      "for session id " + s);
+            throw new IllegalStateException("Cannot find callback handler " +
+                                            "for session id " + remotingSessionId);
          }
       }
       
-      InvocationResponse resp = JMSDispatcher.instance.invoke(i);
-      byte version = mm.getVersion();
-      
-      return new MessagingMarshallable(version, resp.getResponse());
+      ResponseSupport response = request.serverInvoke();
+                  
+      return response;
    }
 
    public void addListener(InvokerCallbackHandler callbackHandler)
    {                 
-      log.debug("adding callback handler " + callbackHandler);
+      if (log.isTraceEnabled()) { log.trace("adding callback handler " + callbackHandler); }
       
       if (callbackHandler instanceof ServerInvokerCallbackHandler)
       {
          ServerInvokerCallbackHandler h = (ServerInvokerCallbackHandler)callbackHandler;
-         String id = h.getClientSessionId(); 
+         String sessionId = h.getClientSessionId();
          
          synchronized(callbackHandlers)
          {
-            if (callbackHandlers.containsKey(id))
+            if (callbackHandlers.containsKey(sessionId))
             {
-               String msg = "The remoting client " + id + " already has a callback handler";
+               String msg = "The remoting client " + sessionId + " already has a callback handler";
                log.error(msg);
-               throw new RuntimeException(msg);
+               throw new IllegalStateException(msg);
             }
-            callbackHandlers.put(id, h);
+            callbackHandlers.put(sessionId, h);
          }
       }
       else
@@ -163,8 +156,8 @@
 
    public void removeListener(InvokerCallbackHandler callbackHandler)
    {
-      log.debug("removing callback handler " + callbackHandler);
-
+      if (log.isTraceEnabled()) { log.trace("removing callback handler " + callbackHandler); }
+      
       synchronized(callbackHandlers)
       {
          for(Iterator i = callbackHandlers.keySet().iterator(); i.hasNext();)

Modified: trunk/src/main/org/jboss/jms/server/remoting/JMSWireFormat.java
===================================================================
--- trunk/src/main/org/jboss/jms/server/remoting/JMSWireFormat.java	2007-01-31 20:11:51 UTC (rev 2118)
+++ trunk/src/main/org/jboss/jms/server/remoting/JMSWireFormat.java	2007-02-01 00:10:20 UTC (rev 2119)
@@ -28,53 +28,41 @@
 import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
 import java.io.OutputStream;
-import java.util.ArrayList;
-import java.util.Iterator;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
-import java.util.HashMap;
 
-import javax.jms.Message;
-
-import org.jboss.aop.Dispatcher;
-import org.jboss.aop.joinpoint.MethodInvocation;
-import org.jboss.jms.client.remoting.CallbackManager;
-import org.jboss.jms.message.JBossMessage;
-import org.jboss.jms.server.ServerPeer;
-import org.jboss.jms.server.Version;
-import org.jboss.jms.server.endpoint.Ack;
-import org.jboss.jms.server.endpoint.Cancel;
-import org.jboss.jms.server.endpoint.ClientDelivery;
-import org.jboss.jms.server.endpoint.DefaultAck;
-import org.jboss.jms.server.endpoint.DefaultCancel;
-import org.jboss.jms.server.endpoint.DeliveryRecovery;
-import org.jboss.jms.tx.TransactionRequest;
+import org.jboss.jms.wireformat.ClientDelivery;
+import org.jboss.jms.wireformat.PacketSupport;
+import org.jboss.jms.wireformat.PolledCallbacksDelivery;
+import org.jboss.jms.wireformat.RequestSupport;
+import org.jboss.jms.wireformat.ResponseSupport;
+import org.jboss.jms.wireformat.SerializedPacket;
 import org.jboss.logging.Logger;
-import org.jboss.messaging.core.message.MessageFactory;
-import org.jboss.messaging.core.plugin.IDBlock;
+import org.jboss.remoting.Client;
 import org.jboss.remoting.InvocationRequest;
 import org.jboss.remoting.InvocationResponse;
-import org.jboss.remoting.Client;
 import org.jboss.remoting.callback.Callback;
 import org.jboss.remoting.invocation.InternalInvocation;
 import org.jboss.remoting.invocation.OnewayInvocation;
 import org.jboss.remoting.marshal.Marshaller;
 import org.jboss.remoting.marshal.UnMarshaller;
-import org.jboss.serial.io.JBossObjectInputStream;
-import org.jboss.serial.io.JBossObjectOutputStream;
 
 /**
  * 
  * A JMSWireFormat.
  * 
- * For some invocations, e.g. message sends, acknowledgements and activations it is vital that we
- * minimise the amount of data sent in the invocation so that we can maximise performance.
- * By default, Invocations and return values are sent over the wire as serialized Java objects.
- * This adds considerable overhead in terms of the amount of data sent (it adds class information
- * plus block data information) which significantly degrades performance. Therefore for the
- * invocations where performance is paramount we define a customer wire format that minimises the
+ * We do not use Java or JBoss serialization to send data over the wire.
+ * Serialization adds considerable overhead in terms of the amount of data sent (it adds class information
+ * plus block data information) which significantly degrades performance.
+ * 
+ * Instead we define a customer wire format that minimises the
  * amount of data sent.
  * 
+ * The only exception to this rule is when sending an ObjectMessage which contains a user
+ * defined object whose type is only known at run-time. In this case we use serialization.
+ * 
+ * 
  * @author <a href="tim.fox at jboss.com">Tim Fox</a>
  * @author <a href="ovidiu at jboss.org">Ovidiu Feodorov</a>
  * @version <tt>$Revision$</tt>
@@ -89,64 +77,10 @@
 
    private static final Logger log = Logger.getLogger(JMSWireFormat.class);
    
-   private static boolean usingJBossSerialization = true;
-
-   // The request codes  - start from zero
-
-   protected static final byte SERIALIZED = 0;   
-   protected static final byte ACKNOWLEDGE = 1;
-   protected static final byte ACKNOWLEDGE_LIST = 2;
-   protected static final byte CANCEL = 3;
-   protected static final byte CANCEL_LIST = 4;
-   protected static final byte SEND = 5;   
-   protected static final byte CHANGE_RATE = 6; 
-   protected static final byte SEND_TRANSACTION = 7;
-   protected static final byte GET_ID_BLOCK = 8;
-   protected static final byte RECOVER_DELIVERIES = 9;
-   protected static final byte CANCEL_INFLIGHT_MESSAGES = 10;
-
-   // The response codes - start from 100
-
-   protected static final byte MESSAGE_DELIVERY = 100;
-   protected static final byte NULL_RESPONSE = 101;
-   protected static final byte ID_BLOCK_RESPONSE = 102;
-   protected static final byte BROWSE_MESSAGE_RESPONSE = 104;
-   protected static final byte BROWSE_MESSAGES_RESPONSE = 105;
-   protected static final byte CALLBACK_LIST = 106;
-
-
    // Static ---------------------------------------------------------------------------------------
 
    private static Map ONE_WAY_METADATA;
    
-   public static void setUsingJBossSerialization(boolean b)
-   {
-      usingJBossSerialization = b;
-   }
-
-   public static String formatTypeToString(byte formatType)
-   {
-      return
-         formatType == SERIALIZED ? "SERIALIZED" :
-         formatType == ACKNOWLEDGE ? "ACKNOWLEDGE" :
-         formatType == ACKNOWLEDGE_LIST ? "ACKNOWLEDGE_LIST" :
-         formatType == CANCEL ? "CANCEL" :
-         formatType == CANCEL_LIST ? "CANCEL_LIST" :
-         formatType == SEND ? "SEND" :
-         formatType == CHANGE_RATE ? "CHANGE_RATE" :
-         formatType == SEND_TRANSACTION ? "SEND_TRANSACTION" :
-         formatType == GET_ID_BLOCK ? "GET_ID_BLOCK" :
-         formatType == RECOVER_DELIVERIES ? "RECOVER_DELIVERIES" :
-         formatType == CANCEL_INFLIGHT_MESSAGES ? "CANCEL_INFLIGHT_MESSAGES" :
-         formatType == MESSAGE_DELIVERY ? "MESSAGE_DELIVERY" :
-         formatType == NULL_RESPONSE ? "NULL_RESPONSE" :
-         formatType == ID_BLOCK_RESPONSE ? "ID_BLOCK_RESPONSE" :
-         formatType == BROWSE_MESSAGE_RESPONSE ? "BROWSE_MESSAGE_RESPONSE" :
-         formatType == BROWSE_MESSAGES_RESPONSE ? "BROWSE_MESSAGES_RESPONSE" :
-         formatType == CALLBACK_LIST ? "CALLBACK_LIST" :
-            "UNKNOWN";
-   }
-
    static
    {
       ONE_WAY_METADATA = new HashMap();
@@ -168,11 +102,17 @@
 
    public void write(Object obj, OutputStream out) throws IOException
    {          
+      if (trace) { log.trace("Writing " + obj); }
+      
       DataOutputStream dos;
       
       if (out instanceof DataOutputStream)
       {
+         //For non HTTP transports - we should ALWAYS be passed a DataOutputStream
+         //We do this by specifying socket wrapper classes on the locator uri
          dos = (DataOutputStream)out;
+         
+         if (trace) { log.trace("Stream is a DataOutputStream"); }
       }
       else
       {
@@ -185,405 +125,141 @@
          
          // This would be the case for the HTTP transport for example. Wrap the stream.
          
-         //TODO Ideally remoting would let us wrap this before invoking the marshaller
-         //but this does not appear to be possible
+         //FIXME - remoting should be fixed to allow socket wrappers to be specified for
+         //all transports - not just socket
+         //until then we have no choice but to create a wrapping stream on every invocation
+         //for HTTP transport
          dos = new DataOutputStream(out);
-      }
-                  
-      handleVersion(obj, dos);
-
+         
+         if (trace) { log.trace("Stream is NOT a DataOutputStream - must be using HTTP transport"); }
+      }                  
+      
       try
       {
+         PacketSupport packet = null;
+         
          if (obj instanceof InvocationRequest)
-         {
+         {                        
             InvocationRequest req = (InvocationRequest)obj;
-
-            if (trace) { log.trace("writing " + obj); }
-
+            
             Object param = req.getParameter();
             
-            if (param instanceof OnewayInvocation)
+            if (param instanceof PacketSupport)
             {
-               // an oneway invocation is only using the first slot in its parameter array so we're
-               // taking some shortcuts here.
-               param = ((OnewayInvocation)param).getParameters()[0];
+               // A JBM invocation
+               packet = (PacketSupport)param;    
+               
+               if (trace) { log.trace("JBM Request"); }
             }
-
-            if (param instanceof InternalInvocation)
+            else if (param instanceof OnewayInvocation)
             {
-               // unwrap callback
+               if (trace) { log.trace("It's a OnewayInvocation"); }
+               
+               // This is fucking horrendous - remoting should not force us to deal with
+               // its internal objects
+               
+               // Hmmm... hidden somewhere in the depths of this crap there must be the callback,
+               // The search begins....
 
-               InternalInvocation ii = (InternalInvocation)param;
-               Object[] params = ii.getParameters();
+               OnewayInvocation oneWay = (OnewayInvocation)param;
                
-               if (params != null && params.length > 0 && params[0] instanceof Callback)
+               param = oneWay.getParameters()[0];
+               
+               if (param instanceof RequestSupport)
                {
-                  Callback callback = (Callback) params[0];
-                  if (callback.getParameter() instanceof MessagingMarshallable)
-                  {
-                     MessagingMarshallable mm = (MessagingMarshallable)callback.getParameter();
-                     param = mm.getLoad();
-                  }
-                  else
-                  {
-                     param = callback.getParameter();
-                  }
-               }
-            }
-            else if (param instanceof MessagingMarshallable)
-            {
-               param = ((MessagingMarshallable)param).getLoad();
-            }
-
-            if (param instanceof MethodInvocation)
-            {
-               MethodInvocation mi = (MethodInvocation)param;
-   
-               String methodName = mi.getMethod().getName();
-   
-               if (trace) { log.trace("methodInvocation (" + methodName + "())"); }
-   
-               if (methodName.equals("send"))
-               {
-                  dos.writeByte(SEND);
-   
-                  writeHeader(mi, dos);
-   
-                  JBossMessage m = (JBossMessage)mi.getArguments()[0];
-   
-                  dos.writeByte(m.getType());
-   
-                  m.write(dos);
-   
-                  dos.flush();
-   
-                  if (trace) { log.trace("wrote send()"); }
-               }
-               else if ("changeRate".equals(methodName))
-               {
-                  dos.writeByte(CHANGE_RATE);
-   
-                  writeHeader(mi, dos);
+                  //A JBM invocation being sent one way (e.g. changeRate)
                   
-                  Float f = (Float)mi.getArguments()[0];
+                  if (trace) { log.trace("JBM oneway request"); }
                   
-                  dos.writeFloat(f.floatValue());
-   
-                  dos.flush();
-   
-                  if (trace) { log.trace("wrote changeRate()"); }
-               }           
-               else if ("acknowledgeDelivery".equals(methodName))
-               {
-                  dos.writeByte(ACKNOWLEDGE);
-   
-                  writeHeader(mi, dos);
-                  
-                  Ack ack = (Ack)mi.getArguments()[0];
-                  
-                  dos.writeLong(ack.getDeliveryID());
-   
-                  dos.flush();
-   
-                  if (trace) { log.trace("wrote acknowledgeDelivery()"); }
+                  packet = (PacketSupport)param;
                }
-               else if ("acknowledgeDeliveries".equals(methodName))
-               {
-                  dos.writeByte(ACKNOWLEDGE_LIST);
-   
-                  writeHeader(mi, dos);
+               else if (param instanceof InternalInvocation)
+               {                      
+                  InternalInvocation ii = (InternalInvocation)param;
                   
-                  List acks = (List)mi.getArguments()[0];
-   
-                  dos.writeInt(acks.size());
-   
-                  Iterator iter = acks.iterator();
-   
-                  while (iter.hasNext())
-                  {
-                     Ack ack = (Ack)iter.next();
-                     dos.writeLong(ack.getDeliveryID());
-                  }
-   
-                  dos.flush();
-   
-                  if (trace) { log.trace("wrote acknowledgeDeliveries()"); }
-               }
-               else if ("cancelDelivery".equals(methodName))
-               {
-                  dos.writeByte(CANCEL);
-   
-                  writeHeader(mi, dos);
+                  Object[] params = ii.getParameters();
                   
-                  Cancel cancel = (Cancel)mi.getArguments()[0];
+                  if (trace) { log.trace("Params is " + params); }
                   
-                  dos.writeLong(cancel.getDeliveryId());
-                  
-                  dos.writeInt(cancel.getDeliveryCount());
-                  
-                  dos.writeBoolean(cancel.isExpired());
-                  
-                  dos.writeBoolean(cancel.isReachedMaxDeliveryAttempts());
-                  
-                  dos.flush();
-   
-                  if (trace) { log.trace("wrote cancelDelivery()"); }
-               }
-               else if ("cancelDeliveries".equals(methodName) && mi.getArguments() != null)
-               {
-                  dos.writeByte(CANCEL_LIST);
-   
-                  writeHeader(mi, dos);
-   
-                  List ids = (List)mi.getArguments()[0];
-   
-                  dos.writeInt(ids.size());
-   
-                  Iterator iter = ids.iterator();
-   
-                  while (iter.hasNext())
+                  if (params != null && params.length > 0 && params[0] instanceof Callback)
                   {
-                     Cancel cancel = (Cancel)iter.next();
+                     Callback callback = (Callback) params[0];
                      
-                     dos.writeLong(cancel.getDeliveryId());
+                     if (trace) { log.trace("It's a callback: " + callback); }
                      
-                     dos.writeInt(cancel.getDeliveryCount());
-                     
-                     dos.writeBoolean(cancel.isExpired());
-                     
-                     dos.writeBoolean(cancel.isReachedMaxDeliveryAttempts());
+                     if (callback.getParameter() instanceof ClientDelivery)
+                     {
+                        // Whooooppee!! found the callback. Hurrah for remoting!
+                        // What a simple and intuitive API ;)
+                        
+                        packet = (ClientDelivery)callback.getParameter();
+                        
+                        ((ClientDelivery)packet).setRemotingSessionID(req.getSessionId());
+                        
+                        if (trace) { log.trace("Message delivery callback"); }
+                     }
                   }
-   
-                  dos.flush();
-   
-                  if (trace) { log.trace("wrote cancelDeliveries()"); }
                }
-               else if ("recoverDeliveries".equals(methodName) && mi.getArguments() != null)
-               {
-                  dos.writeByte(RECOVER_DELIVERIES);
-   
-                  writeHeader(mi, dos);
-   
-                  List ids = (List)mi.getArguments()[0];
-   
-                  dos.writeInt(ids.size());
-   
-                  Iterator iter = ids.iterator();
-   
-                  while (iter.hasNext())
-                  {
-                     DeliveryRecovery d = (DeliveryRecovery)iter.next();
-                     d.write(dos);
-                  }
-   
-                  dos.flush();
-   
-                  if (trace) { log.trace("wrote sendUnackedAckInfos()"); }
-               }
-               else if ("sendTransaction".equals(methodName))
-               {
-                  dos.writeByte(SEND_TRANSACTION);
-   
-                  writeHeader(mi, dos);
-   
-                  TransactionRequest request = (TransactionRequest)mi.getArguments()[0];
-   
-                  request.write(dos);
-   
-                  dos.flush();
-   
-                  if (trace) { log.trace("wrote getMessageNow()"); }
-               }
-               else if ("getIdBlock".equals(methodName))
-               {
-                  dos.writeByte(GET_ID_BLOCK);
-   
-                  writeHeader(mi, dos);
-   
-                  int size = ((Integer)mi.getArguments()[0]).intValue();
-   
-                  dos.writeInt(size);
-   
-                  dos.flush();
-   
-                  if (trace) { log.trace("wrote getIdBlock()"); }
-               }           
-               else if ("cancelInflightMessages".equals(methodName))
-               {
-                  dos.writeByte(CANCEL_INFLIGHT_MESSAGES);
-                  
-                  writeHeader(mi, dos);
-                  
-                  long lastDeliveryId = ((Long)mi.getArguments()[0]).longValue();
-                  
-                  dos.writeLong(lastDeliveryId);
-                  
-                  dos.flush();
-               }
                else
                {
-                  dos.write(SERIALIZED);
-   
-                  // Delegate to serialization to handle the wire format
-                  serialize(dos, obj);
-   
-                  if (trace) { log.trace("wrote using standard serialization"); }
+                  throw new IllegalArgumentException("Invalid request param " + param);
                }
             }
-            else if (param instanceof ClientDelivery)
-            {
-               // Message delivery callback
-   
-               if (trace) { log.trace("DeliveryRunnable"); }
-   
-               ClientDelivery dr = (ClientDelivery)param;
-   
-               dos.writeByte(MESSAGE_DELIVERY);
+            else
+            {               
+               //Some other remoting internal thing, e.g. PING, DISCONNECT, add listener etc
                
-               dos.writeUTF(req.getSessionId());
-   
-               dr.write(dos);
-   
-               dos.flush();
-   
-               if (trace) { log.trace("wrote DeliveryRunnable"); }
+               packet = new SerializedPacket(req);               
             }
-            else
-            {
-               // Internal invocation
-   
-               dos.write(SERIALIZED);
-   
-               // Delegate to serialization to handle the wire format
-               serialize(dos, obj);
-   
-               if (trace) { log.trace("wrote using standard serialization"); }
-            }
-         }
+         }         
          else if (obj instanceof InvocationResponse)
          {
-            if (trace) { log.trace("writing InvocationResponse"); }
-   
             InvocationResponse resp = (InvocationResponse)obj;
-   
-            Object res;
-   
-            if (resp.getResult() instanceof MessagingMarshallable)
+            
+            Object param = resp.getResult();
+            
+            if (param instanceof ResponseSupport)
             {
-               res = ((MessagingMarshallable)resp.getResult()).getLoad();
-            }
-            else
-            {
-               res = resp.getResult();
-            }
-   
-            if (trace) { log.trace("result is " + res); }
-   
-            if (res == null && !resp.isException())
-            {       
-               dos.write(NULL_RESPONSE);
-   
-               dos.flush();
-   
-               if (trace) { log.trace("wrote null response"); }
-            }         
-            else if (res instanceof IDBlock)
-            {
-               // Return value from getMessageNow
-               dos.write(ID_BLOCK_RESPONSE);
-   
-               IDBlock block = (IDBlock)res;
-   
-               block.write(dos);
-   
-               dos.flush();
-   
-               if (trace) { log.trace("wrote id block response"); }
-            }
-            else if (res instanceof JBossMessage)
-            {
-               // Return value from browsing message
-               dos.write(BROWSE_MESSAGE_RESPONSE);
+               // A JBM invocation response
                
-               JBossMessage msg = (JBossMessage)res;
-               
-               dos.writeByte(msg.getType());
-               
-               msg.write(dos);
-               
-               dos.flush();
-               
-               if (trace) { log.trace("wrote browse message response"); }
-            }            
-            else if (res instanceof Message[])
-            {
-               // Return value from browsing messages
-               dos.write(BROWSE_MESSAGES_RESPONSE);
-               
-               Message[] msgs = (Message[])res;
-               
-               dos.writeInt(msgs.length);
-               
-               for (int i = 0; i < msgs.length; i++)
-               {
-                  JBossMessage m = (JBossMessage)msgs[i];
-                  
-                  dos.writeByte(m.getType());
-                  
-                  m.write(dos);
-               }
-               
-               dos.flush();
-               
-               if (trace) { log.trace("wrote browse message response"); }
+               packet = (ResponseSupport)param;
+             
+               if (trace) { log.trace("JBM Response"); }
             }
-            else if (res instanceof ArrayList &&
-                     ((ArrayList) res).size() > 0 &&
-                     ((ArrayList) res).get(0) instanceof Callback)
+            else if (param instanceof List)
             {
-               // Comes from polled Callbacks. (HTTP transport??)
-               ArrayList callbackList = (ArrayList)res;
-               dos.write(CALLBACK_LIST);
-               dos.writeUTF(resp.getSessionId());
-               dos.writeInt(callbackList.size());
+               // List of polled Callbacks, this is how messages are delivered when using
+               // polled callbacks e.g. the HTTP transport
                
-               for(Iterator i = callbackList.iterator(); i.hasNext(); )
-               {
-                  Callback callback = (Callback)i.next();
-
-                  // We don't use acknowledgeable push callbacks
-
-                  MessagingMarshallable mm = (MessagingMarshallable)callback.getParameter();
-                  ClientDelivery delivery = (ClientDelivery)mm.getLoad();
-                  delivery.write(dos);
-                  dos.flush();
-
-                  if (trace) { log.trace("wrote delivery " + delivery); }
-               }
+               packet = new PolledCallbacksDelivery((List)param, resp.getSessionId());             
             }
             else
             {
-               dos.write(SERIALIZED);
-   
-               //Delegate to serialization to handle the wire format
-               serialize(dos, obj);
-   
-               if (trace) { log.trace("wrote using standard serialization"); }
+               // Return value from some remoting internal invocation e.g. PONG - return value from PING
+               packet = new SerializedPacket(obj);
             }
          }
          else
          {
-            throw new IllegalStateException("Invalid object " + obj);
+            //Actually this should never occur
+            packet = new SerializedPacket(obj);
          }
+             
+         if (trace) { log.trace("Writing packet: " + packet); }
+         
+         packet.write(dos);
+         
+         if (trace) { log.trace("Wrote packet"); }
       }
       catch (Exception e)
       {
+         log.error("Failed to write packet", e);
          IOException e2 = new IOException(e.getMessage());
          e2.setStackTrace(e.getStackTrace());
          throw e2;
       }
    }
-
+   
    public Marshaller cloneMarshaller() throws CloneNotSupportedException
    {
       return this;
@@ -593,11 +269,17 @@
 
    public Object read(InputStream in, Map map) throws IOException, ClassNotFoundException
    {            
+      if (trace) { log.trace("Reading"); }
+      
       DataInputStream dis;
       
       if (in instanceof DataInputStream)
       {
+         //For non HTTP transports - we should ALWAYS be passed a DataInputStream
+         //We do this by specifying socket wrapper classes on the locator uri
          dis = (DataInputStream)in;         
+         
+         if (trace) { log.trace("Stream is already DataInputStream :)"); }
       }
       else
       {        
@@ -610,389 +292,26 @@
          
          // This would be the case for the HTTP transport for example. Wrap the stream
          
-         //TODO Ideally remoting would let us wrap this before invoking the marshaller
+         //FIXME Ideally remoting would let us wrap this before invoking the marshaller
          //     but this does not appear to be possible
          dis = new DataInputStream(in);
+         
+         if (trace) { log.trace("Stream is NOT DataInputStream - must be using HTTP transport"); }
       }
       
-      // First byte read is always version
-
-      byte version = dis.readByte();
-      if (trace) { log.trace("read version " + version + " from " + dis); }
-
-      byte formatType = (byte)dis.read();
-      if (trace) { log.trace("read format type " + formatTypeToString(formatType) + " from " + dis); }
-
+      int id = dis.readInt();
+      
+      PacketSupport packet = PacketSupport.createPacket(id);
+      
+      if (trace) { log.trace("Created packet " + packet); }
+      
       try
       {
-   
-         switch (formatType)
-         {
-            case SERIALIZED:
-            {
-               // Delegate to serialization
-               Object ret = deserialize(dis);
-   
-               if (trace) { log.trace("read " + ret + " using standard serialization"); }
-   
-               return ret;
-            }
-            case SEND:
-            {
-               MethodInvocation mi = readHeader(dis);
-   
-               byte messageType = dis.readByte();
-   
-               JBossMessage m = (JBossMessage)MessageFactory.createMessage(messageType);
-   
-               m.read(dis);
-   
-               Object[] args = new Object[] {m};
-   
-               mi.setArguments(args);
-   
-               InvocationRequest request =
-                  new InvocationRequest(null, ServerPeer.REMOTING_JMS_SUBSYSTEM,
-                                        new MessagingMarshallable(version, mi), null, null, null);
-   
-               if (trace) { log.trace("read send()"); }
-   
-               return request;
-            }
-            case CHANGE_RATE:
-            {
-               // asynchronous invocation
-
-               MethodInvocation mi = readHeader(dis);
-               
-               float f = dis.readFloat();
-               
-               Object[] args = new Object[] {new Float(f)};
-               
-               mi.setArguments(args);
-
-               // http://jira.jboss.org/jira/browse/JBMESSAGING-773
-               // The remoting server requires us to "mark" an one-way invocation redundantly once
-               // by wrapping an OnewayInvocation within an InvocationRequest, and then placing
-               // a Client.ONEWAY_FLAG in the same InvocationRequest's metadata. Why?
-
-               OnewayInvocation oi = new OnewayInvocation(new MessagingMarshallable(version, mi));
-
-               InvocationRequest request =
-                  new InvocationRequest(null, ServerPeer.REMOTING_JMS_SUBSYSTEM,
-                                        oi, ONE_WAY_METADATA, null, null);
-   
-               if (trace) { log.trace("read changeRate()"); }
-   
-               return request;
-            }         
-            case SEND_TRANSACTION:
-            {
-               MethodInvocation mi = readHeader(dis);
-   
-               TransactionRequest tr = new TransactionRequest();
-   
-               tr.read(dis);
-   
-               Object[] args = new Object[] {tr};
-   
-               mi.setArguments(args);
-   
-               InvocationRequest request =
-                  new InvocationRequest(null, ServerPeer.REMOTING_JMS_SUBSYSTEM,
-                                        new MessagingMarshallable(version, mi), null, null, null);
-   
-               if (trace) { log.trace("read sendTransaction()"); }
-   
-               return request;
-            }
-            case GET_ID_BLOCK:
-            {
-               MethodInvocation mi = readHeader(dis);
-   
-               int size = dis.readInt();
-   
-               Object[] args = new Object[] {new Integer(size)};
-   
-               mi.setArguments(args);
-   
-               InvocationRequest request =
-                  new InvocationRequest(null, ServerPeer.REMOTING_JMS_SUBSYSTEM,
-                                        new MessagingMarshallable(version, mi), null, null, null);
-   
-               if (trace) { log.trace("read getIdBlock()"); }
-   
-               return request;
-            }
-            case ACKNOWLEDGE:
-            {
-               MethodInvocation mi = readHeader(dis);
-               
-               long l = dis.readLong();
-               
-               Object[] args = new Object[] {new DefaultAck(l)};
-   
-               mi.setArguments(args);
-   
-               InvocationRequest request =
-                  new InvocationRequest(null, ServerPeer.REMOTING_JMS_SUBSYSTEM,
-                                        new MessagingMarshallable(version, mi), null, null, null);
-   
-               if (trace) { log.trace("read acknowledgeDelivery()"); }
-   
-               return request;
-            }
-            case ACKNOWLEDGE_LIST:
-            {
-               MethodInvocation mi = readHeader(dis);
-                           
-               int num = dis.readInt();
-               
-               List acks = new ArrayList(num);
-               
-               for (int i = 0; i < num; i++)
-               {
-                  long l = dis.readLong();                  
-                  
-                  acks.add(new DefaultAck(l));
-               }
-                           
-               Object[] args = new Object[] {acks};
-   
-               mi.setArguments(args);
-   
-               InvocationRequest request =
-                  new InvocationRequest(null, ServerPeer.REMOTING_JMS_SUBSYSTEM,
-                                        new MessagingMarshallable(version, mi), null, null, null);
-   
-               if (trace) { log.trace("read acknowledgeDeliveries()"); }
-   
-               return request;
-            }
-            case CANCEL:
-            {
-               MethodInvocation mi = readHeader(dis);
-               
-               long deliveryId = dis.readLong();
-               
-               int deliveryCount = dis.readInt();
-               
-               boolean expired = dis.readBoolean();
-               
-               boolean reachedMaxDeliveries = dis.readBoolean();
-               
-               Object[] args = new Object[] {new DefaultCancel(deliveryId, deliveryCount, expired, reachedMaxDeliveries)};
-   
-               mi.setArguments(args);
-   
-               InvocationRequest request =
-                  new InvocationRequest(null, ServerPeer.REMOTING_JMS_SUBSYSTEM,
-                                        new MessagingMarshallable(version, mi), null, null, null);
-   
-               if (trace) { log.trace("read cancelDelivery()"); }
-   
-               return request;
-            }
-            case CANCEL_LIST:
-            {
-               MethodInvocation mi = readHeader(dis);
-   
-               int size = dis.readInt();
-   
-               List acks = new ArrayList(size);
-   
-               for (int i = 0; i < size; i++)
-               {                  
-                  long deliveryId = dis.readLong();
-                  
-                  int deliveryCount = dis.readInt();
-                  
-                  boolean expired = dis.readBoolean();
-                  
-                  boolean reachedMaxDeliveries = dis.readBoolean();
-                  
-                  DefaultCancel cancel = new DefaultCancel(deliveryId, deliveryCount, expired, reachedMaxDeliveries);
-                                    
-                  acks.add(cancel);
-               }
-   
-               Object[] args = new Object[] {acks};
-   
-               mi.setArguments(args);
-   
-               InvocationRequest request =
-                  new InvocationRequest(null, ServerPeer.REMOTING_JMS_SUBSYSTEM,
-                                        new MessagingMarshallable(version, mi), null, null, null);
-   
-               if (trace) { log.trace("read cancelDeliveries()"); }
-   
-               return request;
-            }
-            case RECOVER_DELIVERIES:
-            {
-               MethodInvocation mi = readHeader(dis);
-   
-               int size = dis.readInt();
-   
-               List dels = new ArrayList(size);
-   
-               for (int i = 0; i < size; i++)
-               {
-                  DeliveryRecovery d = new DeliveryRecovery();
-                  
-                  d.read(dis);
-                  
-                  dels.add(d);
-               }
-   
-               Object[] args = new Object[] {dels};
-   
-               mi.setArguments(args);
-   
-               InvocationRequest request =
-                  new InvocationRequest(null, ServerPeer.REMOTING_JMS_SUBSYSTEM,
-                                        new MessagingMarshallable(version, mi), null, null, null);
-   
-               if (trace) { log.trace("read unackedAckInfos()"); }
-   
-               return request;
-            }
-            case CANCEL_INFLIGHT_MESSAGES:
-            {
-               MethodInvocation mi = readHeader(dis);
-               
-               long lastDeliveryId = dis.readLong();
-               
-               Object[] args = new Object[] {new Long(lastDeliveryId)};
-               
-               mi.setArguments(args);
-   
-               InvocationRequest request =
-                  new InvocationRequest(null, ServerPeer.REMOTING_JMS_SUBSYSTEM,
-                                        new MessagingMarshallable(version, mi), null, null, null);
-   
-               if (trace) { log.trace("read cancelInflightMessages()"); }
-   
-               return request;
-               
-               
-            }
-            case ID_BLOCK_RESPONSE:
-            {
-               IDBlock block = new IDBlock();
-   
-               block.read(dis);
-   
-               InvocationResponse resp = new InvocationResponse(null, new MessagingMarshallable(version, block), false, null);
-   
-               if (trace) { log.trace("read id block response"); }
-   
-               return resp;
-            }
-            case BROWSE_MESSAGE_RESPONSE:
-            {
-               byte type = dis.readByte();
-               
-               JBossMessage msg = (JBossMessage)MessageFactory.createMessage(type);
-               
-               msg.read(dis);
-               
-               InvocationResponse resp = new InvocationResponse(null, new MessagingMarshallable(version, msg), false, null);
-   
-               if (trace) { log.trace("read browse message response"); }
-   
-               return resp;
-            }
-            case BROWSE_MESSAGES_RESPONSE:
-            {
-               int num = dis.readInt();
-               
-               Message[] msgs = new Message[num];
-               
-               for (int i = 0; i < num; i++)
-               {
-                  byte type = dis.readByte();
-                  
-                  JBossMessage msg = (JBossMessage)MessageFactory.createMessage(type);
-                  
-                  msg.read(dis);
-                  
-                  msgs[i] = msg;
-               }
-               
-               InvocationResponse resp =
-                  new InvocationResponse(null, new MessagingMarshallable(version, msgs), false, null);
-   
-               if (trace) { log.trace("read browse message response"); }
-   
-               return resp;
-            }
-            case NULL_RESPONSE:
-            {
-               MessagingMarshallable mm = new MessagingMarshallable(version, null);
-               InvocationResponse resp = new InvocationResponse(null, mm, false, null);
-               if (trace) { log.trace("read null response"); }
-               return resp;
-            }
-            case MESSAGE_DELIVERY:
-            {
-               // asynchronous invocation
-
-               String sessionId = dis.readUTF();
-               ClientDelivery dr = new ClientDelivery();
-               
-               dr.read(dis);
-
-               // recreate callback
-               MessagingMarshallable mm = new MessagingMarshallable(version, dr);
-               Callback callback = new Callback(mm);
-
-               InternalInvocation ii = new InternalInvocation(InternalInvocation.HANDLECALLBACK,
-                                                              new Object[]{callback});
-
-               // http://jira.jboss.org/jira/browse/JBMESSAGING-773
-               // The remoting server requires us to "mark" an one-way invocation redundantly once
-               // by wrapping an OnewayInvocation within an InvocationRequest, and then placing
-               // a Client.ONEWAY_FLAG in the same InvocationRequest's metadata. Why?
-
-               OnewayInvocation oi = new OnewayInvocation(ii);
-
-               InvocationRequest request
-                  = new InvocationRequest(sessionId, CallbackManager.JMS_CALLBACK_SUBSYSTEM,
-                                          oi, ONE_WAY_METADATA, null, null);
-   
-               if (trace) { log.trace("read callback()"); }
-   
-               return request;
-            }
-            case CALLBACK_LIST:
-            {
-               // Recreate ArrayList of Callbacks (for Callback polling).
-               String sessionId = dis.readUTF();
-               int size = dis.readInt();
-               ArrayList callbackList = new ArrayList(size);
-               for (int i = 0; i < size; i++)
-               {
-                  // We don't use acknowledgeable push callbacks
-
-                  ClientDelivery delivery = new ClientDelivery();
-                  delivery.read(dis);
-
-                  if (trace) { log.trace("read delivery " + delivery); }
-
-                  MessagingMarshallable mm = new MessagingMarshallable(version, delivery);
-                  Callback callback = new Callback(mm);
-
-                  callbackList.add(callback);
-               }
-
-               return new InvocationResponse(sessionId, callbackList, false, null);
-            }
-            default:
-            {
-               throw new IllegalStateException("Invalid format type " + formatType);
-            }
-         }
+         if (trace) { log.trace("Reading packet"); }
+         
+         packet.read(dis);
+         
+         if (trace) { log.trace("Read packet"); }
       }
       catch (Exception e)
       {
@@ -1000,9 +319,14 @@
          e2.setStackTrace(e.getStackTrace());
          throw e2;
       }
+      
+      Object payload = packet.getPayload();
+      
+      if (trace) { log.trace("Returning payload: " + payload); }
+      
+      return payload;
    }
-
-
+      
    public UnMarshaller cloneUnMarshaller() throws CloneNotSupportedException
    {
       return this;
@@ -1018,97 +342,7 @@
 
    // Protected ------------------------------------------------------------------------------------
 
-   protected void handleVersion(Object obj, DataOutputStream oos) throws IOException
-   {
-      Object load = null;
+   // Private --------------------------------------------------------------------------------------      
 
-      if (obj instanceof InvocationRequest)
-      {
-         InvocationRequest ir = (InvocationRequest)obj;
-         load = ir.getParameter();
-      }
-      else if (obj instanceof InvocationResponse)
-      {
-         InvocationResponse ir = (InvocationResponse)obj;
-         load = ir.getResult();
-      }
-
-      byte version;
-      if (load instanceof MessagingMarshallable)
-      {
-         // we need to write the version for the marshallable
-         version = ((MessagingMarshallable)load).getVersion();         
-      }
-      else
-      {
-         // this is some kind of remoting internal invocation, we still write a version but it is
-         // the version of the client code not the connection (since we are not associated to any
-         // connection)
-         version = Version.instance().getProviderIncrementingVersion();
-      }
-    
-      // the first byte written for any request/response is the version
-      oos.writeByte(version);
-   }
-
-   // Private --------------------------------------------------------------------------------------
-
-   private void writeHeader(MethodInvocation mi, DataOutputStream dos) throws IOException
-   {
-      int objectId =
-         ((Integer)mi.getMetaData().getMetaData(Dispatcher.DISPATCHER, Dispatcher.OID)).intValue();
-
-      dos.writeInt(objectId);
-
-      dos.writeLong(mi.getMethodHash());
-   }
-
-   private MethodInvocation readHeader(DataInputStream ois) throws IOException
-   {
-      int objectId = ois.readInt();
-
-      long methodHash = ois.readLong();
-
-      MethodInvocation mi = new MethodInvocation(null, methodHash, null, null, null);
-
-      mi.getMetaData().addMetaData(Dispatcher.DISPATCHER, Dispatcher.OID, new Integer(objectId));
-
-      return mi;
-   }
-   
-   private void serialize(OutputStream os, Object obj) throws Exception
-   { 
-      ObjectOutputStream oos;
-      
-      if (usingJBossSerialization)
-      {
-         oos = new JBossObjectOutputStream(os);
-      }
-      else
-      {
-         oos = new ObjectOutputStream(os);
-      }
-      
-      oos.writeObject(obj);
-      
-      oos.flush();      
-   }
-   
-   private Object deserialize(InputStream is) throws Exception
-   {
-      ObjectInputStream ois;
-      
-      if (usingJBossSerialization)
-      {
-         ois = new JBossObjectInputStream(is);
-      }
-      else
-      {
-         ois = new ObjectInputStream(is);
-      }
-      
-      return ois.readObject();
-   }
-
    // Inner classes --------------------------------------------------------------------------------
 }

Deleted: trunk/src/main/org/jboss/jms/server/remoting/MessagingMarshallable.java
===================================================================
--- trunk/src/main/org/jboss/jms/server/remoting/MessagingMarshallable.java	2007-01-31 20:11:51 UTC (rev 2118)
+++ trunk/src/main/org/jboss/jms/server/remoting/MessagingMarshallable.java	2007-02-01 00:10:20 UTC (rev 2119)
@@ -1,123 +0,0 @@
-/*
-  * JBoss, Home of Professional Open Source
-  * Copyright 2005, JBoss Inc., and individual contributors as indicated
-  * by the @authors tag. See the copyright.txt in the distribution for a
-  * full listing of individual contributors.
-  *
-  * This is free software; you can redistribute it and/or modify it
-  * under the terms of the GNU Lesser General Public License as
-  * published by the Free Software Foundation; either version 2.1 of
-  * the License, or (at your option) any later version.
-  *
-  * This software is distributed in the hope that it will be useful,
-  * but WITHOUT ANY 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 along with this software; if not, write to the Free
-  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-  */
-package org.jboss.jms.server.remoting;
-
-import java.io.Externalizable;
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-
-/**
- * @author <a href="tim.fox at jboss.com">Tim Fox</a>
- * @version $Revision$
- *
- * $Id$
- */
-public class MessagingMarshallable implements Externalizable
-{
-   // Constants ------------------------------------------------------------------------------------
-
-   private static final long serialVersionUID = 4715063783844562048L;
-   
-   // Static ---------------------------------------------------------------------------------------
-
-   // Attributes -----------------------------------------------------------------------------------
-   
-   private byte version;
-   private Object load;
-
-   // it only works as long this class is immutable
-   private String toString;
-
-   // Constructors ---------------------------------------------------------------------------------
-
-   public MessagingMarshallable()
-   {     
-   }
-
-   /**
-    * @param load - can be null (for example, in case of "void" invocation response).
-    */
-   public MessagingMarshallable(byte version, Object load)
-   {
-      this.version = version;
-      this.load = load;
-   }
-
-   // Externalizable implemenation -----------------------------------------------------------------
-
-   public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
-   {
-      version = in.readByte();
-      load = in.readObject();
-   }
-
-   public void writeExternal(ObjectOutput out) throws IOException
-   {
-      out.writeByte(version);
-      out.writeObject(load);
-   }
-
-   // Public ---------------------------------------------------------------------------------------
-
-   public Object getLoad()
-   {
-      return load;
-   }
-
-   public byte getVersion()
-   {
-      return version;
-   }
-
-   public String toString()
-   {
-      if (toString == null)
-      {
-         // this only works as long as this class is immutable
-         StringBuffer sb = new StringBuffer("MessagingMarshallable[");
-         //sb.append(Integer.toHexString(hashCode())).append(", ");
-         sb.append("v").append(version).append(", ");
-         if (load == null)
-         {
-            sb.append("EMPTY");
-         }
-         else
-         {
-            sb.append(load);
-         }
-         sb.append(']');
-         toString = sb.toString();
-      }
-
-      return toString;
-   }
-
-   // Package protected ----------------------------------------------------------------------------
-
-   // Protected ------------------------------------------------------------------------------------
-
-   // Private --------------------------------------------------------------------------------------
-
-   // Inner classes --------------------------------------------------------------------------------
-
-}

Deleted: trunk/src/main/org/jboss/jms/server/remoting/MetaDataConstants.java
===================================================================
--- trunk/src/main/org/jboss/jms/server/remoting/MetaDataConstants.java	2007-01-31 20:11:51 UTC (rev 2118)
+++ trunk/src/main/org/jboss/jms/server/remoting/MetaDataConstants.java	2007-02-01 00:10:20 UTC (rev 2119)
@@ -1,43 +0,0 @@
-/*
-  * JBoss, Home of Professional Open Source
-  * Copyright 2005, JBoss Inc., and individual contributors as indicated
-  * by the @authors tag. See the copyright.txt in the distribution for a
-  * full listing of individual contributors.
-  *
-  * This is free software; you can redistribute it and/or modify it
-  * under the terms of the GNU Lesser General Public License as
-  * published by the Free Software Foundation; either version 2.1 of
-  * the License, or (at your option) any later version.
-  *
-  * This software is distributed in the hope that it will be useful,
-  * but WITHOUT ANY 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 along with this software; if not, write to the Free
-  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-  */
-package org.jboss.jms.server.remoting;
-
-/**
- * Constants for passing stuff in aop meta-data
- * 
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- * @version <tt>$Revision 1.1 $</tt>
- *
- * $Id$
- */
-public class MetaDataConstants
-{
-   public static final String JMS = "JMS";
-   
-   public static final String REMOTING_SESSION_ID = "REMOTING_SESSION_ID";
-   
-   public static final String CALLBACK_HANDLER = "CALLBACK_HANDLER";
-    
-   public static final String VERSION_NUMBER = "VERSION_NUMBER";
-   
-   public static final String JMS_CLIENT_VM_ID = "JMS_CLIENT_VM_ID";
-}

Modified: trunk/src/main/org/jboss/jms/tx/MessagingXAResource.java
===================================================================
--- trunk/src/main/org/jboss/jms/tx/MessagingXAResource.java	2007-01-31 20:11:51 UTC (rev 2118)
+++ trunk/src/main/org/jboss/jms/tx/MessagingXAResource.java	2007-02-01 00:10:20 UTC (rev 2119)
@@ -28,7 +28,8 @@
 import org.jboss.jms.client.state.SessionState;
 import org.jboss.jms.delegate.ConnectionDelegate;
 import org.jboss.logging.Logger;
-import org.jboss.messaging.core.tx.XidImpl;
+import org.jboss.messaging.core.tx.MessagingXid;
+import org.jboss.tm.XidImpl;
 
 /**
  * An XAResource implementation.
@@ -117,8 +118,8 @@
 
       // Recreate Xid. See JBMESSAGING-661 [JPL]
 
-      if (!(xid instanceof XidImpl))
-         xid = new XidImpl(xid.getBranchQualifier(), xid.getFormatId(), xid.getGlobalTransactionId());
+      if (!(xid instanceof MessagingXid))
+         xid = new MessagingXid(xid.getBranchQualifier(), xid.getFormatId(), xid.getGlobalTransactionId());
 
       rm.commit(xid, onePhase, connection);
 
@@ -134,8 +135,8 @@
 
       // Recreate Xid. See JBMESSAGING-661 [JPL]
 
-      if (!(xid instanceof XidImpl))
-         xid = new XidImpl(xid.getBranchQualifier(), xid.getFormatId(), xid.getGlobalTransactionId());
+      if (!(xid instanceof MessagingXid))
+         xid = new MessagingXid(xid.getBranchQualifier(), xid.getFormatId(), xid.getGlobalTransactionId());
 
       synchronized (this)
       {
@@ -163,8 +164,8 @@
 
       // Recreate Xid. See JBMESSAGING-661 [JPL]
 
-      if (!(xid instanceof XidImpl))
-         xid = new XidImpl(xid.getBranchQualifier(), xid.getFormatId(), xid.getGlobalTransactionId());
+      if (!(xid instanceof MessagingXid))
+         xid = new MessagingXid(xid.getBranchQualifier(), xid.getFormatId(), xid.getGlobalTransactionId());
    }
 
    public int prepare(Xid xid) throws XAException
@@ -173,8 +174,8 @@
 
       // Recreate Xid. See JBMESSAGING-661 [JPL]
 
-      if (!(xid instanceof XidImpl))
-         xid = new XidImpl(xid.getBranchQualifier(), xid.getFormatId(), xid.getGlobalTransactionId());
+      if (!(xid instanceof MessagingXid))
+         xid = new MessagingXid(xid.getBranchQualifier(), xid.getFormatId(), xid.getGlobalTransactionId());
 
       return rm.prepare(xid, connection);
    }
@@ -196,8 +197,8 @@
 
       // Recreate Xid. See JBMESSAGING-661 [JPL]
 
-      if (!(xid instanceof XidImpl))
-         xid = new XidImpl(xid.getBranchQualifier(), xid.getFormatId(), xid.getGlobalTransactionId());
+      if (!(xid instanceof MessagingXid))
+         xid = new MessagingXid(xid.getBranchQualifier(), xid.getFormatId(), xid.getGlobalTransactionId());
 
       rm.rollback(xid, connection);
    }
@@ -208,8 +209,8 @@
       
       // Recreate Xid. See JBMESSAGING-661 [JPL]
 
-      if (!(xid instanceof XidImpl))
-         xid = new XidImpl(xid.getBranchQualifier(), xid.getFormatId(), xid.getGlobalTransactionId());
+      if (!(xid instanceof MessagingXid))
+         xid = new MessagingXid(xid.getBranchQualifier(), xid.getFormatId(), xid.getGlobalTransactionId());
 
       boolean convertTx = false;
       

Modified: trunk/src/main/org/jboss/jms/tx/ResourceManager.java
===================================================================
--- trunk/src/main/org/jboss/jms/tx/ResourceManager.java	2007-01-31 20:11:51 UTC (rev 2118)
+++ trunk/src/main/org/jboss/jms/tx/ResourceManager.java	2007-02-01 00:10:20 UTC (rev 2119)
@@ -529,7 +529,7 @@
          try
          {
             Xid[] txs = conn.getPreparedTransactions();
-
+            
             //populate with TxState --MK
             for (int i = 0; i < txs.length;i++)
             {

Modified: trunk/src/main/org/jboss/jms/tx/ResourceManagerFactory.java
===================================================================
--- trunk/src/main/org/jboss/jms/tx/ResourceManagerFactory.java	2007-01-31 20:11:51 UTC (rev 2118)
+++ trunk/src/main/org/jboss/jms/tx/ResourceManagerFactory.java	2007-02-01 00:10:20 UTC (rev 2119)
@@ -46,7 +46,7 @@
    // Static ---------------------------------------------------------------------------------------
 
    public static ResourceManagerFactory instance = new ResourceManagerFactory();
-
+   
    // Attributes -----------------------------------------------------------------------------------
 
    private Map holders;
@@ -60,6 +60,11 @@
 
    // Public ---------------------------------------------------------------------------------------
 
+   public synchronized void clear()
+   {
+      holders.clear();
+   }
+      
    public synchronized int size()
    {
       return holders.size();
@@ -75,6 +80,7 @@
     */
    public synchronized ResourceManager checkOutResourceManager(int serverID)
    {
+      
       Integer i = new Integer(serverID);
 
       Holder h = (Holder)holders.get(i);
@@ -88,7 +94,7 @@
       {
          h.refCount++;
       }
-
+      
       return h.rm;
    }
 
@@ -103,7 +109,7 @@
       }
 
       h.refCount--;
-
+      
       if (h.refCount == 0)
       {
          holders.remove(i);

Modified: trunk/src/main/org/jboss/jms/tx/TransactionRequest.java
===================================================================
--- trunk/src/main/org/jboss/jms/tx/TransactionRequest.java	2007-01-31 20:11:51 UTC (rev 2118)
+++ trunk/src/main/org/jboss/jms/tx/TransactionRequest.java	2007-02-01 00:10:20 UTC (rev 2119)
@@ -26,7 +26,7 @@
 
 import javax.transaction.xa.Xid;
 
-import org.jboss.messaging.core.tx.XidImpl;
+import org.jboss.messaging.core.tx.MessagingXid;
 import org.jboss.messaging.util.Streamable;
 
 /**
@@ -138,7 +138,7 @@
         l = in.readInt();
         byte[] globalTxId = new byte[l];
         in.readFully(globalTxId);
-        xid = new XidImpl(branchQual, formatId, globalTxId);
+        xid = new MessagingXid(branchQual, formatId, globalTxId);
      }
      else
      {

Added: trunk/src/main/org/jboss/jms/wireformat/BrowserHasNextMessageRequest.java
===================================================================
--- trunk/src/main/org/jboss/jms/wireformat/BrowserHasNextMessageRequest.java	                        (rev 0)
+++ trunk/src/main/org/jboss/jms/wireformat/BrowserHasNextMessageRequest.java	2007-02-01 00:10:20 UTC (rev 2119)
@@ -0,0 +1,81 @@
+
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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 along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.jms.wireformat;
+
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+
+import org.jboss.jms.server.endpoint.BrowserEndpoint;
+import org.jboss.jms.server.endpoint.ConnectionFactoryEndpoint;
+
+/**
+ * 
+ * A BrowserHasNextMessageRequest
+ *
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ * @version <tt>$Revision: 1.1 $</tt>
+ *
+ * $Id$
+ *
+ */
+public class BrowserHasNextMessageRequest extends RequestSupport
+{
+   public BrowserHasNextMessageRequest()
+   {      
+   }
+   
+   public BrowserHasNextMessageRequest(int objectId,
+                                       byte version)
+   {
+      super(objectId, PacketSupport.REQ_BROWSER_HASNEXTMESSAGE, version);
+   }
+
+   public void read(DataInputStream is) throws Exception
+   {
+      super.read(is);
+   }
+
+   public ResponseSupport serverInvoke() throws Exception
+   {
+      BrowserEndpoint endpoint = 
+         (BrowserEndpoint)Dispatcher.instance.getTarget(objectId);
+      
+      if (endpoint == null)
+      {
+         throw new IllegalStateException("Cannot find object in dispatcher with id " + objectId);
+      }
+      
+      return new BrowserHasNextMessageResponse(endpoint.hasNextMessage());
+   }
+
+   public void write(DataOutputStream os) throws Exception
+   {
+      super.write(os);
+      
+      os.flush();
+   }
+}
+
+
+
+

Added: trunk/src/main/org/jboss/jms/wireformat/BrowserHasNextMessageResponse.java
===================================================================
--- trunk/src/main/org/jboss/jms/wireformat/BrowserHasNextMessageResponse.java	                        (rev 0)
+++ trunk/src/main/org/jboss/jms/wireformat/BrowserHasNextMessageResponse.java	2007-02-01 00:10:20 UTC (rev 2119)
@@ -0,0 +1,74 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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 along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.jms.wireformat;
+
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+
+/**
+ * 
+ * A BrowserHasNextMessageResponse
+ *
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ * @version <tt>$Revision: 1.1 $</tt>
+ *
+ * $Id$
+ *
+ */
+public class BrowserHasNextMessageResponse extends ResponseSupport
+{
+   private boolean hasNext;
+   
+   public BrowserHasNextMessageResponse()
+   {      
+   }  
+   
+   public BrowserHasNextMessageResponse(boolean hasNext)
+   {
+      super(PacketSupport.RESP_BROWSER_HASNEXTMESSAGE);
+      
+      this.hasNext = hasNext;
+   }
+
+   public Object getResponse()
+   {
+      return Boolean.valueOf(hasNext);
+   }
+   
+   public void write(DataOutputStream os) throws Exception
+   {
+      super.write(os);
+      
+      os.writeBoolean(hasNext);
+      
+      os.flush();
+   }
+   
+   public void read(DataInputStream is) throws Exception
+   {
+      hasNext = is.readBoolean();
+   }
+
+}
+
+
+

Added: trunk/src/main/org/jboss/jms/wireformat/BrowserNextMessageBlockRequest.java
===================================================================
--- trunk/src/main/org/jboss/jms/wireformat/BrowserNextMessageBlockRequest.java	                        (rev 0)
+++ trunk/src/main/org/jboss/jms/wireformat/BrowserNextMessageBlockRequest.java	2007-02-01 00:10:20 UTC (rev 2119)
@@ -0,0 +1,89 @@
+
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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 along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.jms.wireformat;
+
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+
+import org.jboss.jms.server.endpoint.BrowserEndpoint;
+
+/**
+ * 
+ * A BrowserNextMessageBlockRequest
+ *
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ * @version <tt>$Revision: 1.1 $</tt>
+ *
+ * $Id$
+ *
+ */
+public class BrowserNextMessageBlockRequest extends RequestSupport
+{
+   private int maxMessages;
+   
+   public BrowserNextMessageBlockRequest()
+   {      
+   }
+   
+   public BrowserNextMessageBlockRequest(int objectId,
+                                         byte version,
+                                         int maxMessages)
+   {
+      super(objectId, PacketSupport.REQ_BROWSER_NEXTMESSAGEBLOCK, version);
+      
+      this.maxMessages = maxMessages;
+   }
+
+   public void read(DataInputStream is) throws Exception
+   {
+      super.read(is);
+      
+      maxMessages = is.readInt();
+   }
+
+   public ResponseSupport serverInvoke() throws Exception
+   {
+      BrowserEndpoint endpoint = 
+         (BrowserEndpoint)Dispatcher.instance.getTarget(objectId);
+      
+      if (endpoint == null)
+      {
+         throw new IllegalStateException("Cannot find object in dispatcher with id " + objectId);
+      }
+      
+      return new BrowserNextMessageBlockResponse(endpoint.nextMessageBlock(maxMessages));
+   }
+
+   public void write(DataOutputStream os) throws Exception
+   {
+      super.write(os);
+      
+      os.writeInt(maxMessages);
+      
+      os.flush();
+   }
+}
+
+
+
+

Added: trunk/src/main/org/jboss/jms/wireformat/BrowserNextMessageBlockResponse.java
===================================================================
--- trunk/src/main/org/jboss/jms/wireformat/BrowserNextMessageBlockResponse.java	                        (rev 0)
+++ trunk/src/main/org/jboss/jms/wireformat/BrowserNextMessageBlockResponse.java	2007-02-01 00:10:20 UTC (rev 2119)
@@ -0,0 +1,99 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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 along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.jms.wireformat;
+
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+
+import org.jboss.jms.message.JBossMessage;
+import org.jboss.messaging.core.message.MessageFactory;
+
+/**
+ * 
+ * A BrowserNextMessageBlockResponse
+ *
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ * @version <tt>$Revision: 1.1 $</tt>
+ *
+ * $Id$
+ *
+ */
+public class BrowserNextMessageBlockResponse extends ResponseSupport
+{
+   private JBossMessage[] msgs;
+   
+   public BrowserNextMessageBlockResponse()
+   {      
+   }
+   
+   public BrowserNextMessageBlockResponse(JBossMessage[] msgs)
+   {
+      super(PacketSupport.RESP_BROWSER_NEXTMESSAGEBLOCK);
+      
+      this.msgs = msgs;
+   }
+
+   public Object getResponse()
+   {
+      return msgs;
+   }
+   
+   public void write(DataOutputStream os) throws Exception
+   {      
+      super.write(os);
+      
+      int len = msgs.length;
+      
+      os.writeInt(len);
+      
+      for (int i = 0; i < len; i++)
+      {
+         JBossMessage msg = msgs[i];
+         
+         os.writeByte(msg.getType());
+         
+         msg.write(os);
+      }
+      
+      os.flush();
+   }
+   
+   public void read(DataInputStream is) throws Exception
+   {
+      int len = is.readInt();
+      
+      for (int i = 0; i < len; i++)
+      {      
+         byte type = is.readByte();
+         
+         JBossMessage msg = (JBossMessage)MessageFactory.createMessage(type);
+         
+         msg.read(is);
+         
+         msgs[i] = msg;
+      }
+   }
+
+}
+
+
+

Added: trunk/src/main/org/jboss/jms/wireformat/BrowserNextMessageRequest.java
===================================================================
--- trunk/src/main/org/jboss/jms/wireformat/BrowserNextMessageRequest.java	                        (rev 0)
+++ trunk/src/main/org/jboss/jms/wireformat/BrowserNextMessageRequest.java	2007-02-01 00:10:20 UTC (rev 2119)
@@ -0,0 +1,79 @@
+
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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 along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.jms.wireformat;
+
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+
+import org.jboss.jms.server.endpoint.BrowserEndpoint;
+
+/**
+ * 
+ * A BrowserNextMessageRequest
+ *
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ * @version <tt>$Revision: 1.1 $</tt>
+ *
+ * $Id$
+ *
+ */
+public class BrowserNextMessageRequest extends RequestSupport
+{
+   BrowserNextMessageRequest()
+   {      
+   }
+   
+   public BrowserNextMessageRequest(int objectId,
+                                    byte version)
+   {
+      super(objectId, PacketSupport.REQ_BROWSER_NEXTMESSAGE, version);
+   }
+
+   public void read(DataInputStream is) throws Exception
+   {
+      super.read(is);
+   }
+
+   public ResponseSupport serverInvoke() throws Exception
+   {
+      BrowserEndpoint endpoint = 
+         (BrowserEndpoint)Dispatcher.instance.getTarget(objectId);
+      
+      if (endpoint == null)
+      {
+         throw new IllegalStateException("Cannot find object in dispatcher with id " + objectId);
+      }
+      
+      return new BrowserNextMessageResponse(endpoint.nextMessage());
+   }
+
+   public void write(DataOutputStream os) throws Exception
+   {
+      super.write(os);
+      
+      os.flush();
+   }
+}
+
+
+

Added: trunk/src/main/org/jboss/jms/wireformat/BrowserNextMessageResponse.java
===================================================================
--- trunk/src/main/org/jboss/jms/wireformat/BrowserNextMessageResponse.java	                        (rev 0)
+++ trunk/src/main/org/jboss/jms/wireformat/BrowserNextMessageResponse.java	2007-02-01 00:10:20 UTC (rev 2119)
@@ -0,0 +1,83 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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 along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.jms.wireformat;
+
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+
+import org.jboss.jms.message.JBossMessage;
+import org.jboss.messaging.core.message.MessageFactory;
+
+/**
+ * 
+ * A BrowserNextMessageResponse
+ *
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ * @version <tt>$Revision: 1.1 $</tt>
+ *
+ * $Id$
+ *
+ */
+public class BrowserNextMessageResponse extends ResponseSupport
+{
+   private JBossMessage msg;
+   
+   public BrowserNextMessageResponse()
+   {      
+   }
+   
+   public BrowserNextMessageResponse(JBossMessage msg)
+   {
+      super(PacketSupport.RESP_BROWSER_NEXTMESSAGE);
+      
+      this.msg = msg;
+   }
+
+   public Object getResponse()
+   {
+      return msg;
+   }
+   
+   public void write(DataOutputStream os) throws Exception
+   {
+      super.write(os);
+      
+      os.writeByte(msg.getType());
+      
+      msg.write(os);
+      
+      os.flush();
+   }
+   
+   public void read(DataInputStream is) throws Exception
+   {
+      byte type = is.readByte();
+      
+      msg = (JBossMessage)MessageFactory.createMessage(type);
+      
+      msg.read(is);
+   }
+
+}
+
+
+

Added: trunk/src/main/org/jboss/jms/wireformat/CallbackSupport.java
===================================================================
--- trunk/src/main/org/jboss/jms/wireformat/CallbackSupport.java	                        (rev 0)
+++ trunk/src/main/org/jboss/jms/wireformat/CallbackSupport.java	2007-02-01 00:10:20 UTC (rev 2119)
@@ -0,0 +1,91 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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 along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.jms.wireformat;
+
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+
+import org.jboss.jms.client.remoting.CallbackManager;
+import org.jboss.remoting.InvocationRequest;
+import org.jboss.remoting.callback.Callback;
+import org.jboss.remoting.invocation.InternalInvocation;
+import org.jboss.remoting.invocation.OnewayInvocation;
+
+/**
+ * A CallbackSupport
+ *
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ * @version <tt>$Revision: 1.1 $</tt>
+ *
+ * $Id$
+ *
+ */
+public abstract class CallbackSupport extends PacketSupport
+{      
+   protected String remotingSessionID;
+   
+   public void setRemotingSessionID(String sessionID)
+   {
+      this.remotingSessionID = sessionID;
+   }
+   
+   public CallbackSupport()
+   {      
+   }
+   
+   public CallbackSupport(int id)
+   {
+      super(id);
+   }
+
+   public void read(DataInputStream is) throws Exception
+   {
+      remotingSessionID = is.readUTF();
+   }
+
+   public void write(DataOutputStream os) throws Exception
+   {
+      super.write(os);
+      
+      os.writeUTF(remotingSessionID);
+   }
+
+   public Object getPayload()
+   {
+      // Basically remoting forces us to create this ridiculous pile of objects
+      // just to do a callback
+      
+      Callback callback = new Callback(this);
+
+      InternalInvocation ii = new InternalInvocation(InternalInvocation.HANDLECALLBACK,
+                                                     new Object[]{callback});
+
+      OnewayInvocation oi = new OnewayInvocation(ii);
+
+      InvocationRequest request
+         = new InvocationRequest(remotingSessionID, CallbackManager.JMS_CALLBACK_SUBSYSTEM,
+                                 oi, ONE_WAY_METADATA, null, null);
+      
+      return request;
+   }
+   
+}

Copied: trunk/src/main/org/jboss/jms/wireformat/ClientDelivery.java (from rev 2094, trunk/src/main/org/jboss/jms/server/endpoint/ClientDelivery.java)
===================================================================
--- trunk/src/main/org/jboss/jms/wireformat/ClientDelivery.java	                        (rev 0)
+++ trunk/src/main/org/jboss/jms/wireformat/ClientDelivery.java	2007-02-01 00:10:20 UTC (rev 2119)
@@ -0,0 +1,132 @@
+/*
+  * JBoss, Home of Professional Open Source
+  * Copyright 2005, JBoss Inc., and individual contributors as indicated
+  * by the @authors tag. See the copyright.txt in the distribution for a
+  * full listing of individual contributors.
+  *
+  * This is free software; you can redistribute it and/or modify it
+  * under the terms of the GNU Lesser General Public License as
+  * published by the Free Software Foundation; either version 2.1 of
+  * the License, or (at your option) any later version.
+  *
+  * This software is distributed in the hope that it will be useful,
+  * but WITHOUT ANY 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 along with this software; if not, write to the Free
+  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+  */
+package org.jboss.jms.wireformat;
+
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+
+import org.jboss.jms.message.JBossMessage;
+import org.jboss.jms.message.MessageProxy;
+import org.jboss.messaging.core.message.MessageFactory;
+
+/**
+ * 
+ * A ClientDelivery
+ *
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ * @author <a href="mailto:ovidiu at jboss.org">Ovidiu Feodorov</a>
+ * @version <tt>$Revision$</tt>
+ *
+ * $Id$
+ *
+ */
+public class ClientDelivery extends CallbackSupport
+{
+   // Constants -----------------------------------------------------
+   
+   // Static --------------------------------------------------------
+   
+   // Attributes ----------------------------------------------------
+   
+   private MessageProxy msg;
+         
+   private int consumerId;
+    
+   // Constructors --------------------------------------------------
+   
+   public ClientDelivery()
+   {      
+   }
+
+   public ClientDelivery(MessageProxy msg, int consumerId)
+   {
+      super (PacketSupport.CLIENT_DELIVERY);
+      
+      this.msg = msg;
+      
+      this.consumerId = consumerId;
+   }
+         
+   // Streamable implementation
+   // ---------------------------------------------------------------
+   
+   public void write(DataOutputStream out) throws Exception
+   {
+      super.write(out);
+      
+      out.writeInt(consumerId);
+      
+      out.writeByte(msg.getMessage().getType());
+
+      out.writeInt(msg.getDeliveryCount());
+      
+      out.writeLong(msg.getDeliveryId());
+
+      msg.getMessage().write(out);          
+      
+      out.flush();
+   }
+
+   public void read(DataInputStream in) throws Exception
+   {
+      super.read(in);
+      
+      consumerId = in.readInt();
+      
+      byte type = in.readByte();
+      
+      int deliveryCount = in.readInt();
+      
+      long deliveryId = in.readLong();
+      
+      JBossMessage m = (JBossMessage)MessageFactory.createMessage(type);
+
+      m.read(in);
+
+      msg = JBossMessage.createThinDelegate(deliveryId, m, deliveryCount); 
+   }
+
+   // Public --------------------------------------------------------
+   
+   public MessageProxy getMessage()
+   {
+      return msg;
+   }
+   
+   public int getConsumerId()
+   {
+      return consumerId;
+   }
+
+   public String toString()
+   {
+      return "ClientDelivery[" + msg + "]";
+   }
+
+   // Package protected ---------------------------------------------
+   
+   // Protected -----------------------------------------------------
+   
+   // Private -------------------------------------------------------
+   
+   // Inner classes -------------------------------------------------   
+}

Added: trunk/src/main/org/jboss/jms/wireformat/CloseRequest.java
===================================================================
--- trunk/src/main/org/jboss/jms/wireformat/CloseRequest.java	                        (rev 0)
+++ trunk/src/main/org/jboss/jms/wireformat/CloseRequest.java	2007-02-01 00:10:20 UTC (rev 2119)
@@ -0,0 +1,82 @@
+
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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 along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.jms.wireformat;
+
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+
+import org.jboss.jms.client.Closeable;
+
+/**
+ * 
+ * A CloseRequest
+ *
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ * @version <tt>$Revision: 1.1 $</tt>
+ *
+ * $Id$
+ *
+ */
+public class CloseRequest extends RequestSupport
+{
+   public CloseRequest()
+   {      
+   }
+   
+   public CloseRequest(int objectId, byte version)
+   {
+      super(objectId, PacketSupport.REQ_CLOSE, version);
+   }
+   
+   public void read(DataInputStream is) throws Exception
+   {
+      super.read(is);
+   }
+
+   public ResponseSupport serverInvoke() throws Exception
+   {
+      Closeable endpoint = 
+         (Closeable)Dispatcher.instance.getTarget(objectId);
+      
+      if (endpoint == null)
+      {
+         throw new IllegalStateException("Cannot find object in dispatcher with id " + objectId);
+      }
+      
+      endpoint.close();
+      
+      return null;
+   }
+
+   public void write(DataOutputStream os) throws Exception
+   {
+      super.write(os);
+      
+      os.flush();
+   }
+}
+
+
+
+
+

Added: trunk/src/main/org/jboss/jms/wireformat/ClosingRequest.java
===================================================================
--- trunk/src/main/org/jboss/jms/wireformat/ClosingRequest.java	                        (rev 0)
+++ trunk/src/main/org/jboss/jms/wireformat/ClosingRequest.java	2007-02-01 00:10:20 UTC (rev 2119)
@@ -0,0 +1,81 @@
+
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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 along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.jms.wireformat;
+
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+
+import org.jboss.jms.client.Closeable;
+
+/**
+ * 
+ * A ClosingRequest
+ *
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ * @version <tt>$Revision: 1.1 $</tt>
+ *
+ * $Id$
+ *
+ */
+public class ClosingRequest extends RequestSupport
+{
+   public ClosingRequest()
+   {      
+   }
+   
+   public ClosingRequest(int objectId, byte version)
+   {
+      super(objectId, PacketSupport.REQ_CLOSING, version);
+   }
+   
+   public void read(DataInputStream is) throws Exception
+   {
+      super.read(is);
+   }
+
+   public ResponseSupport serverInvoke() throws Exception
+   {
+      Closeable endpoint = 
+         (Closeable)Dispatcher.instance.getTarget(objectId);
+      
+      if (endpoint == null)
+      {
+         throw new IllegalStateException("Cannot find object in dispatcher with id " + objectId);
+      }
+      
+      endpoint.closing();
+      
+      return null;
+   }
+
+   public void write(DataOutputStream os) throws Exception
+   {
+      super.write(os);
+      
+      os.flush();
+   }
+}
+
+
+
+

Added: trunk/src/main/org/jboss/jms/wireformat/ConnectionCreateSessionDelegateRequest.java
===================================================================
--- trunk/src/main/org/jboss/jms/wireformat/ConnectionCreateSessionDelegateRequest.java	                        (rev 0)
+++ trunk/src/main/org/jboss/jms/wireformat/ConnectionCreateSessionDelegateRequest.java	2007-02-01 00:10:20 UTC (rev 2119)
@@ -0,0 +1,106 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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 along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.jms.wireformat;
+
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+
+import org.jboss.jms.client.delegate.ClientSessionDelegate;
+import org.jboss.jms.server.endpoint.ConnectionEndpoint;
+
+/**
+ * 
+ * A ConnectionCreateSessionDelegateRequest
+ *
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ * @version <tt>$Revision: 1.1 $</tt>
+ *
+ * $Id$
+ *
+ */
+public class ConnectionCreateSessionDelegateRequest extends RequestSupport
+{
+   private boolean transacted;
+   
+   private int acknowledgmentMode;
+   
+   private boolean xa;
+   
+   public ConnectionCreateSessionDelegateRequest()
+   {      
+   }
+   
+   public ConnectionCreateSessionDelegateRequest(int objectId,
+                                                 byte version,
+                                                 boolean transacted, int ackMode,
+                                                 boolean xa)
+   {
+      super(objectId, PacketSupport.REQ_CONNECTION_CREATESESSIONDELEGATE, version);
+      
+      this.transacted = transacted;
+      
+      this.acknowledgmentMode = ackMode;
+      
+      this.xa = xa;
+   }
+
+   public void read(DataInputStream is) throws Exception
+   {
+      super.read(is);
+      
+      transacted = is.readBoolean();
+      
+      acknowledgmentMode = is.readInt();
+      
+      xa = is.readBoolean();
+   }
+
+   public ResponseSupport serverInvoke() throws Exception
+   {
+      ConnectionEndpoint endpoint = 
+         (ConnectionEndpoint)Dispatcher.instance.getTarget(objectId);
+      
+      if (endpoint == null)
+      {
+         throw new IllegalStateException("Cannot find object in dispatcher with id " + objectId);
+      }
+      
+      return new ConnectionCreateSessionDelegateResponse((ClientSessionDelegate)endpoint.createSessionDelegate(transacted, acknowledgmentMode, xa));         
+   }
+
+   public void write(DataOutputStream os) throws Exception
+   {
+      super.write(os);
+      
+      //Write the args
+           
+      os.writeBoolean(transacted);
+      
+      os.writeInt(acknowledgmentMode);
+      
+      os.writeBoolean(xa);
+      
+      os.flush();
+   }
+
+}
+

Added: trunk/src/main/org/jboss/jms/wireformat/ConnectionCreateSessionDelegateResponse.java
===================================================================
--- trunk/src/main/org/jboss/jms/wireformat/ConnectionCreateSessionDelegateResponse.java	                        (rev 0)
+++ trunk/src/main/org/jboss/jms/wireformat/ConnectionCreateSessionDelegateResponse.java	2007-02-01 00:10:20 UTC (rev 2119)
@@ -0,0 +1,77 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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 along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.jms.wireformat;
+
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+
+import org.jboss.jms.client.delegate.ClientSessionDelegate;
+
+/**
+ * 
+ * A ConnectionCreateSessionDelegateResponse
+ *
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ * @version <tt>$Revision: 1.1 $</tt>
+ *
+ * $Id$
+ *
+ */
+public class ConnectionCreateSessionDelegateResponse extends ResponseSupport
+{
+   private ClientSessionDelegate del;
+   
+   public ConnectionCreateSessionDelegateResponse()
+   {      
+   }
+   
+   public ConnectionCreateSessionDelegateResponse(ClientSessionDelegate del)
+   {
+      super(PacketSupport.RESP_CONNECTION_CREATESESSIONDELEGATE);
+      
+      this.del = del;
+   }
+
+   public Object getResponse()
+   {
+      return del;
+   }
+   
+   public void write(DataOutputStream os) throws Exception
+   {
+      super.write(os);
+      
+      del.write(os);
+      
+      os.flush();
+   }
+   
+   public void read(DataInputStream is) throws Exception
+   {
+      del = new ClientSessionDelegate();
+      
+      del.read(is);
+   }
+
+}
+
+

Added: trunk/src/main/org/jboss/jms/wireformat/ConnectionFactoryCreateConnectionDelegateRequest.java
===================================================================
--- trunk/src/main/org/jboss/jms/wireformat/ConnectionFactoryCreateConnectionDelegateRequest.java	                        (rev 0)
+++ trunk/src/main/org/jboss/jms/wireformat/ConnectionFactoryCreateConnectionDelegateRequest.java	2007-02-01 00:10:20 UTC (rev 2119)
@@ -0,0 +1,154 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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 along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.jms.wireformat;
+
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+
+import org.jboss.jms.server.endpoint.CreateConnectionResult;
+import org.jboss.jms.server.endpoint.ServerConnectionFactoryEndpoint;
+import org.jboss.jms.server.endpoint.advised.ConnectionFactoryAdvised;
+import org.jboss.remoting.callback.ServerInvokerCallbackHandler;
+
+/**
+ * A ConnectionFactoryCreateConnectionDelegateRequest
+ *
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ * @version <tt>$Revision: 1.1 $</tt>
+ *
+ * $Id$
+ *
+ */
+public class ConnectionFactoryCreateConnectionDelegateRequest extends RequestSupport
+{
+   private String username;
+   
+   private String password;
+   
+   private int failedNodeId;
+   
+   private String remotingSessionId;
+   
+   private String clientVMId;
+   
+   private transient ServerInvokerCallbackHandler callbackHandler;
+   
+   public ConnectionFactoryCreateConnectionDelegateRequest()
+   {      
+   }
+
+   public ConnectionFactoryCreateConnectionDelegateRequest(int objectId,
+                                                           byte version,
+                                                           String remotingSessionId,
+                                                           String clientVMId,
+                                                           String username, String password,
+                                                           int failedNodeId)
+   {
+      super(objectId, PacketSupport.REQ_CONNECTIONFACTORY_CREATECONNECTIONDELEGATE, version);
+      
+      this.remotingSessionId = remotingSessionId;
+      
+      this.clientVMId = clientVMId;
+      
+      this.username = username;
+      
+      this.password = password;
+      
+      this.failedNodeId = failedNodeId;
+   }
+
+   public void read(DataInputStream is) throws Exception
+   {
+      super.read(is);
+      
+      remotingSessionId = is.readUTF();
+      
+      clientVMId = is.readUTF();
+      
+      username = readNullableString(is);
+      
+      password = readNullableString(is);
+      
+      failedNodeId = is.readInt();
+   }
+
+   public ResponseSupport serverInvoke() throws Exception
+   {         
+      ConnectionFactoryAdvised advised =
+         (ConnectionFactoryAdvised)Dispatcher.instance.getTarget(objectId);
+      
+      if (advised == null)
+      {
+         throw new IllegalStateException("Cannot find object in dispatcher with id " + objectId);
+      }
+      
+      ServerConnectionFactoryEndpoint endpoint =
+         (ServerConnectionFactoryEndpoint)advised.getEndpoint();
+                     
+      CreateConnectionResult del = 
+         endpoint.createConnectionDelegate(username, password, failedNodeId,
+                                           remotingSessionId, clientVMId, version,
+                                           callbackHandler);
+      
+      return new ConnectionFactoryCreateConnectionDelegateResponse(del);
+   }
+
+   public void write(DataOutputStream os) throws Exception
+   {
+      super.write(os);
+      
+      os.writeUTF(remotingSessionId);
+      
+      os.writeUTF(clientVMId);
+      
+      //Write the args
+           
+      writeNullableString(username, os);
+      
+      writeNullableString(password, os);
+      
+      os.writeInt(failedNodeId); 
+      
+      os.flush();
+   }
+   
+   public String getRemotingSessionID()
+   {
+      return remotingSessionId;
+   }
+   
+   public String getClientVMID()
+   {
+      return clientVMId;
+   }
+   
+   public ServerInvokerCallbackHandler getCallbackHandler()
+   {
+      return this.callbackHandler;
+   }
+   
+   public void setCallbackHandler(ServerInvokerCallbackHandler handler)
+   {
+      this.callbackHandler = handler;
+   }
+
+}

Added: trunk/src/main/org/jboss/jms/wireformat/ConnectionFactoryCreateConnectionDelegateResponse.java
===================================================================
--- trunk/src/main/org/jboss/jms/wireformat/ConnectionFactoryCreateConnectionDelegateResponse.java	                        (rev 0)
+++ trunk/src/main/org/jboss/jms/wireformat/ConnectionFactoryCreateConnectionDelegateResponse.java	2007-02-01 00:10:20 UTC (rev 2119)
@@ -0,0 +1,74 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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 along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.jms.wireformat;
+
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+
+import org.jboss.jms.server.endpoint.CreateConnectionResult;
+
+/**
+ * A ConnectionFactoryCreateConnectionDelegateResponse
+ *
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ * @version <tt>$Revision: 1.1 $</tt>
+ *
+ * $Id$
+ *
+ */
+public class ConnectionFactoryCreateConnectionDelegateResponse extends ResponseSupport
+{
+   private CreateConnectionResult res;
+   
+   public ConnectionFactoryCreateConnectionDelegateResponse()
+   {            
+   }
+   
+   public ConnectionFactoryCreateConnectionDelegateResponse(CreateConnectionResult res)
+   {
+      super(PacketSupport.RESP_CONNECTIONFACTORY_CREATECONNECTIONDELEGATE);
+      
+      this.res = res;
+   }
+
+   public Object getResponse()
+   {
+      return res;
+   }
+   
+   public void write(DataOutputStream os) throws Exception
+   {
+      super.write(os);
+      
+      res.write(os);
+      
+      os.flush();
+   }
+   
+   public void read(DataInputStream is) throws Exception
+   {
+      res = new CreateConnectionResult();
+      
+      res.read(is);
+   }
+
+}

Added: trunk/src/main/org/jboss/jms/wireformat/ConnectionFactoryGetClientAOPStackRequest.java
===================================================================
--- trunk/src/main/org/jboss/jms/wireformat/ConnectionFactoryGetClientAOPStackRequest.java	                        (rev 0)
+++ trunk/src/main/org/jboss/jms/wireformat/ConnectionFactoryGetClientAOPStackRequest.java	2007-02-01 00:10:20 UTC (rev 2119)
@@ -0,0 +1,76 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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 along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.jms.wireformat;
+
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+
+import org.jboss.jms.server.endpoint.ConnectionFactoryEndpoint;
+
+/**
+ * A ConnectionFactoryCreateConnectionDelegateRequest
+ *
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ * @version <tt>$Revision: 1.1 $</tt>
+ *
+ * $Id$
+ *
+ */
+public class ConnectionFactoryGetClientAOPStackRequest extends RequestSupport
+{
+   public ConnectionFactoryGetClientAOPStackRequest()
+   {      
+   }
+   
+   public ConnectionFactoryGetClientAOPStackRequest(int objectId,
+                                                    byte version)
+   {
+      super(objectId, PacketSupport.REQ_CONNECTIONFACTORY_GETCLIENTAOPSTACK, version);
+   }
+
+   public void read(DataInputStream is) throws Exception
+   {
+      super.read(is);  
+   }
+
+   public ResponseSupport serverInvoke() throws Exception
+   {
+      ConnectionFactoryEndpoint endpoint = 
+         (ConnectionFactoryEndpoint)Dispatcher.instance.getTarget(objectId);
+      
+      if (endpoint == null)
+      {
+         throw new IllegalStateException("Cannot find object in dispatcher with id " + objectId);
+      }
+      
+      return new ConnectionFactoryGetClientAOPStackResponse(endpoint.getClientAOPStack());          
+   }
+
+   public void write(DataOutputStream os) throws Exception
+   {
+      super.write(os);                   
+      
+      os.flush();
+   }
+
+}
+

Added: trunk/src/main/org/jboss/jms/wireformat/ConnectionFactoryGetClientAOPStackResponse.java
===================================================================
--- trunk/src/main/org/jboss/jms/wireformat/ConnectionFactoryGetClientAOPStackResponse.java	                        (rev 0)
+++ trunk/src/main/org/jboss/jms/wireformat/ConnectionFactoryGetClientAOPStackResponse.java	2007-02-01 00:10:20 UTC (rev 2119)
@@ -0,0 +1,78 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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 along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.jms.wireformat;
+
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+
+/**
+ * 
+ * A ConnectionFactoryGetClientAOPStackResponse
+ *
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ * @version <tt>$Revision: 1.1 $</tt>
+ *
+ * $Id$
+ *
+ */
+public class ConnectionFactoryGetClientAOPStackResponse extends ResponseSupport
+{
+   private byte[] stack;
+   
+   public ConnectionFactoryGetClientAOPStackResponse()
+   {      
+   }
+   
+   public Object getResponse()
+   {
+      return stack;
+   }
+   
+   public ConnectionFactoryGetClientAOPStackResponse(byte[] stack)
+   {
+      super(PacketSupport.RESP_CONNECTIONFACTORY_GETCLIENTAOPSTACK);
+      
+      this.stack = stack;
+   }
+   
+   public void write(DataOutputStream os) throws Exception
+   {
+      super.write(os);
+      
+      os.writeInt(stack.length);
+      
+      os.write(stack);
+      
+      os.flush();
+   }
+   
+   public void read(DataInputStream is) throws Exception
+   {
+      int len = is.readInt();      
+      
+      stack = new byte[len];      
+      
+      is.readFully(stack);
+   }
+
+}
+

Added: trunk/src/main/org/jboss/jms/wireformat/ConnectionFactoryGetIDBlockRequest.java
===================================================================
--- trunk/src/main/org/jboss/jms/wireformat/ConnectionFactoryGetIDBlockRequest.java	                        (rev 0)
+++ trunk/src/main/org/jboss/jms/wireformat/ConnectionFactoryGetIDBlockRequest.java	2007-02-01 00:10:20 UTC (rev 2119)
@@ -0,0 +1,75 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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 along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.jms.wireformat;
+
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+
+import org.jboss.jms.server.endpoint.ConnectionFactoryEndpoint;
+
+public class ConnectionFactoryGetIDBlockRequest extends RequestSupport
+{
+   private int size;
+   
+   public ConnectionFactoryGetIDBlockRequest()
+   {      
+   }
+
+   public ConnectionFactoryGetIDBlockRequest(int objectId,
+                                             byte version,
+                                             int size)
+   {
+      super(objectId, PacketSupport.REQ_CONNECTIONFACTORY_GETIDBLOCK, version);
+      
+      this.size = size;
+   }
+
+   public void read(DataInputStream is) throws Exception
+   {
+      super.read(is);
+      
+      size = is.readInt();
+   }
+
+   public ResponseSupport serverInvoke() throws Exception
+   {
+      ConnectionFactoryEndpoint endpoint = 
+         (ConnectionFactoryEndpoint)Dispatcher.instance.getTarget(objectId);
+      
+      if (endpoint == null)
+      {
+         throw new IllegalStateException("Cannot find object in dispatcher with id " + objectId);
+      }
+      return new ConnectionFactoryGetIDBlockResponse(endpoint.getIdBlock(size));           
+   }
+
+   public void write(DataOutputStream os) throws Exception
+   {
+      super.write(os);
+      
+      os.writeInt(size);  
+      
+      os.flush();
+   }
+
+}
+

Added: trunk/src/main/org/jboss/jms/wireformat/ConnectionFactoryGetIDBlockResponse.java
===================================================================
--- trunk/src/main/org/jboss/jms/wireformat/ConnectionFactoryGetIDBlockResponse.java	                        (rev 0)
+++ trunk/src/main/org/jboss/jms/wireformat/ConnectionFactoryGetIDBlockResponse.java	2007-02-01 00:10:20 UTC (rev 2119)
@@ -0,0 +1,76 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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 along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.jms.wireformat;
+
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+
+import org.jboss.messaging.core.plugin.IDBlock;
+
+/**
+ * 
+ * A ConnectionFactoryGetIDBlockResponse
+ *
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ * @version <tt>$Revision: 1.1 $</tt>
+ *
+ * $Id$
+ *
+ */
+public class ConnectionFactoryGetIDBlockResponse extends ResponseSupport
+{
+   private IDBlock idBlock;
+   
+   public ConnectionFactoryGetIDBlockResponse()
+   {      
+   }
+   
+   public ConnectionFactoryGetIDBlockResponse(IDBlock block)
+   {
+      super(PacketSupport.RESP_CONNECTIONFACTORY_GETIDBLOCK);
+      
+      this.idBlock = block;
+   }
+
+   public Object getResponse()
+   {
+      return idBlock;
+   }
+   
+   public void write(DataOutputStream os) throws Exception
+   {
+      super.write(os);
+      
+      idBlock.write(os);
+      
+      os.flush();
+   }
+   
+   public void read(DataInputStream is) throws Exception
+   {
+      idBlock = new IDBlock();
+      
+      idBlock.read(is);
+   }
+
+}
+

Added: trunk/src/main/org/jboss/jms/wireformat/ConnectionFactoryUpdate.java
===================================================================
--- trunk/src/main/org/jboss/jms/wireformat/ConnectionFactoryUpdate.java	                        (rev 0)
+++ trunk/src/main/org/jboss/jms/wireformat/ConnectionFactoryUpdate.java	2007-02-01 00:10:20 UTC (rev 2119)
@@ -0,0 +1,186 @@
+/*
+   * JBoss, Home of Professional Open Source
+   * Copyright 2005, JBoss Inc., and individual contributors as indicated
+   * by the @authors tag. See the copyright.txt in the distribution for a
+   * full listing of individual contributors.
+   *
+   * This is free software; you can redistribute it and/or modify it
+   * under the terms of the GNU Lesser General Public License as
+   * published by the Free Software Foundation; either version 2.1 of
+   * the License, or (at your option) any later version.
+   *
+   * This software is distributed in the hope that it will be useful,
+   * but WITHOUT ANY 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 along with this software; if not, write to the Free
+   * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+   * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+   */
+
+package org.jboss.jms.wireformat;
+
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.jboss.jms.client.delegate.ClientConnectionFactoryDelegate;
+
+/**
+ * This class holds the update cluster view sent by the server to client-side clustered connection
+ * factories.
+ *
+ * @author <a href="mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
+ * @author <a href="mailto:tim.fox at jboss.org">Tim Fox</a>
+ * @version <tt>$Revision: 1998 $</tt>
+ *
+ * $Id: ConnectionFactoryUpdateMessage.java 1998 2007-01-19 20:19:05Z clebert.suconic at jboss.com $
+ */
+public class ConnectionFactoryUpdate extends CallbackSupport
+{
+
+   // Constants ------------------------------------------------------------------------------------
+
+   // Attributes -----------------------------------------------------------------------------------
+
+   private ClientConnectionFactoryDelegate[] delegates;
+   
+   private Map failoverMap;
+
+   // Static ---------------------------------------------------------------------------------------
+
+   // Constructors ---------------------------------------------------------------------------------
+
+   public ConnectionFactoryUpdate(ClientConnectionFactoryDelegate[] delegates,
+                                  Map failoverMap)
+   {
+      super(PacketSupport.CONNECTIONFACTORY_UPDATE);
+      
+      this.delegates = delegates;
+      
+      this.failoverMap = failoverMap;
+   }
+   
+   public ConnectionFactoryUpdate()
+   {      
+   }
+
+   // Public ---------------------------------------------------------------------------------------
+
+   public ClientConnectionFactoryDelegate[] getDelegates()
+   {
+      return delegates;
+   }
+
+   public void setDelegates(ClientConnectionFactoryDelegate[] delegates)
+   {
+      this.delegates = delegates;
+   }
+
+   public Map getFailoverMap()
+   {
+      return failoverMap;
+   }
+
+   public void setFailoverMap(Map failoverMap)
+   {
+      this.failoverMap = failoverMap;
+   }
+   
+
+   public String toString()
+   {
+      StringBuffer sb = new StringBuffer("ConnectionFactoryUpdateMessage[");
+
+      for(int i = 0; i < delegates.length; i++)
+      {
+         sb.append(delegates[i]);
+         if (i < delegates.length - 1)
+         {
+            sb.append(',');
+         }
+      }
+
+      sb.append("]");
+
+      return sb.toString();
+   }   
+   
+   // Streamable implementation
+   // ---------------------------------------------------------------     
+
+   public void read(DataInputStream is) throws Exception
+   {
+      super.read(is);
+      
+      int len = is.readInt();
+      
+      delegates = new ClientConnectionFactoryDelegate[len];
+      
+      for (int i = 0; i < len; i++)
+      {
+         delegates[i] = new ClientConnectionFactoryDelegate();
+         
+         delegates[i].read(is);
+      }
+      
+      len = is.readInt();
+      
+      failoverMap = new HashMap(len);
+      
+      for (int c = 0; c < len; c++)
+      {
+         Integer i = new Integer(is.readInt());
+         
+         Integer j = new Integer(is.readInt());
+         
+         failoverMap.put(i, j);
+      }
+   }
+
+   public void write(DataOutputStream os) throws Exception
+   {
+      super.write(os);
+      
+      int len = delegates.length;
+      
+      os.writeInt(len);
+      
+      for (int i = 0; i < len; i++)
+      {
+         delegates[i].write(os);
+      }
+      
+      os.writeInt(failoverMap.size());
+      
+      Iterator iter = failoverMap.entrySet().iterator();
+      
+      while (iter.hasNext())
+      {
+         Map.Entry entry = (Map.Entry)iter.next();
+         
+         Integer i = (Integer)entry.getKey();
+         
+         Integer j = (Integer)entry.getValue();
+         
+         os.writeInt(i.intValue());
+         
+         os.writeInt(j.intValue());
+      }            
+      
+      os.flush();
+   }
+
+   // Package protected ----------------------------------------------------------------------------
+
+   // Protected ------------------------------------------------------------------------------------
+
+   // Private --------------------------------------------------------------------------------------
+
+   // Inner classes --------------------------------------------------------------------------------
+
+}

Added: trunk/src/main/org/jboss/jms/wireformat/ConnectionGetClientIDRequest.java
===================================================================
--- trunk/src/main/org/jboss/jms/wireformat/ConnectionGetClientIDRequest.java	                        (rev 0)
+++ trunk/src/main/org/jboss/jms/wireformat/ConnectionGetClientIDRequest.java	2007-02-01 00:10:20 UTC (rev 2119)
@@ -0,0 +1,78 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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 along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.jms.wireformat;
+
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+
+import org.jboss.jms.server.endpoint.ConnectionEndpoint;
+
+
+/**
+ * 
+ * A ConnectionGetClientIDRequest
+ *
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ * @version <tt>$Revision: 1.1 $</tt>
+ *
+ * $Id$
+ *
+ */
+public class ConnectionGetClientIDRequest extends RequestSupport
+{
+   public ConnectionGetClientIDRequest()
+   {      
+   }
+   
+   public ConnectionGetClientIDRequest(int objectId,
+                                       byte version)
+   {
+      super(objectId, PacketSupport.REQ_CONNECTION_GETCLIENTID, version);
+   }
+
+   public void read(DataInputStream is) throws Exception
+   {
+      super.read(is);
+   }
+
+   public ResponseSupport serverInvoke() throws Exception
+   {
+      ConnectionEndpoint endpoint = 
+         (ConnectionEndpoint)Dispatcher.instance.getTarget(objectId);
+      
+      if (endpoint == null)
+      {
+         throw new IllegalStateException("Cannot find object in dispatcher with id " + objectId);
+      }
+      
+      return new ConnectionGetClientIDResponse(endpoint.getClientID());
+   }
+
+   public void write(DataOutputStream os) throws Exception
+   {
+      super.write(os);
+      
+      os.flush();
+   }
+
+}
+

Added: trunk/src/main/org/jboss/jms/wireformat/ConnectionGetClientIDResponse.java
===================================================================
--- trunk/src/main/org/jboss/jms/wireformat/ConnectionGetClientIDResponse.java	                        (rev 0)
+++ trunk/src/main/org/jboss/jms/wireformat/ConnectionGetClientIDResponse.java	2007-02-01 00:10:20 UTC (rev 2119)
@@ -0,0 +1,73 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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 along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.jms.wireformat;
+
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+
+/**
+ * 
+ * A ConnectionGetClientIDResponse
+ *
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ * @version <tt>$Revision: 1.1 $</tt>
+ *
+ * $Id$
+ *
+ */
+public class ConnectionGetClientIDResponse extends ResponseSupport
+{
+   private String clientID;
+   
+   public ConnectionGetClientIDResponse()
+   {      
+   }
+   
+   public ConnectionGetClientIDResponse(String clientID)
+   {
+      super(PacketSupport.RESP_CONNECTION_GETCLIENTID);
+      
+      this.clientID = clientID;
+   }
+
+   public Object getResponse()
+   {
+      return clientID;
+   }
+   
+   public void write(DataOutputStream os) throws Exception
+   {
+      super.write(os);
+      
+      writeNullableString(clientID, os);
+      
+      os.flush();
+   }
+   
+   public void read(DataInputStream is) throws Exception
+   {
+      clientID = readNullableString(is);
+   }
+
+}
+
+

Added: trunk/src/main/org/jboss/jms/wireformat/ConnectionGetPreparedTransactionsRequest.java
===================================================================
--- trunk/src/main/org/jboss/jms/wireformat/ConnectionGetPreparedTransactionsRequest.java	                        (rev 0)
+++ trunk/src/main/org/jboss/jms/wireformat/ConnectionGetPreparedTransactionsRequest.java	2007-02-01 00:10:20 UTC (rev 2119)
@@ -0,0 +1,77 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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 along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.jms.wireformat;
+
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+
+import org.jboss.jms.server.endpoint.ConnectionEndpoint;
+
+
+/**
+ * 
+ * A ConnectionGetPreparedTransactionsRequest
+ *
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ * @version <tt>$Revision: 1.1 $</tt>
+ *
+ * $Id$
+ *
+ */
+public class ConnectionGetPreparedTransactionsRequest extends RequestSupport
+{
+   ConnectionGetPreparedTransactionsRequest()
+   {      
+   }
+   
+   public ConnectionGetPreparedTransactionsRequest(int objectId,
+                                                   byte version)
+   {
+      super(objectId, PacketSupport.REQ_CONNECTION_GETPREPAREDTRANSACTIONS, version);
+   }
+
+   public void read(DataInputStream is) throws Exception
+   {
+      super.read(is);
+   }
+
+   public ResponseSupport serverInvoke() throws Exception
+   {
+      ConnectionEndpoint endpoint = 
+         (ConnectionEndpoint)Dispatcher.instance.getTarget(objectId);
+      
+      if (endpoint == null)
+      {
+         throw new IllegalStateException("Cannot find object in dispatcher with id " + objectId);
+      }
+      
+      return new ConnectionGetPreparedTransactionsResponse(endpoint.getPreparedTransactions());
+   }
+
+   public void write(DataOutputStream os) throws Exception
+   {
+      super.write(os);
+      
+      os.flush();
+   }
+}
+

Added: trunk/src/main/org/jboss/jms/wireformat/ConnectionGetPreparedTransactionsResponse.java
===================================================================
--- trunk/src/main/org/jboss/jms/wireformat/ConnectionGetPreparedTransactionsResponse.java	                        (rev 0)
+++ trunk/src/main/org/jboss/jms/wireformat/ConnectionGetPreparedTransactionsResponse.java	2007-02-01 00:10:20 UTC (rev 2119)
@@ -0,0 +1,90 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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 along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.jms.wireformat;
+
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+
+import org.jboss.messaging.core.tx.MessagingXid;
+
+/**
+ * 
+ * A ConnectionGetPreparedTransactionsResponse
+ *
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ * @version <tt>$Revision: 1.1 $</tt>
+ *
+ * $Id$
+ *
+ */
+public class ConnectionGetPreparedTransactionsResponse extends ResponseSupport
+{
+   private MessagingXid[] xids;
+   
+   public ConnectionGetPreparedTransactionsResponse()
+   {      
+   }
+   
+   public ConnectionGetPreparedTransactionsResponse(MessagingXid[] xids)
+   {
+      super(PacketSupport.RESP_CONNECTION_GETPREPAREDTRANSACTIONS);
+      
+      this.xids = xids;
+   }
+
+   public Object getResponse()
+   {
+      return xids;
+   }
+   
+   public void write(DataOutputStream os) throws Exception
+   {
+      super.write(os);
+      
+      os.writeInt(xids.length);
+      
+      for (int i = 0; i < xids.length; i++)
+      {
+         xids[i].write(os);
+      }
+      
+      os.flush();
+   }
+   
+   public void read(DataInputStream is) throws Exception
+   {
+      int num = is.readInt();
+      
+      xids = new MessagingXid[num];
+      
+      for (int i = 0; i < num; i++)
+      {
+         xids[i] = new MessagingXid();
+         
+         xids[i].read(is);
+      }
+   }
+
+}
+
+
+

Added: trunk/src/main/org/jboss/jms/wireformat/ConnectionSendTransactionRequest.java
===================================================================
--- trunk/src/main/org/jboss/jms/wireformat/ConnectionSendTransactionRequest.java	                        (rev 0)
+++ trunk/src/main/org/jboss/jms/wireformat/ConnectionSendTransactionRequest.java	2007-02-01 00:10:20 UTC (rev 2119)
@@ -0,0 +1,91 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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 along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.jms.wireformat;
+
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+
+import org.jboss.jms.server.endpoint.ConnectionEndpoint;
+import org.jboss.jms.tx.TransactionRequest;
+
+/**
+ * 
+ * A ConnectionSendTransactionRequest
+ *
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ * @version <tt>$Revision: 1.1 $</tt>
+ *
+ * $Id$
+ *
+ */
+public class ConnectionSendTransactionRequest extends RequestSupport
+{
+   private TransactionRequest req;
+   
+   public ConnectionSendTransactionRequest()
+   {      
+   }
+   
+   public ConnectionSendTransactionRequest(int objectId,
+                                           byte version,
+                                           TransactionRequest req)
+   {
+      super(objectId, PacketSupport.REQ_CONNECTION_SENDTRANSACTION, version);
+      
+      this.req = req;
+   }
+
+   public void read(DataInputStream is) throws Exception
+   {
+      super.read(is);
+      
+      req = new TransactionRequest();
+      
+      req.read(is);
+   }
+
+   public ResponseSupport serverInvoke() throws Exception
+   {
+      ConnectionEndpoint endpoint = 
+         (ConnectionEndpoint)Dispatcher.instance.getTarget(objectId);
+      
+      if (endpoint == null)
+      {
+         throw new IllegalStateException("Cannot find object in dispatcher with id " + objectId);
+      }
+      
+      endpoint.sendTransaction(req);
+      
+      return null;
+   }
+
+   public void write(DataOutputStream os) throws Exception
+   {
+      super.write(os);
+      
+      req.write(os);
+      
+      os.flush();
+   }
+
+}
+

Added: trunk/src/main/org/jboss/jms/wireformat/ConnectionSetClientIDRequest.java
===================================================================
--- trunk/src/main/org/jboss/jms/wireformat/ConnectionSetClientIDRequest.java	                        (rev 0)
+++ trunk/src/main/org/jboss/jms/wireformat/ConnectionSetClientIDRequest.java	2007-02-01 00:10:20 UTC (rev 2119)
@@ -0,0 +1,88 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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 along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.jms.wireformat;
+
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+
+import org.jboss.jms.server.endpoint.ConnectionEndpoint;
+
+/**
+ * 
+ * A ConnectionSetClientIDRequest
+ *
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ * @version <tt>$Revision: 1.1 $</tt>
+ *
+ * $Id$
+ *
+ */
+public class ConnectionSetClientIDRequest extends RequestSupport
+{
+   private String clientID;
+   
+   public ConnectionSetClientIDRequest()
+   {      
+   }
+   
+   public ConnectionSetClientIDRequest(int objectId,
+                                       byte version,
+                                       String clientID)
+   {
+      super(objectId, PacketSupport.REQ_CONNECTION_SETCLIENTID, version);
+      
+      this.clientID = clientID;
+   }
+
+   public void read(DataInputStream is) throws Exception
+   {
+      super.read(is);
+      
+      clientID = is.readUTF();
+   }
+
+   public ResponseSupport serverInvoke() throws Exception
+   {
+      ConnectionEndpoint endpoint = 
+         (ConnectionEndpoint)Dispatcher.instance.getTarget(objectId);
+      
+      if (endpoint == null)
+      {
+         throw new IllegalStateException("Cannot find object in dispatcher with id " + objectId);
+      }
+      
+      endpoint.setClientID(clientID);
+      
+      return null;
+   }
+
+   public void write(DataOutputStream os) throws Exception
+   {
+      super.write(os);
+      
+      os.writeUTF(clientID);
+      
+      os.flush();
+   }
+
+}
+

Added: trunk/src/main/org/jboss/jms/wireformat/ConnectionStartRequest.java
===================================================================
--- trunk/src/main/org/jboss/jms/wireformat/ConnectionStartRequest.java	                        (rev 0)
+++ trunk/src/main/org/jboss/jms/wireformat/ConnectionStartRequest.java	2007-02-01 00:10:20 UTC (rev 2119)
@@ -0,0 +1,81 @@
+
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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 along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.jms.wireformat;
+
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+
+import org.jboss.jms.server.endpoint.ConnectionEndpoint;
+
+
+/**
+ * 
+ * A ConnectionStartRequest
+ *
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ * @version <tt>$Revision: 1.1 $</tt>
+ *
+ * $Id$
+ *
+ */
+public class ConnectionStartRequest extends RequestSupport
+{
+   public ConnectionStartRequest()
+   {      
+   }
+   
+   public ConnectionStartRequest(int objectId,
+                                 byte version)
+   {
+      super(objectId, PacketSupport.REQ_CONNECTION_START, version);
+   }
+
+   public void read(DataInputStream is) throws Exception
+   {
+      super.read(is);
+   }
+
+   public ResponseSupport serverInvoke() throws Exception
+   {
+      ConnectionEndpoint endpoint = 
+         (ConnectionEndpoint)Dispatcher.instance.getTarget(objectId);
+      
+      if (endpoint == null)
+      {
+         throw new IllegalStateException("Cannot find object in dispatcher with id " + objectId);
+      }
+      
+      endpoint.start();
+      
+      return null;
+   }
+
+   public void write(DataOutputStream os) throws Exception
+   {
+      super.write(os);
+      
+      os.flush();
+   }
+
+}
+

Added: trunk/src/main/org/jboss/jms/wireformat/ConnectionStopRequest.java
===================================================================
--- trunk/src/main/org/jboss/jms/wireformat/ConnectionStopRequest.java	                        (rev 0)
+++ trunk/src/main/org/jboss/jms/wireformat/ConnectionStopRequest.java	2007-02-01 00:10:20 UTC (rev 2119)
@@ -0,0 +1,80 @@
+
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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 along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.jms.wireformat;
+
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+
+import org.jboss.jms.server.endpoint.ConnectionEndpoint;
+
+/**
+ * 
+ * A ConnectionStopRequest
+ *
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ * @version <tt>$Revision: 1.1 $</tt>
+ *
+ * $Id$
+ *
+ */
+public class ConnectionStopRequest extends RequestSupport
+{
+   public ConnectionStopRequest()
+   {      
+   }
+   
+   public ConnectionStopRequest(int objectId,
+                                byte version)
+   {
+      super(objectId, PacketSupport.REQ_CONNECTION_STOP, version);
+   }
+
+   public void read(DataInputStream is) throws Exception
+   {
+      super.read(is);
+   }
+
+   public ResponseSupport serverInvoke() throws Exception
+   {
+      ConnectionEndpoint endpoint = 
+         (ConnectionEndpoint)Dispatcher.instance.getTarget(objectId);
+      
+      if (endpoint == null)
+      {
+         throw new IllegalStateException("Cannot find object in dispatcher with id " + objectId);
+      }
+      
+      endpoint.stop();
+      
+      return null;
+   }
+
+   public void write(DataOutputStream os) throws Exception
+   {
+      super.write(os);
+      
+      os.flush();
+   }
+
+}
+

Added: trunk/src/main/org/jboss/jms/wireformat/ConsumerCancelInflightMessagesRequest.java
===================================================================
--- trunk/src/main/org/jboss/jms/wireformat/ConsumerCancelInflightMessagesRequest.java	                        (rev 0)
+++ trunk/src/main/org/jboss/jms/wireformat/ConsumerCancelInflightMessagesRequest.java	2007-02-01 00:10:20 UTC (rev 2119)
@@ -0,0 +1,91 @@
+
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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 along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.jms.wireformat;
+
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+
+import org.jboss.jms.server.endpoint.ConsumerEndpoint;
+
+/**
+ * 
+ * A ConsumerCancelInflightMessagesRequest
+ *
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ * @version <tt>$Revision: 1.1 $</tt>
+ *
+ * $Id$
+ *
+ */
+public class ConsumerCancelInflightMessagesRequest extends RequestSupport
+{
+   private long lastDeliveryId;
+   
+   public ConsumerCancelInflightMessagesRequest()
+   {      
+   }
+   
+   public ConsumerCancelInflightMessagesRequest(int objectId,
+                                    byte version,
+                                    long lastDeliveryId)
+   {
+      super(objectId, PacketSupport.REQ_CONSUMER_CANCELINFLIGHTMESSAGES, version);
+      
+      this.lastDeliveryId = lastDeliveryId;
+   }
+
+   public void read(DataInputStream is) throws Exception
+   {
+      super.read(is);
+      
+      lastDeliveryId = is.readLong();
+   }
+
+   public ResponseSupport serverInvoke() throws Exception
+   {
+      ConsumerEndpoint endpoint = 
+         (ConsumerEndpoint)Dispatcher.instance.getTarget(objectId);
+      
+      if (endpoint == null)
+      {
+         throw new IllegalStateException("Cannot find object in dispatcher with id " + objectId);
+      }
+      
+      endpoint.cancelInflightMessages(lastDeliveryId);
+      
+      return null;
+   }
+
+   public void write(DataOutputStream os) throws Exception
+   {
+      super.write(os);
+      
+      os.writeLong(lastDeliveryId);
+      
+      os.flush();
+   }
+
+}
+
+
+

Added: trunk/src/main/org/jboss/jms/wireformat/ConsumerChangeRateRequest.java
===================================================================
--- trunk/src/main/org/jboss/jms/wireformat/ConsumerChangeRateRequest.java	                        (rev 0)
+++ trunk/src/main/org/jboss/jms/wireformat/ConsumerChangeRateRequest.java	2007-02-01 00:10:20 UTC (rev 2119)
@@ -0,0 +1,104 @@
+
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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 along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.jms.wireformat;
+
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+
+import org.jboss.jms.server.ServerPeer;
+import org.jboss.jms.server.endpoint.ConsumerEndpoint;
+import org.jboss.remoting.InvocationRequest;
+import org.jboss.remoting.invocation.OnewayInvocation;
+
+/**
+ * 
+ * A ConsumerChangeRateRequest
+ *
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ * @version <tt>$Revision: 1.1 $</tt>
+ *
+ * $Id$
+ *
+ */
+public class ConsumerChangeRateRequest extends RequestSupport
+{
+   private float newRate;
+   
+   public ConsumerChangeRateRequest()
+   {      
+   }
+   
+   public ConsumerChangeRateRequest(int objectId,
+                                    byte version,
+                                    float newRate)
+   {
+      super(objectId, PacketSupport.REQ_CONSUMER_CHANGERATE, version);
+      
+      this.newRate = newRate;
+   }
+
+   public void read(DataInputStream is) throws Exception
+   {
+      super.read(is);
+      
+      newRate = is.readFloat();
+   }
+
+   public ResponseSupport serverInvoke() throws Exception
+   {
+      ConsumerEndpoint endpoint = 
+         (ConsumerEndpoint)Dispatcher.instance.getTarget(objectId);
+      
+      if (endpoint == null)
+      {
+         throw new IllegalStateException("Cannot find object in dispatcher with id " + objectId);
+      }
+      
+      endpoint.changeRate(newRate);
+      
+      return null;
+   }
+
+   public void write(DataOutputStream os) throws Exception
+   {
+      super.write(os);
+      
+      os.writeFloat(newRate);
+      
+      os.flush();
+   }
+   
+   public Object getPayload()
+   {
+      OnewayInvocation oi = new OnewayInvocation(this);
+
+      InvocationRequest request =
+         new InvocationRequest(null, ServerPeer.REMOTING_JMS_SUBSYSTEM,
+                               oi, ONE_WAY_METADATA, null, null);
+      
+      return request;     
+   }
+
+}
+
+

Added: trunk/src/main/org/jboss/jms/wireformat/Dispatcher.java
===================================================================
--- trunk/src/main/org/jboss/jms/wireformat/Dispatcher.java	                        (rev 0)
+++ trunk/src/main/org/jboss/jms/wireformat/Dispatcher.java	2007-02-01 00:10:20 UTC (rev 2119)
@@ -0,0 +1,78 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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 along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.jms.wireformat;
+
+import java.util.Map;
+
+import EDU.oswego.cs.dl.util.concurrent.ConcurrentReaderHashMap;
+
+/**
+ * A NewJMSDispatcher
+ *
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ * @version <tt>$Revision: 1.1 $</tt>
+ *
+ * $Id$
+ *
+ */
+public class Dispatcher
+{
+   public static Dispatcher instance = new Dispatcher();
+   
+   private Map targets;
+   
+   private Dispatcher()
+   {
+      targets = new ConcurrentReaderHashMap();
+   }
+   
+   public Object getTarget(int id)
+   {
+      return getTarget(new Integer(id));
+   }
+   
+   public Object getTarget(Integer id)
+   {
+      return targets.get(id);
+   }
+   
+   public void registerTarget(Integer id, Object obj)
+   {
+      targets.put(id, obj);
+   }
+   
+   public void registerTarget(int id, Object obj)
+   {
+      registerTarget(new Integer(id), obj);
+   }
+   
+   public boolean unregisterTarget(Integer id)
+   {
+      return targets.remove(id) != null;
+   }
+   
+   public boolean unregisterTarget(int id)
+   {
+      return unregisterTarget(new Integer(id));
+   }
+   
+}

Added: trunk/src/main/org/jboss/jms/wireformat/NullResponse.java
===================================================================
--- trunk/src/main/org/jboss/jms/wireformat/NullResponse.java	                        (rev 0)
+++ trunk/src/main/org/jboss/jms/wireformat/NullResponse.java	2007-02-01 00:10:20 UTC (rev 2119)
@@ -0,0 +1,64 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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 along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.jms.wireformat;
+
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+
+/**
+ * 
+ * A NullResponse
+ *
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ * @version <tt>$Revision: 1.1 $</tt>
+ *
+ * $Id$
+ *
+ */
+public class NullResponse extends ResponseSupport
+{
+   public NullResponse()
+   {      
+      super(PacketSupport.NULL_RESPONSE);
+   }
+      
+   public Object getResponse()
+   {
+      return null;
+   }
+   
+   public void write(DataOutputStream os) throws Exception
+   {
+      super.write(os);
+      
+      os.flush();
+   }
+   
+   public void read(DataInputStream is) throws Exception
+   {      
+   }
+
+}
+
+
+
+

Added: trunk/src/main/org/jboss/jms/wireformat/PacketSupport.java
===================================================================
--- trunk/src/main/org/jboss/jms/wireformat/PacketSupport.java	                        (rev 0)
+++ trunk/src/main/org/jboss/jms/wireformat/PacketSupport.java	2007-02-01 00:10:20 UTC (rev 2119)
@@ -0,0 +1,414 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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 along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.jms.wireformat;
+
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.jboss.logging.Logger;
+import org.jboss.messaging.util.Streamable;
+import org.jboss.remoting.Client;
+
+/**
+ * A PacketSupport
+ *
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ * @version <tt>$Revision: 1.1 $</tt>
+ *
+ * $Id$
+ *
+ */
+public abstract class PacketSupport implements Streamable
+{
+   private static final Logger log = Logger.getLogger(PacketSupport.class);
+   
+   private static final int NULL = 0;
+   
+   private static final int NOT_NULL = 1;
+   
+   protected static Map ONE_WAY_METADATA;
+   
+   static
+   {
+      ONE_WAY_METADATA = new HashMap();
+      ONE_WAY_METADATA.put(Client.ONEWAY_FLAG, "true");
+   }
+   
+   // First the non request or response packet codes
+   // ==============================================
+   
+   // General serialized object - only used for remoting internal invocations and pings
+   public static final int SERIALIZED = 1;   
+   
+   // A message delivery from server to client
+   public static final int CLIENT_DELIVERY = 2;
+   
+   // A connection factory update message for failover
+   public static final int CONNECTIONFACTORY_UPDATE = 3;
+   
+   // Delivery of a list of polled callbacks - e.g. for HTTP transport
+   public static final int POLLEDCALLBACKS_DELIVERY = 4;
+   
+   
+   // Then the request codes
+   // ======================
+   
+   // ConnectionFactory   
+   // -----------------      
+   
+   public static final int REQ_CONNECTIONFACTORY_CREATECONNECTIONDELEGATE = 100;
+   public static final int REQ_CONNECTIONFACTORY_GETIDBLOCK = 101;
+   public static final int REQ_CONNECTIONFACTORY_GETCLIENTAOPSTACK = 102;
+   
+   // Connection
+   // ----------
+   
+   public static final int REQ_CONNECTION_CREATESESSIONDELEGATE = 201;
+   public static final int REQ_CONNECTION_GETCLIENTID = 202;
+   public static final int REQ_CONNECTION_SETCLIENTID = 203;
+   public static final int REQ_CONNECTION_START = 204;
+   public static final int REQ_CONNECTION_STOP = 205;
+   public static final int REQ_CONNECTION_SENDTRANSACTION = 206;
+   public static final int REQ_CONNECTION_GETPREPAREDTRANSACTIONS = 207;
+   
+   // Session
+   // -------
+   
+   public static final int REQ_SESSION_CREATECONSUMERDELEGATE = 301;
+   public static final int REQ_SESSION_CREATEBROWSERDELEGATE = 302;
+   public static final int REQ_SESSION_CREATEQUEUE = 303;
+   public static final int REQ_SESSION_CREATETOPIC = 304;
+   public static final int REQ_SESSION_ACKNOWLEDGEDELIVERIES = 305;
+   public static final int REQ_SESSION_ACKNOWLEDGEDELIVERY = 306;
+   public static final int REQ_SESSION_CANCELDELIVERIES = 307;
+   public static final int REQ_SESSION_CANCELDELIVERY = 308;
+   public static final int REQ_SESSION_ADDTEMPORARYDESTINATION = 309;
+   public static final int REQ_SESSION_DELETETEMPORARYDESTINATION = 310;
+   public static final int REQ_SESSION_UNSUBSCRIBE = 311;
+   public static final int REQ_SESSION_SEND = 312;
+   public static final int REQ_SESSION_RECOVERDELIVERIES = 313;
+   
+   // Consumer
+   // --------
+   
+   public static final int REQ_CONSUMER_CHANGERATE = 401;
+   public static final int REQ_CONSUMER_CANCELINFLIGHTMESSAGES = 402;
+   
+   // Browser
+   // -------
+   
+   public static final int REQ_BROWSER_NEXTMESSAGE = 501;
+   public static final int REQ_BROWSER_HASNEXTMESSAGE = 502;
+   public static final int REQ_BROWSER_NEXTMESSAGEBLOCK = 503;
+   
+   // Closeable
+   // ---------
+   
+   public static final int REQ_CLOSING = 601;
+   public static final int REQ_CLOSE = 602;
+   
+   
+   // And now the response codes   
+   // ==========================
+   
+   public static final int NULL_RESPONSE = 100001;
+   
+   // Connection factory
+   // -----------------------------------
+   
+   public static final int RESP_CONNECTIONFACTORY_CREATECONNECTIONDELEGATE = 100100;   
+   public static final int RESP_CONNECTIONFACTORY_GETIDBLOCK = 100101;   
+   public static final int RESP_CONNECTIONFACTORY_GETCLIENTAOPSTACK = 100102;
+      
+   // Connection 
+   // -------------------------------------
+   
+   public static final int RESP_CONNECTION_CREATESESSIONDELEGATE = 100200;   
+   public static final int RESP_CONNECTION_GETCLIENTID = 100201;   
+   public static final int RESP_CONNECTION_GETPREPAREDTRANSACTIONS = 100202;
+   
+   // Session 
+   // -------------------------------------
+   
+   public static final int RESP_SESSION_CREATECONSUMERDELEGATE = 100300;   
+   public static final int RESP_SESSION_CREATEBROWSERDELEGATE = 100301;   
+   public static final int RESP_SESSION_CREATEQUEUE = 100302;   
+   public static final int RESP_SESSION_CREATETOPIC = 100303;
+   
+   // Browser
+   // -----------------------
+   
+   public static final int RESP_BROWSER_NEXTMESSAGE = 100500;   
+   public static final int RESP_BROWSER_HASNEXTMESSAGE = 100501;   
+   public static final int RESP_BROWSER_NEXTMESSAGEBLOCK = 100502;
+  
+   
+   public static PacketSupport createPacket(int id)
+   {
+      PacketSupport packet;
+      
+      switch (id)
+      {
+         //We put the performance critical ones at the top
+         case CLIENT_DELIVERY:
+            packet = new ClientDelivery();
+            break;
+         case REQ_SESSION_SEND:
+            packet = new SessionSendRequest();
+            break; 
+         case REQ_SESSION_ACKNOWLEDGEDELIVERY:
+            packet = new SessionAcknowledgeDeliveryRequest();
+            break; 
+         case REQ_SESSION_ACKNOWLEDGEDELIVERIES:
+            packet = new SessionAcknowledgeDeliveriesRequest();
+            break;
+         case REQ_CONNECTION_SENDTRANSACTION:
+            packet = new ConnectionSendTransactionRequest();
+            break;                     
+         case REQ_CONSUMER_CHANGERATE:
+            packet = new ConsumerChangeRateRequest();
+            break;
+         case NULL_RESPONSE:
+            packet = new NullResponse();
+            break;
+      
+         //Then the rest follow
+            
+         // Requests
+         // --------   
+                
+         // Connection Factory
+         case REQ_CONNECTIONFACTORY_CREATECONNECTIONDELEGATE:         
+            packet = new ConnectionFactoryCreateConnectionDelegateRequest();
+            break;         
+         case REQ_CONNECTIONFACTORY_GETIDBLOCK:         
+            packet = new ConnectionFactoryGetIDBlockRequest();
+            break;
+         case REQ_CONNECTIONFACTORY_GETCLIENTAOPSTACK:
+            packet = new ConnectionFactoryGetClientAOPStackRequest();
+            break;
+            
+         // Connection   
+         case REQ_CONNECTION_CREATESESSIONDELEGATE:
+            packet = new ConnectionCreateSessionDelegateRequest();
+            break;
+         case REQ_CONNECTION_GETCLIENTID:
+            packet = new ConnectionGetClientIDRequest();
+            break;
+         case REQ_CONNECTION_SETCLIENTID:
+            packet = new ConnectionSetClientIDRequest();
+            break;
+         case REQ_CONNECTION_START:
+            packet = new ConnectionStartRequest();
+            break;
+         case REQ_CONNECTION_STOP:
+            packet = new ConnectionStopRequest();
+            break;
+         case REQ_CONNECTION_GETPREPAREDTRANSACTIONS:
+            packet = new ConnectionGetPreparedTransactionsRequest();
+            break;
+         
+         // Session
+         case REQ_SESSION_CREATECONSUMERDELEGATE:
+            packet = new SessionCreateConsumerDelegateRequest();
+            break;
+         case REQ_SESSION_CREATEBROWSERDELEGATE:
+            packet = new SessionCreateBrowserDelegateRequest();
+            break;
+         case REQ_SESSION_CREATEQUEUE:
+            packet = new SessionCreateQueueRequest();
+            break;
+         case REQ_SESSION_CREATETOPIC:
+            packet = new SessionCreateTopicRequest();
+            break;   
+           
+         case REQ_SESSION_CANCELDELIVERIES:
+            packet = new SessionCancelDeliveriesRequest();
+            break;
+         case REQ_SESSION_CANCELDELIVERY:
+            packet = new SessionCancelDeliveryRequest();
+            break;   
+         case REQ_SESSION_ADDTEMPORARYDESTINATION:
+            packet = new SessionAddTemporaryDestinationRequest();
+            break;   
+         case REQ_SESSION_DELETETEMPORARYDESTINATION:
+            packet = new SessionDeleteTemporaryDestinationRequest();
+            break;    
+         case REQ_SESSION_UNSUBSCRIBE:
+            packet = new SessionUnsubscribeRequest();
+            break; 
+
+         case REQ_SESSION_RECOVERDELIVERIES:
+            packet = new SessionRecoverDeliveriesRequest();
+            break;  
+            
+         // Consumer
+
+         case REQ_CONSUMER_CANCELINFLIGHTMESSAGES:
+            packet = new ConsumerCancelInflightMessagesRequest();
+            break;
+                        
+         // Browser   
+            
+         case REQ_BROWSER_NEXTMESSAGE:
+            packet = new BrowserNextMessageRequest();
+            break;
+         case REQ_BROWSER_HASNEXTMESSAGE:
+            packet = new BrowserHasNextMessageRequest();
+            break;
+         case REQ_BROWSER_NEXTMESSAGEBLOCK:
+            packet = new BrowserNextMessageBlockRequest();
+            break;
+            
+         // Closeable
+            
+         case REQ_CLOSE:
+            packet = new CloseRequest();
+            break;
+         case REQ_CLOSING:
+            packet = new ClosingRequest();
+            break;
+            
+            
+         // Responses
+         // ---------
+                  
+         // Connection factory
+         case RESP_CONNECTIONFACTORY_CREATECONNECTIONDELEGATE:
+            packet = new ConnectionFactoryCreateConnectionDelegateResponse();
+            break;
+         case RESP_CONNECTIONFACTORY_GETIDBLOCK:
+            packet = new ConnectionFactoryGetIDBlockResponse();
+            break;
+         case RESP_CONNECTIONFACTORY_GETCLIENTAOPSTACK:
+            packet = new ConnectionFactoryGetClientAOPStackResponse();
+            break;            
+            
+         // Connection 
+         case RESP_CONNECTION_CREATESESSIONDELEGATE:
+            packet = new ConnectionCreateSessionDelegateResponse();
+            break;
+         case RESP_CONNECTION_GETCLIENTID:
+            packet = new ConnectionGetClientIDResponse();
+            break;            
+         case RESP_CONNECTION_GETPREPAREDTRANSACTIONS:
+            packet = new ConnectionGetPreparedTransactionsResponse();
+            break;
+            
+         // Session
+         case RESP_SESSION_CREATECONSUMERDELEGATE:
+            packet = new SessionCreateConsumerDelegateResponse();
+            break;
+         case RESP_SESSION_CREATEBROWSERDELEGATE:
+            packet = new SessionCreateBrowserDelegateResponse();
+            break;            
+         case RESP_SESSION_CREATEQUEUE:
+            packet = new SessionCreateQueueResponse();
+            break;  
+         case RESP_SESSION_CREATETOPIC:
+            packet = new SessionCreateTopicResponse();
+            break; 
+            
+         // Browser
+         case RESP_BROWSER_NEXTMESSAGE:
+            packet = new BrowserNextMessageResponse();
+            break;
+         case RESP_BROWSER_HASNEXTMESSAGE:
+            packet = new BrowserHasNextMessageResponse();
+            break;            
+         case RESP_BROWSER_NEXTMESSAGEBLOCK:
+            packet = new BrowserNextMessageBlockResponse();
+            break;     
+            
+            
+         case SERIALIZED:
+            packet = new SerializedPacket();
+            break;            
+         case CONNECTIONFACTORY_UPDATE:
+            packet = new ConnectionFactoryUpdate();
+            break;
+         case POLLEDCALLBACKS_DELIVERY:
+            packet = new PolledCallbacksDelivery();
+            break;
+                        
+         default:
+           throw new IllegalArgumentException("Invalid packet type: " + id);
+      }
+      
+      return packet;
+   }
+      
+   protected int methodId;
+   
+   public PacketSupport()
+   {      
+   }
+   
+   public PacketSupport(int methodID)   
+   {      
+      this.methodId = methodID;
+   }
+   
+   public Object getPayload()
+   {
+      return this;
+   }
+   
+   public void write(DataOutputStream os) throws Exception
+   {      
+      os.writeInt(methodId);      
+   }
+   
+   public abstract void read(DataInputStream is) throws Exception;
+         
+   protected void writeNullableString(String s, DataOutputStream os) throws Exception
+   {
+      if (s == null)
+      {
+         os.writeByte(NULL);
+      }
+      else
+      {
+         os.writeByte(NOT_NULL);
+         
+         os.writeUTF(s);
+      }
+   }
+   
+   protected String readNullableString(DataInputStream is) throws Exception
+   {
+      byte b = is.readByte();
+      
+      if (b == NULL)
+      {
+         return null;
+      }
+      else
+      {
+         String s = is.readUTF();
+         
+         return s;
+      }
+   }
+}

Added: trunk/src/main/org/jboss/jms/wireformat/PolledCallbacksDelivery.java
===================================================================
--- trunk/src/main/org/jboss/jms/wireformat/PolledCallbacksDelivery.java	                        (rev 0)
+++ trunk/src/main/org/jboss/jms/wireformat/PolledCallbacksDelivery.java	2007-02-01 00:10:20 UTC (rev 2119)
@@ -0,0 +1,133 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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 along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.jms.wireformat;
+
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.jboss.jms.message.JBossMessage;
+import org.jboss.jms.message.MessageProxy;
+import org.jboss.messaging.core.message.MessageFactory;
+import org.jboss.remoting.InvocationResponse;
+import org.jboss.remoting.callback.Callback;
+
+/**
+ * A PolledCallbacksDelivery
+ *
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ * @version <tt>$Revision: 1.1 $</tt>
+ *
+ * $Id$
+ *
+ */
+public class PolledCallbacksDelivery extends PacketSupport
+{
+   private List callbacks;
+   
+   private String sessionID;
+   
+   public PolledCallbacksDelivery()
+   {      
+   }
+   
+   public PolledCallbacksDelivery(List callbacks, String sessionID)
+   {
+      super(PacketSupport.POLLEDCALLBACKS_DELIVERY);
+      
+      this.callbacks = callbacks;
+      
+      this.sessionID = sessionID;
+   }
+
+   public void read(DataInputStream is) throws Exception
+   {
+      sessionID = is.readUTF();
+      
+      int len = is.readInt();
+      
+      callbacks = new ArrayList(len);
+      
+      for (int i = 0; i < len; i++)
+      {
+         int consumerId = is.readInt();
+         
+         byte type = is.readByte();
+         
+         int deliveryCount = is.readInt();
+         
+         long deliveryId = is.readLong();
+         
+         JBossMessage msg = (JBossMessage)MessageFactory.createMessage(type);
+
+         msg.read(is);
+
+         MessageProxy mp = JBossMessage.createThinDelegate(deliveryId, msg, deliveryCount); 
+         
+         ClientDelivery delivery = new ClientDelivery(mp, consumerId);
+         
+         Callback cb = new Callback(delivery);
+                  
+         callbacks.add(cb);
+      }      
+   }
+   
+   public void write(DataOutputStream os) throws Exception
+   {
+      super.write(os);
+      
+      os.writeUTF(sessionID);
+      
+      os.writeInt(callbacks.size());
+      
+      Iterator iter = callbacks.iterator();
+      
+      while (iter.hasNext())
+      {
+         Callback cb = (Callback)iter.next();
+         
+         ClientDelivery cd = (ClientDelivery)cb.getParameter();
+         
+         os.writeInt(cd.getConsumerId());
+         
+         MessageProxy mp = cd.getMessage();
+         
+         os.writeByte(mp.getMessage().getType());
+
+         os.writeInt(mp.getDeliveryCount());
+         
+         os.writeLong(mp.getDeliveryId());
+
+         mp.getMessage().write(os);  
+      }
+      
+      os.flush();
+   }
+   
+   public Object getPayload()
+   {
+      return new InvocationResponse(sessionID, callbacks, false, null);
+   }
+
+}

Added: trunk/src/main/org/jboss/jms/wireformat/RequestSupport.java
===================================================================
--- trunk/src/main/org/jboss/jms/wireformat/RequestSupport.java	                        (rev 0)
+++ trunk/src/main/org/jboss/jms/wireformat/RequestSupport.java	2007-02-01 00:10:20 UTC (rev 2119)
@@ -0,0 +1,102 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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 along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.jms.wireformat;
+
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+
+import org.jboss.jms.server.ServerPeer;
+import org.jboss.remoting.InvocationRequest;
+
+/**
+ * 
+ * A PacketSupport
+ *
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ * @version <tt>$Revision: 1.1 $</tt>
+ *
+ * $Id$
+ *
+ */
+public abstract class RequestSupport extends PacketSupport
+{    
+   protected int objectId;
+  
+   protected byte version;
+   
+   public RequestSupport()
+   {      
+   }  
+   
+   public RequestSupport(int objectId, int methodId, byte version)
+   {
+      super(methodId);
+      
+      this.objectId = objectId;
+            
+      this.version = version;
+   }
+   
+   public Object getPayload()
+   {
+      //Wrap this in an InvocationRequest
+         
+      InvocationRequest req = new InvocationRequest(null, ServerPeer.REMOTING_JMS_SUBSYSTEM,
+                                                    this, null, null, null);
+      
+      return req;
+   }
+   
+   public int getMethodId()
+   {
+      return methodId;
+   }
+
+   public int getObjectId()
+   {
+      return objectId;
+   }
+
+   public byte getVersion()
+   {
+      return version;
+   }
+         
+   public abstract ResponseSupport serverInvoke() throws Exception;
+      
+   public void write(DataOutputStream os) throws Exception
+   {      
+      super.write(os);
+      
+      os.writeByte(version);
+
+      os.writeInt(objectId);
+   }
+   
+   public void read(DataInputStream is) throws Exception
+   {     
+      version = is.readByte();
+      
+      objectId = is.readInt();
+   }
+   
+}

Added: trunk/src/main/org/jboss/jms/wireformat/ResponseSupport.java
===================================================================
--- trunk/src/main/org/jboss/jms/wireformat/ResponseSupport.java	                        (rev 0)
+++ trunk/src/main/org/jboss/jms/wireformat/ResponseSupport.java	2007-02-01 00:10:20 UTC (rev 2119)
@@ -0,0 +1,58 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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 along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.jms.wireformat;
+
+import org.jboss.remoting.InvocationResponse;
+
+
+
+/**
+ * A ResponseSupport
+ *
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ * @version <tt>$Revision: 1.1 $</tt>
+ *
+ * $Id$
+ *
+ */
+public abstract class ResponseSupport extends PacketSupport
+{      
+   public ResponseSupport(int id)
+   {
+      super(id);
+   }
+   
+   public ResponseSupport()
+   {      
+   }
+   
+   public abstract Object getResponse();
+   
+   public Object getPayload()
+   {
+      //Wrap this in an InvocationResponse     
+      InvocationResponse resp = new InvocationResponse(null, this, false, null);
+      
+      return resp;
+   }
+
+}

Added: trunk/src/main/org/jboss/jms/wireformat/SerializedPacket.java
===================================================================
--- trunk/src/main/org/jboss/jms/wireformat/SerializedPacket.java	                        (rev 0)
+++ trunk/src/main/org/jboss/jms/wireformat/SerializedPacket.java	2007-02-01 00:10:20 UTC (rev 2119)
@@ -0,0 +1,117 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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 along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.jms.wireformat;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+
+import org.jboss.logging.Logger;
+
+/**
+ * For carrying a remoting non JBM invocation across the wire
+ * 
+ * Also used for internal invocation request return values e.g. PONG
+ *
+ * This would be used for pings, disconnect, addlistener, removelistener etc
+ *
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ * @version <tt>$Revision: 1.1 $</tt>
+ *
+ * $Id$
+ *
+ */
+public class SerializedPacket extends PacketSupport
+{
+   private static final Logger log = Logger.getLogger(SerializedPacket.class);
+   
+   
+   private Object payload;
+   
+   public SerializedPacket()
+   {      
+   }
+   
+   public SerializedPacket(Object payload)
+   {
+      super(PacketSupport.SERIALIZED);
+      
+      this.payload = payload;
+   }
+   
+   public Object getPayload()
+   {      
+      return payload;           
+   }
+
+   public void read(DataInputStream is) throws Exception
+   {
+//      int len = is.readInt();
+//      
+//      byte[] bytes = new byte[len];
+//      
+//      is.readFully(bytes);
+//      
+//      ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
+//      
+//      ObjectInputStream ois = new ObjectInputStream(bais);
+//      
+//      payload = ois.readObject();         
+      
+      ObjectInputStream ois = new ObjectInputStream(is);
+      
+      payload = ois.readObject();   
+   }
+
+   public void write(DataOutputStream os) throws Exception
+   {
+      super.write(os);
+      
+//      ByteArrayOutputStream baos = new ByteArrayOutputStream();
+//      
+//      ObjectOutputStream oos = new ObjectOutputStream(baos);
+//      
+//      log.info("writing payload " + payload);
+//      
+//      oos.writeObject(payload);
+//      
+//      oos.flush();
+//      
+//      byte[] bytes = baos.toByteArray();
+//      
+//      os.writeInt(bytes.length);
+//      
+//      os.write(bytes);
+//            
+//      os.flush();
+      
+      ObjectOutputStream oos = new ObjectOutputStream(os);
+      
+      oos.writeObject(payload);
+    
+      oos.flush();
+   }
+
+}

Added: trunk/src/main/org/jboss/jms/wireformat/SessionAcknowledgeDeliveriesRequest.java
===================================================================
--- trunk/src/main/org/jboss/jms/wireformat/SessionAcknowledgeDeliveriesRequest.java	                        (rev 0)
+++ trunk/src/main/org/jboss/jms/wireformat/SessionAcknowledgeDeliveriesRequest.java	2007-02-01 00:10:20 UTC (rev 2119)
@@ -0,0 +1,116 @@
+
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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 along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.jms.wireformat;
+
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.jboss.jms.server.endpoint.Ack;
+import org.jboss.jms.server.endpoint.ConsumerEndpoint;
+import org.jboss.jms.server.endpoint.DefaultAck;
+import org.jboss.jms.server.endpoint.SessionEndpoint;
+
+
+/**
+ * 
+ * A SessionAcknowledgeDeliveriesRequest
+ *
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ * @version <tt>$Revision: 1.1 $</tt>
+ *
+ * $Id$
+ *
+ */
+public class SessionAcknowledgeDeliveriesRequest extends RequestSupport
+{
+   private List acks;
+   
+   public SessionAcknowledgeDeliveriesRequest()
+   {      
+   }
+   
+   public SessionAcknowledgeDeliveriesRequest(int objectId,
+                                              byte version,
+                                              List acks)
+   {
+      super(objectId, PacketSupport.REQ_SESSION_ACKNOWLEDGEDELIVERIES, version);
+      
+      this.acks = acks;
+   }
+
+   public void read(DataInputStream is) throws Exception
+   {
+      super.read(is);
+      
+      int size = is.readInt();
+      
+      acks = new ArrayList(size);
+      
+      for (int i = 0; i < size; i++)
+      {
+         long deliveryId = is.readLong();
+         
+         DefaultAck ack = new DefaultAck(deliveryId);
+         
+         acks.add(ack);
+      }
+   }
+
+   public ResponseSupport serverInvoke() throws Exception
+   {
+      SessionEndpoint endpoint = 
+         (SessionEndpoint)Dispatcher.instance.getTarget(objectId);
+      
+      if (endpoint == null)
+      {
+         throw new IllegalStateException("Cannot find object in dispatcher with id " + objectId);
+      }
+      
+      endpoint.acknowledgeDeliveries(acks);
+      
+      return null;
+   }
+
+   public void write(DataOutputStream os) throws Exception
+   {
+      super.write(os);
+      
+      os.writeInt(acks.size());
+
+      Iterator iter = acks.iterator();
+
+      while (iter.hasNext())
+      {
+         Ack ack = (Ack)iter.next();
+         
+         os.writeLong(ack.getDeliveryID());
+      }
+      
+      os.flush();
+   }
+
+}
+

Added: trunk/src/main/org/jboss/jms/wireformat/SessionAcknowledgeDeliveryRequest.java
===================================================================
--- trunk/src/main/org/jboss/jms/wireformat/SessionAcknowledgeDeliveryRequest.java	                        (rev 0)
+++ trunk/src/main/org/jboss/jms/wireformat/SessionAcknowledgeDeliveryRequest.java	2007-02-01 00:10:20 UTC (rev 2119)
@@ -0,0 +1,94 @@
+
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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 along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.jms.wireformat;
+
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+
+import org.jboss.jms.server.endpoint.Ack;
+import org.jboss.jms.server.endpoint.DefaultAck;
+import org.jboss.jms.server.endpoint.SessionEndpoint;
+
+/**
+ * 
+ * A SessionAcknowledgeDeliveryRequest
+ *
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ * @version <tt>$Revision: 1.1 $</tt>
+ *
+ * $Id$
+ *
+ */
+public class SessionAcknowledgeDeliveryRequest extends RequestSupport
+{
+   private Ack ack;
+   
+   public SessionAcknowledgeDeliveryRequest()
+   {      
+   }
+   
+   public SessionAcknowledgeDeliveryRequest(int objectId,
+                                            byte version,
+                                            Ack ack)
+   {
+      super(objectId, PacketSupport.REQ_SESSION_ACKNOWLEDGEDELIVERY, version);
+      
+      this.ack = ack;
+   }
+
+   public void read(DataInputStream is) throws Exception
+   {
+      super.read(is);
+      
+      long deliveryId = is.readLong();
+         
+      ack = new DefaultAck(deliveryId);
+   }
+
+   public ResponseSupport serverInvoke() throws Exception
+   {
+      SessionEndpoint endpoint = 
+         (SessionEndpoint)Dispatcher.instance.getTarget(objectId);
+      
+      if (endpoint == null)
+      {
+         throw new IllegalStateException("Cannot find object in dispatcher with id " + objectId);
+      }
+      
+      endpoint.acknowledgeDelivery(ack);
+      
+      return null;
+   }
+
+   public void write(DataOutputStream os) throws Exception
+   {
+      super.write(os);
+      
+      os.writeLong(ack.getDeliveryID());      
+      
+      os.flush();
+   }
+
+}
+
+

Added: trunk/src/main/org/jboss/jms/wireformat/SessionAddTemporaryDestinationRequest.java
===================================================================
--- trunk/src/main/org/jboss/jms/wireformat/SessionAddTemporaryDestinationRequest.java	                        (rev 0)
+++ trunk/src/main/org/jboss/jms/wireformat/SessionAddTemporaryDestinationRequest.java	2007-02-01 00:10:20 UTC (rev 2119)
@@ -0,0 +1,93 @@
+
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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 along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.jms.wireformat;
+
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+
+import org.jboss.jms.destination.JBossDestination;
+import org.jboss.jms.server.endpoint.SessionEndpoint;
+
+/**
+ * 
+ * A SessionAddTemporaryDestinationRequest
+ *
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ * @version <tt>$Revision: 1.1 $</tt>
+ *
+ * $Id$
+ *
+ */
+public class SessionAddTemporaryDestinationRequest extends RequestSupport
+{
+   private JBossDestination dest;
+   
+   public SessionAddTemporaryDestinationRequest()
+   {      
+   }
+   
+   public SessionAddTemporaryDestinationRequest(int objectId,
+                                                byte version,
+                                                JBossDestination dest)
+   {
+      super(objectId, PacketSupport.REQ_SESSION_ADDTEMPORARYDESTINATION, version);
+      
+      this.dest = dest;
+   }
+
+   public void read(DataInputStream is) throws Exception
+   {
+      super.read(is);
+      
+      dest = JBossDestination.readDestination(is);      
+   }
+
+   public ResponseSupport serverInvoke() throws Exception
+   {
+      SessionEndpoint endpoint = 
+         (SessionEndpoint)Dispatcher.instance.getTarget(objectId);
+      
+      if (endpoint == null)
+      {
+         throw new IllegalStateException("Cannot find object in dispatcher with id " + objectId);
+      }
+      
+      endpoint.addTemporaryDestination(dest);
+      
+      return null;
+   }
+
+   public void write(DataOutputStream os) throws Exception
+   {
+      super.write(os);
+      
+      JBossDestination.writeDestination(os, dest); 
+      
+      os.flush();
+   }
+
+}
+
+
+
+

Added: trunk/src/main/org/jboss/jms/wireformat/SessionCancelDeliveriesRequest.java
===================================================================
--- trunk/src/main/org/jboss/jms/wireformat/SessionCancelDeliveriesRequest.java	                        (rev 0)
+++ trunk/src/main/org/jboss/jms/wireformat/SessionCancelDeliveriesRequest.java	2007-02-01 00:10:20 UTC (rev 2119)
@@ -0,0 +1,126 @@
+
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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 along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.jms.wireformat;
+
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.jboss.jms.server.endpoint.Cancel;
+import org.jboss.jms.server.endpoint.DefaultCancel;
+import org.jboss.jms.server.endpoint.SessionEndpoint;
+
+/**
+ * 
+ * A SessionCancelDeliveriesRequest
+ *
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ * @version <tt>$Revision: 1.1 $</tt>
+ *
+ * $Id$
+ *
+ */
+public class SessionCancelDeliveriesRequest extends RequestSupport
+{
+   private List cancels;
+   
+   public SessionCancelDeliveriesRequest()
+   {      
+   }
+   
+   public SessionCancelDeliveriesRequest(int objectId,
+                                         byte version,
+                                         List cancels)
+   {
+      super(objectId, PacketSupport.REQ_SESSION_CANCELDELIVERIES, version);
+      
+      this.cancels = cancels;
+   }
+
+   public void read(DataInputStream is) throws Exception
+   {
+      super.read(is);
+      
+      int size = is.readInt();
+      
+      cancels = new ArrayList(size);
+      
+      for (int i = 0; i < size; i++)
+      {
+         long deliveryId = is.readLong();
+         
+         int deliveryCount = is.readInt();
+         
+         boolean expired = is.readBoolean();
+         
+         boolean reachedMax = is.readBoolean();
+         
+         DefaultCancel cancel = new DefaultCancel(deliveryId, deliveryCount, expired, reachedMax);
+         
+         cancels.add(cancel);
+      }
+   }
+
+   public ResponseSupport serverInvoke() throws Exception
+   {
+      SessionEndpoint endpoint = 
+         (SessionEndpoint)Dispatcher.instance.getTarget(objectId);
+      
+      if (endpoint == null)
+      {
+         throw new IllegalStateException("Cannot find object in dispatcher with id " + objectId);
+      }
+      
+      endpoint.cancelDeliveries(cancels);
+      
+      return null;
+   }
+
+   public void write(DataOutputStream os) throws Exception
+   {
+      super.write(os);
+      
+      os.writeInt(cancels.size());
+
+      Iterator iter = cancels.iterator();
+
+      while (iter.hasNext())
+      {
+         Cancel cancel = (Cancel)iter.next();
+         
+         os.writeLong(cancel.getDeliveryId());
+         
+         os.writeInt(cancel.getDeliveryCount());
+         
+         os.writeBoolean(cancel.isExpired());
+         
+         os.writeBoolean(cancel.isReachedMaxDeliveryAttempts());         
+      }
+      
+      os.flush();
+   }
+
+}
+

Added: trunk/src/main/org/jboss/jms/wireformat/SessionCancelDeliveryRequest.java
===================================================================
--- trunk/src/main/org/jboss/jms/wireformat/SessionCancelDeliveryRequest.java	                        (rev 0)
+++ trunk/src/main/org/jboss/jms/wireformat/SessionCancelDeliveryRequest.java	2007-02-01 00:10:20 UTC (rev 2119)
@@ -0,0 +1,107 @@
+
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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 along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.jms.wireformat;
+
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+
+import org.jboss.jms.server.endpoint.Cancel;
+import org.jboss.jms.server.endpoint.DefaultCancel;
+import org.jboss.jms.server.endpoint.SessionEndpoint;
+
+/**
+ * 
+ * A SessionCancelDeliveryRequest
+ *
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ * @version <tt>$Revision: 1.1 $</tt>
+ *
+ * $Id$
+ *
+ */
+public class SessionCancelDeliveryRequest extends RequestSupport
+{
+   private Cancel cancel;
+      
+   public SessionCancelDeliveryRequest()
+   {      
+   }
+   
+   public SessionCancelDeliveryRequest(int objectId,
+                                       byte version,
+                                       Cancel cancel)
+   {
+      super(objectId, PacketSupport.REQ_SESSION_CANCELDELIVERY, version);
+      
+      this.cancel = cancel;
+   }
+
+   public void read(DataInputStream is) throws Exception
+   {
+      super.read(is);
+      
+      long deliveryId = is.readLong();
+      
+      int deliveryCount = is.readInt();
+      
+      boolean expired = is.readBoolean();
+      
+      boolean reachedMax = is.readBoolean();
+      
+      cancel = new DefaultCancel(deliveryId, deliveryCount, expired, reachedMax);      
+   }
+
+   public ResponseSupport serverInvoke() throws Exception
+   {
+      SessionEndpoint endpoint = 
+         (SessionEndpoint)Dispatcher.instance.getTarget(objectId);
+      
+      if (endpoint == null)
+      {
+         throw new IllegalStateException("Cannot find object in dispatcher with id " + objectId);
+      }
+      
+      endpoint.cancelDelivery(cancel);
+      
+      return null;
+   }
+
+   public void write(DataOutputStream os) throws Exception
+   {
+      super.write(os);
+      
+      os.writeLong(cancel.getDeliveryId());
+      
+      os.writeInt(cancel.getDeliveryCount());
+      
+      os.writeBoolean(cancel.isExpired());
+      
+      os.writeBoolean(cancel.isReachedMaxDeliveryAttempts());  
+      
+      os.flush();
+   }
+
+}
+
+
+

Added: trunk/src/main/org/jboss/jms/wireformat/SessionCreateBrowserDelegateRequest.java
===================================================================
--- trunk/src/main/org/jboss/jms/wireformat/SessionCreateBrowserDelegateRequest.java	                        (rev 0)
+++ trunk/src/main/org/jboss/jms/wireformat/SessionCreateBrowserDelegateRequest.java	2007-02-01 00:10:20 UTC (rev 2119)
@@ -0,0 +1,104 @@
+
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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 along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.jms.wireformat;
+
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+
+import org.jboss.jms.client.delegate.ClientBrowserDelegate;
+import org.jboss.jms.destination.JBossDestination;
+import org.jboss.jms.server.endpoint.SessionEndpoint;
+
+
+/**
+ * 
+ * A SessionCreateBrowserDelegateRequest
+ *
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ * @version <tt>$Revision: 1.1 $</tt>
+ *
+ * $Id$
+ *
+ */
+public class SessionCreateBrowserDelegateRequest extends RequestSupport
+{
+   private JBossDestination dest;
+   private String selector; 
+   private long failoverChannelID;
+   
+   public SessionCreateBrowserDelegateRequest()
+   {      
+   }
+   
+   public SessionCreateBrowserDelegateRequest(int objectId,
+                                               byte version,
+                                               JBossDestination destination,
+                                               String selector,
+                                               long failoverChannelID)
+   {
+      super(objectId, PacketSupport.REQ_SESSION_CREATEBROWSERDELEGATE, version);
+      
+      this.dest = destination;
+      this.selector = selector;
+      this.failoverChannelID = failoverChannelID;
+   }
+
+   public void read(DataInputStream is) throws Exception
+   {
+      super.read(is);
+      
+      dest = JBossDestination.readDestination(is);
+      
+      selector = readNullableString(is);
+                 
+      failoverChannelID = is.readLong();
+   }
+
+   public ResponseSupport serverInvoke() throws Exception
+   {
+      SessionEndpoint endpoint = 
+         (SessionEndpoint)Dispatcher.instance.getTarget(objectId);
+      
+      if (endpoint == null)
+      {
+         throw new IllegalStateException("Cannot find object in dispatcher with id " + objectId);
+      }
+      
+      return new SessionCreateBrowserDelegateResponse((ClientBrowserDelegate)endpoint.createBrowserDelegate(dest, selector, failoverChannelID));
+   }
+
+   public void write(DataOutputStream os) throws Exception
+   {
+      super.write(os);
+      
+      JBossDestination.writeDestination(os, dest);
+      
+      writeNullableString(selector, os);
+
+      os.writeLong(failoverChannelID);
+      
+      os.flush();
+   }
+
+}
+

Added: trunk/src/main/org/jboss/jms/wireformat/SessionCreateBrowserDelegateResponse.java
===================================================================
--- trunk/src/main/org/jboss/jms/wireformat/SessionCreateBrowserDelegateResponse.java	                        (rev 0)
+++ trunk/src/main/org/jboss/jms/wireformat/SessionCreateBrowserDelegateResponse.java	2007-02-01 00:10:20 UTC (rev 2119)
@@ -0,0 +1,76 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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 along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.jms.wireformat;
+
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+
+import org.jboss.jms.client.delegate.ClientBrowserDelegate;
+
+/**
+ * 
+ * A SessionCreateBrowserDelegateResponse
+ *
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ * @version <tt>$Revision: 1.1 $</tt>
+ *
+ * $Id$
+ *
+ */
+public class SessionCreateBrowserDelegateResponse extends ResponseSupport
+{
+   private ClientBrowserDelegate del;
+   
+   public SessionCreateBrowserDelegateResponse()
+   {      
+   }
+   
+   public SessionCreateBrowserDelegateResponse(ClientBrowserDelegate del)
+   {
+      super(PacketSupport.RESP_SESSION_CREATEBROWSERDELEGATE);
+      
+      this.del = del;
+   }
+
+   public Object getResponse()
+   {
+      return del;
+   }
+   
+   public void write(DataOutputStream os) throws Exception
+   {
+      super.write(os);
+      
+      del.write(os);
+      
+      os.flush();
+   }
+   
+   public void read(DataInputStream is) throws Exception
+   {
+      del = new ClientBrowserDelegate();
+      
+      del.read(is);
+   }
+
+}
+

Added: trunk/src/main/org/jboss/jms/wireformat/SessionCreateConsumerDelegateRequest.java
===================================================================
--- trunk/src/main/org/jboss/jms/wireformat/SessionCreateConsumerDelegateRequest.java	                        (rev 0)
+++ trunk/src/main/org/jboss/jms/wireformat/SessionCreateConsumerDelegateRequest.java	2007-02-01 00:10:20 UTC (rev 2119)
@@ -0,0 +1,123 @@
+
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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 along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.jms.wireformat;
+
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+
+import org.jboss.jms.client.delegate.ClientConsumerDelegate;
+import org.jboss.jms.destination.JBossDestination;
+import org.jboss.jms.server.endpoint.SessionEndpoint;
+
+/**
+ * 
+ * A SessionCreateConsumerDelegateRequest
+ *
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ * @version <tt>$Revision: 1.1 $</tt>
+ *
+ * $Id$
+ *
+ */
+public class SessionCreateConsumerDelegateRequest extends RequestSupport
+{
+
+   private JBossDestination dest;
+   private String selector;
+   private boolean noLocal;
+   private String subName;
+   private boolean connectionConsumer;
+   private long failoverChannelID;
+   
+   public SessionCreateConsumerDelegateRequest()
+   {      
+   }
+   
+   public SessionCreateConsumerDelegateRequest(int objectId,
+                                               byte version,
+                                               JBossDestination destination,
+                                               String selector, boolean noLocal,
+                                               String subName, boolean connectionConsumer,
+                                               long failoverChannelID)
+   {
+      super(objectId, PacketSupport.REQ_SESSION_CREATECONSUMERDELEGATE, version);
+      
+      this.dest = destination;
+      this.selector = selector;
+      this.noLocal = noLocal;
+      this.subName = subName;
+      this.connectionConsumer = connectionConsumer;
+      this.failoverChannelID = failoverChannelID;
+   }
+
+   public void read(DataInputStream is) throws Exception
+   {
+      super.read(is);
+      
+      dest = JBossDestination.readDestination(is);
+      
+      selector = readNullableString(is);
+      
+      noLocal = is.readBoolean();
+      
+      subName = readNullableString(is);
+      
+      connectionConsumer = is.readBoolean();
+      
+      failoverChannelID = is.readLong();
+   }
+
+   public ResponseSupport serverInvoke() throws Exception
+   {
+      SessionEndpoint endpoint = 
+         (SessionEndpoint)Dispatcher.instance.getTarget(objectId);
+      
+      if (endpoint == null)
+      {
+         throw new IllegalStateException("Cannot find object in dispatcher with id " + objectId);
+      }
+      
+      return new SessionCreateConsumerDelegateResponse((ClientConsumerDelegate)endpoint.createConsumerDelegate(dest, selector, noLocal, subName, connectionConsumer, failoverChannelID));
+   }
+
+   public void write(DataOutputStream os) throws Exception
+   {
+      super.write(os);
+      
+      JBossDestination.writeDestination(os, dest);
+      
+      writeNullableString(selector, os);
+      
+      os.writeBoolean(noLocal);
+      
+      writeNullableString(subName, os);
+      
+      os.writeBoolean(connectionConsumer);
+      
+      os.writeLong(failoverChannelID);
+      
+      os.flush();
+   }
+
+}
+

Added: trunk/src/main/org/jboss/jms/wireformat/SessionCreateConsumerDelegateResponse.java
===================================================================
--- trunk/src/main/org/jboss/jms/wireformat/SessionCreateConsumerDelegateResponse.java	                        (rev 0)
+++ trunk/src/main/org/jboss/jms/wireformat/SessionCreateConsumerDelegateResponse.java	2007-02-01 00:10:20 UTC (rev 2119)
@@ -0,0 +1,75 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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 along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.jms.wireformat;
+
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+
+import org.jboss.jms.client.delegate.ClientConsumerDelegate;
+
+/**
+ * 
+ * A SessionCreateConsumerDelegateResponse
+ *
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ * @version <tt>$Revision: 1.1 $</tt>
+ *
+ * $Id$
+ *
+ */
+public class SessionCreateConsumerDelegateResponse extends ResponseSupport
+{
+   private ClientConsumerDelegate del;
+   
+   public SessionCreateConsumerDelegateResponse()
+   {      
+   }
+   
+   public SessionCreateConsumerDelegateResponse(ClientConsumerDelegate del)
+   {
+      super(PacketSupport.RESP_SESSION_CREATECONSUMERDELEGATE);
+      
+      this.del = del;
+   }
+
+   public Object getResponse()
+   {
+      return del;
+   }
+   
+   public void write(DataOutputStream os) throws Exception
+   {
+      super.write(os);
+      
+      del.write(os);
+      
+      os.flush();
+   }
+   
+   public void read(DataInputStream is) throws Exception
+   {
+      del = new ClientConsumerDelegate();
+      
+      del.read(is);
+   }
+
+}

Added: trunk/src/main/org/jboss/jms/wireformat/SessionCreateQueueRequest.java
===================================================================
--- trunk/src/main/org/jboss/jms/wireformat/SessionCreateQueueRequest.java	                        (rev 0)
+++ trunk/src/main/org/jboss/jms/wireformat/SessionCreateQueueRequest.java	2007-02-01 00:10:20 UTC (rev 2119)
@@ -0,0 +1,87 @@
+
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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 along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.jms.wireformat;
+
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+
+import org.jboss.jms.server.endpoint.SessionEndpoint;
+
+/**
+ * 
+ * A SessionCreateQueueRequest
+ *
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ * @version <tt>$Revision: 1.1 $</tt>
+ *
+ * $Id$
+ *
+ */
+public class SessionCreateQueueRequest extends RequestSupport
+{
+   private String queueName;
+   
+   public SessionCreateQueueRequest()
+   {      
+   }
+   
+   public SessionCreateQueueRequest(int objectId,
+                                    byte version,
+                                    String queueName)
+   {
+      super(objectId, PacketSupport.REQ_SESSION_CREATEQUEUE, version);
+      
+      this.queueName = queueName;
+   }
+
+   public void read(DataInputStream is) throws Exception
+   {
+      super.read(is);
+      
+      queueName = is.readUTF();
+   }
+
+   public ResponseSupport serverInvoke() throws Exception
+   {
+      SessionEndpoint endpoint = 
+         (SessionEndpoint)Dispatcher.instance.getTarget(objectId);
+      
+      if (endpoint == null)
+      {
+         throw new IllegalStateException("Cannot find object in dispatcher with id " + objectId);
+      }
+      
+      return new SessionCreateQueueResponse(endpoint.createQueue(queueName));
+   }
+
+   public void write(DataOutputStream os) throws Exception
+   {
+      super.write(os);
+      
+      os.writeUTF(queueName);
+      
+      os.flush();
+   }
+
+}
+

Added: trunk/src/main/org/jboss/jms/wireformat/SessionCreateQueueResponse.java
===================================================================
--- trunk/src/main/org/jboss/jms/wireformat/SessionCreateQueueResponse.java	                        (rev 0)
+++ trunk/src/main/org/jboss/jms/wireformat/SessionCreateQueueResponse.java	2007-02-01 00:10:20 UTC (rev 2119)
@@ -0,0 +1,75 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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 along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.jms.wireformat;
+
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+
+import org.jboss.jms.destination.JBossDestination;
+import org.jboss.jms.destination.JBossQueue;
+
+/**
+ * 
+ * A SessionCreateQueueResponse
+ *
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ * @version <tt>$Revision: 1.1 $</tt>
+ *
+ * $Id$
+ *
+ */
+public class SessionCreateQueueResponse extends ResponseSupport
+{
+   private JBossQueue queue;
+   
+   public SessionCreateQueueResponse()
+   {      
+   }
+   
+   public SessionCreateQueueResponse(JBossQueue queue)
+   {
+      super(PacketSupport.RESP_SESSION_CREATEQUEUE);
+      
+      this.queue = queue;
+   }
+
+   public Object getResponse()
+   {
+      return queue;
+   }
+   
+   public void write(DataOutputStream os) throws Exception
+   {
+      super.write(os);
+      
+      JBossDestination.writeDestination(os, queue);
+      
+      os.flush();
+   }
+   
+   public void read(DataInputStream is) throws Exception
+   {
+      queue = (JBossQueue)JBossDestination.readDestination(is);
+   }
+
+}
+

Added: trunk/src/main/org/jboss/jms/wireformat/SessionCreateTopicRequest.java
===================================================================
--- trunk/src/main/org/jboss/jms/wireformat/SessionCreateTopicRequest.java	                        (rev 0)
+++ trunk/src/main/org/jboss/jms/wireformat/SessionCreateTopicRequest.java	2007-02-01 00:10:20 UTC (rev 2119)
@@ -0,0 +1,87 @@
+
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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 along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.jms.wireformat;
+
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+
+import org.jboss.jms.server.endpoint.SessionEndpoint;
+
+/**
+ * 
+ * A SessionCreateTopicRequest
+ *
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ * @version <tt>$Revision: 1.1 $</tt>
+ *
+ * $Id$
+ *
+ */
+public class SessionCreateTopicRequest extends RequestSupport
+{
+   private String topicName;
+   
+   public SessionCreateTopicRequest()
+   {      
+   }
+   
+   public SessionCreateTopicRequest(int objectId,
+                                    byte version,
+                                    String topicName)
+   {
+      super(objectId, PacketSupport.REQ_SESSION_CREATETOPIC, version);
+      
+      this.topicName = topicName;
+   }
+
+   public void read(DataInputStream is) throws Exception
+   {
+      super.read(is);
+      
+      topicName = is.readUTF();
+   }
+
+   public ResponseSupport serverInvoke() throws Exception
+   {
+      SessionEndpoint endpoint = 
+         (SessionEndpoint)Dispatcher.instance.getTarget(objectId);
+      
+      if (endpoint == null)
+      {
+         throw new IllegalStateException("Cannot find object in dispatcher with id " + objectId);
+      }
+      
+      return new SessionCreateTopicResponse(endpoint.createTopic(topicName));
+   }
+
+   public void write(DataOutputStream os) throws Exception
+   {
+      super.write(os);
+      
+      os.writeUTF(topicName);
+      
+      os.flush();
+   }
+
+}
+

Added: trunk/src/main/org/jboss/jms/wireformat/SessionCreateTopicResponse.java
===================================================================
--- trunk/src/main/org/jboss/jms/wireformat/SessionCreateTopicResponse.java	                        (rev 0)
+++ trunk/src/main/org/jboss/jms/wireformat/SessionCreateTopicResponse.java	2007-02-01 00:10:20 UTC (rev 2119)
@@ -0,0 +1,75 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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 along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.jms.wireformat;
+
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+
+import org.jboss.jms.destination.JBossDestination;
+import org.jboss.jms.destination.JBossTopic;
+
+/**
+ * 
+ * A SessionCreateTopicResponse
+ *
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ * @version <tt>$Revision: 1.1 $</tt>
+ *
+ * $Id$
+ *
+ */
+public class SessionCreateTopicResponse extends ResponseSupport
+{
+   private JBossTopic topic;
+   
+   public SessionCreateTopicResponse()
+   {
+   }
+   
+   public SessionCreateTopicResponse(JBossTopic topic)
+   {
+      super(PacketSupport.RESP_SESSION_CREATETOPIC);
+      
+      this.topic = topic;
+   }
+
+   public Object getResponse()
+   {
+      return topic;
+   }
+   
+   public void write(DataOutputStream os) throws Exception
+   {
+      super.write(os);
+      
+      JBossDestination.writeDestination(os, topic);
+      
+      os.flush();
+   }
+   
+   public void read(DataInputStream is) throws Exception
+   {
+      topic = (JBossTopic)JBossDestination.readDestination(is);
+   }
+
+}
+

Added: trunk/src/main/org/jboss/jms/wireformat/SessionDeleteTemporaryDestinationRequest.java
===================================================================
--- trunk/src/main/org/jboss/jms/wireformat/SessionDeleteTemporaryDestinationRequest.java	                        (rev 0)
+++ trunk/src/main/org/jboss/jms/wireformat/SessionDeleteTemporaryDestinationRequest.java	2007-02-01 00:10:20 UTC (rev 2119)
@@ -0,0 +1,93 @@
+
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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 along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.jms.wireformat;
+
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+
+import org.jboss.jms.destination.JBossDestination;
+import org.jboss.jms.server.endpoint.SessionEndpoint;
+
+/**
+ * 
+ * A SessionDeleteTemporaryDestinationRequest
+ *
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ * @version <tt>$Revision: 1.1 $</tt>
+ *
+ * $Id$
+ *
+ */
+public class SessionDeleteTemporaryDestinationRequest extends RequestSupport
+{
+   private JBossDestination dest;
+   
+   public SessionDeleteTemporaryDestinationRequest()
+   {      
+   }
+   
+   public SessionDeleteTemporaryDestinationRequest(int objectId,
+                                       byte version,
+                                       JBossDestination dest)
+   {
+      super(objectId, PacketSupport.REQ_SESSION_DELETETEMPORARYDESTINATION, version);
+      
+      this.dest = dest;
+   }
+
+   public void read(DataInputStream is) throws Exception
+   {
+      super.read(is);
+      
+      dest = JBossDestination.readDestination(is);      
+   }
+
+   public ResponseSupport serverInvoke() throws Exception
+   {
+      SessionEndpoint endpoint = 
+         (SessionEndpoint)Dispatcher.instance.getTarget(objectId);
+      
+      if (endpoint == null)
+      {
+         throw new IllegalStateException("Cannot find object in dispatcher with id " + objectId);
+      }
+      
+      endpoint.deleteTemporaryDestination(dest);
+      
+      return null;
+   }
+
+   public void write(DataOutputStream os) throws Exception
+   {
+      super.write(os);
+      
+      JBossDestination.writeDestination(os, dest); 
+      
+      os.flush();
+   }
+
+}
+
+
+
+

Added: trunk/src/main/org/jboss/jms/wireformat/SessionRecoverDeliveriesRequest.java
===================================================================
--- trunk/src/main/org/jboss/jms/wireformat/SessionRecoverDeliveriesRequest.java	                        (rev 0)
+++ trunk/src/main/org/jboss/jms/wireformat/SessionRecoverDeliveriesRequest.java	2007-02-01 00:10:20 UTC (rev 2119)
@@ -0,0 +1,114 @@
+
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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 along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.jms.wireformat;
+
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.jboss.jms.server.endpoint.DeliveryRecovery;
+import org.jboss.jms.server.endpoint.SessionEndpoint;
+
+/**
+ * 
+ * A SessionRecoverDeliveriesRequest
+ *
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ * @version <tt>$Revision: 1.1 $</tt>
+ *
+ * $Id$
+ *
+ */
+public class SessionRecoverDeliveriesRequest extends RequestSupport
+{
+   private List dels;
+   
+   public SessionRecoverDeliveriesRequest()
+   {      
+   }
+   
+   public SessionRecoverDeliveriesRequest(int objectId,
+                                          byte version,
+                                          List dels)
+   {
+      super(objectId, PacketSupport.REQ_SESSION_RECOVERDELIVERIES, version);
+      
+      this.dels = dels;
+   }
+
+   public void read(DataInputStream is) throws Exception
+   {
+      super.read(is);
+      
+      int size = is.readInt();
+      
+      dels = new ArrayList(size);
+      
+      for (int i = 0; i < size; i++)
+      {
+         DeliveryRecovery del = new DeliveryRecovery();
+         
+         del.read(is);
+         
+         dels.add(del);
+      }
+   }
+
+   public ResponseSupport serverInvoke() throws Exception
+   {
+      SessionEndpoint endpoint = 
+         (SessionEndpoint)Dispatcher.instance.getTarget(objectId);
+      
+      if (endpoint == null)
+      {
+         throw new IllegalStateException("Cannot find object in dispatcher with id " + objectId);
+      }
+      
+      endpoint.recoverDeliveries(dels);
+      
+      return null;
+   }
+
+   public void write(DataOutputStream os) throws Exception
+   {
+      super.write(os);
+      
+      os.writeInt(dels.size());
+
+      Iterator iter = dels.iterator();
+
+      while (iter.hasNext())
+      {
+         DeliveryRecovery del = (DeliveryRecovery)iter.next();
+         
+         del.write(os);
+      }
+      
+      os.flush();
+   }
+
+}
+
+

Added: trunk/src/main/org/jboss/jms/wireformat/SessionSendRequest.java
===================================================================
--- trunk/src/main/org/jboss/jms/wireformat/SessionSendRequest.java	                        (rev 0)
+++ trunk/src/main/org/jboss/jms/wireformat/SessionSendRequest.java	2007-02-01 00:10:20 UTC (rev 2119)
@@ -0,0 +1,101 @@
+
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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 along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.jms.wireformat;
+
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+
+import org.jboss.jms.message.JBossMessage;
+import org.jboss.jms.server.endpoint.SessionEndpoint;
+import org.jboss.messaging.core.message.MessageFactory;
+
+/**
+ * 
+ * A SessionSendRequest
+ *
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ * @version <tt>$Revision: 1.1 $</tt>
+ *
+ * $Id$
+ *
+ */
+public class SessionSendRequest extends RequestSupport
+{
+   private JBossMessage msg;
+   
+   public SessionSendRequest()
+   {      
+   }
+   
+   public SessionSendRequest(int objectId,
+                             byte version,
+                             JBossMessage msg)
+   {
+      super(objectId, PacketSupport.REQ_SESSION_SEND, version);
+      
+      this.msg = msg;
+   }
+
+   public void read(DataInputStream is) throws Exception
+   {
+      super.read(is);
+      
+      byte messageType = is.readByte();
+      
+      msg = (JBossMessage)MessageFactory.createMessage(messageType);
+
+      msg.read(is);   
+   }
+
+   public ResponseSupport serverInvoke() throws Exception
+   {
+      SessionEndpoint endpoint = 
+         (SessionEndpoint)Dispatcher.instance.getTarget(objectId);
+      
+      if (endpoint == null)
+      {
+         throw new IllegalStateException("Cannot find object in dispatcher with id " + objectId);
+      }
+      
+      endpoint.send(msg);
+      
+      return null;
+   }
+
+   public void write(DataOutputStream os) throws Exception
+   {
+      super.write(os);
+      
+      os.writeByte(msg.getType());
+      
+      msg.write(os);
+      
+      os.flush();
+   }
+
+}
+
+
+
+
+

Added: trunk/src/main/org/jboss/jms/wireformat/SessionUnsubscribeRequest.java
===================================================================
--- trunk/src/main/org/jboss/jms/wireformat/SessionUnsubscribeRequest.java	                        (rev 0)
+++ trunk/src/main/org/jboss/jms/wireformat/SessionUnsubscribeRequest.java	2007-02-01 00:10:20 UTC (rev 2119)
@@ -0,0 +1,92 @@
+
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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 along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.jms.wireformat;
+
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+
+import org.jboss.jms.server.endpoint.SessionEndpoint;
+
+/**
+ * 
+ * A SessionUnsubscribeRequest
+ *
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ * @version <tt>$Revision: 1.1 $</tt>
+ *
+ * $Id$
+ *
+ */
+public class SessionUnsubscribeRequest extends RequestSupport
+{
+   private String subName;
+   
+   public SessionUnsubscribeRequest()
+   {      
+   }
+   
+   public SessionUnsubscribeRequest(int objectId,
+                                    byte version,
+                                    String subName)
+   {
+      super(objectId, PacketSupport.REQ_SESSION_UNSUBSCRIBE, version);
+      
+      this.subName = subName;
+   }
+
+   public void read(DataInputStream is) throws Exception
+   {
+      super.read(is);
+      
+      subName = is.readUTF();     
+   }
+
+   public ResponseSupport serverInvoke() throws Exception
+   {
+      SessionEndpoint endpoint = 
+         (SessionEndpoint)Dispatcher.instance.getTarget(objectId);
+      
+      if (endpoint == null)
+      {
+         throw new IllegalStateException("Cannot find object in dispatcher with id " + objectId);
+      }
+      
+      endpoint.unsubscribe(subName);
+      
+      return null;
+   }
+
+   public void write(DataOutputStream os) throws Exception
+   {
+      super.write(os);
+      
+      os.writeUTF(subName);
+      
+      os.flush();
+   }
+
+}
+
+
+
+

Modified: trunk/src/main/org/jboss/messaging/core/plugin/JDBCPersistenceManager.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/plugin/JDBCPersistenceManager.java	2007-01-31 20:11:51 UTC (rev 2118)
+++ trunk/src/main/org/jboss/messaging/core/plugin/JDBCPersistenceManager.java	2007-02-01 00:10:20 UTC (rev 2119)
@@ -63,7 +63,7 @@
 import org.jboss.messaging.core.tx.PreparedTxInfo;
 import org.jboss.messaging.core.tx.Transaction;
 import org.jboss.messaging.core.tx.TxCallback;
-import org.jboss.messaging.core.tx.XidImpl;
+import org.jboss.messaging.core.tx.MessagingXid;
 import org.jboss.messaging.util.JDBCUtil;
 import org.jboss.messaging.util.StreamUtils;
 import org.jboss.messaging.util.Util;
@@ -218,7 +218,7 @@
             byte[] branchQual = rs.getBytes(2);
             int formatId = rs.getInt(3);
             byte[] globalTxId = rs.getBytes(4);
-            Xid xid = new XidImpl(branchQual, formatId, globalTxId);
+            Xid xid = new MessagingXid(branchQual, formatId, globalTxId);
             
             // create a tx info object with the result set detailsdetails
             txInfo = new PreparedTxInfo(txId, xid);

Copied: trunk/src/main/org/jboss/messaging/core/tx/MessagingXid.java (from rev 2058, trunk/src/main/org/jboss/messaging/core/tx/XidImpl.java)
===================================================================
--- trunk/src/main/org/jboss/messaging/core/tx/MessagingXid.java	                        (rev 0)
+++ trunk/src/main/org/jboss/messaging/core/tx/MessagingXid.java	2007-02-01 00:10:20 UTC (rev 2119)
@@ -0,0 +1,171 @@
+/*
+  * JBoss, Home of Professional Open Source
+  * Copyright 2005, JBoss Inc., and individual contributors as indicated
+  * by the @authors tag. See the copyright.txt in the distribution for a
+  * full listing of individual contributors.
+  *
+  * This is free software; you can redistribute it and/or modify it
+  * under the terms of the GNU Lesser General Public License as
+  * published by the Free Software Foundation; either version 2.1 of
+  * the License, or (at your option) any later version.
+  *
+  * This software is distributed in the hope that it will be useful,
+  * but WITHOUT ANY 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 along with this software; if not, write to the Free
+  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+  */
+package org.jboss.messaging.core.tx;
+
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.Serializable;
+
+import javax.transaction.xa.Xid;
+
+import org.jboss.messaging.util.Streamable;
+
+/**
+ * 
+ * Xid implementation
+ * 
+ * @author <a href="mailto:adrian at jboss.org>Adrian Brock</a>
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ * @author <a href="mailto:juha at jboss.org">Juha Lindfors</a>
+ * 
+ * @version $Revision 1.1 $
+ */
+public class MessagingXid implements Xid, Serializable, Streamable
+{
+   private static final long serialVersionUID = -1893120702576869245L;
+
+   private byte[] branchQualifier;
+   
+   private int formatId;
+   
+   private byte[] globalTransactionId;
+   
+   private int hash;
+
+   public byte[] getBranchQualifier()
+   {
+      return branchQualifier;
+   }
+
+   public int getFormatId()
+   {
+      return formatId;
+   }
+
+   public byte[] getGlobalTransactionId()
+   {
+      return globalTransactionId;
+   }
+   
+   //For serialization
+   public MessagingXid()
+   {      
+   }
+   
+   public MessagingXid(byte[] branchQualifier, int formatId, byte[] globalTransactionId)
+   {
+      this.branchQualifier = branchQualifier;
+      this.formatId = formatId;
+      this.globalTransactionId = globalTransactionId;      
+      calcHash();     
+   }
+   
+   public int hashCode()
+   {
+      return hash;
+   }
+   
+   public boolean equals(Object other)
+   {
+      if (!(other instanceof Xid))
+      {
+         return false;
+      }
+      Xid xother = (Xid)other;
+      if (xother.getFormatId() != formatId)
+      {
+         return false;
+      }
+      if (xother.getBranchQualifier().length != this.branchQualifier.length)
+      {
+         return false;
+      }
+      if (xother.getGlobalTransactionId().length != this.globalTransactionId.length)
+      {
+         return false;
+      }
+      for (int i = 0; i < this.branchQualifier.length; i++)
+      {
+         byte[] otherBQ = xother.getBranchQualifier();
+         if (this.branchQualifier[i] != otherBQ[i])
+         {
+            return false;
+         }
+      }
+      for (int i = 0; i < this.globalTransactionId.length; i++)
+      {
+         byte[] otherGtx = xother.getGlobalTransactionId();
+         if (this.globalTransactionId[i] != otherGtx[i])
+         {
+            return false;
+         }
+      }
+      return true;
+   }
+
+   public String toString()
+   {
+      return getClass().getName() + "(GID: " + new String(getGlobalTransactionId()) +
+                                    ", Branch: " + new String(getBranchQualifier()) +
+                                    ", Format: " + getFormatId() + ")";
+   }
+
+   public void read(DataInputStream in) throws Exception
+   {
+      int len = in.readInt();      
+      branchQualifier = new byte[len];      
+      in.readFully(branchQualifier);
+      
+      formatId = in.readInt();
+      
+      len = in.readInt();      
+      globalTransactionId = new byte[len];      
+      in.readFully(globalTransactionId);            
+   }
+
+   public void write(DataOutputStream out) throws Exception
+   {
+      out.writeInt(branchQualifier.length);
+      out.write(branchQualifier);
+      
+      out.writeInt(formatId);
+      
+      out.writeInt(globalTransactionId.length);
+      out.write(globalTransactionId);
+   }
+   
+   private void calcHash()
+   {
+      byte[] hashBytes = new byte[branchQualifier.length + globalTransactionId.length + 4];
+      System.arraycopy(branchQualifier, 0, hashBytes, 0, branchQualifier.length);
+      System.arraycopy(globalTransactionId, 0, hashBytes, branchQualifier.length, globalTransactionId.length);
+      byte[] intBytes = new byte[4];
+      for (int i = 0; i < 4; i++)
+      {
+         intBytes[i] = (byte)((formatId >> (i * 8)) % 0xFF);
+      }
+      System.arraycopy(intBytes, 0, hashBytes, branchQualifier.length + globalTransactionId.length, 4);
+      String s = new String(hashBytes);
+      hash = s.hashCode();
+   }
+
+}

Deleted: trunk/src/main/org/jboss/messaging/core/tx/XidImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/tx/XidImpl.java	2007-01-31 20:11:51 UTC (rev 2118)
+++ trunk/src/main/org/jboss/messaging/core/tx/XidImpl.java	2007-02-01 00:10:20 UTC (rev 2119)
@@ -1,138 +0,0 @@
-/*
-  * JBoss, Home of Professional Open Source
-  * Copyright 2005, JBoss Inc., and individual contributors as indicated
-  * by the @authors tag. See the copyright.txt in the distribution for a
-  * full listing of individual contributors.
-  *
-  * This is free software; you can redistribute it and/or modify it
-  * under the terms of the GNU Lesser General Public License as
-  * published by the Free Software Foundation; either version 2.1 of
-  * the License, or (at your option) any later version.
-  *
-  * This software is distributed in the hope that it will be useful,
-  * but WITHOUT ANY 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 along with this software; if not, write to the Free
-  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-  */
-package org.jboss.messaging.core.tx;
-
-import java.io.Serializable;
-
-import javax.transaction.xa.Xid;
-
-/**
- * 
- * Xid implementation
- * 
- * @author <a href="mailto:adrian at jboss.org>Adrian Brock</a>
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- * @author <a href="mailto:juha at jboss.org">Juha Lindfors</a>
- * 
- * @version $Revision 1.1 $
- */
-public class XidImpl implements Xid, Serializable
-{
-   private static final long serialVersionUID = -1893120702576869245L;
-
-   protected byte[] branchQualifier;
-   
-   protected int formatId;
-   
-   protected byte[] globalTransactionId;
-   
-   protected int hash;
-
-   public byte[] getBranchQualifier()
-   {
-      return branchQualifier;
-   }
-
-   public int getFormatId()
-   {
-      return formatId;
-   }
-
-   public byte[] getGlobalTransactionId()
-   {
-      return globalTransactionId;
-   }
-   
-   //For serialization
-   public XidImpl()
-   {      
-   }
-   
-   public XidImpl(byte[] branchQualifier, int formatId, byte[] globalTransactionId)
-   {
-      this.branchQualifier = branchQualifier;
-      this.formatId = formatId;
-      this.globalTransactionId = globalTransactionId;
-      byte[] hashBytes = new byte[branchQualifier.length + globalTransactionId.length + 4];
-      System.arraycopy(branchQualifier, 0, hashBytes, 0, branchQualifier.length);
-      System.arraycopy(globalTransactionId, 0, hashBytes, branchQualifier.length, globalTransactionId.length);
-      byte[] intBytes = new byte[4];
-      for (int i = 0; i < 4; i++)
-      {
-         intBytes[i] = (byte)((formatId >> (i * 8)) % 0xFF);
-      }
-      System.arraycopy(intBytes, 0, hashBytes, branchQualifier.length + globalTransactionId.length, 4);
-      String s = new String(hashBytes);
-      hash = s.hashCode();
-   }
-   
-   public int hashCode()
-   {
-      return hash;
-   }
-   
-   public boolean equals(Object other)
-   {
-      if (!(other instanceof Xid))
-      {
-         return false;
-      }
-      Xid xother = (Xid)other;
-      if (xother.getFormatId() != formatId)
-      {
-         return false;
-      }
-      if (xother.getBranchQualifier().length != this.branchQualifier.length)
-      {
-         return false;
-      }
-      if (xother.getGlobalTransactionId().length != this.globalTransactionId.length)
-      {
-         return false;
-      }
-      for (int i = 0; i < this.branchQualifier.length; i++)
-      {
-         byte[] otherBQ = xother.getBranchQualifier();
-         if (this.branchQualifier[i] != otherBQ[i])
-         {
-            return false;
-         }
-      }
-      for (int i = 0; i < this.globalTransactionId.length; i++)
-      {
-         byte[] otherGtx = xother.getGlobalTransactionId();
-         if (this.globalTransactionId[i] != otherGtx[i])
-         {
-            return false;
-         }
-      }
-      return true;
-   }
-
-   public String toString()
-   {
-      return getClass().getName() + "(GID: " + new String(getGlobalTransactionId()) +
-                                    ", Branch: " + new String(getBranchQualifier()) +
-                                    ", Format: " + getFormatId() + ")";
-   }
-
-}

Modified: trunk/tests/build.xml
===================================================================
--- trunk/tests/build.xml	2007-01-31 20:11:51 UTC (rev 2118)
+++ trunk/tests/build.xml	2007-02-01 00:10:20 UTC (rev 2119)
@@ -422,7 +422,7 @@
             <formatter type="plain" usefile="${junit.formatter.usefile}"/>
             <fileset dir="${build.tests.classes}">
                <include name="**/*Test.class"/>
-               <exclude name="**/messaging/core/ha/**/*Test.class"/>
+               <exclude name="**/messaging/graveyard/**/*Test.class"/>
                <exclude name="**/jms/stress/**"/>
                <exclude name="**/jms/crash/*Test.class"/>
                <exclude name="**/*LeakTest.class"/>
@@ -477,6 +477,7 @@
             <formatter type="plain" usefile="${junit.formatter.usefile}"/>
             <fileset dir="${build.tests.classes}">
                <include name="**/messaging/jms/**/*Test.class"/>
+               <exclude name="**/messaging/graveyard/**/*Test.class"/>
                <exclude name="**/jms/stress/**"/>
                <exclude name="**/jms/crash/*Test.class"/>
                <exclude name="**/*LeakTest.class"/>
@@ -519,6 +520,7 @@
             <formatter type="plain" usefile="${junit.formatter.usefile}"/>
             <fileset dir="${build.tests.classes}">
                <include name="**/messaging/jms/ReferenceableTest.class"/>
+               <exclude name="**/messaging/graveyard/**/*Test.class"/>
                <exclude name="**/jms/stress/**"/>
                <exclude name="**/jms/crash/*Test.class"/>
                <exclude name="**/*LeakTest.class"/>
@@ -633,6 +635,8 @@
             <fileset dir="${build.tests.classes}">
                <include name="**/jms/**/*Test.class"/>
                <include name="**/thirdparty/**/*Test.class"/>
+               <exclude name="**/messaging/graveyard/**/*Test.class"/>
+               <exclude name="**/jms/WireFormatTest.class"/>
                <exclude name="**/jms/stress/**"/>
                <exclude name="**/jms/server/**"/>
                <exclude name="**/jms/persistence/**"/>
@@ -1188,6 +1192,7 @@
             <formatter type="plain" usefile="${junit.formatter.usefile}"/>
             <fileset dir="${build.tests.classes}">
                <include name="**/messaging/jms/**/*Test.class"/>
+               <exclude name="**/messaging/graveyard/**/*Test.class"/>
                <exclude name="**/jms/stress/**"/>
                <exclude name="org/jboss/test/messaging/jms/ManifestTest.class"/>
                <exclude name="**/jms/clustering/*Test.class"/>
@@ -1258,6 +1263,7 @@
             <formatter type="plain" usefile="${junit.formatter.usefile}"/>
             <fileset dir="${build.tests.classes}">
                <include name="**/messaging/**/*Test.class"/>
+               <exclude name="**/messaging/graveyard/**/*Test.class"/>
                <exclude name="**/messaging/jms/**"/>
             </fileset>
          </batchtest>

Modified: trunk/tests/etc/log4j.xml
===================================================================
--- trunk/tests/etc/log4j.xml	2007-01-31 20:11:51 UTC (rev 2118)
+++ trunk/tests/etc/log4j.xml	2007-02-01 00:10:20 UTC (rev 2119)
@@ -47,8 +47,8 @@
    </category>
 
    <category name="org.jboss.remoting">
+      <priority value="TRACE" class="org.jboss.logging.XLevel"/>
       <!-- <priority value="DEBUG"/> -->
-      <priority value="TRACE" class="org.jboss.logging.XLevel"/>
    </category>
 
    <category name="org.jboss">
@@ -82,7 +82,8 @@
    </category>
 
    <category name="org.jboss.jms.server.remoting.JMSWireFormat">
-      <priority value="DEBUG"/>
+      <priority value="TRACE" class="org.jboss.logging.XLevel"/>
+      <!-- <priority value="DEBUG"/> -->
    </category>
 
    <root>

Modified: trunk/tests/src/org/jboss/test/messaging/core/paging/base/PagingStateTestBase.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/core/paging/base/PagingStateTestBase.java	2007-01-31 20:11:51 UTC (rev 2118)
+++ trunk/tests/src/org/jboss/test/messaging/core/paging/base/PagingStateTestBase.java	2007-02-01 00:10:20 UTC (rev 2119)
@@ -44,7 +44,7 @@
 import org.jboss.messaging.core.plugin.contract.PersistenceManager;
 import org.jboss.messaging.core.tx.Transaction;
 import org.jboss.messaging.core.tx.TransactionRepository;
-import org.jboss.messaging.core.tx.XidImpl;
+import org.jboss.messaging.core.tx.MessagingXid;
 import org.jboss.test.messaging.MessagingTestCase;
 import org.jboss.test.messaging.tools.jmx.ServiceContainer;
 import org.jboss.tm.TransactionManagerService;
@@ -123,7 +123,7 @@
    
    protected Transaction createXATx() throws Exception
    {
-      XidImpl xid = new XidImpl(new GUID().toString().getBytes(), 345, new GUID().toString().getBytes());
+      MessagingXid xid = new MessagingXid(new GUID().toString().getBytes(), 345, new GUID().toString().getBytes());
       
       return tr.createTransaction(xid);
    }

Added: trunk/tests/src/org/jboss/test/messaging/graveyard/GraveyardTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/graveyard/GraveyardTest.java	                        (rev 0)
+++ trunk/tests/src/org/jboss/test/messaging/graveyard/GraveyardTest.java	2007-02-01 00:10:20 UTC (rev 2119)
@@ -0,0 +1,176 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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 along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.messaging.graveyard;
+
+import java.io.Serializable;
+import java.util.Set;
+
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.Destination;
+import javax.management.MBeanServer;
+import javax.naming.InitialContext;
+
+import org.jboss.jms.server.ServerPeer;
+import org.jboss.logging.Logger;
+import org.jboss.remoting.InvocationRequest;
+import org.jboss.remoting.ServerInvocationHandler;
+import org.jboss.remoting.ServerInvoker;
+import org.jboss.remoting.callback.InvokerCallbackHandler;
+import org.jboss.test.messaging.MessagingTestCase;
+import org.jboss.test.messaging.tools.ServerManagement;
+
+/**
+ * 
+ * This is where we put individual tests that are no longer valid.
+ * 
+ *
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ * @version <tt>$Revision: 1.1 $</tt>
+ *
+ * $Id$
+ *
+ */
+public class GraveyardTest extends MessagingTestCase
+{
+   private static final Logger log = Logger.getLogger(GraveyardTest.class);
+
+   
+   public GraveyardTest(String name)
+   {
+      super(name);
+   }
+   
+   protected InitialContext initialContext;
+
+   protected ConnectionFactory cf;
+   
+   protected Destination topic;
+
+
+   protected void setUp() throws Exception
+   {
+      super.setUp();
+      
+      ServerManagement.start("all");      
+      
+      initialContext = new InitialContext(ServerManagement.getJNDIEnvironment());
+      
+      cf = (ConnectionFactory)initialContext.lookup("/ConnectionFactory");
+      
+      ServerManagement.undeployTopic("Topic");
+      
+      ServerManagement.deployTopic("Topic");
+      
+      topic = (Destination)initialContext.lookup("/topic/Topic");
+   }
+
+   protected void tearDown() throws Exception
+   {
+      ServerManagement.undeployTopic("Topic");
+      
+      super.tearDown();      
+   }
+
+   
+   /*
+    * This test was excluded on 31/01/07 since we do not pass a session id in every invocation therefore
+    * it's not possible to guarantee the "correct" one is used.
+    * This is ok, since our remoting connector is exclusively ours, no one else will use it
+    */
+   
+   /**
+    * Test create connection when there is another Remoting invocation handler registered with the
+    * Connector. I uncovered this bug while trying to run TCK/integration tests. In real life
+    * Messaging has to co-exist with other invocation handlers registered with the Unified invoker's
+    * Connector.
+    */
+   public void testCreateConnectionMultipleRemotingInvocationHandlers() throws Exception
+   {
+      // stop the Messaging server and re-start it after I register an extra remoting invocation
+      // handler with the connector
+
+      ServerManagement.stopServerPeer();
+
+      Set subsystems = ServerManagement.getConnectorSubsystems();
+      assertTrue(subsystems.contains(ServerPeer.REMOTING_JMS_SUBSYSTEM));
+      assertEquals(1, subsystems.size());
+
+      ServerManagement.addServerInvocationHandler("DEFAULT_INVOCATION_HANDLER",
+                                                  new SimpleServerInvocationHandler());
+      subsystems = ServerManagement.getConnectorSubsystems();
+      assertTrue(subsystems.contains(ServerPeer.REMOTING_JMS_SUBSYSTEM));
+      assertTrue(subsystems.contains("DEFAULT_INVOCATION_HANDLER"));
+      assertEquals(2, subsystems.size());
+
+      try
+      {
+         // restart the server peer so it will add its ServerInvocationHandler AFTER
+         // SimpleServerInvocationHandler - this simulates the situation where the same Connector
+         // has more than one ServerInvocationHandler instance
+         ServerManagement.startServerPeer();
+
+         // We need to re-lookup the connection factory after server restart, the new connection
+         // factory points to a different thing
+         cf = (ConnectionFactory)initialContext.lookup("/ConnectionFactory");
+
+         Connection connection = cf.createConnection();
+         connection.close();
+      }
+      finally
+      {
+         // remove the test invocation handler
+         ServerManagement.removeServerInvocationHandler("DEFAULT_INVOCATION_HANDLER");
+      }
+   }
+   
+   private static class SimpleServerInvocationHandler
+   implements ServerInvocationHandler, Serializable
+   {
+      private static final long serialVersionUID = 23847329753297523L;
+      
+      public void setMBeanServer(MBeanServer server)
+      {
+      }
+      
+      public void setInvoker(ServerInvoker invoker)
+      {
+      }
+      
+      public Object invoke(InvocationRequest invocation) throws Throwable
+      {
+         log.error("received invocation " + invocation + ", " + invocation.getParameter());
+         fail("This ServerInvocationHandler is not supposed to handle invocations");
+         return null;
+      }
+      
+      public void addListener(InvokerCallbackHandler callbackHandler)
+      {
+         fail("This ServerInvocationHandler is not supposed to add listeners");
+      }
+      
+      public void removeListener(InvokerCallbackHandler callbackHandler)
+      {
+         fail("This ServerInvocationHandler is not supposed to remove listeners");
+      }
+   }
+}

Copied: trunk/tests/src/org/jboss/test/messaging/graveyard/MultipleServerInvocationHandlersTest.java (from rev 2112, trunk/tests/src/org/jboss/test/messaging/jms/MultipleServerInvocationHandlersTest.java)
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/graveyard/MultipleServerInvocationHandlersTest.java	                        (rev 0)
+++ trunk/tests/src/org/jboss/test/messaging/graveyard/MultipleServerInvocationHandlersTest.java	2007-02-01 00:10:20 UTC (rev 2119)
@@ -0,0 +1,194 @@
+/*
+  * JBoss, Home of Professional Open Source
+  * Copyright 2005, JBoss Inc., and individual contributors as indicated
+  * by the @authors tag. See the copyright.txt in the distribution for a
+  * full listing of individual contributors.
+  *
+  * This is free software; you can redistribute it and/or modify it
+  * under the terms of the GNU Lesser General Public License as
+  * published by the Free Software Foundation; either version 2.1 of
+  * the License, or (at your option) any later version.
+  *
+  * This software is distributed in the hope that it will be useful,
+  * but WITHOUT ANY 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 along with this software; if not, write to the Free
+  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+  */
+package org.jboss.test.messaging.graveyard;
+
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.DeliveryMode;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageProducer;
+import javax.jms.Queue;
+import javax.jms.Session;
+import javax.jms.TextMessage;
+import javax.naming.InitialContext;
+import javax.management.MBeanServer;
+
+import org.jboss.test.messaging.MessagingTestCase;
+import org.jboss.test.messaging.tools.ServerManagement;
+import org.jboss.remoting.ServerInvocationHandler;
+import org.jboss.remoting.ServerInvoker;
+import org.jboss.remoting.InvocationRequest;
+import org.jboss.remoting.callback.InvokerCallbackHandler;
+import org.jboss.jms.server.ServerPeer;
+
+import java.util.Set;
+import java.io.Serializable;
+
+/**
+ * 
+ * This test was excluded on 31/01/07 since we do not pass a session id in every invocation therefore
+ * it's not possible to guarantee the "correct" one is used.
+ * This is ok, since our remoting connector is exclusively ours, no one else will use it
+ * 
+ * Tests the situation when there is more than one ServerInvokerHandler registered with the
+ * Remoting connector. Goes through a combination of most common use cases.
+ *
+ * @author <a href="mailto:ovidiu at jboss.org">Ovidiu Feodorov</a>
+ * @version <tt>$Revision$</tt>
+ *
+ * $Id$
+ */
+public class MultipleServerInvocationHandlersTest extends MessagingTestCase
+{
+   // Constants -----------------------------------------------------
+
+   // Static --------------------------------------------------------
+
+   // Attributes ----------------------------------------------------
+
+   InitialContext ic;
+
+   // Constructors --------------------------------------------------
+
+   public MultipleServerInvocationHandlersTest(String name)
+   {
+      super(name);
+   }
+
+   // Public --------------------------------------------------------
+
+   public void testMessageRoundTrip() throws Exception
+   {
+      Set subsystems = ServerManagement.getConnectorSubsystems();
+      assertEquals(2, subsystems.size());
+
+      assertTrue(subsystems.contains("DEFAULT_INVOCATION_HANDLER"));
+      assertTrue(subsystems.contains(ServerPeer.REMOTING_JMS_SUBSYSTEM));
+
+      ConnectionFactory cf = (ConnectionFactory)ic.lookup("/ConnectionFactory");
+      Queue queue = (Queue)ic.lookup("/queue/MultipleServerInvocationHandlerTestQueue");
+
+      Connection conn = cf.createConnection();
+      Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+      MessageProducer prod = session.createProducer(queue);
+      prod.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
+
+      TextMessage m = session.createTextMessage("payload");
+
+      prod.send(m);
+
+      conn.close();
+
+      conn = cf.createConnection();
+
+      session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+      MessageConsumer cons = session.createConsumer(queue);
+
+      conn.start();
+
+      TextMessage rm = (TextMessage)cons.receive();
+
+      assertEquals("payload", rm.getText());
+
+      conn.close();
+   }
+
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+
+   protected void setUp() throws Exception
+   {
+      super.setUp();
+
+      ServerManagement.start("all");
+      
+      ic = new InitialContext(ServerManagement.getJNDIEnvironment());
+
+      // stop the Messaging server and re-start it after I register an extra remoting invocation
+      // handler with the connector
+
+      ServerManagement.stopServerPeer();
+
+      Set subsystems = ServerManagement.getConnectorSubsystems();
+      assertEquals(1, subsystems.size());
+      assertTrue(subsystems.contains(ServerPeer.REMOTING_JMS_SUBSYSTEM));
+
+      ServerManagement.addServerInvocationHandler("DEFAULT_INVOCATION_HANDLER",
+                                                  new SimpleServerInvocationHandler());
+
+      // restart the server peer so it will add its ServerInvocationHandler AFTER
+      // SimpleServerInvocationHandler - this simulates the situation where the same Connector
+      // has more than one ServerInvocationHandler instance
+      ServerManagement.startServerPeer();
+
+      ServerManagement.deployQueue("MultipleServerInvocationHandlerTestQueue");
+
+      log.debug("setup done");
+   }
+
+   protected void tearDown() throws Exception
+   {
+      // remove the test invocation handler
+      ServerManagement.removeServerInvocationHandler("DEFAULT_INVOCATION_HANDLER");
+      ServerManagement.undeployQueue("MultipleServerInvocationHandlerTestQueue");
+      ic.close();
+      ServerManagement.stop();
+      super.tearDown();
+   }
+
+   // Private -------------------------------------------------------
+
+   // Inner classes -------------------------------------------------
+
+   private static class SimpleServerInvocationHandler
+      implements ServerInvocationHandler, Serializable
+   {
+      private static final long serialVersionUID = 398759739753345L;
+
+      public void setMBeanServer(MBeanServer server)
+      {
+      }
+
+      public void setInvoker(ServerInvoker invoker)
+      {
+      }
+
+      public Object invoke(InvocationRequest invocation) throws Throwable
+      {
+         fail("This ServerInvocationHandler is not supposed to handle invocations");
+         return null;
+      }
+
+      public void addListener(InvokerCallbackHandler callbackHandler)
+      {
+         fail("This ServerInvocationHandler is not supposed to add listeners");
+      }
+
+      public void removeListener(InvokerCallbackHandler callbackHandler)
+      {
+         fail("This ServerInvocationHandler is not supposed to remove listeners");
+      }
+   }
+}

Modified: trunk/tests/src/org/jboss/test/messaging/jms/BrowserTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/BrowserTest.java	2007-01-31 20:11:51 UTC (rev 2118)
+++ trunk/tests/src/org/jboss/test/messaging/jms/BrowserTest.java	2007-02-01 00:10:20 UTC (rev 2119)
@@ -121,7 +121,7 @@
       }
    }
 
-   public void testCreateBrowserOnInexistentQueue() throws Exception
+   public void testCreateBrowserOnNonExistentQueue() throws Exception
    {
       Connection pconn = cf.createConnection();
 

Modified: trunk/tests/src/org/jboss/test/messaging/jms/ConnectionClosedTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/ConnectionClosedTest.java	2007-01-31 20:11:51 UTC (rev 2118)
+++ trunk/tests/src/org/jboss/test/messaging/jms/ConnectionClosedTest.java	2007-02-01 00:10:20 UTC (rev 2119)
@@ -255,7 +255,12 @@
    public void testGetMetadataOnClosedConnection() throws Exception
    {
       Connection connection = cf.createConnection();
+      
+      log.info("Closing connection");
+      
       connection.close();
+      
+      log.info("Closed connection");
 
       try
       {

Modified: trunk/tests/src/org/jboss/test/messaging/jms/ConnectionTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/ConnectionTest.java	2007-01-31 20:11:51 UTC (rev 2118)
+++ trunk/tests/src/org/jboss/test/messaging/jms/ConnectionTest.java	2007-02-01 00:10:20 UTC (rev 2119)
@@ -21,9 +21,6 @@
   */
 package org.jboss.test.messaging.jms;
 
-import java.io.Serializable;
-import java.util.Set;
-
 import javax.jms.Connection;
 import javax.jms.ConnectionFactory;
 import javax.jms.ConnectionMetaData;
@@ -35,7 +32,6 @@
 import javax.jms.Session;
 import javax.jms.TopicConnection;
 import javax.jms.TopicConnectionFactory;
-import javax.management.MBeanServer;
 import javax.naming.InitialContext;
 
 import org.jboss.jms.client.JBossConnection;
@@ -43,14 +39,9 @@
 import org.jboss.jms.client.state.ConnectionState;
 import org.jboss.jms.message.MessageIdGenerator;
 import org.jboss.jms.message.MessageIdGeneratorFactory;
-import org.jboss.jms.server.ServerPeer;
 import org.jboss.jms.tx.ResourceManager;
 import org.jboss.jms.tx.ResourceManagerFactory;
 import org.jboss.logging.Logger;
-import org.jboss.remoting.InvocationRequest;
-import org.jboss.remoting.ServerInvocationHandler;
-import org.jboss.remoting.ServerInvoker;
-import org.jboss.remoting.callback.InvokerCallbackHandler;
 import org.jboss.test.messaging.MessagingTestCase;
 import org.jboss.test.messaging.tools.ServerManagement;
 
@@ -79,6 +70,7 @@
    protected InitialContext initialContext;
 
    protected ConnectionFactory cf;
+   
    protected Destination topic;
 
    // Constructors --------------------------------------------------
@@ -93,21 +85,24 @@
    public void setUp() throws Exception
    {
       super.setUp();
-      ServerManagement.start("all");
       
-      
+      ServerManagement.start("all");
+            
       initialContext = new InitialContext(ServerManagement.getJNDIEnvironment());
+      
       cf = (ConnectionFactory)initialContext.lookup("/ConnectionFactory");
+      
       ServerManagement.undeployTopic("Topic");
+      
       ServerManagement.deployTopic("Topic");
+      
       topic = (Destination)initialContext.lookup("/topic/Topic");
-
-      log.debug("setup done");
    }
 
    public void tearDown() throws Exception
    {
       ServerManagement.undeployTopic("Topic");
+      
       super.tearDown();
    }
 
@@ -499,51 +494,8 @@
 //      {}
 //   }
 
-   /**
-    * Test create connection when there is another Remoting invocation handler registered with the
-    * Connector. I uncovered this bug while trying to run TCK/integration tests. In real life
-    * Messaging has to co-exist with other invocation handlers registered with the Unified invoker's
-    * Connector.
-    */
-   public void testCreateConnectionMultipleRemotingInvocationHandlers() throws Exception
-   {
-      // stop the Messaging server and re-start it after I register an extra remoting invocation
-      // handler with the connector
+   
 
-      ServerManagement.stopServerPeer();
-
-      Set subsystems = ServerManagement.getConnectorSubsystems();
-      assertTrue(subsystems.contains(ServerPeer.REMOTING_JMS_SUBSYSTEM));
-      assertEquals(1, subsystems.size());
-
-      ServerManagement.addServerInvocationHandler("DEFAULT_INVOCATION_HANDLER",
-                                                  new SimpleServerInvocationHandler());
-      subsystems = ServerManagement.getConnectorSubsystems();
-      assertTrue(subsystems.contains(ServerPeer.REMOTING_JMS_SUBSYSTEM));
-      assertTrue(subsystems.contains("DEFAULT_INVOCATION_HANDLER"));
-      assertEquals(2, subsystems.size());
-
-      try
-      {
-         // restart the server peer so it will add its ServerInvocationHandler AFTER
-         // SimpleServerInvocationHandler - this simulates the situation where the same Connector
-         // has more than one ServerInvocationHandler instance
-         ServerManagement.startServerPeer();
-
-         // We need to re-lookup the connection factory after server restart, the new connection
-         // factory points to a different thing
-         cf = (ConnectionFactory)initialContext.lookup("/ConnectionFactory");
-
-         Connection connection = cf.createConnection();
-         connection.close();
-      }
-      finally
-      {
-         // remove the test invocation handler
-         ServerManagement.removeServerInvocationHandler("DEFAULT_INVOCATION_HANDLER");
-      }
-   }
-
    // Package protected ---------------------------------------------
 
    // Protected -----------------------------------------------------
@@ -563,35 +515,6 @@
       }
    }
 
-   private static class SimpleServerInvocationHandler
-      implements ServerInvocationHandler, Serializable
-   {
-      private static final long serialVersionUID = 23847329753297523L;
+   
 
-      public void setMBeanServer(MBeanServer server)
-      {
-      }
-
-      public void setInvoker(ServerInvoker invoker)
-      {
-      }
-
-      public Object invoke(InvocationRequest invocation) throws Throwable
-      {
-         log.error("received invocation " + invocation + ", " + invocation.getParameter());
-         fail("This ServerInvocationHandler is not supposed to handle invocations");
-         return null;
-      }
-
-      public void addListener(InvokerCallbackHandler callbackHandler)
-      {
-         fail("This ServerInvocationHandler is not supposed to add listeners");
-      }
-
-      public void removeListener(InvokerCallbackHandler callbackHandler)
-      {
-         fail("This ServerInvocationHandler is not supposed to remove listeners");
-      }
-   }
-
 }

Deleted: trunk/tests/src/org/jboss/test/messaging/jms/MultipleServerInvocationHandlersTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/MultipleServerInvocationHandlersTest.java	2007-01-31 20:11:51 UTC (rev 2118)
+++ trunk/tests/src/org/jboss/test/messaging/jms/MultipleServerInvocationHandlersTest.java	2007-02-01 00:10:20 UTC (rev 2119)
@@ -1,189 +0,0 @@
-/*
-  * JBoss, Home of Professional Open Source
-  * Copyright 2005, JBoss Inc., and individual contributors as indicated
-  * by the @authors tag. See the copyright.txt in the distribution for a
-  * full listing of individual contributors.
-  *
-  * This is free software; you can redistribute it and/or modify it
-  * under the terms of the GNU Lesser General Public License as
-  * published by the Free Software Foundation; either version 2.1 of
-  * the License, or (at your option) any later version.
-  *
-  * This software is distributed in the hope that it will be useful,
-  * but WITHOUT ANY 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 along with this software; if not, write to the Free
-  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-  */
-package org.jboss.test.messaging.jms;
-
-import javax.jms.Connection;
-import javax.jms.ConnectionFactory;
-import javax.jms.DeliveryMode;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageProducer;
-import javax.jms.Queue;
-import javax.jms.Session;
-import javax.jms.TextMessage;
-import javax.naming.InitialContext;
-import javax.management.MBeanServer;
-
-import org.jboss.test.messaging.MessagingTestCase;
-import org.jboss.test.messaging.tools.ServerManagement;
-import org.jboss.remoting.ServerInvocationHandler;
-import org.jboss.remoting.ServerInvoker;
-import org.jboss.remoting.InvocationRequest;
-import org.jboss.remoting.callback.InvokerCallbackHandler;
-import org.jboss.jms.server.ServerPeer;
-
-import java.util.Set;
-import java.io.Serializable;
-
-/**
- * Tests the situation when there is more than one ServerInvokerHandler registered with the
- * Remoting connector. Goes through a combination of most common use cases.
- *
- * @author <a href="mailto:ovidiu at jboss.org">Ovidiu Feodorov</a>
- * @version <tt>$Revision$</tt>
- *
- * $Id$
- */
-public class MultipleServerInvocationHandlersTest extends MessagingTestCase
-{
-   // Constants -----------------------------------------------------
-
-   // Static --------------------------------------------------------
-
-   // Attributes ----------------------------------------------------
-
-   InitialContext ic;
-
-   // Constructors --------------------------------------------------
-
-   public MultipleServerInvocationHandlersTest(String name)
-   {
-      super(name);
-   }
-
-   // Public --------------------------------------------------------
-
-   public void testMessageRoundTrip() throws Exception
-   {
-      Set subsystems = ServerManagement.getConnectorSubsystems();
-      assertEquals(2, subsystems.size());
-
-      assertTrue(subsystems.contains("DEFAULT_INVOCATION_HANDLER"));
-      assertTrue(subsystems.contains(ServerPeer.REMOTING_JMS_SUBSYSTEM));
-
-      ConnectionFactory cf = (ConnectionFactory)ic.lookup("/ConnectionFactory");
-      Queue queue = (Queue)ic.lookup("/queue/MultipleServerInvocationHandlerTestQueue");
-
-      Connection conn = cf.createConnection();
-      Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
-      MessageProducer prod = session.createProducer(queue);
-      prod.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
-
-      TextMessage m = session.createTextMessage("payload");
-
-      prod.send(m);
-
-      conn.close();
-
-      conn = cf.createConnection();
-
-      session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
-      MessageConsumer cons = session.createConsumer(queue);
-
-      conn.start();
-
-      TextMessage rm = (TextMessage)cons.receive();
-
-      assertEquals("payload", rm.getText());
-
-      conn.close();
-   }
-
-   // Package protected ---------------------------------------------
-
-   // Protected -----------------------------------------------------
-
-   protected void setUp() throws Exception
-   {
-      super.setUp();
-
-      ServerManagement.start("all");
-      
-      ic = new InitialContext(ServerManagement.getJNDIEnvironment());
-
-      // stop the Messaging server and re-start it after I register an extra remoting invocation
-      // handler with the connector
-
-      ServerManagement.stopServerPeer();
-
-      Set subsystems = ServerManagement.getConnectorSubsystems();
-      assertEquals(1, subsystems.size());
-      assertTrue(subsystems.contains(ServerPeer.REMOTING_JMS_SUBSYSTEM));
-
-      ServerManagement.addServerInvocationHandler("DEFAULT_INVOCATION_HANDLER",
-                                                  new SimpleServerInvocationHandler());
-
-      // restart the server peer so it will add its ServerInvocationHandler AFTER
-      // SimpleServerInvocationHandler - this simulates the situation where the same Connector
-      // has more than one ServerInvocationHandler instance
-      ServerManagement.startServerPeer();
-
-      ServerManagement.deployQueue("MultipleServerInvocationHandlerTestQueue");
-
-      log.debug("setup done");
-   }
-
-   protected void tearDown() throws Exception
-   {
-      // remove the test invocation handler
-      ServerManagement.removeServerInvocationHandler("DEFAULT_INVOCATION_HANDLER");
-      ServerManagement.undeployQueue("MultipleServerInvocationHandlerTestQueue");
-      ic.close();
-      ServerManagement.stop();
-      super.tearDown();
-   }
-
-   // Private -------------------------------------------------------
-
-   // Inner classes -------------------------------------------------
-
-   private static class SimpleServerInvocationHandler
-      implements ServerInvocationHandler, Serializable
-   {
-      private static final long serialVersionUID = 398759739753345L;
-
-      public void setMBeanServer(MBeanServer server)
-      {
-      }
-
-      public void setInvoker(ServerInvoker invoker)
-      {
-      }
-
-      public Object invoke(InvocationRequest invocation) throws Throwable
-      {
-         fail("This ServerInvocationHandler is not supposed to handle invocations");
-         return null;
-      }
-
-      public void addListener(InvokerCallbackHandler callbackHandler)
-      {
-         fail("This ServerInvocationHandler is not supposed to add listeners");
-      }
-
-      public void removeListener(InvokerCallbackHandler callbackHandler)
-      {
-         fail("This ServerInvocationHandler is not supposed to remove listeners");
-      }
-   }
-}

Modified: trunk/tests/src/org/jboss/test/messaging/jms/WireFormatTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/WireFormatTest.java	2007-01-31 20:11:51 UTC (rev 2118)
+++ trunk/tests/src/org/jboss/test/messaging/jms/WireFormatTest.java	2007-02-01 00:10:20 UTC (rev 2119)
@@ -25,46 +25,80 @@
 import java.io.ByteArrayOutputStream;
 import java.io.DataInputStream;
 import java.io.DataOutputStream;
-import java.io.EOFException;
-import java.io.InputStream;
 import java.io.OutputStream;
 import java.io.Serializable;
-import java.lang.reflect.Method;
 import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
 import java.util.List;
-import java.util.Map;
 
-import org.jboss.aop.Dispatcher;
-import org.jboss.aop.joinpoint.MethodInvocation;
-import org.jboss.jms.delegate.ConnectionDelegate;
-import org.jboss.jms.delegate.ConsumerDelegate;
-import org.jboss.jms.delegate.SessionDelegate;
+import org.jboss.jms.client.delegate.ClientBrowserDelegate;
+import org.jboss.jms.client.delegate.ClientConsumerDelegate;
+import org.jboss.jms.client.delegate.ClientSessionDelegate;
+import org.jboss.jms.destination.JBossQueue;
+import org.jboss.jms.destination.JBossTemporaryQueue;
+import org.jboss.jms.destination.JBossTopic;
 import org.jboss.jms.message.JBossMessage;
-import org.jboss.jms.message.MessageProxy;
 import org.jboss.jms.server.endpoint.Ack;
 import org.jboss.jms.server.endpoint.Cancel;
-import org.jboss.jms.server.endpoint.ClientDelivery;
+import org.jboss.jms.server.endpoint.CreateConnectionResult;
 import org.jboss.jms.server.endpoint.DefaultAck;
 import org.jboss.jms.server.endpoint.DefaultCancel;
-import org.jboss.jms.server.endpoint.DeliveryInfo;
+import org.jboss.jms.server.endpoint.DeliveryRecovery;
 import org.jboss.jms.server.remoting.JMSWireFormat;
-import org.jboss.jms.server.remoting.MessagingMarshallable;
 import org.jboss.jms.tx.ClientTransaction;
 import org.jboss.jms.tx.TransactionRequest;
-import org.jboss.jms.tx.ClientTransaction.SessionTxState;
+import org.jboss.jms.wireformat.BrowserHasNextMessageRequest;
+import org.jboss.jms.wireformat.BrowserHasNextMessageResponse;
+import org.jboss.jms.wireformat.BrowserNextMessageBlockRequest;
+import org.jboss.jms.wireformat.BrowserNextMessageBlockResponse;
+import org.jboss.jms.wireformat.BrowserNextMessageRequest;
+import org.jboss.jms.wireformat.BrowserNextMessageResponse;
+import org.jboss.jms.wireformat.CloseRequest;
+import org.jboss.jms.wireformat.ClosingRequest;
+import org.jboss.jms.wireformat.ConnectionCreateSessionDelegateRequest;
+import org.jboss.jms.wireformat.ConnectionCreateSessionDelegateResponse;
+import org.jboss.jms.wireformat.ConnectionFactoryCreateConnectionDelegateRequest;
+import org.jboss.jms.wireformat.ConnectionFactoryCreateConnectionDelegateResponse;
+import org.jboss.jms.wireformat.ConnectionFactoryGetClientAOPStackRequest;
+import org.jboss.jms.wireformat.ConnectionFactoryGetClientAOPStackResponse;
+import org.jboss.jms.wireformat.ConnectionFactoryGetIDBlockRequest;
+import org.jboss.jms.wireformat.ConnectionFactoryGetIDBlockResponse;
+import org.jboss.jms.wireformat.ConnectionGetClientIDRequest;
+import org.jboss.jms.wireformat.ConnectionGetClientIDResponse;
+import org.jboss.jms.wireformat.ConnectionGetPreparedTransactionsRequest;
+import org.jboss.jms.wireformat.ConnectionGetPreparedTransactionsResponse;
+import org.jboss.jms.wireformat.ConnectionSendTransactionRequest;
+import org.jboss.jms.wireformat.ConnectionSetClientIDRequest;
+import org.jboss.jms.wireformat.ConnectionStartRequest;
+import org.jboss.jms.wireformat.ConnectionStopRequest;
+import org.jboss.jms.wireformat.ConsumerCancelInflightMessagesRequest;
+import org.jboss.jms.wireformat.ConsumerChangeRateRequest;
+import org.jboss.jms.wireformat.NullResponse;
+import org.jboss.jms.wireformat.PacketSupport;
+import org.jboss.jms.wireformat.RequestSupport;
+import org.jboss.jms.wireformat.ResponseSupport;
+import org.jboss.jms.wireformat.SessionAcknowledgeDeliveriesRequest;
+import org.jboss.jms.wireformat.SessionAcknowledgeDeliveryRequest;
+import org.jboss.jms.wireformat.SessionAddTemporaryDestinationRequest;
+import org.jboss.jms.wireformat.SessionCancelDeliveriesRequest;
+import org.jboss.jms.wireformat.SessionCancelDeliveryRequest;
+import org.jboss.jms.wireformat.SessionCreateBrowserDelegateRequest;
+import org.jboss.jms.wireformat.SessionCreateBrowserDelegateResponse;
+import org.jboss.jms.wireformat.SessionCreateConsumerDelegateRequest;
+import org.jboss.jms.wireformat.SessionCreateConsumerDelegateResponse;
+import org.jboss.jms.wireformat.SessionCreateQueueRequest;
+import org.jboss.jms.wireformat.SessionCreateQueueResponse;
+import org.jboss.jms.wireformat.SessionCreateTopicRequest;
+import org.jboss.jms.wireformat.SessionCreateTopicResponse;
+import org.jboss.jms.wireformat.SessionDeleteTemporaryDestinationRequest;
+import org.jboss.jms.wireformat.SessionRecoverDeliveriesRequest;
+import org.jboss.jms.wireformat.SessionSendRequest;
+import org.jboss.jms.wireformat.SessionUnsubscribeRequest;
 import org.jboss.logging.Logger;
 import org.jboss.messaging.core.plugin.IDBlock;
+import org.jboss.messaging.core.tx.MessagingXid;
 import org.jboss.remoting.InvocationRequest;
-import org.jboss.remoting.InvocationResponse;
-import org.jboss.remoting.InvokerLocator;
-import org.jboss.remoting.callback.Callback;
-import org.jboss.remoting.invocation.InternalInvocation;
-import org.jboss.remoting.invocation.OnewayInvocation;
 import org.jboss.test.messaging.MessagingTestCase;
-import org.jboss.test.messaging.jms.message.MessageTest;
-import org.jboss.util.id.GUID;
+import org.jboss.test.messaging.tools.ServerManagement;
 
 /**
  * 
@@ -81,40 +115,12 @@
       
    private static final Logger log = Logger.getLogger(WireFormatTest.class);
 
-   // TODO - replace with a dynamic value
-   private static final byte CURRENT_VERSION = 8;
-
    // Static --------------------------------------------------------
       
    // Attributes ----------------------------------------------------
    
-   protected TestWireFormat wf;
+   private TestWireFormat wf;
    
-   //Session
-   
-   protected Method sendMethod;
-   
-   protected Method acknowledgeDeliveryMethod;
-   
-   protected Method acknowledgeDeliveriesMethod;
-   
-   protected Method cancelDeliveryMethod;
-   
-   protected Method cancelDeliveriesMethod;      
-   
-   //Consumer
-        
-   protected Method changeRateMethod;
-   
-   protected Method cancelInflightMessagesMethod;
-   
- 
-   //connection
-   
-   protected Method sendTransactionMethod;
-   
-   //callback
-   
    // Constructors --------------------------------------------------
 
    public WireFormatTest(String name)
@@ -126,41 +132,14 @@
 
    public void setUp() throws Exception
    {
+      if (ServerManagement.isRemote())
+      {
+         fail("This test should not be run in a remote config");
+      }
+      
       super.setUp();
       
-      wf = new TestWireFormat();
-      
-      Class sessionDelegate = SessionDelegate.class;
-      
-      Class consumerDelegate = ConsumerDelegate.class;
-      
-      Class connectionDelegate = ConnectionDelegate.class;
-      
-      //Session
-      
-      sendMethod = sessionDelegate.getMethod("send", new Class[] { JBossMessage.class });
-       
-      acknowledgeDeliveryMethod = sessionDelegate.getMethod("acknowledgeDelivery", new Class[] { Ack.class });
-      
-      acknowledgeDeliveriesMethod = sessionDelegate.getMethod("acknowledgeDeliveries", new Class[] { java.util.List.class });
-      
-      cancelDeliveryMethod = sessionDelegate.getMethod("cancelDelivery", new Class[] { Cancel.class });
-            
-      cancelDeliveriesMethod = sessionDelegate.getMethod("cancelDeliveries", new Class[] { java.util.List.class });
-      
-      //TODO - this isn't complete - there are other methods to test
-            
-      //Consumer
-            
-      changeRateMethod = consumerDelegate.getMethod("changeRate", new Class[] { Float.TYPE });
-      
-      cancelInflightMessagesMethod = consumerDelegate.getMethod("cancelInflightMessages", new Class[] { Long.TYPE });
-
-      //Connection
-      
-      sendTransactionMethod = connectionDelegate.getMethod("sendTransaction", new Class[] { TransactionRequest.class });
-      
-      log.debug("setup done");
+      wf = new TestWireFormat();            
    }
 
    public void tearDown() throws Exception
@@ -168,1334 +147,743 @@
       super.tearDown();
    }
    
-   //Session
    
-   public void testAcknowledgeDelivery() throws Exception
+   public void testSerialized() throws Exception
    {
-      wf.testAcknowledgeDelivery();
+      wf.testSerialized();
    }
    
-   public void testAcknowledgeDeliveries() throws Exception
+   // Connection factory
+   
+   public void testConnectionFactoryCreateConnectionDelegate() throws Exception
    {
-      wf.testAcknowledgeDeliveries();
+      wf.testConnectionFactoryCreateConnectionDelegate();
    }
    
-   public void testCancelDelivery() throws Exception
-   {
-      wf.testCancelDelivery();
+   public void testConnectionFactoryGetIDBlock() throws Exception
+   {                          
+      wf.testConnectionFactoryGetIDBlock();
    }
    
-   public void testCancelDeliveries() throws Exception
-   {
-      wf.testCancelDeliveries();
+   public void testConnectionFactoryGetClientAOPStack() throws Exception
+   {                         
+      wf.testConnectionFactoryGetClientAOPStack();
    }
    
-   public void testSend() throws Exception
-   {
-      wf.testSend();
+   // Connection
+   
+   public void testConnectionCreateSessionDelegateRequest() throws Exception
+   {                     
+      wf.testConnectionCreateSessionDelegateRequest();
    }
    
-   //Consumer
+   public void testConnectionGetClientIDRequest() throws Exception
+   {                 
+      wf.testConnectionGetClientIDRequest();
+   }
    
-   public void testChangeRate() throws Exception
-   {
-      wf.testChangeRate();
+   public void testConnectionSetClientIDRequest() throws Exception
+   {                         
+      wf.testConnectionSetClientIDRequest();      
    }
    
-   public void testCancelInflightMessages() throws Exception
-   {
-      wf.testCancelInflightMessages();
+   public void testConnectionStartRequest() throws Exception
+   {                         
+      wf.testConnectionStartRequest();
    }
    
+   public void testConnectionStopRequest() throws Exception
+   {                          
+      wf.testConnectionStopRequest();
+   }
    
-   //Connection
+   public void testConnectionSendTransactionRequest() throws Exception
+   {              
+      wf.testConnectionSendTransactionRequest();
+   }      
    
-   public void testSendTransaction() throws Exception
-   {
-      wf.testSendTransaction();
+   public void testConnectionGetPreparedTransactionsRequest() throws Exception
+   {              
+      wf.testConnectionGetPreparedTransactionsRequest();
+   }  
+   
+   // Session
+   
+   public void testSessionCreateConsumerDelegateRequest() throws Exception
+   {                     
+      wf.testSessionCreateConsumerDelegateRequest();
+   } 
+   
+   public void testSessionCreateBrowserDelegateRequest() throws Exception
+   {                        
+      wf.testSessionCreateBrowserDelegateRequest();
    }
    
-   //Others
+   public void testSessionCreateQueueRequest() throws Exception
+   {           
+      wf.testSessionCreateQueueRequest();
+   }      
    
-      
-   public void testExceptionResponse() throws Exception
-   {
-      wf.testExceptionResponse();
+   public void testSessionCreateTopicRequest() throws Exception
+   {           
+      wf.testSessionCreateTopicRequest();
    }
-    
-   public void testNullResponse() throws Exception
-   {
-      wf.testNullResponse();
+   
+   public void testSessionAcknowledgeDeliveriesRequest() throws Exception
+   {                 
+      wf.testSessionCreateTopicRequest();
+   }   
+   
+   public void testSessionAcknowledgeDeliveryRequest() throws Exception
+   {                
+      wf.testSessionAcknowledgeDeliveryRequest();
+   } 
+   
+   public void testSessionCancelDeliveriesRequest() throws Exception
+   {                       
+      wf.testSessionCancelDeliveriesRequest();
+   }   
+   
+   public void testSessionCancelDeliveryRequest() throws Exception
+   {           
+      wf.testSessionCancelDeliveryRequest();
+   } 
+   
+   public void testSessionAddTemporaryDestinationRequest() throws Exception
+   {         
+      wf.testSessionAddTemporaryDestinationRequest();
+   } 
+   
+   public void testSessionDeleteTemporaryDestinationRequest() throws Exception
+   {             
+      wf.testSessionDeleteTemporaryDestinationRequest();
+   } 
+   
+   public void testSessionUnsubscribeRequest() throws Exception
+   {            
+      wf.testSessionUnsubscribeRequest();
    }
    
-   public void testSerializableRequest() throws Exception
-   {
-      wf.testSerializableRequest();
+   public void testSessionSendRequest() throws Exception
+   {          
+      wf.testSessionSendRequest();
    }
    
-   public void testSerializableResponse() throws Exception
-   {
-      wf.testSerializableResponse();
+   public void testSessionRecoverDeliveriesRequest() throws Exception
+   {            
+      wf.testSessionRecoverDeliveriesRequest();
    }
    
-   public void testMessageDelivery() throws Exception
-   {
-      wf.testMessageDelivery();
+   // Consumer
+   
+   public void testConsumerChangeRateRequest() throws Exception
+   {                         
+      wf.testConsumerChangeRateRequest();
    }
    
-   public void testIDBlockResponse() throws Exception
-   {
-      wf.testGetIdBlockResponse();
+   public void testConsumerCancelInflightMessagesRequest() throws Exception
+   {                       
+      wf.testConsumerCancelInflightMessagesRequest();
    }
    
-   //TODO need a test for the polled callbacks
-          
-   // Public --------------------------------------------------------
+   // Browser
    
-   public static class SerializableObject implements Serializable
-   {      
-      /** The serialVersionUID */
-      private static final long serialVersionUID = 1L;
-
-      public SerializableObject()
-      {         
-      }
-
-      SerializableObject(String s, long l)
-      {
-         this.s = s;
-         this.l = l;
-      }
-      
-      public String s;
-      
-      public long l;      
+   public void testBrowserNextMessageRequest() throws Exception
+   {                        
+      wf.testBrowserNextMessageRequest();
    }
-         
-   /**
-    * We extend the class so we have access to protected fields
-    */
+   
+   public void testBrowserHasNextMessageRequest() throws Exception
+   {                           
+      wf.testBrowserHasNextMessageRequest();
+   }
+   
+   public void testBrowserNextMessageBlockRequest() throws Exception
+   {                    
+      wf.testBrowserNextMessageBlockRequest();
+   }
+   
+   
+   public void testClosingRequest() throws Exception
+   {                    
+      wf.testClosingRequest();
+   }
+   
+   public void testCloseRequest() throws Exception
+   {            
+      wf.testCloseRequest();
+   }
+   
+   
+   // Responses
+   
+   // Connection Factory
+   
+   public void testConnectionFactoryCreateConnectionDelegateResponse() throws Exception
+   {            
+      wf.testConnectionFactoryCreateConnectionDelegateResponse();
+   }
+   
+   public void testConnectionFactoryGetIDBlockResponse() throws Exception
+   {                         
+      wf.testConnectionFactoryGetIDBlockResponse();
+   }
+   
+   public void testConnectionFactoryGetClientAOPStackResponse() throws Exception
+   {                        
+      wf.testConnectionFactoryGetClientAOPStackResponse();
+   }
+   
+   // Connection
+   
+   public void testConnectionCreateSessionDelegateResponse() throws Exception
+   {                   
+      wf.testConnectionCreateSessionDelegateResponse();      
+   }
+   
+   public void testConnectionGetClientIDResponse() throws Exception
+   {                            
+      wf.testConnectionGetClientIDResponse();
+   }
+   
+   public void testConnectionGetClientPreparedTransactionsResponse() throws Exception
+   {                      
+      wf.testConnectionGetClientPreparedTransactionsResponse();
+   }
+   
+   
+   
+   // Session
+   
+   public void testSessionCreateConsumerDelegateResponse() throws Exception
+   {                        
+      wf.testSessionCreateConsumerDelegateResponse();
+   }
+   
+   
+   public void testSessionCreateBrowserDelegateResponse() throws Exception
+   {                    
+      wf.testSessionCreateBrowserDelegateResponse();
+   }
+   
+   public void testSessionCreateQueueResponse() throws Exception
+   {                          
+      wf.testSessionCreateQueueResponse();
+   }
+   
+   public void testSessionCreateTopicResponse() throws Exception
+   {                            
+      wf.testSessionCreateTopicResponse();
+   }
+   
+   // Browser
+   
+   public void testBrowserNextMessageResponse() throws Exception
+   {                          
+      wf.testBrowserNextMessageResponse();
+   }
+   
+   public void testBrowserHasNextMessageResponse() throws Exception
+   {                           
+      wf.testBrowserHasNextMessageResponse();
+   }
+   
+   public void testBrowserNextMessageBlockResponse() throws Exception
+   {                            
+      wf.testBrowserNextMessageBlockResponse();
+   }
+   
+   public void testNullResponse() throws Exception
+   {                 
+      wf.testNullResponse();
+   }
+   
+   
+   //We just check the first byte to make sure serialization is not be used.
+   
    private class TestWireFormat extends JMSWireFormat
    {      
-      public void testAcknowledgeDelivery() throws Exception
+      private void testPacket(PacketSupport req, int id) throws Exception
       {
-         long methodHash = 62365354;
-         
-         int objectId = 54321;
-         
-         MethodInvocation mi = new MethodInvocation(null, methodHash, acknowledgeDeliveryMethod, acknowledgeDeliveryMethod, null);
-         
-         mi.getMetaData().addMetaData(Dispatcher.DISPATCHER, Dispatcher.OID, new Integer(objectId));   
-         
-         int deliveryID = 765;
-         Ack ack = new DefaultAck(deliveryID);
-         
-         Object[] args = new Object[] { ack };
-         
-         mi.setArguments(args);
-         
-         MessagingMarshallable mm = new MessagingMarshallable((byte)77, mi);
-         
-         InvocationRequest ir = new InvocationRequest(null, null, mm, null, null, null);
-         
          ByteArrayOutputStream bos = new ByteArrayOutputStream();
          
          OutputStream oos = new DataOutputStream(bos);
-                  
-         wf.write(ir, oos);
          
-         oos.flush();
+         InvocationRequest ir = new InvocationRequest("session123", null, req, null, null, null);   
          
+         wf.write(ir, oos);
+                  
          byte[] bytes = bos.toByteArray();
          
          ByteArrayInputStream bis = new ByteArrayInputStream(bytes);
                   
          DataInputStream dis = new DataInputStream(bis); 
                  
-         //Check the bytes
+         int theId = dis.readInt();
          
-         //First byte should be version
-         assertEquals(77, dis.readByte());
-         
-         //First byte should be ACKNOWLEDGE
-         assertEquals(JMSWireFormat.ACKNOWLEDGE, dis.readByte());
-         
-         //Next int should be objectId
-         assertEquals(objectId, dis.readInt());
-         
-         //Next long should be methodHash
-         assertEquals(methodHash, dis.readLong());
-         
-         //Next should be the deliveryid
-         long l = dis.readLong();
-         
-         assertEquals(deliveryID, l);
-
-         //Now eos
-         try
-         {
-            dis.readByte();
-            fail("End of stream expected");
-         }
-         catch (EOFException e)
-         {
-            //Ok
-         }
-         
-         bis.reset();
-         
-         InputStream ois = new DataInputStream(bis);
-         
-         InvocationRequest ir2 = (InvocationRequest)wf.read(ois, null);
-         
-         mm = (MessagingMarshallable)ir2.getParameter();
-         
-         assertEquals(77, mm.getVersion());
-         
-         MethodInvocation mi2 = (MethodInvocation)mm.getLoad();
-         
-         assertEquals(methodHash, mi2.getMethodHash());
-         
-         assertEquals(objectId, ((Integer)mi2.getMetaData().getMetaData(Dispatcher.DISPATCHER, Dispatcher.OID)).intValue());
-         
-         Ack l2 = (Ack)mi2.getArguments()[0];
-         
-         assertEquals(deliveryID, l2.getDeliveryID());
-         
+         assertEquals(id, theId);
       }
       
-      public void testAcknowledgeDeliveries() throws Exception
+      public void testSerialized() throws Exception
       {
-         long methodHash = 62365354;
+         Serializable obj = new SerializableObject("uyuiyiu", 234234);
          
-         int objectId = 54321;
-         
-         MethodInvocation mi = new MethodInvocation(null, methodHash, acknowledgeDeliveriesMethod, acknowledgeDeliveriesMethod, null);
-         
-         mi.getMetaData().addMetaData(Dispatcher.DISPATCHER, Dispatcher.OID, new Integer(objectId));   
-         
-         long ackA = 1343;
-         
-         long ackB = 176276;
-         
-         long ackC = 17261726;
-                  
-         List acks = new ArrayList();
-         acks.add(new DefaultAck(ackA));
-         acks.add(new DefaultAck(ackB));
-         acks.add(new DefaultAck(ackC));
-         
-         Object[] args = new Object[] { acks };
-         
-         mi.setArguments(args);
-                  
-         MessagingMarshallable mm = new MessagingMarshallable((byte)77, mi);
-         
-         InvocationRequest ir = new InvocationRequest(null, null, mm, null, null, null);
-         
          ByteArrayOutputStream bos = new ByteArrayOutputStream();
-                  
-         OutputStream oos = new DataOutputStream(bos);
-      
-         wf.write(ir, oos);
          
-         oos.flush();
-         
+         OutputStream oos = new DataOutputStream(bos);
+
+         wf.write(obj, oos);
+                  
          byte[] bytes = bos.toByteArray();
          
          ByteArrayInputStream bis = new ByteArrayInputStream(bytes);
                   
          DataInputStream dis = new DataInputStream(bis); 
                  
-         //Check the bytes
+         int theId = dis.readInt();
          
-         //First byte should be version
-         assertEquals(77, dis.readByte());
-         
-         //First byte should be ACKNOWLEDGE
-         assertEquals(JMSWireFormat.ACKNOWLEDGE_LIST, dis.readByte());
-         
-         //Next int should be objectId
-         assertEquals(objectId, dis.readInt());
-         
-         //Next long should be methodHash
-         assertEquals(methodHash, dis.readLong());
-         
-         //Next should be number of acks
-         assertEquals(3, dis.readInt());
-         
-         //Now the acks
-         long l1 = dis.readLong();
-         
-         long l2 = dis.readLong();
-         
-         long l3 = dis.readLong();
-         
-         assertEquals(ackA, l1);
-         assertEquals(ackB, l2);
-         assertEquals(ackC, l3);
-         
-         
-         //Now eos
-         try
-         {
-            dis.readByte();
-            fail("End of stream expected");
-         }
-         catch (EOFException e)
-         {
-            //Ok
-         }
-         
-         bis.reset();
-         
-         InputStream ois = new DataInputStream(bis);
-         
-         InvocationRequest ir2 = (InvocationRequest)wf.read(ois, null);
-         
-         mm = (MessagingMarshallable)ir2.getParameter();
-         
-         assertEquals(77, mm.getVersion());
-         
-         MethodInvocation mi2 = (MethodInvocation)mm.getLoad();
-         
-         assertEquals(methodHash, mi2.getMethodHash());
-         
-         assertEquals(objectId, ((Integer)mi2.getMetaData().getMetaData(Dispatcher.DISPATCHER, Dispatcher.OID)).intValue());
-         
-         List acks2 = (List)mi2.getArguments()[0];
-         
-         assertEquals(3, acks.size());
-         
-         assertEquals(ackA, ((DefaultAck)acks2.get(0)).getDeliveryID());
-         assertEquals(ackB, ((DefaultAck)acks2.get(1)).getDeliveryID());
-         assertEquals(ackC, ((DefaultAck)acks2.get(2)).getDeliveryID());
-         
+         assertEquals(PacketSupport.SERIALIZED, theId);
       }
       
-      public void testCancelDelivery() throws Exception
+      // Requests
+      
+      // Connection Factory
+      
+      public void testConnectionFactoryCreateConnectionDelegate() throws Exception
       {
-         long methodHash = 6236354;
-         
-         int objectId = 543271;
-         
-         MethodInvocation mi = new MethodInvocation(null, methodHash, cancelDeliveryMethod, cancelDeliveryMethod, null);
-         
-         mi.getMetaData().addMetaData(Dispatcher.DISPATCHER, Dispatcher.OID, new Integer(objectId));   
-         
-         long deliveryID = 765;
-         
-         int deliveryCount = 12;
-         
-         Cancel cancel = new DefaultCancel(deliveryID, deliveryCount, true, true);
-         
-         Object[] args = new Object[] { cancel };
-         
-         mi.setArguments(args);
-         
-         MessagingMarshallable mm = new MessagingMarshallable((byte)77, mi);
-         
-         InvocationRequest ir = new InvocationRequest(null, null, mm, null, null, null);
-         
-         ByteArrayOutputStream bos = new ByteArrayOutputStream();
-         
-         OutputStream oos = new DataOutputStream(bos);
-                  
-         wf.write(ir, oos);
-         
-         oos.flush();
-         
-         byte[] bytes = bos.toByteArray();
-         
-         ByteArrayInputStream bis = new ByteArrayInputStream(bytes);
-                  
-         DataInputStream dis = new DataInputStream(bis); 
+         RequestSupport req =
+            new ConnectionFactoryCreateConnectionDelegateRequest(23, (byte)77, "session123", "vm123", null, null, -1);;
                  
-         //Check the bytes
-         
-         //First byte should be version
-         assertEquals(77, dis.readByte());
-         
-         //First byte should be CANCEL
-         assertEquals(JMSWireFormat.CANCEL, dis.readByte());
-         
-         //Next int should be objectId
-         assertEquals(objectId, dis.readInt());
-         
-         //Next long should be methodHash
-         assertEquals(methodHash, dis.readLong());
-         
-         //Next should be the deliveryid
-         long l = dis.readLong();
-         
-         //Then delivery count
-         int count = dis.readInt();
-         
-         boolean expired = dis.readBoolean();
-         
-         boolean reachedMaxDeliveries = dis.readBoolean();
-         
-         assertEquals(deliveryID, l);
-         
-         assertEquals(deliveryCount, count);
-         
-         assertEquals(expired, true);
-         
-         assertEquals(reachedMaxDeliveries, true);
-
-         //Now eos
-         try
-         {
-            dis.readByte();
-            fail("End of stream expected");
-         }
-         catch (EOFException e)
-         {
-            //Ok
-         }
-         
-         bis.reset();
-         
-         InputStream ois = new DataInputStream(bis);
-         
-         InvocationRequest ir2 = (InvocationRequest)wf.read(ois, null);
-         
-         mm = (MessagingMarshallable)ir2.getParameter();
-         
-         assertEquals(77, mm.getVersion());
-         
-         MethodInvocation mi2 = (MethodInvocation)mm.getLoad();
-         
-         assertEquals(methodHash, mi2.getMethodHash());
-         
-         assertEquals(objectId, ((Integer)mi2.getMetaData().getMetaData(Dispatcher.DISPATCHER, Dispatcher.OID)).intValue());
-         
-         Cancel l2 = (Cancel)mi2.getArguments()[0];
-         
-         assertEquals(deliveryID, l2.getDeliveryId());
-         
-         assertEquals(deliveryCount, l2.getDeliveryCount());
-         
-         assertEquals(expired, l2.isExpired());
-         
-         assertEquals(reachedMaxDeliveries, l2.isReachedMaxDeliveryAttempts());
-         
+         testPacket(req, PacketSupport.REQ_CONNECTIONFACTORY_CREATECONNECTIONDELEGATE);                           
       }
       
-      public void testCancelDeliveries() throws Exception
-      {                            
-         long methodHash = 62365354;
-         
-         int objectId = 54321;
-         
-         List cancels = new ArrayList();
-         
-         DefaultCancel cancel1 = new DefaultCancel(65654, 43, true, false);
-         DefaultCancel cancel2 = new DefaultCancel(65765, 2, false, true);
-         cancels.add(cancel1);
-         cancels.add(cancel2);
-         
-         MethodInvocation mi = new MethodInvocation(null, methodHash, cancelDeliveriesMethod, cancelDeliveriesMethod, null);
-         
-         mi.getMetaData().addMetaData(Dispatcher.DISPATCHER, Dispatcher.OID, new Integer(objectId));   
-         
-         mi.setArguments(new Object[] {cancels});
-         
-         MessagingMarshallable mm = new MessagingMarshallable((byte)77, mi);
-         
-         InvocationRequest ir = new InvocationRequest(null, null, mm, null, null, null);
-         
-         ByteArrayOutputStream bos = new ByteArrayOutputStream();
-         
-         OutputStream oos = new DataOutputStream(bos);
-                  
-         wf.write(ir, oos);
-        
-         oos.flush();
-               
-         byte[] bytes = bos.toByteArray();
-              
-         ByteArrayInputStream bis = new ByteArrayInputStream(bytes);
-                  
-         DataInputStream dis = new DataInputStream(bis); 
-               
-         //Check the bytes
-             
-         //First byte should be version
-         assertEquals(77, dis.readByte());
-         
-         //Next byte should be CANCEL_MESSAGES
-         assertEquals(JMSWireFormat.CANCEL_LIST, dis.readByte());
-         
-         //Next int should be objectId
-         assertEquals(objectId, dis.readInt());
-         
-         //Next long should be methodHash
-         assertEquals(methodHash, dis.readLong());
-                  
-         //Next should the size of the list
-         
-         int size = dis.readInt();
-         
-         assertEquals(2, size);
-         
-         //then the AckInfos
-         long deliveryId = dis.readLong();
-         int deliveryCount = dis.readInt();
-         boolean expired = dis.readBoolean();
-         boolean reachedMaxDeliveries = dis.readBoolean();
-         DefaultCancel rcancel1 = new DefaultCancel(deliveryId, deliveryCount, expired, reachedMaxDeliveries);
-         
-         deliveryId = dis.readLong();
-         deliveryCount = dis.readInt();
-         expired = dis.readBoolean();
-         reachedMaxDeliveries = dis.readBoolean();
-         DefaultCancel rcancel2 = new DefaultCancel(deliveryId, deliveryCount, expired, reachedMaxDeliveries);
-
-         assertEquals(cancel1.getDeliveryCount(), rcancel1.getDeliveryCount());
-         
-         assertEquals(cancel1.getDeliveryId(), cancel1.getDeliveryId());
-         
-         assertEquals(cancel1.isExpired(), cancel1.isExpired());
-         
-         assertEquals(cancel1.isReachedMaxDeliveryAttempts(), cancel1.isReachedMaxDeliveryAttempts());
-         
-         assertEquals(cancel2.getDeliveryCount(), rcancel2.getDeliveryCount());
-         
-         assertEquals(cancel2.getDeliveryId(), cancel2.getDeliveryId());
-         
-         assertEquals(cancel2.isExpired(), cancel2.isExpired());
-         
-         assertEquals(cancel2.isReachedMaxDeliveryAttempts(), cancel2.isReachedMaxDeliveryAttempts());
-                   
-         //should be eos
-                
-         try
-         {
-            dis.readByte();
-            fail("End of stream expected");
-         }
-         catch (EOFException e)
-         {
-            //Ok
-         }
-         
-         
-         bis.reset();
-         
-         InputStream ois = new DataInputStream(bis);
-         
-         InvocationRequest ir2 = (InvocationRequest)wf.read(ois, null);
-         
-         mm = (MessagingMarshallable)ir2.getParameter();
-         
-         assertEquals(77, mm.getVersion());
-         
-         MethodInvocation mi2 = (MethodInvocation)mm.getLoad();
-         
-         assertEquals(methodHash, mi2.getMethodHash());
-         
-         assertEquals(objectId, ((Integer)mi2.getMetaData().getMetaData(Dispatcher.DISPATCHER, Dispatcher.OID)).intValue());
-         
-         List list = (List)mi2.getArguments()[0];
-        
-         assertEquals(2, list.size());
-         
-         DefaultCancel xack1 = (DefaultCancel)list.get(0);
-         DefaultCancel xack2 = (DefaultCancel)list.get(1);
-         
-         assertEquals(cancel1.getDeliveryId(), xack1.getDeliveryId());
-         
-         assertEquals(cancel1.getDeliveryCount(), xack1.getDeliveryCount());
-         
-         assertEquals(cancel2.getDeliveryId(), xack2.getDeliveryId());
-         
-         assertEquals(cancel2.getDeliveryCount(), xack2.getDeliveryCount());
-         
-      }  
+      public void testConnectionFactoryGetIDBlock() throws Exception
+      {
+         RequestSupport req =
+            new ConnectionFactoryGetIDBlockRequest(23, (byte)77, 66);;
+                 
+         testPacket(req, PacketSupport.REQ_CONNECTIONFACTORY_GETIDBLOCK);                           
+      }
       
-      public void testCancelInflightMessages() throws Exception
+      public void testConnectionFactoryGetClientAOPStack() throws Exception
       {
-         long methodHash = 6236354;
-         
-         int objectId = 543271;
-         
-         MethodInvocation mi = new MethodInvocation(null, methodHash, cancelInflightMessagesMethod, cancelInflightMessagesMethod, null);
-         
-         mi.getMetaData().addMetaData(Dispatcher.DISPATCHER, Dispatcher.OID, new Integer(objectId));   
-         
-         long lastDeliveryId = 765;
-         
-         Object[] args = new Object[] { new Long(lastDeliveryId) };
-         
-         mi.setArguments(args);
-         
-         MessagingMarshallable mm = new MessagingMarshallable((byte)77, mi);
-         
-         InvocationRequest ir = new InvocationRequest(null, null, mm, null, null, null);
-         
-         ByteArrayOutputStream bos = new ByteArrayOutputStream();
-         
-         OutputStream oos = new DataOutputStream(bos);
-                  
-         wf.write(ir, oos);
-         
-         oos.flush();
-         
-         byte[] bytes = bos.toByteArray();
-         
-         ByteArrayInputStream bis = new ByteArrayInputStream(bytes);
-                  
-         DataInputStream dis = new DataInputStream(bis); 
+         RequestSupport req =
+            new ConnectionFactoryGetClientAOPStackRequest(23, (byte)77);;
                  
-         //Check the bytes
-         
-         //First byte should be version
-         assertEquals(77, dis.readByte());
-         
-         //First byte should be CANCEL
-         assertEquals(JMSWireFormat.CANCEL_INFLIGHT_MESSAGES, dis.readByte());
-         
-         //Next int should be objectId
-         assertEquals(objectId, dis.readInt());
-         
-         //Next long should be methodHash
-         assertEquals(methodHash, dis.readLong());
-         
-         //Next should be the lastdeliveryid
-         long l = dis.readLong();
-         
-         assertEquals(lastDeliveryId, l);
-         
-         //Now eos
-         try
-         {
-            dis.readByte();
-            fail("End of stream expected");
-         }
-         catch (EOFException e)
-         {
-            //Ok
-         }
-         
-         bis.reset();
-         
-         InputStream ois = new DataInputStream(bis);
-         
-         InvocationRequest ir2 = (InvocationRequest)wf.read(ois, null);
-         
-         mm = (MessagingMarshallable)ir2.getParameter();
-         
-         assertEquals(77, mm.getVersion());
-         
-         MethodInvocation mi2 = (MethodInvocation)mm.getLoad();
-         
-         assertEquals(methodHash, mi2.getMethodHash());
-         
-         assertEquals(objectId, ((Integer)mi2.getMetaData().getMetaData(Dispatcher.DISPATCHER, Dispatcher.OID)).intValue());
-         
-         Long l2 = (Long)mi2.getArguments()[0];
-         
-         assertEquals(lastDeliveryId, l2.longValue());
+         testPacket(req, PacketSupport.REQ_CONNECTIONFACTORY_GETCLIENTAOPSTACK);                           
       }
       
+      // Connection
       
-      /*
-       * Test that general serializable invocation requests are marshalled correctky
-       */
-      public void testSerializableRequest() throws Exception
+      public void testConnectionCreateSessionDelegateRequest() throws Exception
       {
-         String s = new GUID().toString();
-         
-         long l = 123456789;
-         
-         SerializableObject so = new SerializableObject(s, l);  
-         
-         String sessionID = "sessionid123";
-         
-         String subsystem = "Testing123";
-         
-         Map requestPayload = new HashMap();
-         
-         requestPayload.put("testingkey1", "wibble1");
-         
-         Map returnPayload = new HashMap();
-         
-         returnPayload.put("testingkey2", "wibble2");
-         
-         InvokerLocator locator = new InvokerLocator("socket://0.0.0.0:0");
-                
-         InvocationRequest ir = new InvocationRequest(sessionID, subsystem, so, requestPayload, returnPayload, locator);
-         
-         ByteArrayOutputStream bos = new ByteArrayOutputStream();
-         
-         OutputStream oos = new DataOutputStream(bos);
-         
-         wf.write(ir, oos);
-         
-         oos.flush();
-         
-         ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
-         
-         // Check the bytes
-                  
-         DataInputStream dis = new DataInputStream(bis);
-         
-         // First byte should be version
-         byte version = dis.readByte();
-         
-         assertEquals(CURRENT_VERSION, version);
-         
-         bis.reset();
-         
-         InputStream ois = new DataInputStream(bis);
-                                 
-         InvocationRequest ir2 = (InvocationRequest)wf.read(ois, null);
-         
-         assertNotNull(ir2);
-         
-         assertEquals("sessionid123", ir2.getSessionId());
-         
-         assertEquals("Testing123", ir2.getSubsystem());
-         
-         assertEquals("wibble1", ir2.getRequestPayload().get("testingkey1"));
-         
-         assertEquals("wibble2", ir2.getReturnPayload().get("testingkey2"));
-         
-         assertEquals("socket", ir2.getLocator().getProtocol());
-         
-         assertEquals(s, ((SerializableObject)ir2.getParameter()).s);
-         
-         assertEquals(l, ((SerializableObject)ir2.getParameter()).l);                          
+         RequestSupport req =
+            new ConnectionCreateSessionDelegateRequest(23, (byte)77, true, 23, true);;
+                 
+         testPacket(req, PacketSupport.REQ_CONNECTION_CREATESESSIONDELEGATE);                           
       }
       
-      /*
-       * Test that general serializable invocation responses are marshalled correctky
-       */
-      public void testSerializableResponse() throws Exception
+      public void testConnectionGetClientIDRequest() throws Exception
       {
-         String s = new GUID().toString();
-         
-         long l = 987654321;
-         
-         SerializableObject so = new SerializableObject(s, l);  
-         
-         String sessionID = "sessionid456";
-         
-         Map payload = new HashMap();
-         
-         payload.put("testingkey3", "wibble3");
-                        
-         InvocationResponse ir = new InvocationResponse(sessionID, so, false, payload);
-         
-         ByteArrayOutputStream bos = new ByteArrayOutputStream();
-         
-         OutputStream oos = new DataOutputStream(bos);
-         
-         wf.write(ir, oos);
-         
-         oos.flush();
-         
-         ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
-         
-         DataInputStream dis = new DataInputStream(bis);
-         
-         // First byte should be version
-         byte version = dis.readByte();
-         
-         assertEquals(CURRENT_VERSION, version);
-         
-         bis.reset();
-         
-         InputStream ois = new DataInputStream(bis);
-            
-         InvocationResponse ir2 = (InvocationResponse)wf.read(ois, null);
-         
-         assertNotNull(ir2);
-         
-         assertEquals("sessionid456", ir2.getSessionId());
-         
-         assertEquals("wibble3", ir2.getPayload().get("testingkey3"));
-         
-         assertEquals(s, ((SerializableObject)ir2.getResult()).s);
-         
-         assertEquals(l, ((SerializableObject)ir2.getResult()).l);         
+         RequestSupport req =
+            new ConnectionGetClientIDRequest(23, (byte)77);;
+                 
+         testPacket(req, PacketSupport.REQ_CONNECTION_GETCLIENTID);                           
       }
       
-      public void testExceptionResponse() throws Exception
+      public void testConnectionSetClientIDRequest() throws Exception
       {
-         String sessionID = "sessionid456";
-         
-         Map payload = new HashMap();
-         
-         payload.put("testingkey3", "wibble3");
-                        
-         InvocationResponse ir = new InvocationResponse(sessionID, new Exception("Flamingo"), true, payload);
-         
-         ByteArrayOutputStream bos = new ByteArrayOutputStream();
-         
-         OutputStream oos = new DataOutputStream(bos);
-         
-         wf.write(ir, oos);
-         
-         oos.flush();
-         
-         ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
-         
-         DataInputStream dis = new DataInputStream(bis);
-         
-         // First byte should be version
-         byte version = dis.readByte();
-         
-         assertEquals(CURRENT_VERSION, version);
-         
-         bis.reset();
-         
-         InputStream ois = new DataInputStream(bis);
-                  
-         InvocationResponse ir2 = (InvocationResponse)wf.read(ois, null);
-         
-         assertNotNull(ir2);
-         
-         assertEquals("sessionid456", ir2.getSessionId());
-         
-         assertEquals("wibble3", ir2.getPayload().get("testingkey3"));
-         
-         assertEquals("Flamingo", ((Exception)ir2.getResult()).getMessage());
-         
-         assertTrue(ir2.isException());
+         RequestSupport req =
+            new ConnectionSetClientIDRequest(23, (byte)77, "blah");;
                  
+         testPacket(req, PacketSupport.REQ_CONNECTION_SETCLIENTID);                           
       }
-                  
-      public void testSend() throws Exception
-      {       
-         JBossMessage m = new JBossMessage(123);
-         
-         MessageTest.configureMessage(m);
-         
-         long methodHash = 62365354;
-         
-         int objectId = 54321;
-         
-         MethodInvocation mi = new MethodInvocation(null, methodHash, sendMethod, sendMethod, null);
-         
-         mi.getMetaData().addMetaData(Dispatcher.DISPATCHER, Dispatcher.OID, new Integer(objectId));   
-         
-         mi.setArguments(new Object[] {m});
-         
-         MessagingMarshallable mm = new MessagingMarshallable((byte)77, mi);
-         
-         InvocationRequest ir = new InvocationRequest(null, null, mm, null, null, null);
-         
-         ByteArrayOutputStream bos = new ByteArrayOutputStream();
-         
-         OutputStream oos = new DataOutputStream(bos);
-                  
-         wf.write(ir, oos);
-         
-         oos.flush();
-         
-         byte[] bytes = bos.toByteArray();
-         
-         ByteArrayInputStream bis = new ByteArrayInputStream(bytes);
-                  
-         DataInputStream dis = new DataInputStream(bis); 
-               
-         //Check the bytes
-         
-         //First byte should be version
-         assertEquals(77, dis.readByte());
-         
-         //First byte should be SEND
-         assertEquals(JMSWireFormat.SEND, dis.readByte());
-         
-         //Next int should be objectId
-         assertEquals(objectId, dis.readInt());
-         
-         //Next long should be methodHash
-         assertEquals(methodHash, dis.readLong());
-         
-         //Next should be be type         
-         byte type = dis.readByte();
-         
-         assertEquals(JBossMessage.TYPE, type);
-         
-         //Next should come the message
-         JBossMessage m2 = new JBossMessage();
-         
-         m2.read(dis);
-         
-         //should be eos
-         
-         try
-         {
-            dis.readByte();
-            fail("End of stream expected");
-         }
-         catch (EOFException e)
-         {
-            //Ok
-         }
-
-         MessageTest.ensureEquivalent(m, m2);
-         
-         bis.reset();
-         
-         InputStream ois = new DataInputStream(bis);
-         
-         InvocationRequest ir2 = (InvocationRequest)wf.read(ois, null);
-         
-         mm = (MessagingMarshallable)ir2.getParameter();
-         
-         assertEquals(77, mm.getVersion());
-         
-         MethodInvocation mi2 = (MethodInvocation)mm.getLoad();
-         
-         assertEquals(methodHash, mi2.getMethodHash());
-         
-         assertEquals(objectId, ((Integer)mi2.getMetaData().getMetaData(Dispatcher.DISPATCHER, Dispatcher.OID)).intValue());
-         
-         JBossMessage m3 = (JBossMessage)mi2.getArguments()[0];
-         
-         MessageTest.ensureEquivalent(m, m3);
-                  
-      }  
       
-      public void testSendTransaction() throws Exception
-      {       
-         JBossMessage m = new JBossMessage(123);
-         MessageTest.configureMessage(m);
+      public void testConnectionStartRequest() throws Exception
+      {
+         RequestSupport req =
+            new ConnectionStartRequest(23, (byte)77);;
+                 
+         testPacket(req, PacketSupport.REQ_CONNECTION_START);                           
+      }
+      
+      public void testConnectionStopRequest() throws Exception
+      {
+         RequestSupport req =
+            new ConnectionStopRequest(23, (byte)77);;
+                 
+         testPacket(req, PacketSupport.REQ_CONNECTION_STOP);                           
+      }
+      
+      public void testConnectionSendTransactionRequest() throws Exception
+      {
+         ClientTransaction tx = new ClientTransaction();
          
-         long deliveryId = 89281389;
+         TransactionRequest tr = new TransactionRequest(TransactionRequest.ONE_PHASE_COMMIT_REQUEST, null, tx);
          
-         int deliveryCount = 12;
-         
-         MessageProxy proxy = JBossMessage.createThinDelegate(deliveryId, m, deliveryCount);
-                     
-         DeliveryInfo info = new DeliveryInfo(proxy, 76762, 98982, null);
-         
-         int sessionId = 8787;
-         
-         ClientTransaction state = new ClientTransaction();
-         state.addMessage(sessionId, m);
-         state.addAck(sessionId, info);
-          
-         TransactionRequest request = new TransactionRequest(TransactionRequest.ONE_PHASE_COMMIT_REQUEST, null, state);
-                           
-         long methodHash = 62365354;
-         
-         int objectId = 54321;
-         
-         MethodInvocation mi = new MethodInvocation(null, methodHash, sendTransactionMethod, sendTransactionMethod, null);
-         
-         mi.getMetaData().addMetaData(Dispatcher.DISPATCHER, Dispatcher.OID, new Integer(objectId));   
-         
-         mi.setArguments(new Object[] {request});
-         
-         MessagingMarshallable mm = new MessagingMarshallable((byte)77, mi);
-         
-         InvocationRequest ir = new InvocationRequest(null, null, mm, null, null, null);
-         
-         ByteArrayOutputStream bos = new ByteArrayOutputStream();
-         
-         OutputStream oos = new DataOutputStream(bos);
-                  
-         wf.write(ir, oos);
-        
-         oos.flush();
-               
-         byte[] bytes = bos.toByteArray();
-              
-         ByteArrayInputStream bis = new ByteArrayInputStream(bytes);
-                  
-         DataInputStream dis = new DataInputStream(bis); 
-               
-         //Check the bytes
-             
-         //First byte should be version
-         assertEquals(77, dis.readByte());
-         
-         //First byte should be SEND_TRANSACTION
-         assertEquals(JMSWireFormat.SEND_TRANSACTION, dis.readByte());
-         
-         //Next int should be objectId
-         assertEquals(objectId, dis.readInt());
-         
-         //Next long should be methodHash
-         assertEquals(methodHash, dis.readLong());
-                  
-         //Next should come the transaction request
-         
-         TransactionRequest req = new TransactionRequest();
-                         
-         req.read(dis);
-         
-         //should be eos
-                
-         try
-         {
-            dis.readByte();
-            fail("End of stream expected");
-         }
-         catch (EOFException e)
-         {
-            //Ok
-         }
-         
-         ClientTransaction state2 = req.getState();
-         
-         Collection sessionStates = state2.getSessionStates();
-         
-         assertEquals(1, sessionStates.size());
-         
-         SessionTxState sess = (SessionTxState)sessionStates.iterator().next();
-
-         JBossMessage m2 = (JBossMessage)sess.getMsgs().get(0);
-         
-         MessageTest.ensureEquivalent(m, m2);
-         
-         assertEquals(TransactionRequest.ONE_PHASE_COMMIT_REQUEST, req.getRequestType());
-         
-         Ack ack = (Ack)sess.getAcks().get(0);
-         
-         assertEquals(deliveryId, ack.getDeliveryID());
-         
-         bis.reset();
-         
-         InputStream ois = new DataInputStream(bis);
-         
-         InvocationRequest ir2 = (InvocationRequest)wf.read(ois, null);
-         
-         mm = (MessagingMarshallable)ir2.getParameter();
-         
-         assertEquals(77, mm.getVersion());
-         
-         MethodInvocation mi2 = (MethodInvocation)mm.getLoad();
-         
-         assertEquals(methodHash, mi2.getMethodHash());
-         
-         assertEquals(objectId, ((Integer)mi2.getMetaData().getMetaData(Dispatcher.DISPATCHER, Dispatcher.OID)).intValue());
-         
-         TransactionRequest req2 = (TransactionRequest)mi2.getArguments()[0];
-         
-         ClientTransaction state3 = req2.getState();
-         
-         Collection sessionStates2 = state3.getSessionStates();
-         
-         SessionTxState sess2 = (SessionTxState)sessionStates2.iterator().next();
-         
-         JBossMessage m3 = (JBossMessage)sess2.getMsgs().get(0);
-         
-         MessageTest.ensureEquivalent(m, m3);
-         
-         assertEquals(TransactionRequest.ONE_PHASE_COMMIT_REQUEST, req2.getRequestType());
-         
-         Ack ack2 = (Ack)sess2.getAcks().get(0);
-         
-         assertEquals(deliveryId, ack2.getDeliveryID());
-         
+         RequestSupport req =
+            new ConnectionSendTransactionRequest(23, (byte)77, tr);
+                 
+         testPacket(req, PacketSupport.REQ_CONNECTION_SENDTRANSACTION);                           
+      }      
+      
+      public void testConnectionGetPreparedTransactionsRequest() throws Exception
+      {
+         RequestSupport req =
+            new ConnectionGetPreparedTransactionsRequest(23, (byte)77);
+                 
+         testPacket(req, PacketSupport.REQ_CONNECTION_GETPREPAREDTRANSACTIONS);                           
       }  
-            
-                  
-      public void testNullResponse() throws Exception
+      
+      // Session
+      
+      public void testSessionCreateConsumerDelegateRequest() throws Exception
       {
-         MessagingMarshallable mm = new MessagingMarshallable((byte)77, null);
-         InvocationResponse resp = new InvocationResponse(null, mm, false, null);
-
-         ByteArrayOutputStream bos = new ByteArrayOutputStream();
-         OutputStream oos = new DataOutputStream(bos);
-         
-         wf.write(resp, oos);
-         oos.flush();
-         
-         ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
-       
-         DataInputStream dis = new DataInputStream(bis);
-
-         // First byte should be version
-         assertEquals(77, dis.readByte());
-
-         // Should be 1 byte
-         byte b = dis.readByte();
-
-         assertEquals(JMSWireFormat.NULL_RESPONSE, b);
-
-         // Should be eos
-         try
-         {
-            dis.readByte();
-            fail("End of stream expected");
-         }
-         catch (EOFException e)
-         {
-            //Ok
-         }
-         
-         bis.reset();
-
-         InputStream ois = new DataInputStream(bis);
-
-         InvocationResponse ir2 = (InvocationResponse)wf.read(ois, null);
-         
-         mm = (MessagingMarshallable)ir2.getResult();
-         
-         assertEquals(77, mm.getVersion());
-         
-         assertNull(mm.getLoad());
-            
+         RequestSupport req =
+            new SessionCreateConsumerDelegateRequest(23, (byte)77, new JBossQueue("wibble"), null, false, null, false, -1);
+                 
+         testPacket(req, PacketSupport.REQ_SESSION_CREATECONSUMERDELEGATE);                           
+      } 
+      
+      public void testSessionCreateBrowserDelegateRequest() throws Exception
+      {
+         RequestSupport req =
+            new SessionCreateBrowserDelegateRequest(23, (byte)77, new JBossQueue("wibble"), null, -1);
+                 
+         testPacket(req, PacketSupport.REQ_SESSION_CREATEBROWSERDELEGATE);                           
       }
-                  
-      public void testChangeRate() throws Exception
+      
+      public void testSessionCreateQueueRequest() throws Exception
       {
-         long methodHash = 62365354;
+         RequestSupport req =
+            new SessionCreateQueueRequest(23, (byte)77, "wibble");
+                 
+         testPacket(req, PacketSupport.REQ_SESSION_CREATEQUEUE);                           
+      }      
+      
+      public void testSessionCreateTopicRequest() throws Exception
+      {
+         RequestSupport req =
+            new SessionCreateTopicRequest(23, (byte)77, "wibble");
+                 
+         testPacket(req, PacketSupport.REQ_SESSION_CREATETOPIC);                           
+      }
+      
+      public void testSessionAcknowledgeDeliveriesRequest() throws Exception
+      {
+         List acks = new ArrayList();
          
-         int objectId = 54321;
+         acks.add(new DefaultAck(12323));
          
-         float rate = 123.45f;
+         RequestSupport req =
+            new SessionAcknowledgeDeliveriesRequest(23, (byte)77, acks);
+                 
+         testPacket(req, PacketSupport.REQ_SESSION_ACKNOWLEDGEDELIVERIES);                           
+      }   
+      
+      public void testSessionAcknowledgeDeliveryRequest() throws Exception
+      {
+         Ack ack = new DefaultAck(12323);
          
-         MethodInvocation mi = new MethodInvocation(null, methodHash, changeRateMethod, changeRateMethod, null);
+         RequestSupport req =
+            new SessionAcknowledgeDeliveryRequest(23, (byte)77, ack);
+                 
+         testPacket(req, PacketSupport.REQ_SESSION_ACKNOWLEDGEDELIVERY);                           
+      } 
+      
+      public void testSessionCancelDeliveriesRequest() throws Exception
+      {
+         List cancels = new ArrayList();
          
-         mi.getMetaData().addMetaData(Dispatcher.DISPATCHER, Dispatcher.OID, new Integer(objectId)); 
+         cancels.add(new DefaultCancel(12323, 12, false, false));
          
-         Object[] args = new Object[] { new Float(rate) };
+         RequestSupport req =
+            new SessionCancelDeliveriesRequest(23, (byte)77, cancels);
+                 
+         testPacket(req, PacketSupport.REQ_SESSION_CANCELDELIVERIES);                           
+      }   
+      
+      public void testSessionCancelDeliveryRequest() throws Exception
+      {
+         Cancel cancel = (new DefaultCancel(12323, 12, false, false));
          
-         mi.setArguments(args);
-         
-         MessagingMarshallable mm = new MessagingMarshallable((byte)77, mi);
-         
-         InvocationRequest ir = new InvocationRequest(null, null, mm, null, null, null);
-         
-         ByteArrayOutputStream bos = new ByteArrayOutputStream();
-         
-         OutputStream oos = new DataOutputStream(bos);
-                  
-         wf.write(ir, oos);
-         
-         oos.flush();
-         
-         byte[] bytes = bos.toByteArray();
-         
-         ByteArrayInputStream bis = new ByteArrayInputStream(bytes);
-                  
-         DataInputStream dis = new DataInputStream(bis); 
-         
-         //Check the bytes
-         
-         //First byte should be version
-         assertEquals(77, dis.readByte());         
-         
-         //Second byte should be CHANGE_RATE
-         assertEquals(JMSWireFormat.CHANGE_RATE, dis.readByte());
-         
-         //Next int should be objectId
-         assertEquals(objectId, dis.readInt());
-         
-         //Next long should be methodHash
-         assertEquals(methodHash, dis.readLong());
-         
-         //Next should be the float
-         float f2 = dis.readFloat();
-         
-         assertTrue(rate == f2);
-         
-         //Now eos
-         try
-         {
-            dis.readByte();
-            fail("End of stream expected");
-         }
-         catch (EOFException e)
-         {
-            //Ok
-         }
-         
-         bis.reset();
-         InputStream ois = new DataInputStream(bis);
-         
-         InvocationRequest ir2 = (InvocationRequest)wf.read(ois, null);
-
-         OnewayInvocation oneWay = (OnewayInvocation)ir2.getParameter();
-         
-         mm = (MessagingMarshallable)oneWay.getParameters()[0];
-         
-         assertEquals(77, mm.getVersion());
-         
-         MethodInvocation mi2 = (MethodInvocation)mm.getLoad();
-         
-         Float f3 = (Float)mi2.getArguments()[0];
-         
-         assertTrue(rate == f3.floatValue());
-         
-         assertEquals(methodHash, mi2.getMethodHash());
-         
-         assertEquals(objectId, ((Integer)mi2.getMetaData().getMetaData(Dispatcher.DISPATCHER, Dispatcher.OID)).intValue());         
+         RequestSupport req =
+            new SessionCancelDeliveryRequest(23, (byte)77, cancel);
+                 
+         testPacket(req, PacketSupport.REQ_SESSION_CANCELDELIVERY);                           
+      } 
+      
+      public void testSessionAddTemporaryDestinationRequest() throws Exception
+      {
+         RequestSupport req =
+            new SessionAddTemporaryDestinationRequest(23, (byte)77, new JBossTemporaryQueue("blah"));
+                 
+         testPacket(req, PacketSupport.REQ_SESSION_ADDTEMPORARYDESTINATION);                           
+      } 
+      
+      public void testSessionDeleteTemporaryDestinationRequest() throws Exception
+      {
+         RequestSupport req =
+            new SessionDeleteTemporaryDestinationRequest(23, (byte)77, new JBossTemporaryQueue("blah"));
+                 
+         testPacket(req, PacketSupport.REQ_SESSION_DELETETEMPORARYDESTINATION);                           
+      } 
+      
+      public void testSessionUnsubscribeRequest() throws Exception
+      {
+         RequestSupport req =
+            new SessionUnsubscribeRequest(23, (byte)77, "blah");
+                 
+         testPacket(req, PacketSupport.REQ_SESSION_UNSUBSCRIBE);                           
       }
       
-            
-      public void testMessageDelivery() throws Exception
+      public void testSessionSendRequest() throws Exception
       {
-         int consumerID = 12345678;
+         JBossMessage msg = new JBossMessage(123);
          
-         JBossMessage m1 = new JBossMessage(123);
-
-         MessageProxy del1 = JBossMessage.createThinDelegate(1, m1, 7);
+         RequestSupport req =
+            new SessionSendRequest(23, (byte)77, msg);
+                 
+         testPacket(req, PacketSupport.REQ_SESSION_SEND);                           
+      }
+      
+      public void testSessionRecoverDeliveriesRequest() throws Exception
+      { 
+         List dels = new ArrayList();
          
-         MessageTest.configureMessage(m1);
-
-         ClientDelivery dr = new ClientDelivery(del1, consumerID);
+         DeliveryRecovery info = new DeliveryRecovery();
          
-         ByteArrayOutputStream bos = new ByteArrayOutputStream();
+         dels.add(info);
          
-         OutputStream oos = new DataOutputStream(bos);
+         RequestSupport req =
+            new SessionRecoverDeliveriesRequest(23, (byte)77, dels);
+                 
+         testPacket(req, PacketSupport.REQ_SESSION_RECOVERDELIVERIES);                           
+      }
+      
+      // Consumer
+      
+      public void testConsumerChangeRateRequest() throws Exception
+      { 
+         RequestSupport req =
+            new ConsumerChangeRateRequest(23, (byte)77, 123.23f);
+                 
+         testPacket(req, PacketSupport.REQ_CONSUMER_CHANGERATE);                           
+      }
+      
+      public void testConsumerCancelInflightMessagesRequest() throws Exception
+      { 
+         RequestSupport req =
+            new ConsumerCancelInflightMessagesRequest(23, (byte)77, 123);
+                 
+         testPacket(req, PacketSupport.REQ_CONSUMER_CANCELINFLIGHTMESSAGES);                           
+      }
+      
+      // Browser
+      
+      public void testBrowserNextMessageRequest() throws Exception
+      { 
+         RequestSupport req =
+            new BrowserNextMessageRequest(23, (byte)77);
+                 
+         testPacket(req, PacketSupport.REQ_BROWSER_NEXTMESSAGE);                           
+      }
+      
+      public void testBrowserHasNextMessageRequest() throws Exception
+      { 
+         RequestSupport req =
+            new BrowserHasNextMessageRequest(23, (byte)77);
+                 
+         testPacket(req, PacketSupport.REQ_BROWSER_HASNEXTMESSAGE);                           
+      }
+      
+      public void testBrowserNextMessageBlockRequest() throws Exception
+      { 
+         RequestSupport req =
+            new BrowserNextMessageBlockRequest(23, (byte)77, 123);
+                 
+         testPacket(req, PacketSupport.REQ_BROWSER_NEXTMESSAGEBLOCK);                           
+      }
+      
+      
+      public void testClosingRequest() throws Exception
+      { 
+         RequestSupport req =  new ClosingRequest(23, (byte)77);
+                 
+         testPacket(req, PacketSupport.REQ_CLOSING);                           
+      }
+      
+      public void testCloseRequest() throws Exception
+      { 
+         RequestSupport req =  new CloseRequest(23, (byte)77);
+                 
+         testPacket(req, PacketSupport.REQ_CLOSE);                           
+      }
+      
+      
+      // Responses
+      
+      // Connection Factory
+      
+      public void testConnectionFactoryCreateConnectionDelegateResponse() throws Exception
+      { 
+         CreateConnectionResult res = new CreateConnectionResult(123);
          
-         MessagingMarshallable mm = new MessagingMarshallable((byte)77, dr);
+         ResponseSupport resp =
+            new ConnectionFactoryCreateConnectionDelegateResponse(res);
+                 
+         testPacket(resp, PacketSupport.RESP_CONNECTIONFACTORY_CREATECONNECTIONDELEGATE);                           
+      }
+      
+      public void testConnectionFactoryGetIDBlockResponse() throws Exception
+      { 
+         IDBlock block = new IDBlock(1, 76);
          
-         InvocationRequest ir = new InvocationRequest("dummySessionId", null, mm, null, null, null);
+         ResponseSupport resp =
+            new ConnectionFactoryGetIDBlockResponse(block);
+                 
+         testPacket(resp, PacketSupport.RESP_CONNECTIONFACTORY_GETIDBLOCK);                           
+      }
+      
+      public void testConnectionFactoryGetClientAOPStackResponse() throws Exception
+      { 
+         String s = "ioqjwoijqsdoijqdoij";
          
-         wf.write(ir, oos);
+         byte[] bytes = s.getBytes();
          
-         oos.flush();
+         ResponseSupport resp =
+            new ConnectionFactoryGetClientAOPStackResponse(bytes);
+                 
+         testPacket(resp, PacketSupport.RESP_CONNECTIONFACTORY_GETCLIENTAOPSTACK);                           
+      }
+      
+      // Connection
+      
+      public void testConnectionCreateSessionDelegateResponse() throws Exception
+      { 
+         ClientSessionDelegate del = new ClientSessionDelegate(786);
          
-         ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
+         ResponseSupport resp =
+            new ConnectionCreateSessionDelegateResponse(del);
+                 
+         testPacket(resp, PacketSupport.RESP_CONNECTION_CREATESESSIONDELEGATE);                           
+      }
+      
+      public void testConnectionGetClientIDResponse() throws Exception
+      { 
+         ResponseSupport resp =
+            new ConnectionGetClientIDResponse("isij");
+                 
+         testPacket(resp, PacketSupport.RESP_CONNECTION_GETCLIENTID);                           
+      }
+      
+      public void testConnectionGetClientPreparedTransactionsResponse() throws Exception
+      { 
+         MessagingXid xid = new MessagingXid("okokko".getBytes(), 23, "okjokokdd".getBytes());         
                   
-         DataInputStream dis = new DataInputStream(bis);
+         ResponseSupport resp =
+            new ConnectionGetPreparedTransactionsResponse(new MessagingXid[] { xid });
+                 
+         testPacket(resp, PacketSupport.RESP_CONNECTION_GETPREPAREDTRANSACTIONS);                           
+      }
+      
+      
+      
+      // Session
+      
+      public void testSessionCreateConsumerDelegateResponse() throws Exception
+      { 
+         ClientConsumerDelegate del = new ClientConsumerDelegate(786, 13123, 213, 123);
          
-         //Check the bytes
+         ResponseSupport resp =
+            new SessionCreateConsumerDelegateResponse(del);
+                 
+         testPacket(resp, PacketSupport.RESP_SESSION_CREATECONSUMERDELEGATE);                           
+      }
+      
+      
+      public void testSessionCreateBrowserDelegateResponse() throws Exception
+      { 
+         ClientBrowserDelegate del = new ClientBrowserDelegate(786, 12);
          
-         //First byte should be version
-         assertEquals(77, dis.readByte());         
+         ResponseSupport resp =
+            new SessionCreateBrowserDelegateResponse(del);
+                 
+         testPacket(resp, PacketSupport.RESP_SESSION_CREATEBROWSERDELEGATE);                           
+      }
+      
+      public void testSessionCreateQueueResponse() throws Exception
+      { 
+         ResponseSupport resp =
+            new SessionCreateQueueResponse(new JBossQueue("ijoij"));
+                 
+         testPacket(resp, PacketSupport.RESP_SESSION_CREATEQUEUE);                           
+      }
+      
+      public void testSessionCreateTopicResponse() throws Exception
+      { 
+         ResponseSupport resp =
+            new SessionCreateTopicResponse(new JBossTopic("ijoij"));
+                 
+         testPacket(resp, PacketSupport.RESP_SESSION_CREATETOPIC);                           
+      }
+      
+      // Browser
+      
+      public void testBrowserNextMessageResponse() throws Exception
+      { 
+         JBossMessage msg = new JBossMessage(123);
          
-         //Second byte should be MESSAGE_DELIVERY
-         assertEquals(JMSWireFormat.MESSAGE_DELIVERY, dis.readByte());
+         ResponseSupport resp =
+            new BrowserNextMessageResponse(msg);
+                 
+         testPacket(resp, PacketSupport.RESP_BROWSER_NEXTMESSAGE);                           
+      }
+      
+      public void testBrowserHasNextMessageResponse() throws Exception
+      { 
+         ResponseSupport resp =
+            new BrowserHasNextMessageResponse(true);
+                 
+         testPacket(resp, PacketSupport.RESP_BROWSER_HASNEXTMESSAGE);                           
+      }
+      
+      public void testBrowserNextMessageBlockResponse() throws Exception
+      { 
+         JBossMessage msg = new JBossMessage(123);
          
-         //Next should be sessionID
-         assertEquals("dummySessionId", dis.readUTF());
-         
-         //Next int should be consumer id
-         assertEquals(12345678, dis.readInt());
-                     
-         //Next byte should be type
-         assertEquals(JBossMessage.TYPE, dis.readByte());
-         
-         //Next int should be delivery count
-         assertEquals(7, dis.readInt());
-         
-         //Delivery id
-         assertEquals(1, dis.readLong());
-         
-         //And now the message itself
-         JBossMessage r1 = new JBossMessage();
-         
-         r1.read(dis);         
-         
-         MessageTest.ensureEquivalent(m1, r1);
-         
-         //eos
-         try
-         {
-            dis.readByte();
-            fail("End of stream expected");
-         }
-         catch (EOFException e)
-         {
-            //Ok
-         }
-         
-         bis.reset();
-         
-         InputStream ois = new DataInputStream(bis);
-         
-         InvocationRequest ir2 = (InvocationRequest)wf.read(ois, null);
+         ResponseSupport resp =
+            new BrowserNextMessageBlockResponse(new JBossMessage[] { msg });
+                 
+         testPacket(resp, PacketSupport.RESP_BROWSER_NEXTMESSAGEBLOCK);                           
+      }
+      
+      public void testNullResponse() throws Exception
+      { 
+         ResponseSupport resp =  new NullResponse();
+                 
+         testPacket(resp, PacketSupport.NULL_RESPONSE);                           
+      }
+      
+   }
+   
+   public static class SerializableObject implements Serializable
+   {      
+      /** The serialVersionUID */
+      private static final long serialVersionUID = 1L;
 
-         OnewayInvocation oneway = (OnewayInvocation) ir2.getParameter();
+      public SerializableObject()
+      {         
+      }
 
-         InternalInvocation ii = (InternalInvocation) oneway.getParameters()[0];
-         
-         Object[] parameters = ii.getParameters();
-         
-         assertNotNull(parameters);
-         
-         Callback callback = (Callback) parameters[0];
-         
-         mm = (MessagingMarshallable)callback.getParameter();
-         
-         assertEquals(77, mm.getVersion());
-                  
-         ClientDelivery dr2 = (ClientDelivery)mm.getLoad();
-         
-         MessageProxy p1 = dr2.getMessage();
-         
-         assertEquals(consumerID, dr2.getConsumerId());
-         
-
-         assertEquals(del1.getDeliveryCount(), p1.getDeliveryCount());
-
-         JBossMessage q1 = p1.getMessage();
-  
-         MessageTest.ensureEquivalent(m1, q1);      
+      SerializableObject(String s, long l)
+      {
+         this.s = s;
+         this.l = l;
       }
       
-                  
-      public void testGetIdBlockResponse() throws Exception
-      {
-         IDBlock block = new IDBlock(132, 465);
-         
-         MessagingMarshallable mm = new MessagingMarshallable((byte)77, block);
-                  
-         InvocationResponse ir = new InvocationResponse(null, mm, false, null);
-         
-         ByteArrayOutputStream bos = new ByteArrayOutputStream();
-         
-         OutputStream oos = new DataOutputStream(bos);
-         
-         wf.write(ir, oos);
-         
-         oos.flush();
-         
-         ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
-         
-         DataInputStream dis = new DataInputStream(bis);
-                   
-         // First byte should be version
-         assertEquals(77, dis.readByte());
-         
-         int b = dis.readByte();
-         
-         assertEquals(JMSWireFormat.ID_BLOCK_RESPONSE, b);
-         
-         IDBlock block2 = new IDBlock();
-         
-         block2.read(dis);
-         
-         assertEquals(block.getLow(), block2.getLow());
-         assertEquals(block.getHigh(), block2.getHigh());
-         
-         //eos
-         try
-         {
-            dis.readByte();
-            fail("End of stream expected");
-         }
-         catch (EOFException e)
-         {
-            //Ok
-         }
-         
-         bis.reset();
-         
-         InputStream ois = new DataInputStream(bis);
-         
-         InvocationResponse ir2 = (InvocationResponse)wf.read(ois, null);
-         
-         mm = (MessagingMarshallable)ir2.getResult();
-         
-         assertEquals(77, mm.getVersion());
-         
-         IDBlock block3 = (IDBlock)mm.getLoad();
-         
-         assertEquals(block.getLow(), block3.getLow());
-         assertEquals(block.getHigh(), block3.getHigh());                  
-      }    
-            
+      public String s;
+      
+      public long l;      
    }
 }
\ No newline at end of file

Modified: trunk/tests/src/org/jboss/test/messaging/jms/XARecoveryTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/XARecoveryTest.java	2007-01-31 20:11:51 UTC (rev 2118)
+++ trunk/tests/src/org/jboss/test/messaging/jms/XARecoveryTest.java	2007-02-01 00:10:20 UTC (rev 2119)
@@ -36,7 +36,8 @@
 import javax.transaction.xa.Xid;
 
 import org.jboss.jms.client.JBossConnectionFactory;
-import org.jboss.messaging.core.tx.XidImpl;
+import org.jboss.jms.tx.ResourceManagerFactory;
+import org.jboss.messaging.core.tx.MessagingXid;
 import org.jboss.test.messaging.MessagingTestCase;
 import org.jboss.test.messaging.tools.ServerManagement;
 
@@ -121,7 +122,9 @@
       ServerManagement.undeployQueue("TXQ");
       
       ServerManagement.undeployTopic("TXTOPIC");
-
+      
+      ResourceManagerFactory.instance.clear();
+      
       super.tearDown();
    }
 
@@ -183,7 +186,7 @@
          
          XAResource res = sess2.getXAResource();
          
-         Xid xid1 = new XidImpl("bq1".getBytes(), 42, "eemeli".getBytes());
+         Xid xid1 = new MessagingXid("bq1".getBytes(), 42, "eemeli".getBytes());
          
          res.start(xid1, XAResource.TMNOFLAGS);
          
@@ -420,7 +423,7 @@
          
          XAResource res = sess2.getXAResource();
          
-         Xid xid1 = new XidImpl("bq1".getBytes(), 42, "eemeli".getBytes());
+         Xid xid1 = new MessagingXid("bq1".getBytes(), 42, "eemeli".getBytes());
          
          res.start(xid1, XAResource.TMNOFLAGS);
          
@@ -679,7 +682,7 @@
          
          XAResource res = sess2.getXAResource();
          
-         Xid xid1 = new XidImpl("bq1".getBytes(), 42, "eemeli".getBytes());
+         Xid xid1 = new MessagingXid("bq1".getBytes(), 42, "eemeli".getBytes());
          
          res.start(xid1, XAResource.TMNOFLAGS);
          
@@ -947,7 +950,7 @@
          
          XAResource res = sess2.getXAResource();
          
-         Xid xid1 = new XidImpl("bq1".getBytes(), 42, "eemeli".getBytes());
+         Xid xid1 = new MessagingXid("bq1".getBytes(), 42, "eemeli".getBytes());
          
          res.start(xid1, XAResource.TMNOFLAGS);
          
@@ -1164,6 +1167,7 @@
       }
    }
    
+   
    /* Not really necessary - but it does no harm */
    public void testComplexTransactional() throws Exception
    {
@@ -1210,7 +1214,7 @@
          
          XAResource res = sess2.getXAResource();
          
-         Xid xid1 = new XidImpl("bq1".getBytes(), 42, "eemeli".getBytes());
+         Xid xid1 = new MessagingXid("bq1".getBytes(), 42, "eemeli".getBytes());
          
          res.start(xid1, XAResource.TMNOFLAGS);
          
@@ -1413,7 +1417,7 @@
          XAResource res1 = sess1.getXAResource();
    
          //Pretend to be a transaction manager by interacting through the XAResources
-         Xid xid1 = new XidImpl("bq1".getBytes(), 42, "eemeli".getBytes());
+         Xid xid1 = new MessagingXid("bq1".getBytes(), 42, "eemeli".getBytes());
    
          log.trace("Sending message");
          
@@ -1551,7 +1555,7 @@
          XAResource res1 = sess1.getXAResource();
    
          //Pretend to be a transaction manager by interacting through the XAResources
-         Xid xid1 = new XidImpl("bq1".getBytes(), 42, "eemeli".getBytes());
+         Xid xid1 = new MessagingXid("bq1".getBytes(), 42, "eemeli".getBytes());
    
          log.trace("Sending message");
          
@@ -1733,7 +1737,7 @@
          XAResource res1 = sess2.getXAResource();
    
          //Pretend to be a transaction manager by interacting through the XAResources
-         Xid xid1 = new XidImpl("bq1".getBytes(), 42, "eemeli".getBytes());
+         Xid xid1 = new MessagingXid("bq1".getBytes(), 42, "eemeli".getBytes());
          
          res1.start(xid1, XAResource.TMNOFLAGS);
          
@@ -1874,7 +1878,7 @@
          XAResource res1 = sess2.getXAResource();
    
          //Pretend to be a transaction manager by interacting through the XAResources
-         Xid xid1 = new XidImpl("bq1".getBytes(), 42, "eemeli".getBytes());
+         Xid xid1 = new MessagingXid("bq1".getBytes(), 42, "eemeli".getBytes());
          
          res1.start(xid1, XAResource.TMNOFLAGS);
          
@@ -2049,7 +2053,7 @@
          
          XAResource res = sess2.getXAResource();
          
-         Xid xid1 = new XidImpl("bq1".getBytes(), 42, "eemeli".getBytes());
+         Xid xid1 = new MessagingXid("bq1".getBytes(), 42, "eemeli".getBytes());
          
          res.start(xid1, XAResource.TMNOFLAGS);
          
@@ -2304,7 +2308,7 @@
          
          XAResource res = sess2.getXAResource();
          
-         Xid xid1 = new XidImpl("bq1".getBytes(), 42, "eemeli".getBytes());
+         Xid xid1 = new MessagingXid("bq1".getBytes(), 42, "eemeli".getBytes());
          
          res.start(xid1, XAResource.TMNOFLAGS);
          
@@ -2546,8 +2550,8 @@
          XAResource res2 = sess2.getXAResource();
    
          //Pretend to be a transaction manager by interacting through the XAResources
-         Xid xid1 = new XidImpl("bq1".getBytes(), 42, "eemeli".getBytes());
-         Xid xid2 = new XidImpl("bq2".getBytes(), 42, "frigtard".getBytes());
+         Xid xid1 = new MessagingXid("bq1".getBytes(), 42, "eemeli".getBytes());
+         Xid xid2 = new MessagingXid("bq2".getBytes(), 42, "frigtard".getBytes());
    
          log.trace("Sending messages");
          
@@ -2752,8 +2756,8 @@
          XAResource res2 = sess2.getXAResource();
    
          //Pretend to be a transaction manager by interacting through the XAResources
-         Xid xid1 = new XidImpl("bq1".getBytes(), 42, "aapeli".getBytes());
-         Xid xid2 = new XidImpl("bq2".getBytes(), 42, "belsebub".getBytes());
+         Xid xid1 = new MessagingXid("bq1".getBytes(), 42, "aapeli".getBytes());
+         Xid xid2 = new MessagingXid("bq2".getBytes(), 42, "belsebub".getBytes());
    
          //    Send a message in each tx
    
@@ -3052,8 +3056,8 @@
          XAResource res2 = sess2.getXAResource();
    
          //Pretend to be a transaction manager by interacting through the XAResources
-         Xid xid1 = new XidImpl("bq1".getBytes(), 123, "gbtxid1".getBytes());
-         Xid xid2 = new XidImpl("bq2".getBytes(), 124, "gbtxid2".getBytes());
+         Xid xid1 = new MessagingXid("bq1".getBytes(), 123, "gbtxid1".getBytes());
+         Xid xid2 = new MessagingXid("bq2".getBytes(), 124, "gbtxid2".getBytes());
    
          //    Send a message in each tx
    
@@ -3194,8 +3198,8 @@
          XAResource res2 = sess2.getXAResource();
    
          //Pretend to be a transaction manager by interacting through the XAResources
-         Xid xid1 = new XidImpl("bq1".getBytes(), 123, "gbtxid1".getBytes());
-         Xid xid2 = new XidImpl("bq2".getBytes(), 124, "gbtxid2".getBytes());
+         Xid xid1 = new MessagingXid("bq1".getBytes(), 123, "gbtxid1".getBytes());
+         Xid xid2 = new MessagingXid("bq2".getBytes(), 124, "gbtxid2".getBytes());
    
          //    Send a message in each tx
    

Modified: trunk/tests/src/org/jboss/test/messaging/jms/clustering/base/ClusteringTestBase.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/clustering/base/ClusteringTestBase.java	2007-01-31 20:11:51 UTC (rev 2118)
+++ trunk/tests/src/org/jboss/test/messaging/jms/clustering/base/ClusteringTestBase.java	2007-02-01 00:10:20 UTC (rev 2119)
@@ -233,10 +233,14 @@
          // TODO This is a dangerous hack, relying on an arbitrary distribution algorithm
          // (round-robin in this case). If we want a connection to a specific node, we should be
          // able to look up something like "/ConnectionFactory0"
+         
+         log.info("cf is " + cf);
 
          for(int i = 0; i < nodeCount; i++)
          {
             conn[i] = cf.createConnection();
+            
+            log.info("************ connection is " + conn[i].getClass().getName() + ":" + conn[i]);
          }
 
          // Safety check, making sure we get connections to distinct nodes

Modified: trunk/tests/src/org/jboss/test/messaging/jms/server/ServerPeerTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/server/ServerPeerTest.java	2007-01-31 20:11:51 UTC (rev 2118)
+++ trunk/tests/src/org/jboss/test/messaging/jms/server/ServerPeerTest.java	2007-02-01 00:10:20 UTC (rev 2119)
@@ -47,7 +47,7 @@
 import org.jboss.jms.server.messagecounter.MessageCounter;
 import org.jboss.jms.server.messagecounter.MessageStatistics;
 import org.jboss.jms.util.MessagingJMSException;
-import org.jboss.messaging.core.tx.XidImpl;
+import org.jboss.messaging.core.tx.MessagingXid;
 import org.jboss.test.messaging.MessagingTestCase;
 import org.jboss.test.messaging.tools.ServerManagement;
 
@@ -241,7 +241,7 @@
             
             MessageProducer prod = sess.createProducer(queue);
             
-            xid1 = new XidImpl("blah1".getBytes(), 42, "blahblah1".getBytes());
+            xid1 = new MessagingXid("blah1".getBytes(), 42, "blahblah1".getBytes());
                      
             TextMessage tm = sess.createTextMessage("message1");
             
@@ -263,7 +263,7 @@
             
             MessageProducer prod = sess.createProducer(queue);
             
-            xid2 = new XidImpl("blah2".getBytes(), 42, "blahblah2".getBytes());
+            xid2 = new MessagingXid("blah2".getBytes(), 42, "blahblah2".getBytes());
                      
             TextMessage tm = sess.createTextMessage("message1");
             

Modified: trunk/tests/src/org/jboss/test/messaging/jms/server/connectionmanager/SimpleConnectionManagerTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/server/connectionmanager/SimpleConnectionManagerTest.java	2007-01-31 20:11:51 UTC (rev 2118)
+++ trunk/tests/src/org/jboss/test/messaging/jms/server/connectionmanager/SimpleConnectionManagerTest.java	2007-02-01 00:10:20 UTC (rev 2119)
@@ -28,7 +28,6 @@
 import javax.jms.JMSException;
 import javax.jms.Session;
 import javax.naming.InitialContext;
-import javax.transaction.xa.Xid;
 
 import org.jboss.jms.client.JBossConnection;
 import org.jboss.jms.client.JBossConnectionFactory;
@@ -38,6 +37,7 @@
 import org.jboss.jms.server.connectionmanager.SimpleConnectionManager;
 import org.jboss.jms.server.endpoint.ConnectionEndpoint;
 import org.jboss.jms.tx.TransactionRequest;
+import org.jboss.messaging.core.tx.MessagingXid;
 import org.jboss.test.messaging.MessagingTestCase;
 import org.jboss.test.messaging.tools.ServerManagement;
 
@@ -290,7 +290,7 @@
          return null;
       }
 
-      public Xid[] getPreparedTransactions()
+      public MessagingXid[] getPreparedTransactions()
       {
          return null;
       }

Modified: trunk/tests/src/org/jboss/test/messaging/jms/stress/Transactional2PCReceiver.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/stress/Transactional2PCReceiver.java	2007-01-31 20:11:51 UTC (rev 2118)
+++ trunk/tests/src/org/jboss/test/messaging/jms/stress/Transactional2PCReceiver.java	2007-02-01 00:10:20 UTC (rev 2119)
@@ -27,7 +27,7 @@
 import javax.transaction.xa.XAResource;
 
 import org.jboss.logging.Logger;
-import org.jboss.messaging.core.tx.XidImpl;
+import org.jboss.messaging.core.tx.MessagingXid;
 import org.jboss.util.id.GUID;
 
 /**
@@ -84,9 +84,9 @@
       {      
          int iterations = numMessages / commitSize;
          
-         XidImpl xid = null;
+         MessagingXid xid = null;
          
-         xid = new XidImpl("bq1".getBytes(), 1, new GUID().toString().getBytes());
+         xid = new MessagingXid("bq1".getBytes(), 1, new GUID().toString().getBytes());
             xaResource.start(xid, XAResource.TMNOFLAGS);
          
          for (int outerCount = 0; outerCount < iterations; outerCount++)
@@ -143,7 +143,7 @@
                   xaResource.commit(xid, false);
                                     
                   //Starting new tx
-                  xid = new XidImpl("bq1".getBytes(), 1, new GUID().toString().getBytes());
+                  xid = new MessagingXid("bq1".getBytes(), 1, new GUID().toString().getBytes());
                   xaResource.start(xid, XAResource.TMNOFLAGS);
                  
                }
@@ -205,7 +205,7 @@
                   xaResource.prepare(xid);
                   xaResource.rollback(xid);
                   
-                  xid = new XidImpl("bq1".getBytes(), 1, new GUID().toString().getBytes());
+                  xid = new MessagingXid("bq1".getBytes(), 1, new GUID().toString().getBytes());
                   xaResource.start(xid, XAResource.TMNOFLAGS);
                }
                processingDone();

Modified: trunk/tests/src/org/jboss/test/messaging/jms/stress/Transactional2PCSender.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/stress/Transactional2PCSender.java	2007-01-31 20:11:51 UTC (rev 2118)
+++ trunk/tests/src/org/jboss/test/messaging/jms/stress/Transactional2PCSender.java	2007-02-01 00:10:20 UTC (rev 2119)
@@ -27,7 +27,7 @@
 import javax.transaction.xa.XAResource;
 
 import org.jboss.logging.Logger;
-import org.jboss.messaging.core.tx.XidImpl;
+import org.jboss.messaging.core.tx.MessagingXid;
 import org.jboss.util.id.GUID;
 
 /**
@@ -75,10 +75,10 @@
       {
          for (int outerCount = 0; outerCount < iterations; outerCount++)
          {
-            XidImpl xid = null;
+            MessagingXid xid = null;
             if (commitSize > 0)
             {
-               xid = new XidImpl("bq1".getBytes(), 1, new GUID().toString().getBytes());
+               xid = new MessagingXid("bq1".getBytes(), 1, new GUID().toString().getBytes());
                xaResource.start(xid, XAResource.TMNOFLAGS);
             }
             for (int innerCount = 0; innerCount < commitSize; innerCount++)
@@ -96,7 +96,7 @@
             }
             if (rollbackSize > 0)
             {
-               xid = new XidImpl("bq1".getBytes(), 1, new GUID().toString().getBytes());
+               xid = new MessagingXid("bq1".getBytes(), 1, new GUID().toString().getBytes());
                xaResource.start(xid, XAResource.TMNOFLAGS);
             }
             for (int innerCount = 0; innerCount < rollbackSize; innerCount++)

Modified: trunk/tests/src/org/jboss/test/messaging/tools/ServerManagement.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/tools/ServerManagement.java	2007-01-31 20:11:51 UTC (rev 2118)
+++ trunk/tests/src/org/jboss/test/messaging/tools/ServerManagement.java	2007-02-01 00:10:20 UTC (rev 2119)
@@ -402,7 +402,7 @@
       {
          sb.append("-Dtest.remoting=").append(remoting).append(' ');
       }
-
+      
       String testLogfileSuffix = System.getProperty("test.logfile.suffix");
 
       if (testLogfileSuffix == null)

Modified: trunk/tests/src/org/jboss/test/messaging/tools/jmx/ServiceContainer.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/tools/jmx/ServiceContainer.java	2007-01-31 20:11:51 UTC (rev 2118)
+++ trunk/tests/src/org/jboss/test/messaging/tools/jmx/ServiceContainer.java	2007-02-01 00:10:20 UTC (rev 2119)
@@ -36,10 +36,10 @@
 import java.util.Hashtable;
 import java.util.Iterator;
 import java.util.List;
+import java.util.Map;
 import java.util.Properties;
 import java.util.Set;
 import java.util.StringTokenizer;
-import java.util.Map;
 
 import javax.management.Attribute;
 import javax.management.MBeanAttributeInfo;
@@ -571,7 +571,7 @@
          "server/default/deploy/" + databaseType + "-persistence-service.xml";
 
       log.info("Persistence config file: .... " + persistenceConfigFile);
-
+      
       URL persistenceConfigFileURL = getClass().getClassLoader().getResource(persistenceConfigFile);
       if (persistenceConfigFileURL == null)
       {




More information about the jboss-cvs-commits mailing list