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

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Apr 17 04:45:40 EDT 2008


Author: ataylor
Date: 2008-04-17 04:45:39 -0400 (Thu, 17 Apr 2008)
New Revision: 4071

Added:
   trunk/src/etc/version.properties
Modified:
   trunk/build-messaging.xml
   trunk/src/main/org/jboss/messaging/core/client/ClientConnection.java
   trunk/src/main/org/jboss/messaging/core/client/ClientConnectionFactory.java
   trunk/src/main/org/jboss/messaging/core/client/impl/ClientConnectionFactoryImpl.java
   trunk/src/main/org/jboss/messaging/core/client/impl/ClientConnectionImpl.java
   trunk/src/main/org/jboss/messaging/core/exception/MessagingException.java
   trunk/src/main/org/jboss/messaging/core/management/impl/MessagingServerManagementImpl.java
   trunk/src/main/org/jboss/messaging/core/remoting/impl/codec/CreateConnectionResponseMessageCodec.java
   trunk/src/main/org/jboss/messaging/core/remoting/impl/wireformat/CreateConnectionResponse.java
   trunk/src/main/org/jboss/messaging/core/server/MessagingServer.java
   trunk/src/main/org/jboss/messaging/core/server/impl/MessagingServerImpl.java
   trunk/src/main/org/jboss/messaging/core/server/impl/MessagingServerPacketHandler.java
   trunk/src/main/org/jboss/messaging/core/version/impl/VersionImpl.java
   trunk/src/main/org/jboss/messaging/jms/client/JBossConnection.java
   trunk/src/main/org/jboss/messaging/jms/client/JBossConnectionFactory.java
   trunk/tests/src/org/jboss/messaging/tests/integration/CoreClientTest.java
   trunk/tests/src/org/jboss/messaging/tests/integration/core/remoting/impl/ClientCrashTest.java
   trunk/tests/src/org/jboss/messaging/tests/integration/core/remoting/impl/ClientExitTest.java
   trunk/tests/src/org/jboss/messaging/tests/integration/core/remoting/impl/CrashClient.java
   trunk/tests/src/org/jboss/messaging/tests/integration/core/remoting/impl/GracefulClient.java
   trunk/tests/src/org/jboss/messaging/tests/integration/core/remoting/impl/PacketFilterTest.java
   trunk/tests/src/org/jboss/messaging/tests/integration/core/remoting/ssl/CoreClientOverSSL.java
   trunk/tests/src/org/jboss/messaging/tests/integration/core/remoting/ssl/CoreClientOverSSLTest.java
   trunk/tests/src/org/jboss/messaging/tests/unit/core/remoting/impl/wireformat/PacketTypeTest.java
   trunk/tests/src/org/jboss/messaging/tests/unit/jms/network/ClientNetworkFailureTest.java
   trunk/tests/src/org/jboss/messaging/tests/unit/jms/server/ConnectionManagerTest.java
Log:
changed how the server and client acces version info. both client and server load in the version info from the version.properties file in its jar. on creating a connection, the incremental version is checked to make sure the client is compatible with the server.

Modified: trunk/build-messaging.xml
===================================================================
--- trunk/build-messaging.xml	2008-04-16 23:49:50 UTC (rev 4070)
+++ trunk/build-messaging.xml	2008-04-17 08:45:39 UTC (rev 4071)
@@ -323,6 +323,9 @@
          <include name="**/*.java"/>
          <classpath refid="compilation.classpath"/>
       </javac>
+
+      <echo message="messaging.version.versionName=${messaging.version.name}${line.separator}messaging.version.majorVersion=${messaging.version.major}${line.separator}messaging.version.minorVersion=${messaging.version.minor}${line.separator}messaging.version.microVersion=${messaging.version.micro}${line.separator}messaging.version.incrementingVersion=${messaging.version.incrementing}${line.separator}messaging.version.versionSuffix=${messaging.version.suffix}${line.separator}"
+            file="${build.classes.dir}/version.properties"/>
    </target>
 
    <!-- ======================================================================================== -->
@@ -345,6 +348,7 @@
 
       <jar jarfile="${build.jars.dir}/jboss-${module.name}-client.jar">
          <fileset dir="${build.classes.dir}">
+            <include name="version.properties"/>
             <include name="org/jboss/messaging/jms/**/*.class"/>
             <include name="org/jboss/messaging/core/client/**/*.class"/>
             <include name="org/jboss/messaging/core/exception/**/*.class"/>
@@ -695,7 +699,7 @@
       </junitreport>
    </target>
 
-    <property name="test.execution.classpath.file" value=".test.execution.classpath"/>
+   <property name="test.execution.classpath.file" value=".test.execution.classpath"/>
 
    <target name="get-unit-test-execution-classpath" depends="init">
       <pathconvert refid="unit.test.execution.classpath"

Added: trunk/src/etc/version.properties
===================================================================
--- trunk/src/etc/version.properties	                        (rev 0)
+++ trunk/src/etc/version.properties	2008-04-17 08:45:39 UTC (rev 4071)
@@ -0,0 +1,6 @@
+messaging.version.versionName=Stilton
+messaging.version.majorVersion=2
+messaging.version.minorVersion=0
+messaging.version.microVersion=0
+messaging.version.incrementingVersion=100
+messaging.version.versionSuffix=alpha1
\ No newline at end of file

