[jboss-cvs] JBoss Messaging SVN: r3580 - in trunk/src/main/org/jboss/jms/client: delegate and 1 other directory.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Jan 16 16:38:26 EST 2008


Author: clebert.suconic at jboss.com
Date: 2008-01-16 16:38:26 -0500 (Wed, 16 Jan 2008)
New Revision: 3580

Modified:
   trunk/src/main/org/jboss/jms/client/api/ClientConnection.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/CommunicationSupport.java
Log:
JBMESSAGING-681 - Fixing version byte

Modified: trunk/src/main/org/jboss/jms/client/api/ClientConnection.java
===================================================================
--- trunk/src/main/org/jboss/jms/client/api/ClientConnection.java	2008-01-16 21:03:52 UTC (rev 3579)
+++ trunk/src/main/org/jboss/jms/client/api/ClientConnection.java	2008-01-16 21:38:26 UTC (rev 3580)
@@ -76,6 +76,8 @@
    
    public String getID();
    
+   public byte getVersion();
    
    
+   
 }

Modified: trunk/src/main/org/jboss/jms/client/delegate/ClientBrowserDelegate.java
===================================================================
--- trunk/src/main/org/jboss/jms/client/delegate/ClientBrowserDelegate.java	2008-01-16 21:03:52 UTC (rev 3579)
+++ trunk/src/main/org/jboss/jms/client/delegate/ClientBrowserDelegate.java	2008-01-16 21:38:26 UTC (rev 3580)
@@ -164,11 +164,20 @@
 
    // Protected ------------------------------------------------------------------------------------
 
+   @Override
    protected Client getClient()
    {
       return this.session.getConnection().getClient();
    }
+
+   @Override
+   protected byte getVersion()
+   {
+      return this.session.getConnection().getVersion();
+   }
    
+   
+   
 
    // Package Private ------------------------------------------------------------------------------
 

Modified: trunk/src/main/org/jboss/jms/client/delegate/ClientClusteredConnectionFactoryDelegate.java
===================================================================
--- trunk/src/main/org/jboss/jms/client/delegate/ClientClusteredConnectionFactoryDelegate.java	2008-01-16 21:03:52 UTC (rev 3579)
+++ trunk/src/main/org/jboss/jms/client/delegate/ClientClusteredConnectionFactoryDelegate.java	2008-01-16 21:38:26 UTC (rev 3580)
@@ -178,6 +178,12 @@
       sendOneWay(remoting.getRemotingClient(), currentDelegate.getID(), Version.instance().getProviderIncrementingVersion(), message);
    }
 
+   @Override
+   protected byte getVersion()
+   {
+      return Version.instance().getProviderIncrementingVersion();
+   }
+
    protected void finalize() throws Throwable
    {
       super.finalize();

Modified: trunk/src/main/org/jboss/jms/client/delegate/ClientConnectionDelegate.java
===================================================================
--- trunk/src/main/org/jboss/jms/client/delegate/ClientConnectionDelegate.java	2008-01-16 21:03:52 UTC (rev 3579)
+++ trunk/src/main/org/jboss/jms/client/delegate/ClientConnectionDelegate.java	2008-01-16 21:38:26 UTC (rev 3580)
@@ -426,6 +426,18 @@
       }
    }
 
+   
+   @Override
+   public byte getVersion()
+   {
+      if (versionToUse == null)
+      {
+         log.warn("Version to use it null");
+      }
+      return versionToUse.getProviderIncrementingVersion();
+   }
+
+   
    // Streamable implementation -------------------------------------------------------------------
 
    public void read(DataInputStream in) throws Exception
@@ -453,6 +465,8 @@
    }
    
    
+   
+   
 
    // Package Private ------------------------------------------------------------------------------
 

Modified: trunk/src/main/org/jboss/jms/client/delegate/ClientConnectionFactoryDelegate.java
===================================================================
--- trunk/src/main/org/jboss/jms/client/delegate/ClientConnectionFactoryDelegate.java	2008-01-16 21:03:52 UTC (rev 3579)
+++ trunk/src/main/org/jboss/jms/client/delegate/ClientConnectionFactoryDelegate.java	2008-01-16 21:38:26 UTC (rev 3580)
@@ -162,7 +162,7 @@
          String sessionID = client.getSessionID();
          
          CreateConnectionRequest request = new CreateConnectionRequest(v, sessionID, JMSClientVMIdentifier.instance, failedNodeID, username, password);
-         CreateConnectionResponse response = (CreateConnectionResponse) sendBlocking(client, request);
+         CreateConnectionResponse response = (CreateConnectionResponse) sendBlocking(client, this.getID(), this.getVersion(), request);
          ClientConnectionDelegate connectionDelegate = new ClientConnectionDelegate(response.getConnectionID(), response.getServerID());
          connectionDelegate.setStrictTck(strictTck);
 

Modified: trunk/src/main/org/jboss/jms/client/delegate/ClientConsumerDelegate.java
===================================================================
--- trunk/src/main/org/jboss/jms/client/delegate/ClientConsumerDelegate.java	2008-01-16 21:03:52 UTC (rev 3579)
+++ trunk/src/main/org/jboss/jms/client/delegate/ClientConsumerDelegate.java	2008-01-16 21:38:26 UTC (rev 3580)
@@ -120,6 +120,12 @@
 
    // DelegateSupport overrides --------------------------------------------------------------------
 
