FileDocCategorySizeDatePackage
ServerVersionMatcher.javaAPI DocGlassfish v2 API5776Fri May 04 22:36:26 BST 2007com.sun.enterprise.admin.jmx.remote.server

ServerVersionMatcher

public class ServerVersionMatcher extends Object
author
Kedar Mhaswade
since
S1AS8.0
version
$Revision: 1.4 $

Fields Summary
private static final ServerVersionMatcher
matcher
private static final Logger
logger
Constructors Summary
private ServerVersionMatcher()

	  
	
Methods Summary
public static com.sun.enterprise.admin.jmx.remote.server.ServerVersionMatchergetMatcher()

		return ( matcher );
	
booleanmajorCompatible(com.sun.enterprise.admin.jmx.remote.protocol.Version c, com.sun.enterprise.admin.jmx.remote.protocol.Version s)

		//client version can at most equal server version
		boolean compatible = false;
		final int cmv = c.getMajorVersion();
		final int smv = s.getMajorVersion();
		if (cmv < smv) {
			logger.finer("S1AS JSR 160 - Using Backword compatibility, as client version: " +
			cmv + " is smaller than server version: " + smv);
			logger.finer("It is better to upgrade the client software");
			compatible = true;
		}
		else if (cmv == smv) {
			compatible = true;
		}
		else {
			logger.finer("S1AS JSR 160 - Version Compatibility failed, as client version: " +
			cmv + " is higher than server version: " + smv);
			logger.finer("Server software has to be upgraded to atleast major version: " + cmv);
			compatible = false;
		}
		return ( compatible );
	
public booleanmatch(com.sun.enterprise.admin.jmx.remote.protocol.Version client, com.sun.enterprise.admin.jmx.remote.protocol.Version server)
Returns true if and only if the client version and server version are compatible. The server version matches with client version if and only if
  • Client Major Version is <= Server Major Version
  • Client Minor Version is <= Server Minor Version
  • Upgrade Data is compatible in both the versions

		return (majorCompatible(client, server) &&
				minorCompatible(client, server) &&
				upgradeCompatible(client, server) );
	
booleanminorCompatible(com.sun.enterprise.admin.jmx.remote.protocol.Version c, com.sun.enterprise.admin.jmx.remote.protocol.Version s)

		//client version can at most equal server version
		boolean compatible = false;
		final int cmv = c.getMinorVersion();
		final int smv = s.getMinorVersion();
		if (cmv < smv) {
			logger.finer("S1AS JSR 160 - Using Backword compatibility, as client version: " +
			cmv + " is smaller than server version: " + smv);
			logger.finer("It is better to upgrade the client software");
			compatible = true;
		}
		else if (cmv == smv) {
			compatible = true;
		}
		else {
			logger.finer("S1AS JSR 160 - Version Compatibility failed, as client version: " +
			cmv + " is higher than server version: " + smv);
			logger.finer("Server software has to be upgraded to atleast major version: " + cmv);
			compatible = false;
		}
		return ( compatible );
	
booleanupgradeCompatible(com.sun.enterprise.admin.jmx.remote.protocol.Version c, com.sun.enterprise.admin.jmx.remote.protocol.Version s)

		final String[] cud = c.getUpgradeData();
		final String[] sud = s.getUpgradeData();
		boolean uc = true;
		uc = uc && (cud.length == sud.length); //lengths must be the same
		if (uc) {
			for (int i = 0 ; i < cud.length ; i++) {
				if (cud[i] != null && sud[i] != null) {
					uc = uc && cud[i].equals(sud[i]);
					if (!uc) {
						break;
					}
				}
			}
		}
		return ( uc );