Modified: trunk/src/main/org/jboss/messaging/core/client/ClientConnection.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/client/ClientConnection.java	2008-04-16 23:49:50 UTC (rev 4070)
+++ trunk/src/main/org/jboss/messaging/core/client/ClientConnection.java	2008-04-17 08:45:39 UTC (rev 4071)
@@ -8,6 +8,7 @@
 package org.jboss.messaging.core.client;
 
 import org.jboss.messaging.core.exception.MessagingException;
+import org.jboss.messaging.core.version.Version;
 
 /**
  * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
@@ -27,4 +28,6 @@
    void close() throws MessagingException;
    
    boolean isClosed();
+
+   Version getServerVersion();
 }

Modified: trunk/src/main/org/jboss/messaging/core/client/ClientConnectionFactory.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/client/ClientConnectionFactory.java	2008-04-16 23:49:50 UTC (rev 4070)
+++ trunk/src/main/org/jboss/messaging/core/client/ClientConnectionFactory.java	2008-04-17 08:45:39 UTC (rev 4071)
@@ -35,7 +35,5 @@
 {         
    ClientConnection createConnection() throws MessagingException;
    
-   ClientConnection createConnection(String username, String password) throws MessagingException; 
-   
-   Version getServerVersion();   
+   ClientConnection createConnection(String username, String password) throws MessagingException;   
 }

Modified: trunk/src/main/org/jboss/messaging/core/client/impl/ClientConnectionFactoryImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/client/impl/ClientConnectionFactoryImpl.java	2008-04-16 23:49:50 UTC (rev 4070)
+++ trunk/src/main/org/jboss/messaging/core/client/impl/ClientConnectionFactoryImpl.java	2008-04-17 08:45:39 UTC (rev 4071)
@@ -33,6 +33,7 @@
 import org.jboss.messaging.core.remoting.impl.wireformat.CreateConnectionRequest;
 import org.jboss.messaging.core.remoting.impl.wireformat.CreateConnectionResponse;
 import org.jboss.messaging.core.version.Version;
+import org.jboss.messaging.core.version.impl.VersionImpl;
 
 
 /**
@@ -63,8 +64,6 @@
    private final Configuration config;
    
    private final PacketDispatcher dispatcher;
-
-   private final Version serverVersion;
  
    private final int serverID;
    
@@ -83,14 +82,12 @@
     
    // Constructors ---------------------------------------------------------------------------------
 
-   public ClientConnectionFactoryImpl(final int serverID, final Configuration config,
-   		                             final Version serverVersion, final boolean strictTck,
+   public ClientConnectionFactoryImpl(final int serverID, final Configuration config, final boolean strictTck,
                                       final int defaultConsumerWindowSize, final int defaultConsumerMaxRate,
                                       final int defaultProducerWindowSize, final int defaultProducerMaxRate)
    {
       this.serverID = serverID;
       this.config = config;
-      this.serverVersion = serverVersion;
       this.strictTck = strictTck;
       this.defaultConsumerWindowSize = defaultConsumerWindowSize;  
       this.defaultConsumerMaxRate = defaultConsumerMaxRate;
@@ -99,12 +96,10 @@
       this.dispatcher = new PacketDispatcherImpl(null);
    }
    
-   public ClientConnectionFactoryImpl(final int serverID, final Configuration config,
-                                      final Version serverVersion)
+   public ClientConnectionFactoryImpl(final int serverID, final Configuration config)
    {
       this.serverID = serverID;
       this.config = config;
-      this.serverVersion = serverVersion;
       this.strictTck = false;
       this.defaultConsumerWindowSize = 1000;      
       this.defaultConsumerMaxRate = -1;
@@ -120,7 +115,7 @@
    
    public ClientConnection createConnection(final String username, final String password) throws MessagingException
    {
-      int v = serverVersion.getIncrementingVersion();
+      Version clientVersion = VersionImpl.load();
                        
       RemotingConnection remotingConnection = null;
       try
@@ -132,7 +127,7 @@
          long sessionID = remotingConnection.getSessionID();
          
          CreateConnectionRequest request =
-            new CreateConnectionRequest(v, sessionID, JMSClientVMIdentifier.instance, username, password);
+            new CreateConnectionRequest(clientVersion.getIncrementingVersion(), sessionID, JMSClientVMIdentifier.instance, username, password);
          
          CreateConnectionResponse response =
             (CreateConnectionResponse)remotingConnection.send(0, request);
@@ -140,8 +135,7 @@
          ClientConnectionImpl connection =
             new ClientConnectionImpl(response.getConnectionTargetID(), serverID, strictTck, remotingConnection,
             		defaultConsumerWindowSize, defaultConsumerMaxRate,
-            		defaultProducerWindowSize, defaultProducerMaxRate);
-
+            		defaultProducerWindowSize, defaultProducerMaxRate, response.getServerVersion());
          return connection;
       }
       catch (Throwable t)
@@ -178,11 +172,6 @@
    {
       return config;
    }
-   
-   public Version getServerVersion()
-   {
-      return serverVersion;
-   }
 
 	public int getConsumerWindowSize()
 	{

Modified: trunk/src/main/org/jboss/messaging/core/client/impl/ClientConnectionImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/client/impl/ClientConnectionImpl.java	2008-04-16 23:49:50 UTC (rev 4070)
+++ trunk/src/main/org/jboss/messaging/core/client/impl/ClientConnectionImpl.java	2008-04-17 08:45:39 UTC (rev 4071)
@@ -35,6 +35,7 @@
 import org.jboss.messaging.core.remoting.impl.wireformat.ConnectionCreateSessionMessage;
 import org.jboss.messaging.core.remoting.impl.wireformat.ConnectionCreateSessionResponseMessage;
 import org.jboss.messaging.core.remoting.impl.wireformat.PacketImpl;
+import org.jboss.messaging.core.version.Version;
 import org.jboss.messaging.util.ConcurrentHashSet;
 
 /**
@@ -78,6 +79,8 @@
    private final int defaultProducerWindowSize;
    
    private final int defaultProducerMaxRate;
+
+   private final Version serverVersion;
    
 
    // Static ---------------------------------------------------------------------------------------
@@ -89,7 +92,8 @@
                                final int defaultConsumerWindowSize,     
                                final int defaultConsumerMaxRate,
                                final int defaultProducerWindowSize,
-                               final int defaultProducerMaxRate)
+                               final int defaultProducerMaxRate,
+                               final Version serverVersion)
    {
       this.serverTargetID = serverTargetID;
       
@@ -106,6 +110,8 @@
       this.defaultProducerWindowSize = defaultProducerWindowSize;
       
       this.defaultProducerMaxRate = defaultProducerMaxRate;
+
+      this.serverVersion = serverVersion;
    }
    
    // ClientConnection implementation --------------------------------------------------------------
@@ -195,6 +201,11 @@
       sessions.remove(session);
    }
 
+   public Version getServerVersion()
+   {
+      return serverVersion;
+   }
+
    // Public ---------------------------------------------------------------------------------------
 
    // Protected ------------------------------------------------------------------------------------

Modified: trunk/src/main/org/jboss/messaging/core/exception/MessagingException.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/exception/MessagingException.java	2008-04-16 23:49:50 UTC (rev 4070)
+++ trunk/src/main/org/jboss/messaging/core/exception/MessagingException.java	2008-04-17 08:45:39 UTC (rev 4071)
@@ -58,6 +58,8 @@
    public static final int ADDRESS_DOES_NOT_EXIST = 106;
    
    public static final int ADDRESS_EXISTS = 107;
+
+   public static final int INCOMPATIBLE_CLIENT_SERVER_VERSIONS = 108;
    
    private int code;
    

Modified: trunk/src/main/org/jboss/messaging/core/management/impl/MessagingServerManagementImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/management/impl/MessagingServerManagementImpl.java	2008-04-16 23:49:50 UTC (rev 4070)
+++ trunk/src/main/org/jboss/messaging/core/management/impl/MessagingServerManagementImpl.java	2008-04-17 08:45:39 UTC (rev 4071)
@@ -117,7 +117,6 @@
    {
       return new ClientConnectionFactoryImpl(messagingServer.getConfiguration().getMessagingServerID(),
               messagingServer.getConfiguration(),
-              messagingServer.getVersion(),
               messagingServer.getConfiguration().isStrictTck() || strictTck,
               consumerWindowSize, consumerMaxRate,
               producerWindowSize, producerMaxRate);

Modified: trunk/src/main/org/jboss/messaging/core/remoting/impl/codec/CreateConnectionResponseMessageCodec.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/impl/codec/CreateConnectionResponseMessageCodec.java	2008-04-16 23:49:50 UTC (rev 4070)
+++ trunk/src/main/org/jboss/messaging/core/remoting/impl/codec/CreateConnectionResponseMessageCodec.java	2008-04-17 08:45:39 UTC (rev 4071)
@@ -9,6 +9,8 @@
 import static org.jboss.messaging.core.remoting.impl.wireformat.PacketType.CREATECONNECTION_RESP;
 
 import org.jboss.messaging.core.remoting.impl.wireformat.CreateConnectionResponse;
+import org.jboss.messaging.core.version.impl.VersionImpl;
+import org.jboss.messaging.core.version.Version;
 
 /**
  * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
@@ -32,23 +34,43 @@
    }
 
    // AbstractPackedCodec overrides----------------------------------
-   
+
    public int getBodyLength(final CreateConnectionResponse packet) throws Exception
    {
-   	return LONG_LENGTH;
+      return LONG_LENGTH +
+              sizeof(packet.getServerVersion().getVersionName()) +
+              INT_LENGTH +
+              INT_LENGTH +
+              INT_LENGTH +
+              INT_LENGTH +
+              sizeof(packet.getServerVersion().getVersionSuffix());
    }
 
    @Override
    protected void encodeBody(final CreateConnectionResponse response, final RemotingBuffer out)
-         throws Exception
+           throws Exception
    {
       out.putLong(response.getConnectionTargetID());
+      out.putNullableString(response.getServerVersion().getVersionName());
+      out.putInt(response.getServerVersion().getMajorVersion());
+      out.putInt(response.getServerVersion().getMinorVersion());
+      out.putInt(response.getServerVersion().getMicroVersion());
+      out.putInt(response.getServerVersion().getIncrementingVersion());
+      out.putNullableString(response.getServerVersion().getVersionSuffix());
    }
 
    @Override
    protected CreateConnectionResponse decodeBody(final RemotingBuffer in) throws Exception
    {
-      return new CreateConnectionResponse(in.getLong());
+      long connectionTargetID = in.getLong();
+      String versionName = in.getNullableString();
+      int majorVersion = in.getInt();
+      int minorVersion = in.getInt();
+      int microVersion = in.getInt();
+      int incrementingVersion = in.getInt();
+      String versionSuffix = in.getNullableString();
+      Version version =  new VersionImpl(versionName, majorVersion, minorVersion, microVersion, incrementingVersion, versionSuffix);
+      return new CreateConnectionResponse(connectionTargetID, version);
    }
 
    // Package protected ---------------------------------------------

Modified: trunk/src/main/org/jboss/messaging/core/remoting/impl/wireformat/CreateConnectionResponse.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/impl/wireformat/CreateConnectionResponse.java	2008-04-16 23:49:50 UTC (rev 4070)
+++ trunk/src/main/org/jboss/messaging/core/remoting/impl/wireformat/CreateConnectionResponse.java	2008-04-17 08:45:39 UTC (rev 4071)
@@ -7,6 +7,7 @@
 package org.jboss.messaging.core.remoting.impl.wireformat;
 
 import static org.jboss.messaging.core.remoting.impl.wireformat.PacketType.CREATECONNECTION_RESP;
+import org.jboss.messaging.core.version.Version;
 
 /**
  * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
@@ -21,16 +22,19 @@
    // Attributes ----------------------------------------------------
 
    private final long connectionTargetID;
+
+   private final Version serverVersion;
    
    // Static --------------------------------------------------------
 
    // Constructors --------------------------------------------------
 
-   public CreateConnectionResponse(final long connectionTargetID)
+   public CreateConnectionResponse(final long connectionTargetID, final Version serverVersion)
    {
       super(CREATECONNECTION_RESP);
 
       this.connectionTargetID = connectionTargetID;
+      this.serverVersion = serverVersion;
    }
 
    // Public --------------------------------------------------------
@@ -39,7 +43,12 @@
    {
       return connectionTargetID;
    }
-   
+
+   public Version getServerVersion()
+   {
+      return serverVersion;
+   }
+
    @Override
    public String toString()
    {

Modified: trunk/src/main/org/jboss/messaging/core/server/MessagingServer.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/server/MessagingServer.java	2008-04-16 23:49:50 UTC (rev 4070)
+++ trunk/src/main/org/jboss/messaging/core/server/MessagingServer.java	2008-04-17 08:45:39 UTC (rev 4071)
@@ -89,7 +89,8 @@
    
    CreateConnectionResponse createConnection(String username, String password,
                                              long remotingClientSessionID, String clientVMID,
-                                             String clientAddress) throws Exception;
+                                             String clientAddress,
+                                             int incrementVersion) throws Exception;
 
    DeploymentManager getDeploymentManager();
    

Modified: trunk/src/main/org/jboss/messaging/core/server/impl/MessagingServerImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/server/impl/MessagingServerImpl.java	2008-04-16 23:49:50 UTC (rev 4070)
+++ trunk/src/main/org/jboss/messaging/core/server/impl/MessagingServerImpl.java	2008-04-17 08:45:39 UTC (rev 4071)
@@ -61,6 +61,7 @@
 import org.jboss.messaging.core.transaction.impl.ResourceManagerImpl;
 import org.jboss.messaging.core.version.Version;
 import org.jboss.messaging.core.version.impl.VersionImpl;
+import org.jboss.messaging.core.exception.MessagingException;
 
 /**
  * A Messaging Server
@@ -122,7 +123,7 @@
    {
       //We need to hard code the version information into a source file
 
-      version = new VersionImpl("Stilton", 2, 0, 0, 100, "alpha1");
+      version = VersionImpl.load();
 
       started = false;
    }
@@ -332,11 +333,17 @@
 
    public CreateConnectionResponse createConnection(final String username, final String password,
                                                     final long remotingClientSessionID, final String clientVMID,
-                                                    final String clientAddress)
+                                                    final String clientAddress,
+                                                    final int incrementVersion)
       throws Exception
    {
       log.trace("creating a new connection for user " + username);
 
+      if(version.getIncrementingVersion() < incrementVersion)
+      {
+         throw new MessagingException(MessagingException.INCOMPATIBLE_CLIENT_SERVER_VERSIONS,
+                 "client not compatible with version: " + version.getFullVersion());
+      }
       // Authenticate. Successful autentication will place a new SubjectContext on thread local,
       // which will be used in the authorization process. However, we need to make sure we clean
       // up thread local immediately after we used the information, otherwise some other people
@@ -354,7 +361,7 @@
 
       remotingService.getDispatcher().register(new ServerConnectionPacketHandler(connection));
 
-      return new CreateConnectionResponse(connection.getID());
+      return new CreateConnectionResponse(connection.getID(), version);
    }
    
    public ObjectIDGenerator getObjectIDGenerator()

Modified: trunk/src/main/org/jboss/messaging/core/server/impl/MessagingServerPacketHandler.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/server/impl/MessagingServerPacketHandler.java	2008-04-16 23:49:50 UTC (rev 4070)
+++ trunk/src/main/org/jboss/messaging/core/server/impl/MessagingServerPacketHandler.java	2008-04-17 08:45:39 UTC (rev 4071)
@@ -76,7 +76,8 @@
          response = server.createConnection(request.getUsername(), request.getPassword(),
          		                             request.getRemotingSessionID(),
                                             request.getClientVMID(),
-                                            sender.getRemoteAddress());
+                                            sender.getRemoteAddress(),
+                                            request.getVersion());
       }     
       else
       {

Modified: trunk/src/main/org/jboss/messaging/core/version/impl/VersionImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/version/impl/VersionImpl.java	2008-04-16 23:49:50 UTC (rev 4070)
+++ trunk/src/main/org/jboss/messaging/core/version/impl/VersionImpl.java	2008-04-17 08:45:39 UTC (rev 4071)
@@ -6,20 +6,18 @@
  */
 package org.jboss.messaging.core.version.impl;
 