+   @Override
+   protected byte getVersion()
+   {
+      return session.getConnection().getVersion();
+   }
+
    protected Client getClient()
    {
       return this.session.getConnection().getClient();

Modified: trunk/src/main/org/jboss/jms/client/delegate/ClientProducerDelegate.java
===================================================================
--- trunk/src/main/org/jboss/jms/client/delegate/ClientProducerDelegate.java	2008-01-16 21:03:52 UTC (rev 3579)
+++ trunk/src/main/org/jboss/jms/client/delegate/ClientProducerDelegate.java	2008-01-16 21:38:26 UTC (rev 3580)
@@ -388,12 +388,19 @@
    // Protected ------------------------------------------------------------------------------------
    
 
+   @Override
    protected Client getClient()
    {
       return connection.getClient();
    }
    // Package Private ------------------------------------------------------------------------------
 
+   @Override
+   protected byte getVersion()
+   {
+      return connection.getVersion();
+   }
+
    // Private --------------------------------------------------------------------------------------
 
    // Inner Classes --------------------------------------------------------------------------------

Modified: trunk/src/main/org/jboss/jms/client/delegate/ClientSessionDelegate.java
===================================================================
--- trunk/src/main/org/jboss/jms/client/delegate/ClientSessionDelegate.java	2008-01-16 21:03:52 UTC (rev 3579)
+++ trunk/src/main/org/jboss/jms/client/delegate/ClientSessionDelegate.java	2008-01-16 21:38:26 UTC (rev 3580)
@@ -1124,10 +1124,20 @@
 
    // Protected ------------------------------------------------------------------------------------
 
+   @Override
    protected Client getClient()
    {
       return connection.getClient();
    }
+   
+   @Override
+   protected byte getVersion()
+   {
+      return connection.getVersion();
+   }
+
+   
+   
    // Package Private ------------------------------------------------------------------------------
 
    // Private --------------------------------------------------------------------------------------

Modified: trunk/src/main/org/jboss/jms/client/delegate/CommunicationSupport.java
===================================================================
--- trunk/src/main/org/jboss/jms/client/delegate/CommunicationSupport.java	2008-01-16 21:03:52 UTC (rev 3579)
+++ trunk/src/main/org/jboss/jms/client/delegate/CommunicationSupport.java	2008-01-16 21:38:26 UTC (rev 3580)
@@ -24,6 +24,7 @@
 import org.jboss.messaging.core.remoting.wireformat.JMSExceptionMessage;
 import org.jboss.messaging.util.Streamable;
 import org.jgroups.persistence.CannotConnectException;
+import org.jboss.messaging.util.Version;
 
 /**
  * @author <a href="mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
@@ -40,8 +41,12 @@
    // This is set on the server.
    protected String id;
    
-   // TODO move this to Client class
-   protected byte version;
+   
+   transient private boolean firstTime = true;
+   
+   
+   // getVersion cached (instead of calling it every time)
+   transient private byte cacheVersion;
 
    public CommunicationSupport(String id)
    {
@@ -72,6 +77,11 @@
 
    protected abstract Client getClient();
    
+   protected byte getVersion()
+   {
+      return Version.instance().getProviderIncrementingVersion();
+   }
+   
    public String getID()
    {
       return id;
@@ -82,12 +92,6 @@
       this.id = id;
    }
    
-   public void setState(Client client, byte version)
-   {
-      //this.client = client;
-      this.version = version;
-   }
-
    public void synchronizeWith(T nd) throws Exception
    {
       this.id = nd.getID();
@@ -99,29 +103,11 @@
    
    // Protected Methods-----------------------------------------------------------------------------
    
-   // TODO: Refactor these methods into ConnectionImpl/Jeff's Client class
-   
-   public byte getVersion()
-   {
-      return version;
-   }
-
-   public void setVersion(byte version)
-   {
-      this.version = version;
-   }
-
    protected void sendOneWay(AbstractPacket packet) throws JMSException
    {
-      sendOneWay(getClient(), id, version, packet);
+      sendOneWay(getClient(), id, lookupVersion(), packet);
    }
    
-   protected void sendOneWay(Client client, AbstractPacket packet) throws JMSException
-   {
-      sendOneWay(client, id, version, packet);
-   }
-   
-
    protected static void sendOneWay(Client client, String targetID, byte version, AbstractPacket packet) throws JMSException
    {
       assert client != null;
@@ -133,17 +119,13 @@
 
       client.sendOneWay(packet);
    }
-
-   protected AbstractPacket sendBlocking(AbstractPacket request) throws JMSException
+   
+   
+   protected  AbstractPacket sendBlocking(AbstractPacket request) throws JMSException
    {
-      return sendBlocking(getClient(), id, version, request);
+      return sendBlocking(getClient(), id, lookupVersion(), request);
    }
 
-   protected AbstractPacket sendBlocking(Client client, AbstractPacket request) throws JMSException
-   {
-      return sendBlocking(client, id, version, request);
-   }
-
    protected static AbstractPacket sendBlocking(Client client, String targetID, byte version, AbstractPacket request) throws JMSException
    {
       assert client != null;
@@ -168,6 +150,16 @@
       }
    }
    
+   private byte lookupVersion()
+   {
+      if (firstTime)
+      {
+         firstTime=false;
+         cacheVersion = getVersion();
+      }
+      return cacheVersion;
+   }
+   
    protected static JMSException handleThrowable(Throwable t)
    {
       // ConnectionFailedException could happen during ConnectionFactory.createConnection.




More information about the jboss-cvs-commits mailing list