-import java.io.DataInputStream;
-import java.io.DataOutputStream;
-import java.io.Serializable;
+import java.io.*;
+import java.util.Properties;
+import java.net.URL;
 
 import org.jboss.messaging.core.logging.Logger;
 import org.jboss.messaging.core.version.Version;
 import org.jboss.messaging.util.Streamable;
 
 /**
- * 
  * A VersionImpl
- * 
+ *
  * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- *
  */
 public class VersionImpl implements Version, Streamable, Serializable
 {
@@ -28,112 +26,140 @@
    private static final Logger log = Logger.getLogger(VersionImpl.class);
 
    // Static --------------------------------------------------------
-   
+
    // Attributes ----------------------------------------------------
 
    private String versionName;
-   
+
    private int majorVersion;
-   
+
    private int minorVersion;
-   
+
    private int microVersion;
-   
+
    private int incrementingVersion;
-   
+
    private String versionSuffix;
-   
+
    // Constructors --------------------------------------------------
 
+
    public VersionImpl(final String versionName, final int majorVersion, final int minorVersion,
-   		             final int microVersion, final int incrementingVersion, final String versionSuffix)
+                      final int microVersion, final int incrementingVersion, final String versionSuffix)
    {
-   	this.versionName = versionName;
-   	
-   	this.majorVersion = majorVersion;
-   	
-   	this.minorVersion = minorVersion;
-   	
-   	this.microVersion = microVersion;
-   	
-   	this.incrementingVersion = incrementingVersion;
-   	
-   	this.versionSuffix = versionSuffix;
+      this.versionName = versionName;
+
+      this.majorVersion = majorVersion;
+
+      this.minorVersion = minorVersion;
+
+      this.microVersion = microVersion;
+
+      this.incrementingVersion = incrementingVersion;
+
+      this.versionSuffix = versionSuffix;
    }
-   
+
+   public static Version load()
+   {
+      Properties versionProps = new Properties();
+      InputStream in = VersionImpl.class.getClassLoader().getResourceAsStream("version.properties");
+      if (in == null)
+      {
+         throw new RuntimeException("version.properties is not available");
+      }
+      try
+      {
+         versionProps.load(in);
+         String versionName = versionProps.getProperty("messaging.version.versionName");
+         int majorVersion = Integer.valueOf(versionProps.getProperty("messaging.version.majorVersion"));
+         int minorVersion = Integer.valueOf(versionProps.getProperty("messaging.version.minorVersion"));
+         int microVersion = Integer.valueOf(versionProps.getProperty("messaging.version.microVersion"));
+         int incrementingVersion = Integer.valueOf(versionProps.getProperty("messaging.version.incrementingVersion"));
+         String versionSuffix = versionProps.getProperty("messaging.version.versionSuffix");
+         return new VersionImpl(versionName, majorVersion, minorVersion, microVersion, incrementingVersion, versionSuffix);
+      }
+      catch (IOException e)
+      {
+         //if we get here then the messaging hasnt been built properly and the version.properties is skewed in some way
+         throw new RuntimeException("unable to load version.properties", e);
+      }
+
+   }
+
    // Version implementation ------------------------------------------
-   
+
    public String getFullVersion()
    {
-   	return majorVersion + "." + minorVersion + "." + microVersion + "." + versionSuffix +
-   	       " (" + versionName + ", " + incrementingVersion +")";
+      return majorVersion + "." + minorVersion + "." + microVersion + "." + versionSuffix +
+              " (" + versionName + ", " + incrementingVersion + ")";
    }
-   
+
    public String getVersionName()
    {
-   	return versionName;
+      return versionName;
    }
-	
-	public int getMajorVersion()
-	{
-		return majorVersion;
-	}
-	
-	public int getMinorVersion()
-	{
-		return minorVersion;
-	}
-	
-	public int getMicroVersion()
-	{
-		return microVersion;
-	}
-	
-	public String getVersionSuffix()
-	{
-		return versionSuffix;
-	}
-	
-	public int getIncrementingVersion()
-	{
-		return incrementingVersion;
-	}
-   
+
+   public int getMajorVersion()
+   {
+      return majorVersion;
+   }
+
+   public int getMinorVersion()
+   {
+      return minorVersion;
+   }
+
+   public int getMicroVersion()
+   {
+      return microVersion;
+   }
+
+   public String getVersionSuffix()
+   {
+      return versionSuffix;
+   }
+
+   public int getIncrementingVersion()
+   {
+      return incrementingVersion;
+   }
+
    // Public -------------------------------------------------------
-   
+
    // Package protected ---------------------------------------------
-   	
+
    // Protected -----------------------------------------------------
-   
+
    // Private -------------------------------------------------------
-   
+
    public void read(DataInputStream in) throws Exception
    {
       versionName = in.readUTF();
-      
+
       majorVersion = in.readInt();
-      
+
       minorVersion = in.readInt();
-      
+
       microVersion = in.readInt();
-      
+
       versionSuffix = in.readUTF();
-      
-      incrementingVersion = in.readInt();            
+
+      incrementingVersion = in.readInt();
    }
 
    public void write(DataOutputStream out) throws Exception
    {
       out.writeUTF(versionName);
-      
+
       out.writeInt(majorVersion);
-      
+
       out.writeInt(minorVersion);
-      
+
       out.writeInt(microVersion);
-      
+
       out.writeUTF(versionSuffix);
-      
+
       out.writeInt(incrementingVersion);
    }
 

Modified: trunk/src/main/org/jboss/messaging/jms/client/JBossConnection.java
===================================================================
--- trunk/src/main/org/jboss/messaging/jms/client/JBossConnection.java	2008-04-16 23:49:50 UTC (rev 4070)
+++ trunk/src/main/org/jboss/messaging/jms/client/JBossConnection.java	2008-04-17 08:45:39 UTC (rev 4071)
@@ -80,8 +80,6 @@
    
    private final int connectionType;
    
-   private final Version version;
-   
    private final int dupsOKBatchSize;
    
    private volatile ExceptionListener exceptionListener;
@@ -94,15 +92,13 @@
               
    // Constructors ---------------------------------------------------------------------------------
 
-   public JBossConnection(final ClientConnection connection, final int connectionType, final Version version,
+   public JBossConnection(final ClientConnection connection, final int connectionType,
                           final String clientID, final int dupsOKBatchSize)
    {
       this.connection = connection;
       
       this.connectionType = connectionType;
       
-      this.version = version;
-      
       this.clientID = clientID;
       
       this.dupsOKBatchSize = dupsOKBatchSize;
@@ -151,7 +147,7 @@
 
       if (metaData == null)
       {
-         metaData = new JBossConnectionMetaData(version);
+         metaData = new JBossConnectionMetaData(connection.getServerVersion());
       }
 
       return metaData;

Modified: trunk/src/main/org/jboss/messaging/jms/client/JBossConnectionFactory.java
===================================================================
--- trunk/src/main/org/jboss/messaging/jms/client/JBossConnectionFactory.java	2008-04-16 23:49:50 UTC (rev 4070)
+++ trunk/src/main/org/jboss/messaging/jms/client/JBossConnectionFactory.java	2008-04-17 08:45:39 UTC (rev 4071)
@@ -201,7 +201,7 @@
       {
          ClientConnection res = connectionFactory.createConnection(username, password);
                     
-         return new JBossConnection(res, type, connectionFactory.getServerVersion(), clientID, dupsOKBatchSize);
+         return new JBossConnection(res, type, clientID, dupsOKBatchSize);
       }
       catch (MessagingException e)
       {

Modified: trunk/tests/src/org/jboss/messaging/tests/integration/CoreClientTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/CoreClientTest.java	2008-04-16 23:49:50 UTC (rev 4070)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/CoreClientTest.java	2008-04-17 08:45:39 UTC (rev 4071)
@@ -54,7 +54,7 @@
    
    public void testINVMCoreClient() throws Exception
    {
-      ClientConnectionFactory cf = new ClientConnectionFactoryImpl(0, invmServer.getConfiguration(), invmServer.getVersion());
+      ClientConnectionFactory cf = new ClientConnectionFactoryImpl(0, invmServer.getConfiguration());
       ClientConnection conn = cf.createConnection();
       
       ClientSession session = conn.createClientSession(false, true, true, -1, false, false);
@@ -75,7 +75,9 @@
       
       conn.close();
    }
-      
+
+
+
    // Package protected ---------------------------------------------
 
    // Protected -----------------------------------------------------

Modified: trunk/tests/src/org/jboss/messaging/tests/integration/core/remoting/impl/ClientCrashTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/core/remoting/impl/ClientCrashTest.java	2008-04-16 23:49:50 UTC (rev 4070)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/core/remoting/impl/ClientCrashTest.java	2008-04-17 08:45:39 UTC (rev 4071)
@@ -164,7 +164,7 @@
       server = new MessagingServerImpl(config);
       server.start();
 
-      cf = new ClientConnectionFactoryImpl(0, config, server.getVersion());
+      cf = new ClientConnectionFactoryImpl(0, config);
    }
 
    @Override

Modified: trunk/tests/src/org/jboss/messaging/tests/integration/core/remoting/impl/ClientExitTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/core/remoting/impl/ClientExitTest.java	2008-04-16 23:49:50 UTC (rev 4070)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/core/remoting/impl/ClientExitTest.java	2008-04-17 08:45:39 UTC (rev 4071)
@@ -103,7 +103,7 @@
       server = new MessagingServerImpl(config);
       server.start();
 
-      ClientConnectionFactory cf = new ClientConnectionFactoryImpl(0, config, server.getVersion());
+      ClientConnectionFactory cf = new ClientConnectionFactoryImpl(0, config);
       connection = cf.createConnection(null, null);
       ClientSession session = connection.createClientSession(false, true, true, -1, false, false);
       session.createQueue(QUEUE, QUEUE, null, false, false);

Modified: trunk/tests/src/org/jboss/messaging/tests/integration/core/remoting/impl/CrashClient.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/core/remoting/impl/CrashClient.java	2008-04-16 23:49:50 UTC (rev 4070)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/core/remoting/impl/CrashClient.java	2008-04-17 08:45:39 UTC (rev 4071)
@@ -79,7 +79,7 @@
          // FIXME there should be another way to get a meaningful Version on the
          // client side...
          MessagingServer server = new MessagingServerImpl();
-         ClientConnectionFactory cf = new ClientConnectionFactoryImpl(0, config, server.getVersion());
+         ClientConnectionFactory cf = new ClientConnectionFactoryImpl(0, config);
          ClientConnection conn = cf.createConnection();
          ClientSession session = conn.createClientSession(false, true, true, -1, false, false);
          ClientProducer producer = session.createProducer(QUEUE);

Modified: trunk/tests/src/org/jboss/messaging/tests/integration/core/remoting/impl/GracefulClient.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/core/remoting/impl/GracefulClient.java	2008-04-16 23:49:50 UTC (rev 4070)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/core/remoting/impl/GracefulClient.java	2008-04-17 08:45:39 UTC (rev 4071)
@@ -66,7 +66,7 @@
          // FIXME there should be another way to get a meaningful Version on the
          // client side...
          MessagingServer server = new MessagingServerImpl();
-         ClientConnectionFactory cf = new ClientConnectionFactoryImpl(0, config, server.getVersion());
+         ClientConnectionFactory cf = new ClientConnectionFactoryImpl(0, config);
          ClientConnection conn = cf.createConnection(null, null);
          ClientSession session = conn.createClientSession(false, true, true, -1, false, false);
          ClientProducer producer = session.createProducer(QUEUE);

Modified: trunk/tests/src/org/jboss/messaging/tests/integration/core/remoting/impl/PacketFilterTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/core/remoting/impl/PacketFilterTest.java	2008-04-16 23:49:50 UTC (rev 4070)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/core/remoting/impl/PacketFilterTest.java	2008-04-17 08:45:39 UTC (rev 4071)
@@ -52,7 +52,7 @@
       DummyInterceptor interceptorA = null;
       DummyInterceptorB interceptorB = null;
 
-      ClientConnectionFactory cf = new ClientConnectionFactoryImpl(0, server.getConfiguration(), server.getVersion());
+      ClientConnectionFactory cf = new ClientConnectionFactoryImpl(0, server.getConfiguration());
       ClientConnection conn = null;
       try
       {
@@ -159,7 +159,7 @@
          interceptor.sendException=false;
 
 
-         ClientConnectionFactory cf = new ClientConnectionFactoryImpl(0, server.getConfiguration(), server.getVersion());
+         ClientConnectionFactory cf = new ClientConnectionFactoryImpl(0, server.getConfiguration());
          conn = cf.createConnection();
          conn.start();
          ClientSession session = conn.createClientSession(false, true, true, -1, false, false);

Modified: trunk/tests/src/org/jboss/messaging/tests/integration/core/remoting/ssl/CoreClientOverSSL.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/core/remoting/ssl/CoreClientOverSSL.java	2008-04-16 23:49:50 UTC (rev 4070)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/core/remoting/ssl/CoreClientOverSSL.java	2008-04-17 08:45:39 UTC (rev 4071)
@@ -79,7 +79,7 @@
          // FIXME there should be another way to get a meaningful Version on the
          // client side...
          MessagingServer server = new MessagingServerImpl();
-         ClientConnectionFactory cf = new ClientConnectionFactoryImpl(0, config, server.getVersion());
+         ClientConnectionFactory cf = new ClientConnectionFactoryImpl(0, config);
          ClientConnection conn = cf.createConnection(null, null);
          ClientSession session = conn.createClientSession(false, true, true, -1, false, false);
          ClientProducer producer = session.createProducer(CoreClientOverSSLTest.QUEUE);

Modified: trunk/tests/src/org/jboss/messaging/tests/integration/core/remoting/ssl/CoreClientOverSSLTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/core/remoting/ssl/CoreClientOverSSLTest.java	2008-04-16 23:49:50 UTC (rev 4070)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/core/remoting/ssl/CoreClientOverSSLTest.java	2008-04-17 08:45:39 UTC (rev 4071)
@@ -129,7 +129,7 @@
       server = new MessagingServerImpl(config);
       server.start();
 
-      ClientConnectionFactory cf = new ClientConnectionFactoryImpl(0, config, server.getVersion());
+      ClientConnectionFactory cf = new ClientConnectionFactoryImpl(0, config);
       connection = cf.createConnection(null, null);
       ClientSession session = connection.createClientSession(false, true, true, -1, false, false);
       session.createQueue(QUEUE, QUEUE, null, false, false);

Modified: trunk/tests/src/org/jboss/messaging/tests/unit/core/remoting/impl/wireformat/PacketTypeTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/core/remoting/impl/wireformat/PacketTypeTest.java	2008-04-16 23:49:50 UTC (rev 4070)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/core/remoting/impl/wireformat/PacketTypeTest.java	2008-04-17 08:45:39 UTC (rev 4071)
@@ -183,6 +183,7 @@
 import org.jboss.messaging.core.remoting.impl.wireformat.SessionXASetTimeoutResponseMessage;
 import org.jboss.messaging.core.remoting.impl.wireformat.SessionXAStartMessage;
 import org.jboss.messaging.core.remoting.impl.wireformat.TextPacket;
+import org.jboss.messaging.core.version.impl.VersionImpl;
 import org.jboss.messaging.tests.util.UnitTestCase;
 import org.jboss.messaging.util.StreamUtils;
 
@@ -469,17 +470,24 @@
    public void testCreateConnectionResponse() throws Exception
    {
       CreateConnectionResponse response = new CreateConnectionResponse(
-            randomLong());
+            randomLong(), new VersionImpl("test", 1,2,3,4,"xxx"));
       AbstractPacketCodec<CreateConnectionResponse> codec = new CreateConnectionResponseMessageCodec();
 
       Packet decodedPacket = encodeAndCheckBytesAndDecode(response, codec,
-            response.getConnectionTargetID());
+            response.getConnectionTargetID(),
+              response.getServerVersion().getVersionName(),
+              response.getServerVersion().getMajorVersion(),
+              response.getServerVersion().getMinorVersion(),
+              response.getServerVersion().getMicroVersion(),
+              response.getServerVersion().getIncrementingVersion(),
+              response.getServerVersion().getVersionSuffix());
 
       assertTrue(decodedPacket instanceof CreateConnectionResponse);
       CreateConnectionResponse decodedResponse = (CreateConnectionResponse) decodedPacket;
       assertEquals(PacketType.CREATECONNECTION_RESP, decodedResponse.getType());
       assertEquals(response.getConnectionTargetID(), decodedResponse
             .getConnectionTargetID());
+      assertEquals(response.getServerVersion().getFullVersion(), decodedResponse.getServerVersion().getFullVersion());
    }
 
    public void testConnectionCreateSessionMessage() throws Exception

Modified: trunk/tests/src/org/jboss/messaging/tests/unit/jms/network/ClientNetworkFailureTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/jms/network/ClientNetworkFailureTest.java	2008-04-16 23:49:50 UTC (rev 4070)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/jms/network/ClientNetworkFailureTest.java	2008-04-17 08:45:39 UTC (rev 4071)
@@ -104,7 +104,7 @@
    public void testServerResourcesCleanUpWhenClientCommThrowsException()
          throws Exception
    {
-      ClientConnectionFactory cf = new ClientConnectionFactoryImpl(0, server.getConfiguration(), server.getVersion());
+      ClientConnectionFactory cf = new ClientConnectionFactoryImpl(0, server.getConfiguration());
 
       ClientConnection conn = cf.createConnection();
 
@@ -144,7 +144,7 @@
    public void testServerResourcesCleanUpWhenClientCommDropsPacket()
          throws Exception
    {
-       ClientConnectionFactory cf = new ClientConnectionFactoryImpl(0, server.getConfiguration(), server.getVersion());
+       ClientConnectionFactory cf = new ClientConnectionFactoryImpl(0, server.getConfiguration());
 
       ClientConnection conn = cf.createConnection();
 

Modified: trunk/tests/src/org/jboss/messaging/tests/unit/jms/server/ConnectionManagerTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/jms/server/ConnectionManagerTest.java	2008-04-16 23:49:50 UTC (rev 4070)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/jms/server/ConnectionManagerTest.java	2008-04-17 08:45:39 UTC (rev 4071)
@@ -77,7 +77,7 @@
    {
       
       assertActiveConnectionsOnTheServer(0);
-      ClientConnectionFactory cf = new ClientConnectionFactoryImpl(0, server.getConfiguration(), server.getVersion());
+      ClientConnectionFactory cf = new ClientConnectionFactoryImpl(0, server.getConfiguration());
 
       ClientConnection conn_1 = cf.createConnection();
       




More information about the jboss-cvs-commits mailing list