db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kmars...@apache.org
Subject svn commit: r1370674 [11/12] - in /db/derby/code/trunk/java/drda/org/apache/derby: drda/ impl/drda/
Date Wed, 08 Aug 2012 06:54:47 GMT
Modified: db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java?rev=1370674&r1=1370673&r2=1370674&view=diff
==============================================================================
--- db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java (original)
+++ db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java Wed Aug  8 06:54:46 2012
@@ -86,258 +86,258 @@ import org.apache.derby.mbeans.drda.Netw
 import org.apache.derby.security.SystemPermission;
 
 /** 
-	
-	NetworkServerControlImpl does all the work for NetworkServerControl
-	@see NetworkServerControl for description
+    
+    NetworkServerControlImpl does all the work for NetworkServerControl
+    @see NetworkServerControl for description
 
 */
 public final class NetworkServerControlImpl {
-	private final static int NO_USAGE_MSGS= 12;
-	private final static String [] COMMANDS = 
-	{"start","shutdown","trace","tracedirectory","ping", 
-	 "logconnections", "sysinfo", "runtimeinfo",  "maxthreads", "timeslice", ""};
-	// number of required arguments for each command
-	private final static int [] COMMAND_ARGS =
-	{0, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0};
-	public final static int COMMAND_START = 0;
-	public final static int COMMAND_SHUTDOWN = 1;
-	public final static int COMMAND_TRACE = 2;
-	public final static int COMMAND_TRACEDIRECTORY = 3;
-	public final static int COMMAND_TESTCONNECTION = 4;
-	public final static int COMMAND_LOGCONNECTIONS = 5;
-	public final static int COMMAND_SYSINFO = 6;
-	public final static int COMMAND_RUNTIME_INFO = 7;
-	public final static int COMMAND_MAXTHREADS = 8;
-	public final static int COMMAND_TIMESLICE = 9;
-	public final static int COMMAND_PROPERTIES = 10;
-	public final static int COMMAND_UNKNOWN = -1;
-	public final static String [] DASHARGS =
-	{"p", "d", "user", "password", "ld", "ea", "ep", "b", "h", "s",
-		 "noSecurityManager", "ssl"};
-	public final static int DASHARG_PORT = 0;
-	public final static int DASHARG_DATABASE = 1;
-	public final static int DASHARG_USER = 2;
-	public final static int DASHARG_PASSWORD = 3;
-	public final static int DASHARG_LOADSYSIBM = 4;
-	public final static int DASHARG_ENCALG = 5;
-	public final static int DASHARG_ENCPRV = 6;
-	public final static int DASHARG_BOOTPASSWORD = 7;
-	public final static int DASHARG_HOST = 8;
-	public final static int DASHARG_SESSION = 9;
-	public final static int DASHARG_UNSECURE = 10;
-	private final static int DASHARG_SSL = 11;
-
-	//All the commands except shutdown with username and password are at 
-	//protocol level 1. 
-	private final static int DEFAULT_PROTOCOL_VERSION = 1;
-	// DERBY-2109: shutdown command now transmits optional user credentials
-	//For shutdown with username/password, we have added a new protocol level
-	private final static int SHUTDOWN_WITH_CREDENTIAL_PROTOCOL_VERSION = 2;
-	//The highest protocol level is 2. The reason for it to be at 2 is 
-	//the shutdown command with username/password
-	private final static int MAX_ALLOWED_PROTOCOL_VERSION = 2;
-
-	private final static String COMMAND_HEADER = "CMD:";
-	private final static String REPLY_HEADER = "RPY:";
-	private final static int REPLY_HEADER_LENGTH = REPLY_HEADER.length();
-	private final static int OK = 0;
-	private final static int WARNING = 1;
-	private final static int ERROR = 2;
-	private final static int SQLERROR = 3;
-	private final static int SQLWARNING = 4;
-
-	private final static String DRDA_PROP_MESSAGES = "org.apache.derby.loc.drda.messages";
-	private final static String DRDA_PROP_DEBUG = "derby.drda.debug";
-	private final static String CLOUDSCAPE_DRIVER = "org.apache.derby.jdbc.EmbeddedDriver";
-
-	public final static String UNEXPECTED_ERR = "Unexpected exception";
-
-	private final static int MIN_MAXTHREADS = -1;
-	private final static int MIN_TIMESLICE = -1;
-	private final static int USE_DEFAULT = -1;
-	private final static int DEFAULT_MAXTHREADS = 0; //for now create whenever needed
-	private final static int DEFAULT_TIMESLICE = 0;	//for now never yield
-
-	private final static String DEFAULT_HOST = "localhost";
-	private final static String DRDA_MSG_PREFIX = "DRDA_";
-	private final static String DEFAULT_LOCALE= "en";
-	private final static String DEFAULT_LOCALE_COUNTRY="US";
-
-	// Check up to 10 seconds to see if shutdown occurred
-	private final static int SHUTDOWN_CHECK_ATTEMPTS = 100;
-	private final static int SHUTDOWN_CHECK_INTERVAL= 100;
-
-	// maximum reply size
-	private final static int MAXREPLY = 32767;
-
-	// Application Server Attributes.
-	protected static String att_srvclsnm;
-	protected final static String ATT_SRVNAM = "NetworkServerControl";
-
-	protected static String att_extnam;
-	protected static String att_srvrlslv; 
-	protected static String prdId;
+    private final static int NO_USAGE_MSGS= 12;
+    private final static String [] COMMANDS = 
+    {"start","shutdown","trace","tracedirectory","ping", 
+     "logconnections", "sysinfo", "runtimeinfo",  "maxthreads", "timeslice", ""};
+    // number of required arguments for each command
+    private final static int [] COMMAND_ARGS =
+    {0, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0};
+    public final static int COMMAND_START = 0;
+    public final static int COMMAND_SHUTDOWN = 1;
+    public final static int COMMAND_TRACE = 2;
+    public final static int COMMAND_TRACEDIRECTORY = 3;
+    public final static int COMMAND_TESTCONNECTION = 4;
+    public final static int COMMAND_LOGCONNECTIONS = 5;
+    public final static int COMMAND_SYSINFO = 6;
+    public final static int COMMAND_RUNTIME_INFO = 7;
+    public final static int COMMAND_MAXTHREADS = 8;
+    public final static int COMMAND_TIMESLICE = 9;
+    public final static int COMMAND_PROPERTIES = 10;
+    public final static int COMMAND_UNKNOWN = -1;
+    public final static String [] DASHARGS =
+    {"p", "d", "user", "password", "ld", "ea", "ep", "b", "h", "s",
+         "noSecurityManager", "ssl"};
+    public final static int DASHARG_PORT = 0;
+    public final static int DASHARG_DATABASE = 1;
+    public final static int DASHARG_USER = 2;
+    public final static int DASHARG_PASSWORD = 3;
+    public final static int DASHARG_LOADSYSIBM = 4;
+    public final static int DASHARG_ENCALG = 5;
+    public final static int DASHARG_ENCPRV = 6;
+    public final static int DASHARG_BOOTPASSWORD = 7;
+    public final static int DASHARG_HOST = 8;
+    public final static int DASHARG_SESSION = 9;
+    public final static int DASHARG_UNSECURE = 10;
+    private final static int DASHARG_SSL = 11;
+
+    //All the commands except shutdown with username and password are at 
+    //protocol level 1. 
+    private final static int DEFAULT_PROTOCOL_VERSION = 1;
+    // DERBY-2109: shutdown command now transmits optional user credentials
+    //For shutdown with username/password, we have added a new protocol level
+    private final static int SHUTDOWN_WITH_CREDENTIAL_PROTOCOL_VERSION = 2;
+    //The highest protocol level is 2. The reason for it to be at 2 is 
+    //the shutdown command with username/password
+    private final static int MAX_ALLOWED_PROTOCOL_VERSION = 2;
+
+    private final static String COMMAND_HEADER = "CMD:";
+    private final static String REPLY_HEADER = "RPY:";
+    private final static int REPLY_HEADER_LENGTH = REPLY_HEADER.length();
+    private final static int OK = 0;
+    private final static int WARNING = 1;
+    private final static int ERROR = 2;
+    private final static int SQLERROR = 3;
+    private final static int SQLWARNING = 4;
+
+    private final static String DRDA_PROP_MESSAGES = "org.apache.derby.loc.drda.messages";
+    private final static String DRDA_PROP_DEBUG = "derby.drda.debug";
+    private final static String CLOUDSCAPE_DRIVER = "org.apache.derby.jdbc.EmbeddedDriver";
+
+    public final static String UNEXPECTED_ERR = "Unexpected exception";
+
+    private final static int MIN_MAXTHREADS = -1;
+    private final static int MIN_TIMESLICE = -1;
+    private final static int USE_DEFAULT = -1;
+    private final static int DEFAULT_MAXTHREADS = 0; //for now create whenever needed
+    private final static int DEFAULT_TIMESLICE = 0;    //for now never yield
+
+    private final static String DEFAULT_HOST = "localhost";
+    private final static String DRDA_MSG_PREFIX = "DRDA_";
+    private final static String DEFAULT_LOCALE= "en";
+    private final static String DEFAULT_LOCALE_COUNTRY="US";
+
+    // Check up to 10 seconds to see if shutdown occurred
+    private final static int SHUTDOWN_CHECK_ATTEMPTS = 100;
+    private final static int SHUTDOWN_CHECK_INTERVAL= 100;
+
+    // maximum reply size
+    private final static int MAXREPLY = 32767;
+
+    // Application Server Attributes.
+    protected static String att_srvclsnm;
+    protected final static String ATT_SRVNAM = "NetworkServerControl";
+
+    protected static String att_extnam;
+    protected static String att_srvrlslv; 
+    protected static String prdId;
     protected static byte[] prdIdBytes_;
     
-	private static String buildNumber;
-	private static String versionString;
-	// we will use single or mixed, not double byte to reduce traffic on the
-	// wire, this is in keeping with JCC
-	// Note we specify UTF8 for the single byte encoding even though it can
-	// be multi-byte.
-	protected final static int CCSIDSBC = 1208; //use UTF8
-	protected final static int CCSIDMBC = 1208; //use UTF8
-	protected final static String DEFAULT_ENCODING = "UTF8"; // use UTF8 for writing
-	final static Charset DEFAULT_CHARSET = Charset.forName(DEFAULT_ENCODING);
-	protected final static int DEFAULT_CCSID = 1208;
-	protected final static byte SPACE_CHAR = 32;
-														
-
-	// Application Server manager levels - this needs to be in sync
-	// with CodePoint.MGR_CODEPOINTS
-	protected final static int [] MGR_LEVELS = { 7, // AGENT
-												 4,	// CCSID Manager
-												 0, // CNMAPPC not implemented
-												 0, // CMNSYNCPT not implemented
-												 5, // CMNTCPIP
-												 0, // DICTIONARY
-												 7, // RDB
-												 0, // RSYNCMGR
-												 7, // SECMGR
-												 7, // SQLAM
-												 0, // SUPERVISOR
-												 0, // SYNCPTMGR
-												 1208, // UNICODE Manager
-												 7  // XAMGR
-												};
-											
-	
-	protected PrintWriter logWriter;                        // console
-	protected PrintWriter cloudscapeLogWriter;              // derby.log
-	private static Driver cloudscapeDriver;
-
-	// error types
-	private final static int ERRTYPE_SEVERE = 1;
-	private final static int ERRTYPE_USER = 2;
-	private final static int ERRTYPE_INFO = 3;
-	private final static int ERRTYPE_UNKNOWN = -1;
-
-	// command argument information
-	private Vector<String> commandArgs = new Vector<String>();
-	private String databaseArg;
-	// DERBY-2109: Note that derby JDBC clients have a default user name
+    private static String buildNumber;
+    private static String versionString;
+    // we will use single or mixed, not double byte to reduce traffic on the
+    // wire, this is in keeping with JCC
+    // Note we specify UTF8 for the single byte encoding even though it can
+    // be multi-byte.
+    protected final static int CCSIDSBC = 1208; //use UTF8
+    protected final static int CCSIDMBC = 1208; //use UTF8
+    protected final static String DEFAULT_ENCODING = "UTF8"; // use UTF8 for writing
+    final static Charset DEFAULT_CHARSET = Charset.forName(DEFAULT_ENCODING);
+    protected final static int DEFAULT_CCSID = 1208;
+    protected final static byte SPACE_CHAR = 32;
+                                                        
+
+    // Application Server manager levels - this needs to be in sync
+    // with CodePoint.MGR_CODEPOINTS
+    protected final static int [] MGR_LEVELS = { 7, // AGENT
+                                                 4,    // CCSID Manager
+                                                 0, // CNMAPPC not implemented
+                                                 0, // CMNSYNCPT not implemented
+                                                 5, // CMNTCPIP
+                                                 0, // DICTIONARY
+                                                 7, // RDB
+                                                 0, // RSYNCMGR
+                                                 7, // SECMGR
+                                                 7, // SQLAM
+                                                 0, // SUPERVISOR
+                                                 0, // SYNCPTMGR
+                                                 1208, // UNICODE Manager
+                                                 7  // XAMGR
+                                                };
+                                            
+    
+    protected PrintWriter logWriter;                        // console
+    protected PrintWriter cloudscapeLogWriter;              // derby.log
+    private static Driver cloudscapeDriver;
+
+    // error types
+    private final static int ERRTYPE_SEVERE = 1;
+    private final static int ERRTYPE_USER = 2;
+    private final static int ERRTYPE_INFO = 3;
+    private final static int ERRTYPE_UNKNOWN = -1;
+
+    // command argument information
+    private Vector<String> commandArgs = new Vector<String>();
+    private String databaseArg;
+    // DERBY-2109: Note that derby JDBC clients have a default user name
     // "APP" (= Property.DEFAULT_USER_NAME) assigned if they don't provide
     // credentials.  We could do the same for NetworkServerControl clients
     // here, but this class is robust enough to allow for null as default.
-	private String userArg = null;
-	private String passwordArg = null;
-	private String bootPasswordArg;
-	private String encAlgArg;
-	private String encPrvArg;
-	private String hostArg = DEFAULT_HOST;	
-	private InetAddress hostAddress;
-	private int sessionArg;
-	private boolean unsecureArg;
-
-	// Used to debug memory in SanityManager.DEBUG mode
-	private memCheck mc;
-
-	// reply buffer
-	private byte [] replyBuffer;	
-	private int replyBufferCount;	//length of reply
-	private int replyBufferPos;		//current position in reply
-
-	//
-	// server configuration
-	//
-	// static values - set at start can't be changed once server has started
-	private int	portNumber = NetworkServerControl.DEFAULT_PORTNUMBER;	// port server listens to
-
-	// configurable values
-	private String traceDirectory;		// directory to place trace files in
-	private Object traceDirectorySync = new Object();// object to use for syncing
-	private boolean traceAll;			// trace all sessions
-	private Object traceAllSync = new Object();	// object to use for syncing reading
-										// and changing trace all
-	private Object serverStartSync = new Object();	// for syncing start of server.
-	private boolean logConnections;		// log connects
-	private Object logConnectionsSync = new Object(); // object to use for syncing 
-										// logConnections value
-	private int minThreads;				// default minimum number of connection threads
-	private int maxThreads;				// default maximum number of connection threads
-	private Object threadsSync = new Object(); // object to use for syncing reading
-										// and changing default min and max threads
-	private int timeSlice;				// default time slice of a session to a thread
-	private Object timeSliceSync = new Object();// object to use for syncing reading
-										// and changing timeSlice
-
-	private boolean keepAlive = true;   // keepAlive value for client socket 
-	private int minPoolSize;			//minimum pool size for pooled connections
-	private int maxPoolSize;			//maximum pool size for pooled connections
-	private Object poolSync = new Object();	// object to use for syning reading
-
-	protected boolean debugOutput = false;
-	private boolean cleanupOnStart = false;	// Should we clean up when starting the server?
-	private boolean restartFlag = false;
+    private String userArg = null;
+    private String passwordArg = null;
+    private String bootPasswordArg;
+    private String encAlgArg;
+    private String encPrvArg;
+    private String hostArg = DEFAULT_HOST;    
+    private InetAddress hostAddress;
+    private int sessionArg;
+    private boolean unsecureArg;
+
+    // Used to debug memory in SanityManager.DEBUG mode
+    private memCheck mc;
+
+    // reply buffer
+    private byte [] replyBuffer;    
+    private int replyBufferCount;    //length of reply
+    private int replyBufferPos;        //current position in reply
+
+    //
+    // server configuration
+    //
+    // static values - set at start can't be changed once server has started
+    private int    portNumber = NetworkServerControl.DEFAULT_PORTNUMBER;    // port server listens to
+
+    // configurable values
+    private String traceDirectory;        // directory to place trace files in
+    private Object traceDirectorySync = new Object();// object to use for syncing
+    private boolean traceAll;            // trace all sessions
+    private Object traceAllSync = new Object();    // object to use for syncing reading
+                                        // and changing trace all
+    private Object serverStartSync = new Object();    // for syncing start of server.
+    private boolean logConnections;        // log connects
+    private Object logConnectionsSync = new Object(); // object to use for syncing 
+                                        // logConnections value
+    private int minThreads;                // default minimum number of connection threads
+    private int maxThreads;                // default maximum number of connection threads
+    private Object threadsSync = new Object(); // object to use for syncing reading
+                                        // and changing default min and max threads
+    private int timeSlice;                // default time slice of a session to a thread
+    private Object timeSliceSync = new Object();// object to use for syncing reading
+                                        // and changing timeSlice
+
+    private boolean keepAlive = true;   // keepAlive value for client socket 
+    private int minPoolSize;            //minimum pool size for pooled connections
+    private int maxPoolSize;            //maximum pool size for pooled connections
+    private Object poolSync = new Object();    // object to use for syning reading
+
+    protected boolean debugOutput = false;
+    private boolean cleanupOnStart = false;    // Should we clean up when starting the server?
+    private boolean restartFlag = false;
 
     protected final static int INVALID_OR_NOTSET_SECURITYMECHANISM = -1; 
     // variable to store value set to derby.drda.securityMechanism
     // default value is -1 which indicates that this property isnt set or
     // the value is invalid
     private int allowOnlySecurityMechanism = INVALID_OR_NOTSET_SECURITYMECHANISM;
-	//
-	// variables for a client command session
-	//
-	private Socket clientSocket = null;
-	private InputStream clientIs = null;
-	private OutputStream clientOs = null;
-	private ByteArrayOutputStream byteArrayOs = new ByteArrayOutputStream();
-	private DataOutputStream commandOs = new DataOutputStream(byteArrayOs);
-	
-	private Object shutdownSync = new Object();
-	private boolean shutdown;
-	private int connNum;		// number of connections since server started
-	private ServerSocket serverSocket;
-	private NetworkServerControlImpl serverInstance;
-	private LocalizedResource langUtil;
-	public String clientLocale;
+    //
+    // variables for a client command session
+    //
+    private Socket clientSocket = null;
+    private InputStream clientIs = null;
+    private OutputStream clientOs = null;
+    private ByteArrayOutputStream byteArrayOs = new ByteArrayOutputStream();
+    private DataOutputStream commandOs = new DataOutputStream(byteArrayOs);
+    
+    private Object shutdownSync = new Object();
+    private boolean shutdown;
+    private int connNum;        // number of connections since server started
+    private ServerSocket serverSocket;
+    private NetworkServerControlImpl serverInstance;
+    private LocalizedResource langUtil;
+    public String clientLocale;
     /** List of local addresses for checking admin commands. */
     ArrayList<InetAddress> localAddresses;
 
-	// open sessions
-	private Hashtable<Integer, Session> sessionTable =
+    // open sessions
+    private Hashtable<Integer, Session> sessionTable =
             new Hashtable<Integer, Session>();
 
-	// current session
-	private Session currentSession;
-	// DRDAConnThreads
-	private Vector<DRDAConnThread> threadList = new Vector<DRDAConnThread>();
-
-	// queue of sessions waiting for a free thread - the queue is managed
-	// in a simple first come, first serve manner - no priorities
-	private Vector<Session> runQueue = new Vector<Session>();
+    // current session
+    private Session currentSession;
+    // DRDAConnThreads
+    private Vector<DRDAConnThread> threadList = new Vector<DRDAConnThread>();
+
+    // queue of sessions waiting for a free thread - the queue is managed
+    // in a simple first come, first serve manner - no priorities
+    private Vector<Session> runQueue = new Vector<Session>();
 
-	// number of DRDAConnThreads waiting for something to do
-	private int freeThreads;
+    // number of DRDAConnThreads waiting for something to do
+    private int freeThreads;
 
-	// known application requesters
-	private Hashtable<String, AppRequester> appRequesterTable =
+    // known application requesters
+    private Hashtable<String, AppRequester> appRequesterTable =
             new Hashtable<String, AppRequester>();
 
-	// accessed by inner classes for privileged action
-	private String propertyFileName;
-	private NetworkServerControlImpl thisControl = this;
-
-	// if the server is started from the command line, it should shutdown the
-	// databases it has booted.
-	private boolean shutdownDatabasesOnShutdown = false;
-
-	// SSL related stuff
-	private static final int SSL_OFF = 0;
-	private static final int SSL_BASIC = 1;
-	private static final int SSL_PEER_AUTHENTICATION = 2;
+    // accessed by inner classes for privileged action
+    private String propertyFileName;
+    private NetworkServerControlImpl thisControl = this;
+
+    // if the server is started from the command line, it should shutdown the
+    // databases it has booted.
+    private boolean shutdownDatabasesOnShutdown = false;
+
+    // SSL related stuff
+    private static final int SSL_OFF = 0;
+    private static final int SSL_BASIC = 1;
+    private static final int SSL_PEER_AUTHENTICATION = 2;
 
-	private int sslMode = SSL_OFF;
+    private int sslMode = SSL_OFF;
 
     /**
      * Can EUSRIDPWD security mechanism be used with 
@@ -384,144 +384,144 @@ public final class NetworkServerControlI
     public  boolean runningUnsecure() { return unsecureArg; }
     
     // constructor
-	public NetworkServerControlImpl() throws Exception
-	{
-		init();
-		getPropertyInfo();
-    }
-
-	/**
-	 * Internal constructor for NetworkServerControl API. 
-	 * @param address InetAddress to listen on, throws NPE if null
-	 * @param portNumber portNumber to listen on, -1 use property or default
-	 * @throws Exception on error
-	 * @see NetworkServerControl
-	 */
-	public NetworkServerControlImpl(InetAddress address, int portNumber) throws Exception
-	{
-		this();
-		this.hostAddress = address;
-		this.portNumber = (portNumber <= 0) ?
-			this.portNumber: portNumber;
-		this.hostArg = address.getHostAddress();
-	}
-
-	/**
-	 * Internal constructor for NetworkServerControl API. 
-	 * @param userName the user name for actions requiring authorization
-	 * @param password the password for actions requiring authorization
-	 * @throws Exception on error
-	 * @see NetworkServerControl
-	 */
-	public NetworkServerControlImpl(String userName, String password)
-		throws Exception
-	{
+    public NetworkServerControlImpl() throws Exception
+    {
+        init();
+        getPropertyInfo();
+    }
+
+    /**
+     * Internal constructor for NetworkServerControl API. 
+     * @param address InetAddress to listen on, throws NPE if null
+     * @param portNumber portNumber to listen on, -1 use property or default
+     * @throws Exception on error
+     * @see NetworkServerControl
+     */
+    public NetworkServerControlImpl(InetAddress address, int portNumber) throws Exception
+    {
+        this();
+        this.hostAddress = address;
+        this.portNumber = (portNumber <= 0) ?
+            this.portNumber: portNumber;
+        this.hostArg = address.getHostAddress();
+    }
+
+    /**
+     * Internal constructor for NetworkServerControl API. 
+     * @param userName the user name for actions requiring authorization
+     * @param password the password for actions requiring authorization
+     * @throws Exception on error
+     * @see NetworkServerControl
+     */
+    public NetworkServerControlImpl(String userName, String password)
+        throws Exception
+    {
         this();
-		this.userArg = userName;
-		this.passwordArg = password;
-	}
-
-	/**
-	 * Internal constructor for NetworkServerControl API. 
-	 * @param address InetAddress to listen on, throws NPE if null
-	 * @param portNumber portNumber to listen on, -1 use property or default
-	 * @param userName the user name for actions requiring authorization
-	 * @param password the password for actions requiring authorization
-	 * @throws Exception on error
-	 * @see NetworkServerControl
-	 */
-	public NetworkServerControlImpl(InetAddress address, int portNumber,
-									String userName, String password)
-		throws Exception
-	{
-		this(address, portNumber);
-		this.userArg = userName;
-		this.passwordArg = password;
-	}
+        this.userArg = userName;
+        this.passwordArg = password;
+    }
+
+    /**
+     * Internal constructor for NetworkServerControl API. 
+     * @param address InetAddress to listen on, throws NPE if null
+     * @param portNumber portNumber to listen on, -1 use property or default
+     * @param userName the user name for actions requiring authorization
+     * @param password the password for actions requiring authorization
+     * @throws Exception on error
+     * @see NetworkServerControl
+     */
+    public NetworkServerControlImpl(InetAddress address, int portNumber,
+                                    String userName, String password)
+        throws Exception
+    {
+        this(address, portNumber);
+        this.userArg = userName;
+        this.passwordArg = password;
+    }
 
     private void init() throws Exception
     {
 
         // adjust the application in accordance with derby.ui.locale and derby.ui.codeset
-		langUtil = new LocalizedResource(null,null,DRDA_PROP_MESSAGES);
+        langUtil = new LocalizedResource(null,null,DRDA_PROP_MESSAGES);
+
+        serverInstance = this;
+        
+        //set Server attributes to be used in EXCSAT
+        ProductVersionHolder myPVH = getNetProductVersionHolder();
+        att_extnam = ATT_SRVNAM + " " + java.lang.Thread.currentThread().getName();
+        
+        att_srvclsnm = myPVH.getProductName();
+        versionString = myPVH.getVersionBuildString(true);
+        
+        String majorStr = String.valueOf(myPVH.getMajorVersion());
+        String minorStr = String.valueOf(myPVH.getMinorVersion());
+        // Maintenance version. Server protocol version.
+        // Only changed if client needs to recognize a new server version.
+        String drdaMaintStr = String.valueOf(myPVH.getDrdaMaintVersion());
+
+        // PRDID format as JCC expects it: CSSMMmx
+        // MM = major version
+        // mm = minor version
+        // x = drda MaintenanceVersion
+
+        prdId = DRDAConstants.DERBY_DRDA_SERVER_ID;
+        if (majorStr.length() == 1)
+            prdId += "0";
+        prdId += majorStr;
+
+        if (minorStr.length() == 1)
+            prdId += "0";
 
-		serverInstance = this;
-		
-		//set Server attributes to be used in EXCSAT
-		ProductVersionHolder myPVH = getNetProductVersionHolder();
-		att_extnam = ATT_SRVNAM + " " + java.lang.Thread.currentThread().getName();
-		
-		att_srvclsnm = myPVH.getProductName();
-		versionString = myPVH.getVersionBuildString(true);
-		
-		String majorStr = String.valueOf(myPVH.getMajorVersion());
-		String minorStr = String.valueOf(myPVH.getMinorVersion());
-		// Maintenance version. Server protocol version.
-		// Only changed if client needs to recognize a new server version.
-		String drdaMaintStr = String.valueOf(myPVH.getDrdaMaintVersion());
-
-		// PRDID format as JCC expects it: CSSMMmx
-		// MM = major version
-		// mm = minor version
-		// x = drda MaintenanceVersion
-
-		prdId = DRDAConstants.DERBY_DRDA_SERVER_ID;
-		if (majorStr.length() == 1)
-			prdId += "0";
-		prdId += majorStr;
-
-		if (minorStr.length() == 1)
-			prdId += "0";
-
-		prdId += minorStr;
-		
-		prdId += drdaMaintStr;
-		att_srvrlslv = prdId + "/" + myPVH.getVersionBuildString(true);
+        prdId += minorStr;
+        
+        prdId += drdaMaintStr;
+        att_srvrlslv = prdId + "/" + myPVH.getVersionBuildString(true);
                 // Precompute this to save some cycles
                 prdIdBytes_ = prdId.getBytes(DEFAULT_ENCODING);
  
-		if (SanityManager.DEBUG)
-		{
-			if (majorStr.length() > 2  || 
-				minorStr.length() > 2 || 
-				drdaMaintStr.length() > 1)
-				SanityManager.THROWASSERT("version values out of expected range  for PRDID");
-		}
+        if (SanityManager.DEBUG)
+        {
+            if (majorStr.length() > 2  || 
+                minorStr.length() > 2 || 
+                drdaMaintStr.length() > 1)
+                SanityManager.THROWASSERT("version values out of expected range  for PRDID");
+        }
 
-		buildNumber = myPVH.getBuildNumber();
-	}
+        buildNumber = myPVH.getBuildNumber();
+    }
 
     private PrintWriter makePrintWriter( OutputStream out)
     {
-		if (out != null)
-			return new PrintWriter(out, true /* flush the buffer at the end of each line */);
-		else
-			return null;
-    }
-
-	protected static Driver getDriver()
-	{
-		return cloudscapeDriver;
-	}
-	
-
-	/********************************************************************************
-	 * Implementation of NetworkServerControl API
-	 * The server commands throw exceptions for errors, so that users can handle
-	 * them themselves in addition to having the errors written to the console
-	 * and possibly derby.log.  To turn off logging the errors to the console,
-	 * set the output writer to null.
-	 ********************************************************************************/
-
-
-	/**
-	 * Set the output stream for console messages
-	 * If this is set to null, no messages will be written to the console
-	 *
-	 * @param outWriter	output stream for console messages
-	 */
-	public void setLogWriter(PrintWriter outWriter)
-	{
+        if (out != null)
+            return new PrintWriter(out, true /* flush the buffer at the end of each line */);
+        else
+            return null;
+    }
+
+    protected static Driver getDriver()
+    {
+        return cloudscapeDriver;
+    }
+    
+
+    /********************************************************************************
+     * Implementation of NetworkServerControl API
+     * The server commands throw exceptions for errors, so that users can handle
+     * them themselves in addition to having the errors written to the console
+     * and possibly derby.log.  To turn off logging the errors to the console,
+     * set the output writer to null.
+     ********************************************************************************/
+
+
+    /**
+     * Set the output stream for console messages
+     * If this is set to null, no messages will be written to the console
+     *
+     * @param outWriter    output stream for console messages
+     */
+    public void setLogWriter(PrintWriter outWriter)
+    {
         // wrap the user-set outWriter with, autoflush to true.
         // this will ensure that messages to console will be 
         // written out to the outWriter on a println.
@@ -533,242 +533,242 @@ public final class NetworkServerControlI
     }
 
 
-	
-	/**
-	 * Write an error message to console output stream
-	 * and throw an exception for this error
-	 *
-	 * @param msg	error message
-	 * @exception Exception
-	 */
-	public void consoleError(String msg)
-		throws Exception
-	{
-		consoleMessage(msg, true);
-		throw new Exception(msg);
-	}
-
-	/**
-	 * Write an exception to console output stream,
-	 * but only if debugOutput is true.
-	 *
-	 * @param e	exception 
-	 */
-	public void consoleExceptionPrint(Exception e)
-	{
-		if (debugOutput == true)
-			consoleExceptionPrintTrace(e);
-
-		return;
-	}
-
-	/**
-	 * Write an exception (with trace) to console
-	 * output stream.
-	 *
-	 * @param e	exception 
-	 */
-	public void consoleExceptionPrintTrace(Throwable e)
-	{
-		consoleMessage(e.getMessage(), true);
-		PrintWriter lw = logWriter;
-		if (lw != null)
-		{
-			synchronized (lw) {
-				e.printStackTrace(lw);
-			}
-		}
-		else
-		{
-			e.printStackTrace();
-		}
-		
-		lw = cloudscapeLogWriter;
-		if (lw != null)
-		{
-			synchronized(lw) {
-				e.printStackTrace(lw);
-			}
-		}
-	}
-
-
-
-
-	/**
-	 * Write a message to console output stream
-	 *
-	 * @param msg	message
+    
+    /**
+     * Write an error message to console output stream
+     * and throw an exception for this error
+     *
+     * @param msg    error message
+     * @exception Exception
+     */
+    public void consoleError(String msg)
+        throws Exception
+    {
+        consoleMessage(msg, true);
+        throw new Exception(msg);
+    }
+
+    /**
+     * Write an exception to console output stream,
+     * but only if debugOutput is true.
+     *
+     * @param e    exception 
+     */
+    public void consoleExceptionPrint(Exception e)
+    {
+        if (debugOutput == true)
+            consoleExceptionPrintTrace(e);
+
+        return;
+    }
+
+    /**
+     * Write an exception (with trace) to console
+     * output stream.
+     *
+     * @param e    exception 
+     */
+    public void consoleExceptionPrintTrace(Throwable e)
+    {
+        consoleMessage(e.getMessage(), true);
+        PrintWriter lw = logWriter;
+        if (lw != null)
+        {
+            synchronized (lw) {
+                e.printStackTrace(lw);
+            }
+        }
+        else
+        {
+            e.printStackTrace();
+        }
+        
+        lw = cloudscapeLogWriter;
+        if (lw != null)
+        {
+            synchronized(lw) {
+                e.printStackTrace(lw);
+            }
+        }
+    }
+
+
+
+
+    /**
+     * Write a message to console output stream
+     *
+     * @param msg    message
      * @param printTimeStamp Whether to prepend a timestamp to the message or not
-	 */
-	public void consoleMessage(String msg, boolean printTimeStamp)
-	{
-		// print to console if we have one
-		PrintWriter lw = logWriter;
-		if (lw != null)
-		{
-			synchronized(lw) {
+     */
+    public void consoleMessage(String msg, boolean printTimeStamp)
+    {
+        // print to console if we have one
+        PrintWriter lw = logWriter;
+        if (lw != null)
+        {
+            synchronized(lw) {
                 if (printTimeStamp) {
                     lw.println(new Date() + " : " + msg);
                 } else {
                     lw.println(msg);                    
                 }
-			}
-		}
-		// always print to derby.log
-		lw = cloudscapeLogWriter;
-		if (lw != null)
-			synchronized(lw)
-			{
-				if (printTimeStamp) {
+            }
+        }
+        // always print to derby.log
+        lw = cloudscapeLogWriter;
+        if (lw != null)
+            synchronized(lw)
+            {
+                if (printTimeStamp) {
                     Monitor.logMessage(new Date() + " : " + msg);
                 } else {
                     Monitor.logMessage(msg);
                 }
-			}
-	}
+            }
+    }
 
 
 
-	/**
-	 * Start a network server.  Launches a separate thread with 
-	 * DRDAServerStarter.  Want to use Monitor.startModule,
-	 * so it can all get shutdown when Derby shuts down, but 
-	 * can't get it working right now.
-	 *
-	 * @param consoleWriter   PrintWriter to which server console will be 
-	 *                        output. Null will disable console output.
-	 *
-	 *		   
-	 * @exception Exception	throws an exception if an error occurs
-	 */
-	public void start(PrintWriter consoleWriter)
-		throws Exception
-	{
-		DRDAServerStarter starter = new DRDAServerStarter();
-		starter.setStartInfo(hostAddress,portNumber,consoleWriter);
+    /**
+     * Start a network server.  Launches a separate thread with 
+     * DRDAServerStarter.  Want to use Monitor.startModule,
+     * so it can all get shutdown when Derby shuts down, but 
+     * can't get it working right now.
+     *
+     * @param consoleWriter   PrintWriter to which server console will be 
+     *                        output. Null will disable console output.
+     *
+     *           
+     * @exception Exception    throws an exception if an error occurs
+     */
+    public void start(PrintWriter consoleWriter)
+        throws Exception
+    {
+        DRDAServerStarter starter = new DRDAServerStarter();
+        starter.setStartInfo(hostAddress,portNumber,consoleWriter);
         this.setLogWriter(consoleWriter);
-		startNetworkServer();
-		starter.boot(false,null);
-	}
-
-	/**
-	 * Create the right kind of server socket
-	 */
-	
-	private ServerSocket createServerSocket()
-		throws IOException
-	{
-		if (hostAddress == null)
-			hostAddress = InetAddress.getByName(hostArg);
-		// Make a list of valid
-		// InetAddresses for NetworkServerControl
-		// admin commands.
-		buildLocalAddressList(hostAddress);
-											
-		// Create the right kind of socket
-		switch (getSSLMode()) {
-		case SSL_OFF:
-		default:
-			ServerSocketFactory sf =
-				ServerSocketFactory.getDefault();
-			return sf.createServerSocket(portNumber
-										 ,0,
-										 hostAddress);
-		case SSL_BASIC:
-			SSLServerSocketFactory ssf =
-				(SSLServerSocketFactory)SSLServerSocketFactory.getDefault();
-			return (SSLServerSocket)ssf.createServerSocket(portNumber,
-														   0,
-														   hostAddress);
-		case SSL_PEER_AUTHENTICATION:
-			SSLServerSocketFactory ssf2 =
-				(SSLServerSocketFactory)SSLServerSocketFactory.getDefault();
-			SSLServerSocket sss2= 
-				(SSLServerSocket)ssf2.createServerSocket(portNumber,
-														 0,
-														 hostAddress);
-			sss2.setNeedClientAuth(true);
-			return sss2;
-		}
-	}
-	
-
-	/**
-	 * Start a network server
-	 *
-	 * @param consoleWriter   PrintWriter to which server console will be 
-	 *                        output. Null will disable console output.
-	 *
-	 *		   
-	 * @exception Exception	throws an exception if an error occurs
-	 */
-	public void blockingStart(PrintWriter consoleWriter)
-		throws Exception
-	{
-		startNetworkServer();
-		setLogWriter(consoleWriter);
-		cloudscapeLogWriter = Monitor.getStream().getPrintWriter();
-		if (SanityManager.DEBUG && debugOutput)
-		{
-			memCheck.showmem();
-			mc = new memCheck(200000);
-			mc.start();
-		}
-		// Open a server socket listener	  
-		try{
-			serverSocket = 
-				AccessController.doPrivileged(
+        startNetworkServer();
+        starter.boot(false,null);
+    }
+
+    /**
+     * Create the right kind of server socket
+     */
+    
+    private ServerSocket createServerSocket()
+        throws IOException
+    {
+        if (hostAddress == null)
+            hostAddress = InetAddress.getByName(hostArg);
+        // Make a list of valid
+        // InetAddresses for NetworkServerControl
+        // admin commands.
+        buildLocalAddressList(hostAddress);
+                                            
+        // Create the right kind of socket
+        switch (getSSLMode()) {
+        case SSL_OFF:
+        default:
+            ServerSocketFactory sf =
+                ServerSocketFactory.getDefault();
+            return sf.createServerSocket(portNumber
+                                         ,0,
+                                         hostAddress);
+        case SSL_BASIC:
+            SSLServerSocketFactory ssf =
+                (SSLServerSocketFactory)SSLServerSocketFactory.getDefault();
+            return (SSLServerSocket)ssf.createServerSocket(portNumber,
+                                                           0,
+                                                           hostAddress);
+        case SSL_PEER_AUTHENTICATION:
+            SSLServerSocketFactory ssf2 =
+                (SSLServerSocketFactory)SSLServerSocketFactory.getDefault();
+            SSLServerSocket sss2= 
+                (SSLServerSocket)ssf2.createServerSocket(portNumber,
+                                                         0,
+                                                         hostAddress);
+            sss2.setNeedClientAuth(true);
+            return sss2;
+        }
+    }
+    
+
+    /**
+     * Start a network server
+     *
+     * @param consoleWriter   PrintWriter to which server console will be 
+     *                        output. Null will disable console output.
+     *
+     *           
+     * @exception Exception    throws an exception if an error occurs
+     */
+    public void blockingStart(PrintWriter consoleWriter)
+        throws Exception
+    {
+        startNetworkServer();
+        setLogWriter(consoleWriter);
+        cloudscapeLogWriter = Monitor.getStream().getPrintWriter();
+        if (SanityManager.DEBUG && debugOutput)
+        {
+            memCheck.showmem();
+            mc = new memCheck(200000);
+            mc.start();
+        }
+        // Open a server socket listener      
+        try{
+            serverSocket = 
+                AccessController.doPrivileged(
                     new PrivilegedExceptionAction<ServerSocket>() {
-						public ServerSocket run() throws IOException
-						{
-							return createServerSocket();
-						}
-					});
-		} catch (PrivilegedActionException e) {
-			Exception e1 = e.getException();
-
-			// Test for UnknownHostException first since it's a
-			// subbclass of IOException (and consolePropertyMessage
-			// throws an exception when the severity is S (or U).
-			if (e1 instanceof UnknownHostException) {
-				consolePropertyMessage("DRDA_UnknownHost.S", hostArg);
-			} else if (e1 instanceof IOException) {
-				consolePropertyMessage("DRDA_ListenPort.S", 
-									   new String [] {
-										   Integer.toString(portNumber), 
-										   hostArg,
-										   // Since SocketException
-										   // is used for a phletora
-										   // of situations, we need
-										   // to communicate the
-										   // underlying exception
-										   // string to the user.
-										   e1.toString()}); 
-			} else {
-				throw e1;
-			}
-		} catch (Exception e) {
-		// If we find other (unexpected) errors, we ultimately exit--so make
-		// sure we print the error message before doing so (Beetle 5033).
-			throwUnexpectedException(e);
-		}
-        
-		switch (getSSLMode()) {
-		default:
-		case SSL_OFF:
-			consolePropertyMessage("DRDA_Ready.I", new String [] 
-				{Integer.toString(portNumber), att_srvclsnm, versionString});
-			break;
-		case SSL_BASIC:
-			consolePropertyMessage("DRDA_SSLReady.I", new String [] 
-				{Integer.toString(portNumber), att_srvclsnm, versionString});
-			break;
-		case SSL_PEER_AUTHENTICATION:
-			consolePropertyMessage("DRDA_SSLClientAuthReady.I", new String [] 
-				{Integer.toString(portNumber), att_srvclsnm, versionString});
-			break;
-		}
+                        public ServerSocket run() throws IOException
+                        {
+                            return createServerSocket();
+                        }
+                    });
+        } catch (PrivilegedActionException e) {
+            Exception e1 = e.getException();
+
+            // Test for UnknownHostException first since it's a
+            // subbclass of IOException (and consolePropertyMessage
+            // throws an exception when the severity is S (or U).
+            if (e1 instanceof UnknownHostException) {
+                consolePropertyMessage("DRDA_UnknownHost.S", hostArg);
+            } else if (e1 instanceof IOException) {
+                consolePropertyMessage("DRDA_ListenPort.S", 
+                                       new String [] {
+                                           Integer.toString(portNumber), 
+                                           hostArg,
+                                           // Since SocketException
+                                           // is used for a phletora
+                                           // of situations, we need
+                                           // to communicate the
+                                           // underlying exception
+                                           // string to the user.
+                                           e1.toString()}); 
+            } else {
+                throw e1;
+            }
+        } catch (Exception e) {
+        // If we find other (unexpected) errors, we ultimately exit--so make
+        // sure we print the error message before doing so (Beetle 5033).
+            throwUnexpectedException(e);
+        }
+        
+        switch (getSSLMode()) {
+        default:
+        case SSL_OFF:
+            consolePropertyMessage("DRDA_Ready.I", new String [] 
+                {Integer.toString(portNumber), att_srvclsnm, versionString});
+            break;
+        case SSL_BASIC:
+            consolePropertyMessage("DRDA_SSLReady.I", new String [] 
+                {Integer.toString(portNumber), att_srvclsnm, versionString});
+            break;
+        case SSL_PEER_AUTHENTICATION:
+            consolePropertyMessage("DRDA_SSLClientAuthReady.I", new String [] 
+                {Integer.toString(portNumber), att_srvclsnm, versionString});
+            break;
+        }
 
         // First, register any MBeans. We do this before we start accepting
         // connections from the clients to ease testing of JMX (DERBY-3689).
@@ -788,246 +788,246 @@ public final class NetworkServerControlI
                             NetworkServerMBean.class,
                             "type=NetworkServer");
 
-		// We accept clients on a separate thread so we don't run into a problem
-		// blocking on the accept when trying to process a shutdown
+        // We accept clients on a separate thread so we don't run into a problem
+        // blocking on the accept when trying to process a shutdown
         final ClientThread clientThread = AccessController.doPrivileged(
                 new PrivilegedExceptionAction<ClientThread>() {
                     public ClientThread run() throws Exception {
                         return new ClientThread(thisControl, serverSocket);
                     }
                 });
-		clientThread.start();
+        clientThread.start();
 
-		try {
-			// wait until we are told to shutdown or someone sends an InterruptedException
-	        synchronized(shutdownSync) {
-	            try {
+        try {
+            // wait until we are told to shutdown or someone sends an InterruptedException
+            synchronized(shutdownSync) {
+                try {
                     while (!shutdown) {
                         shutdownSync.wait();
                     }
-	            }
-	            catch (InterruptedException e)
-	            {
-	                shutdown = true;
-	            }
-	        }
-	        
-	        try {
-	            AccessController.doPrivileged(
-	                    new PrivilegedAction<Void>() {
-	                        public Void run() {
-	                        // Need to interrupt the memcheck thread if it is sleeping.
-	                            if (mc != null)
-	                                mc.interrupt();
-
-	                            //interrupt client thread
-	                            clientThread.interrupt();
-
-	                            return null;
-	                       }
-	                    });
-	        } catch (Exception exception) {
-	        	consolePrintAndIgnore("DRDA_UnexpectedException.S", exception, true);
-	        }
-			
-	 		// Close out the sessions
-	 		synchronized(sessionTable) {
-	 			for (Session session : sessionTable.values())
-	 			{	
-	 				try {
-	 					session.close();
-	 				} catch (Exception exception) {
-	 		        	consolePrintAndIgnore("DRDA_UnexpectedException.S", exception, true);
-	 				}
-	 			}
-	 		}
-
-			synchronized (threadList)
-			{
-	 			//interupt any connection threads still active
-	 			for (final DRDAConnThread threadi : threadList)
-	 			{
-	 				try {
-	 	 				threadi.close();
-	 					AccessController.doPrivileged(
+                }
+                catch (InterruptedException e)
+                {
+                    shutdown = true;
+                }
+            }
+            
+            try {
+                AccessController.doPrivileged(
+                        new PrivilegedAction<Void>() {
+                            public Void run() {
+                            // Need to interrupt the memcheck thread if it is sleeping.
+                                if (mc != null)
+                                    mc.interrupt();
+
+                                //interrupt client thread
+                                clientThread.interrupt();
+
+                                return null;
+                           }
+                        });
+            } catch (Exception exception) {
+                consolePrintAndIgnore("DRDA_UnexpectedException.S", exception, true);
+            }
+            
+             // Close out the sessions
+             synchronized(sessionTable) {
+                 for (Session session : sessionTable.values())
+                 {    
+                     try {
+                         session.close();
+                     } catch (Exception exception) {
+                         consolePrintAndIgnore("DRDA_UnexpectedException.S", exception, true);
+                     }
+                 }
+             }
+
+            synchronized (threadList)
+            {
+                 //interupt any connection threads still active
+                 for (final DRDAConnThread threadi : threadList)
+                 {
+                     try {
+                          threadi.close();
+                         AccessController.doPrivileged(
                                 new PrivilegedAction<Void>() {
                                     public Void run() {
                                         threadi.interrupt();
                                         return null;
                                     }
                                 });
-	 				} catch (Exception exception) {
-	 		        	consolePrintAndIgnore("DRDA_UnexpectedException.S", exception, true);
-	 				}
-	 			}
-	 			threadList.clear();
-			}
-		   	
-		    // close the listener socket
-		    try{
-		       serverSocket.close();
-		    }catch(IOException e){
-				consolePropertyMessage("DRDA_ListenerClose.S", true);
-		    } catch (Exception exception) {
-	        	consolePrintAndIgnore("DRDA_UnexpectedException.S", exception, true);
-		    }
-
-			// Wake up those waiting on sessions, so
-			// they can close down
-		    try{
-				synchronized (runQueue) {
-					runQueue.notifyAll();
-				}	
-		    } catch (Exception exception) {
-	        	consolePrintAndIgnore("DRDA_UnexpectedException.S", exception, true);
-		    }
-	        
-	        // And now unregister any MBeans.
-		    try {
-		        mgmtService.unregisterMBean(versionMBean);
-		        mgmtService.unregisterMBean(networkServerMBean);
-		    } catch (Exception exception) {
-	        	consolePrintAndIgnore("DRDA_UnexpectedException.S", exception, true);
-		    }
-
-			if (shutdownDatabasesOnShutdown) {
-
-				// Shutdown Derby
-				try {
-					// tell driver to shutdown the engine
-					if (cloudscapeDriver != null) {
-						// DERBY-2109: pass user credentials for driver shutdown
-						final Properties p = new Properties();
-						if (userArg != null) {
-							p.setProperty("user", userArg);
-						}
-						if (passwordArg != null) {
-							p.setProperty("password", passwordArg);
-						}
-						cloudscapeDriver.connect("jdbc:derby:;shutdown=true", p);
-					}
-				} catch (SQLException sqle) {
-					// If we can't shutdown Derby, perhaps, authentication has
-					// failed or System Privileges weren't granted. We will just
-					// print a message to the console and proceed.
-					String expectedState =
-						StandardException.getSQLStateFromIdentifier(
-								SQLState.CLOUDSCAPE_SYSTEM_SHUTDOWN);
-					if (!expectedState.equals(sqle.getSQLState())) {
-						consolePropertyMessage("DRDA_ShutdownWarning.I",
-											   sqle.getMessage());
-					}
-				} catch (Exception exception) {
-					consolePrintAndIgnore("DRDA_UnexpectedException.S", exception, true);
-				}
-			}
-
-			consolePropertyMessage("DRDA_ShutdownSuccess.I", new String [] 
-							        {att_srvclsnm, versionString});
-			
-		} catch (Exception ex) {
-			try {
-				//If the console printing is not available,  then we have
-				//a simple stack trace print below to atleast print some
-				//exception info
-	        	consolePrintAndIgnore("DRDA_UnexpectedException.S", ex, true);				
-			} catch (Exception e) {}
-			ex.printStackTrace();
-		}
-    }
-	
-	//Print the passed exception on the console and ignore it after that
-	private void consolePrintAndIgnore(String msgProp, 
-			Exception e, boolean printTimeStamp) {
-		// catch the exception consolePropertyMessage will throw since we
-		// just want to print information about it and move on.
-		try {
-			consolePropertyMessage(msgProp, true);
-		} catch (Exception ce) {} 
-		consoleExceptionPrintTrace(e);		
-	}
-	
-	/** 
-	 * Load Derby and save driver for future use.
-	 * We can't call Driver Manager when the client connects, 
-	 * because they might be holding the DriverManager lock.
-	 *
-	 * 
-	 */
-
-	
-
-
-	protected void startNetworkServer() throws Exception
-	{
-
-		// we start the Derby server here.
-		boolean restartCheck = this.restartFlag;
-		synchronized (serverStartSync) {
-
-			if (restartCheck == this.restartFlag) {
-			// then we can go ahead and restart the server (odds
-			// that some else has just done so are very slim (but not
-			// impossible--however, even if it does happen, things
-			// should still work correctly, just not as efficiently...))
-
-				try {
-	
-					if (cleanupOnStart) {
-					// we're restarting the server (probably after a shutdown
-					// exception), so we need to clean up first.
-
-						// Close and remove sessions on runQueue.
-						synchronized (runQueue) {
-							for (Session s : runQueue) {
-								s.close();
-								removeFromSessionTable(s.getConnNum());
-							}
-							runQueue.clear();
-						}
-
-						// DERBY-1326: There could be active threads that
-						// contain old/invalid sessions. These sessions won't
-						// be cleaned up until there is some activity on
-						// them. We could optimize this by going through
-						// sessionTable and closing the sessions' socket
-						// streams.
-
-						// Unload driver, then restart the server.
-						cloudscapeDriver = null;	// so it gets collected.
-						System.gc();
-					}
+                     } catch (Exception exception) {
+                         consolePrintAndIgnore("DRDA_UnexpectedException.S", exception, true);
+                     }
+                 }
+                 threadList.clear();
+            }
+               
+            // close the listener socket
+            try{
+               serverSocket.close();
+            }catch(IOException e){
+                consolePropertyMessage("DRDA_ListenerClose.S", true);
+            } catch (Exception exception) {
+                consolePrintAndIgnore("DRDA_UnexpectedException.S", exception, true);
+            }
+
+            // Wake up those waiting on sessions, so
+            // they can close down
+            try{
+                synchronized (runQueue) {
+                    runQueue.notifyAll();
+                }    
+            } catch (Exception exception) {
+                consolePrintAndIgnore("DRDA_UnexpectedException.S", exception, true);
+            }
+            
+            // And now unregister any MBeans.
+            try {
+                mgmtService.unregisterMBean(versionMBean);
+                mgmtService.unregisterMBean(networkServerMBean);
+            } catch (Exception exception) {
+                consolePrintAndIgnore("DRDA_UnexpectedException.S", exception, true);
+            }
+
+            if (shutdownDatabasesOnShutdown) {
+
+                // Shutdown Derby
+                try {
+                    // tell driver to shutdown the engine
+                    if (cloudscapeDriver != null) {
+                        // DERBY-2109: pass user credentials for driver shutdown
+                        final Properties p = new Properties();
+                        if (userArg != null) {
+                            p.setProperty("user", userArg);
+                        }
+                        if (passwordArg != null) {
+                            p.setProperty("password", passwordArg);
+                        }
+                        cloudscapeDriver.connect("jdbc:derby:;shutdown=true", p);
+                    }
+                } catch (SQLException sqle) {
+                    // If we can't shutdown Derby, perhaps, authentication has
+                    // failed or System Privileges weren't granted. We will just
+                    // print a message to the console and proceed.
+                    String expectedState =
+                        StandardException.getSQLStateFromIdentifier(
+                                SQLState.CLOUDSCAPE_SYSTEM_SHUTDOWN);
+                    if (!expectedState.equals(sqle.getSQLState())) {
+                        consolePropertyMessage("DRDA_ShutdownWarning.I",
+                                               sqle.getMessage());
+                    }
+                } catch (Exception exception) {
+                    consolePrintAndIgnore("DRDA_UnexpectedException.S", exception, true);
+                }
+            }
+
+            consolePropertyMessage("DRDA_ShutdownSuccess.I", new String [] 
+                                    {att_srvclsnm, versionString});
+            
+        } catch (Exception ex) {
+            try {
+                //If the console printing is not available,  then we have
+                //a simple stack trace print below to atleast print some
+                //exception info
+                consolePrintAndIgnore("DRDA_UnexpectedException.S", ex, true);                
+            } catch (Exception e) {}
+            ex.printStackTrace();
+        }
+    }
+    
+    //Print the passed exception on the console and ignore it after that
+    private void consolePrintAndIgnore(String msgProp, 
+            Exception e, boolean printTimeStamp) {
+        // catch the exception consolePropertyMessage will throw since we
+        // just want to print information about it and move on.
+        try {
+            consolePropertyMessage(msgProp, true);
+        } catch (Exception ce) {} 
+        consoleExceptionPrintTrace(e);        
+    }
+    
+    /** 
+     * Load Derby and save driver for future use.
+     * We can't call Driver Manager when the client connects, 
+     * because they might be holding the DriverManager lock.
+     *
+     * 
+     */
+
+    
+
+
+    protected void startNetworkServer() throws Exception
+    {
+
+        // we start the Derby server here.
+        boolean restartCheck = this.restartFlag;
+        synchronized (serverStartSync) {
+
+            if (restartCheck == this.restartFlag) {
+            // then we can go ahead and restart the server (odds
+            // that some else has just done so are very slim (but not
+            // impossible--however, even if it does happen, things
+            // should still work correctly, just not as efficiently...))
+
+                try {
+    
+                    if (cleanupOnStart) {
+                    // we're restarting the server (probably after a shutdown
+                    // exception), so we need to clean up first.
+
+                        // Close and remove sessions on runQueue.
+                        synchronized (runQueue) {
+                            for (Session s : runQueue) {
+                                s.close();
+                                removeFromSessionTable(s.getConnNum());
+                            }
+                            runQueue.clear();
+                        }
+
+                        // DERBY-1326: There could be active threads that
+                        // contain old/invalid sessions. These sessions won't
+                        // be cleaned up until there is some activity on
+                        // them. We could optimize this by going through
+                        // sessionTable and closing the sessions' socket
+                        // streams.
+
+                        // Unload driver, then restart the server.
+                        cloudscapeDriver = null;    // so it gets collected.
+                        System.gc();
+                    }
 
-					// start the server.
-					cloudscapeDriver = (Driver) Class.forName(CLOUDSCAPE_DRIVER).newInstance();
+                    // start the server.
+                    cloudscapeDriver = (Driver) Class.forName(CLOUDSCAPE_DRIVER).newInstance();
 
-				}
-				catch (Exception e) {
+                }
+                catch (Exception e) {
                     this.consoleExceptionPrintTrace(e);
-					consolePropertyMessage("DRDA_LoadException.S", e.getMessage());
-				}
-				cleanupOnStart = true;
-				this.restartFlag = !this.restartFlag;
-			}
-			// else, multiple threads hit this synchronize block at the same
-			// time, but one of them already executed it--so all others just
-			// return and do nothing (no need to restart the server multiple
-			// times in a row).
-		}
-	}
-
-	/**
-	 * Shutdown a network server
-	 *
-	 * @exception Exception	throws an exception if an error occurs
-	 */
-	public void shutdown()
-		throws Exception
-	{
-		// Wait up to 10 seconds for things to really shut down
-		// need a quiet ping so temporarily disable the logwriter
-		PrintWriter savWriter;
-		int ntry;
+                    consolePropertyMessage("DRDA_LoadException.S", e.getMessage());
+                }
+                cleanupOnStart = true;
+                this.restartFlag = !this.restartFlag;
+            }
+            // else, multiple threads hit this synchronize block at the same
+            // time, but one of them already executed it--so all others just
+            // return and do nothing (no need to restart the server multiple
+            // times in a row).
+        }
+    }
+
+    /**
+     * Shutdown a network server
+     *
+     * @exception Exception    throws an exception if an error occurs
+     */
+    public void shutdown()
+        throws Exception
+    {
+        // Wait up to 10 seconds for things to really shut down
+        // need a quiet ping so temporarily disable the logwriter
+        PrintWriter savWriter;
+        int ntry;
         try {
             setUpSocket();
             try {
@@ -1038,23 +1038,23 @@ public final class NetworkServerControlI
                 send();
                 readResult();
             } catch (Exception e) {
-            	//The shutdown command with protocol level 2 failed. If 
-            	//the username or password were supplied then we can't 
-            	//try the shutdown with protocol level 1 because protocol
-            	//leve 1 does not support username/password. Because of
-            	//that, we should simply throw the caught exception to the
-            	//client
-            	if(userArg != null || passwordArg != null)
-            		throw e;
+                //The shutdown command with protocol level 2 failed. If 
+                //the username or password were supplied then we can't 
+                //try the shutdown with protocol level 1 because protocol
+                //leve 1 does not support username/password. Because of
+                //that, we should simply throw the caught exception to the
+                //client
+                if(userArg != null || passwordArg != null)
+                    throw e;
                 //If no username and password is specified then we can try
-            	//shutdown with the old protocol level of 1 which is the 
-            	//default protocol level. But this can be tried only if the
-            	//exception for attempt of shutdown with protocol level 2
-            	//was DRDA_InvalidReplyHead. This can happen if we are 
-            	//dealing with an older Network server product which do not
-            	//recognize shutdown at protocol level 2.
-            	if (e.getMessage().indexOf("DRDA_InvalidReplyHead") != -1)
-            	{
+                //shutdown with the old protocol level of 1 which is the 
+                //default protocol level. But this can be tried only if the
+                //exception for attempt of shutdown with protocol level 2
+                //was DRDA_InvalidReplyHead. This can happen if we are 
+                //dealing with an older Network server product which do not
+                //recognize shutdown at protocol level 2.
+                if (e.getMessage().indexOf("DRDA_InvalidReplyHead") != -1)
+                {
                     try {
                         closeSocket();
                         setUpSocket();
@@ -1062,12 +1062,12 @@ public final class NetworkServerControlI
                         send();
                         readResult();
                     } catch (Exception e1) {
-                    	e1.initCause(e);
-                    	throw e1;
+                        e1.initCause(e);
+                        throw e1;
                     }
-            	}
-            	else
-            		throw e;
+                }
+                else
+                    throw e;
             }
             savWriter = logWriter;
             // DERBY-1571: If logWriter is null, stack traces are printed to
@@ -1095,16 +1095,16 @@ public final class NetworkServerControlI
             }
         } finally {
             closeSocket();
-        }		
+        }        
         
         if (ntry == SHUTDOWN_CHECK_ATTEMPTS)
             consolePropertyMessage("DRDA_ShutdownError.S", new String [] {
                 Integer.toString(portNumber), 
                 hostArg}); 
         
-		logWriter= savWriter;
-		return;
-	}
+        logWriter= savWriter;
+        return;
+    }
 
     /**
      * Authenticates the user and checks for shutdown System Privileges.
@@ -1171,54 +1171,54 @@ public final class NetworkServerControlI
             // SecurityUtil.checkUserHasPermission(userArg, sp);
         } catch (AccessControlException ace) {
             throw Util.generateCsSQLException(
-				SQLState.AUTH_SHUTDOWN_MISSING_PERMISSION,
-				userArg, (Object)ace); // overloaded method
+                SQLState.AUTH_SHUTDOWN_MISSING_PERMISSION,
+                userArg, (Object)ace); // overloaded method
         }
     }
 
-	/*
-	 Shutdown the server directly (If you have the original object)
-	 No Network communication needed.
-	*/
-	public void directShutdown() throws SQLException {
-		// DERBY-2109: the public shutdown method now checks privileges
-		checkShutdownPrivileges();
-		directShutdownInternal();
-	}
-	
-	/*
-	 Shutdown the server directly (If you have the original object)
-	 No Network communication needed.
-	*/
+    /*
+     Shutdown the server directly (If you have the original object)
+     No Network communication needed.
+    */
+    public void directShutdown() throws SQLException {
+        // DERBY-2109: the public shutdown method now checks privileges
+        checkShutdownPrivileges();
+        directShutdownInternal();
+    }
+    
+    /*
+     Shutdown the server directly (If you have the original object)
+     No Network communication needed.
+    */
     void directShutdownInternal() {
-		// DERBY-2109: the direct, unchecked shutdown is made private
-		synchronized(shutdownSync) {						
-			shutdown = true;
-			// wake up the server thread
-			shutdownSync.notifyAll();
-		}
-	}
-
-
-	/**
-	 */
-	public boolean isServerStarted() throws Exception
-	{
-		try {
-			ping();
-		}
-		catch (Exception e) {
-			return false;
-		}
-		return true;
-	}
+        // DERBY-2109: the direct, unchecked shutdown is made private
+        synchronized(shutdownSync) {                        
+            shutdown = true;
+            // wake up the server thread
+            shutdownSync.notifyAll();
+        }
+    }
+
+
+    /**
+     */
+    public boolean isServerStarted() throws Exception
+    {
+        try {
+            ping();
+        }
+        catch (Exception e) {
+            return false;
+        }
+        return true;
+    }
 
     /**
      * Ping opening an new socket and close it.
      * @throws Exception
      */
-	public void ping() throws Exception
-	{
+    public void ping() throws Exception
+    {
         try {
             setUpSocket();
             pingWithNoOpen();
@@ -1233,47 +1233,47 @@ public final class NetworkServerControlI
     private void pingWithNoOpen() throws Exception
     {
     
-		// database no longer used, but don't change the protocol 
-		// in case we add
-		// authorization  later.
-		String database = null; // no longer used but don't change the protocol
-		String user = null;
-		String password = null;
-
-			
-			writeCommandHeader(COMMAND_TESTCONNECTION);
-			writeLDString(database);
-			writeLDString(user);
-			writeLDString(password);
-			send();
-			readResult();
-	}
-
-
-	/**
-	 * Turn tracing on or off for all sessions
-	 *
-	 * @param on			true to turn tracing on, false to turn tracing off
-	 *
-	 * @exception Exception	throws an exception if an error occurs
-	 */
-	public void trace(boolean on)
-		throws Exception
-	{
-		trace(0, on);
-	}
-
-	/**
-	 * Turn tracing on or off for one session or all sessions
-	 *
-	 * @param connNum	the connNum of the session, 0 if all sessions
-	 * @param on			true to turn tracing on, false to turn tracing off
-	 *
-	 * @exception Exception	throws an exception if an error occurs
-	 */
-	public void trace(int connNum, boolean on)
-		throws Exception
-	{
+        // database no longer used, but don't change the protocol 
+        // in case we add
+        // authorization  later.
+        String database = null; // no longer used but don't change the protocol
+        String user = null;
+        String password = null;
+
+            
+            writeCommandHeader(COMMAND_TESTCONNECTION);
+            writeLDString(database);
+            writeLDString(user);
+            writeLDString(password);
+            send();
+            readResult();
+    }
+
+
+    /**
+     * Turn tracing on or off for all sessions
+     *
+     * @param on            true to turn tracing on, false to turn tracing off
+     *
+     * @exception Exception    throws an exception if an error occurs
+     */
+    public void trace(boolean on)
+        throws Exception
+    {
+        trace(0, on);
+    }
+
+    /**
+     * Turn tracing on or off for one session or all sessions
+     *
+     * @param connNum    the connNum of the session, 0 if all sessions
+     * @param on            true to turn tracing on, false to turn tracing off
+     *
+     * @exception Exception    throws an exception if an error occurs
+     */
+    public void trace(int connNum, boolean on)
+        throws Exception
+    {
         try {
             setUpSocket();
             writeCommandHeader(COMMAND_TRACE);
@@ -1286,49 +1286,49 @@ public final class NetworkServerControlI
             closeSocket();
         }
         
-	}
+    }
 
-	/**
-	 * Print trace change message to console
-	 *
-	 * @param on			true to print tracing on, false to print tracing off
-	 *
-	 * @exception Exception	throws an exception if an error occurs
-	 */
-	private void consoleTraceMessage(int connNum, boolean on)
-		throws Exception
-	{
+    /**
+     * Print trace change message to console
+     *
+     * @param on            true to print tracing on, false to print tracing off
+     *
+     * @exception Exception    throws an exception if an error occurs
+     */
+    private void consoleTraceMessage(int connNum, boolean on)
+        throws Exception
+    {
         String  messageID;
         String[]    args = null;
         
-		if (connNum == 0)
+        if (connNum == 0)
         {
             if ( on ) { messageID = "DRDA_TraceChangeAllOn.I"; }
             else { messageID = "DRDA_TraceChangeAllOff.I"; }
         }
-		else
-		{
+        else
+        {
             if ( on ) { messageID = "DRDA_TraceChangeOneOn.I"; }
             else { messageID = "DRDA_TraceChangeOneOff.I"; }
 
             args = new String[] { Integer.toString(connNum) };
             
-		}
+        }
         
         consolePropertyMessage( messageID, args );
-	}
+    }
 
-	/**
-	 * Turn logging connections on or off. When logging is turned on a message is
-	 * written to derby.log each time a connection is made.
-	 *
-	 * @param on			true to turn on, false to turn  off
-	 *
-	 * @exception Exception	throws an exception if an error occurs
-	 */
-	public void logConnections(boolean on)
-		throws Exception
-	{
+    /**
+     * Turn logging connections on or off. When logging is turned on a message is
+     * written to derby.log each time a connection is made.
+     *
+     * @param on            true to turn on, false to turn  off
+     *
+     * @exception Exception    throws an exception if an error occurs
+     */
+    public void logConnections(boolean on)
+        throws Exception
+    {
         try {
             setUpSocket();
             writeCommandHeader(COMMAND_LOGCONNECTIONS);
@@ -1337,15 +1337,15 @@ public final class NetworkServerControlI
             readResult();
         } finally {
             closeSocket();
-        }		
-	}
+        }        
+    }
 
-	/**
-	 *@see NetworkServerControl#setTraceDirectory
-	 */
-	public void sendSetTraceDirectory(String traceDirectory)
-		throws Exception
-	{
+    /**
+     *@see NetworkServerControl#setTraceDirectory
+     */
+    public void sendSetTraceDirectory(String traceDirectory)
+        throws Exception
+    {
         try {
             setUpSocket();
             writeCommandHeader(COMMAND_TRACEDIRECTORY);
@@ -1354,17 +1354,17 @@ public final class NetworkServerControlI
             readResult();
         } finally {
             closeSocket();
-        }		
+        }        
         
-	}
+    }
 
-	/**
-	 *@see NetworkServerControl#getSysinfo
-	 */
-	public String sysinfo()
-		throws Exception
-	{
-		try {
+    /**
+     *@see NetworkServerControl#getSysinfo
+     */
+    public String sysinfo()
+        throws Exception
+    {
+        try {
             setUpSocket();
             writeCommandHeader(COMMAND_SYSINFO);
             send();
@@ -1372,15 +1372,15 @@ public final class NetworkServerControlI
         } finally {
             closeSocket();
         }
-	}
+    }
 
-	/**
-	 *@see NetworkServerControl#getRuntimeInfo
-	 */
-	public String runtimeInfo()
-	throws Exception 
-	{
-		try {
+    /**
+     *@see NetworkServerControl#getRuntimeInfo
+     */
+    public String runtimeInfo()
+    throws Exception 
+    {
+        try {
             setUpSocket();
             writeCommandHeader(COMMAND_RUNTIME_INFO);
             send();
@@ -1388,34 +1388,34 @@ public final class NetworkServerControlI
         } finally {
             closeSocket();
         }
-	}
+    }
 
-	/**
-	 * Display usage information
-	 *
-	 */
-	public void usage()
-	{
-		try {
-		for (int i = 1; i <= NO_USAGE_MSGS; i++)
-			consolePropertyMessage("DRDA_Usage"+i+".I", false);
-		} catch (Exception e) {}	// ignore exceptions - there shouldn't be any
-	}
-
-	/**
-	 * Connect to  network server and set connection maxthread parameter
-	 *
-	 * @param max		maximum number of connections, if 0, connections 
-	 *						created when no free connection available
-	 *						if -1, use default
-	 *
-	 * @exception Exception	throws an exception if an error occurs
-	 */
-	public void netSetMaxThreads(int max) throws Exception
-	{
+    /**
+     * Display usage information
+     *
+     */
+    public void usage()
+    {
         try {
-            setUpSocket();
-            writeCommandHeader(COMMAND_MAXTHREADS);
+        for (int i = 1; i <= NO_USAGE_MSGS; i++)
+            consolePropertyMessage("DRDA_Usage"+i+".I", false);
+        } catch (Exception e) {}    // ignore exceptions - there shouldn't be any
+    }
+
+    /**
+     * Connect to  network server and set connection maxthread parameter
+     *
+     * @param max        maximum number of connections, if 0, connections 
+     *                        created when no free connection available
+     *                        if -1, use default
+     *
+     * @exception Exception    throws an exception if an error occurs
+     */
+    public void netSetMaxThreads(int max) throws Exception
+    {
+        try {
+            setUpSocket();
+            writeCommandHeader(COMMAND_MAXTHREADS);
             commandOs.writeInt(max);
             send();
             readResult();
@@ -1424,21 +1424,21 @@ public final class NetworkServerControlI
                     String.valueOf(newval));
         } finally {
             closeSocket();
-        }		
+        }        
         
-	}
+    }
 
-	/**
-	 * Set network server connection timeslice parameter
-	 *
-	 * @param timeslice	amount of time given to each session before yielding to 
-	 *						another session, if 0, never yield. if -1, use default.
-	 *
-	 * @exception Exception	throws an exception if an error occurs
-	 */
-	public void netSetTimeSlice(int timeslice)
-		throws Exception
-	{
+    /**
+     * Set network server connection timeslice parameter
+     *
+     * @param timeslice    amount of time given to each session before yielding to 
+     *                        another session, if 0, never yield. if -1, use default.
+     *
+     * @exception Exception    throws an exception if an error occurs
+     */
+    public void netSetTimeSlice(int timeslice)
+        throws Exception
+    {
         try {
             setUpSocket();
             writeCommandHeader(COMMAND_TIMESLICE);
@@ -1451,17 +1451,17 @@ public final class NetworkServerControlI
         } finally {
             closeSocket();
         }  
-	}
+    }
 
-	/**
-	 * Get current properties
-	 *
-	 * @return Properties object containing properties
-	 * @exception Exception	throws an exception if an error occurs
-	 */
-	public Properties getCurrentProperties() 
-		throws Exception
-	{
+    /**
+     * Get current properties
+     *
+     * @return Properties object containing properties
+     * @exception Exception    throws an exception if an error occurs
+     */
+    public Properties getCurrentProperties() 
+        throws Exception
+    {
         try {
             setUpSocket();
             writeCommandHeader(COMMAND_PROPERTIES);
@@ -1478,8 +1478,8 @@ public final class NetworkServerControlI
             return p;
         } finally {
             closeSocket();
-        }		
-	}
+        }        
+    }
 
     /**
      * Holds the sequence number to be assigned to the next thread that
@@ -1499,292 +1499,292 @@ public final class NetworkServerControlI
         return base + "_" + nextThreadNumber.getAndIncrement();
     }
 
-	/*******************************************************************************/
-	/*        Protected methods                                                    */
-	/*******************************************************************************/
-	/**
-	 * Remove session from session table
-	 *
-	 * @param sessionid 	id of session to be removed
-	 */
-	protected void removeFromSessionTable(int sessionid)
-	{
+    /*******************************************************************************/
+    /*        Protected methods                                                    */
+    /*******************************************************************************/
+    /**
+     * Remove session from session table
+     *
+     * @param sessionid     id of session to be removed
+     */
+    protected void removeFromSessionTable(int sessionid)
+    {
         sessionTable.remove(sessionid);
-	}
+    }
 
-	/**
-	 * 	processCommands reads and processes NetworkServerControlImpl commands sent
-	 * 	to the network server over the socket.  The protocol used is
-	 * 		4 bytes 	- String CMD:
-	 * 		2 bytes		- Protocol version
-	 *		1 byte		- length of locale (0 for default)
-	 *			n bytes - locale
-	 *		1 byte		- length of codeset (0 for default)
-	 *			n bytes - codeset
-	 * 		1 byte		- command
-	 * 		n bytes		- parameters for the command
-	 * 	The server returns
-	 *		4 bytes		- String RPY:
-	 *	for most commands
-	 *		1 byte		- command result, 0 - OK, 1 - warning, 2 - error
-	 *	 if warning or error
-	 *		1 bytes		- length of message key
-	 *		n bytes		- message key
-	 *		1 byte		- number of parameters to message
-	 *		{2 bytes		- length of parameter
-	 *		n bytes		- parameter} for each parameter
-	 *  for sysinfo
-	 *		1 byte		- command result, 0 - OK, 1 - warning, 2 - error
-	 *   if OK 
-	 *		2 bytes		- length of sysinfo
-	 *		n bytes		- sysinfo
-	 *		
-	 * 		
-	 * 	Note, the 3rd byte of the command must not be 'D0' to distinquish it 
-	 *	from DSS structures.
-	 * 	The protocol for the parameters for each command follows:
-	 *
-	 * 	Command: trace <connection id> {on | off}
-	 * 	Protocol:
-	 * 		4 bytes		- connection id - connection id of 0 means all sessions
-	 * 		1 byte		- 0 off, 1 on
-	 * 
-	 * 	Command: logConnections {on | off}
-	 * 	Protocol:
-	 * 		1 byte		- 0 off, 1 on
-	 * 
-	 *	Command: shutdown
-	 *		// DERBY-2109: transmit user credentials for System Privileges check
-	 *		2 bytes		- length of user name
-	 *		n bytes		- user name
-	 *		2 bytes		- length of password
-	 *		n bytes		- password
-	 * 
-	 * 	Command: sysinfo
-	 * 	No parameters
-	 * 
-	 * 	Command: dbstart
-	 * 	Protocol:
-	 * 		2 bytes		- length of database name
-	 * 		n bytes		- database name
-	 * 		2 bytes		- length of boot password
-	 * 		n bytes		- boot password 
-	 * 		2 bytes		- length of encryption algorithm
-	 * 		n bytes		- encryption algorithm
-	 * 		2 bytes		- length of encryption provider
-	 * 		n bytes		- encryption provider
-	 * 		2 bytes		- length of user name
-	 * 		n bytes		- user name
-	 * 		2 bytes		- length of password
-	 * 		n bytes		- password
-	 *
-	 * 	Command: dbshutdown
-	 * 	Protocol:
-	 * 		2 bytes		- length of database name
-	 * 		n bytes		- database name
-	 * 		2 bytes		- length of user name
-	 * 		n bytes		- user name
-	 * 		2 bytes		- length of password
-	 * 		n bytes		- password
-	 *
-	 * 	Command: connpool
-	 * 	Protocol:
-	 * 		2 bytes		- length of database name, if 0, default for all databases
-	 *						is set
-	 * 		n bytes		- database name
-	 *		2 bytes		- minimum number of connections, if 0, connection pool not used
-	 *						if value is -1 use default
-	 *		2 bytes		- maximum number of connections, if 0, connections are created
-	 *						as needed, if value is -1 use default
-	 *
-	 * 	Command: maxthreads
-	 * 	Protocol:
-	 *		2 bytes		- maximum number of threads
-	 *
-	 * 	Command: timeslice 
-	 * 	Protocol:
-	 *		4 bytes		- timeslice value
-	 *
-	 * 	Command: tracedirectory
-	 * 	Protocol:
-	 * 		2 bytes		- length of directory name
-	 * 		n bytes		- directory name
-	 *
-	 *	Command: test connection
-	 * 	Protocol:
-	 * 		2 bytes		- length of database name if 0, just the connection
-	 *						to the network server is tested and user name and 
-	 *						password aren't sent
-	 * 		n bytes		- database name
-	 * 		2 bytes		- length of user name (optional)
-	 * 		n bytes		- user name
-	 * 		2 bytes		- length of password  (optional)
-	 * 		n bytes		- password
-	 *
-	 *	The calling routine is synchronized so that multiple threads don't clobber each
-	 * 	other. This means that configuration commands will be serialized.
-	 * 	This shouldn't be a problem since they should be fairly rare.
-	 * 		
-	 * @param reader	input reader for command
-	 * @param writer output writer for command
-	 * @param session	session information
-	 *
-	 * @exception Throwable	throws an exception if an error occurs
-	 */
-	protected synchronized void processCommands(DDMReader reader, DDMWriter writer, 
-		Session session) throws Throwable
-	{
-		try {
-			String protocolStr = reader.readCmdString(4);
-			String locale = DEFAULT_LOCALE;
-			String codeset = null;
-			// get the version
-			int version = reader.readNetworkShort();
+    /**
+     *     processCommands reads and processes NetworkServerControlImpl commands sent
+     *     to the network server over the socket.  The protocol used is
+     *         4 bytes     - String CMD:
+     *         2 bytes        - Protocol version
+     *        1 byte        - length of locale (0 for default)
+     *            n bytes - locale
+     *        1 byte        - length of codeset (0 for default)
+     *            n bytes - codeset
+     *         1 byte        - command
+     *         n bytes        - parameters for the command
+     *     The server returns
+     *        4 bytes        - String RPY:
+     *    for most commands
+     *        1 byte        - command result, 0 - OK, 1 - warning, 2 - error
+     *     if warning or error
+     *        1 bytes        - length of message key
+     *        n bytes        - message key
+     *        1 byte        - number of parameters to message
+     *        {2 bytes        - length of parameter
+     *        n bytes        - parameter} for each parameter
+     *  for sysinfo
+     *        1 byte        - command result, 0 - OK, 1 - warning, 2 - error
+     *   if OK 
+     *        2 bytes        - length of sysinfo
+     *        n bytes        - sysinfo
+     *        
+     *         
+     *     Note, the 3rd byte of the command must not be 'D0' to distinquish it 
+     *    from DSS structures.
+     *     The protocol for the parameters for each command follows:
+     *
+     *     Command: trace <connection id> {on | off}
+     *     Protocol:
+     *         4 bytes        - connection id - connection id of 0 means all sessions
+     *         1 byte        - 0 off, 1 on
+     * 
+     *     Command: logConnections {on | off}
+     *     Protocol:
+     *         1 byte        - 0 off, 1 on
+     * 
+     *    Command: shutdown
+     *        // DERBY-2109: transmit user credentials for System Privileges check
+     *        2 bytes        - length of user name
+     *        n bytes        - user name
+     *        2 bytes        - length of password
+     *        n bytes        - password
+     * 
+     *     Command: sysinfo
+     *     No parameters
+     * 
+     *     Command: dbstart
+     *     Protocol:
+     *         2 bytes        - length of database name
+     *         n bytes        - database name
+     *         2 bytes        - length of boot password
+     *         n bytes        - boot password 
+     *         2 bytes        - length of encryption algorithm
+     *         n bytes        - encryption algorithm
+     *         2 bytes        - length of encryption provider
+     *         n bytes        - encryption provider
+     *         2 bytes        - length of user name
+     *         n bytes        - user name
+     *         2 bytes        - length of password
+     *         n bytes        - password
+     *
+     *     Command: dbshutdown
+     *     Protocol:
+     *         2 bytes        - length of database name
+     *         n bytes        - database name
+     *         2 bytes        - length of user name
+     *         n bytes        - user name
+     *         2 bytes        - length of password
+     *         n bytes        - password
+     *
+     *     Command: connpool
+     *     Protocol:
+     *         2 bytes        - length of database name, if 0, default for all databases
+     *                        is set
+     *         n bytes        - database name
+     *        2 bytes        - minimum number of connections, if 0, connection pool not used
+     *                        if value is -1 use default
+     *        2 bytes        - maximum number of connections, if 0, connections are created
+     *                        as needed, if value is -1 use default
+     *
+     *     Command: maxthreads
+     *     Protocol:
+     *        2 bytes        - maximum number of threads
+     *
+     *     Command: timeslice 
+     *     Protocol:
+     *        4 bytes        - timeslice value
+     *
+     *     Command: tracedirectory
+     *     Protocol:
+     *         2 bytes        - length of directory name
+     *         n bytes        - directory name
+     *
+     *    Command: test connection
+     *     Protocol:
+     *         2 bytes        - length of database name if 0, just the connection
+     *                        to the network server is tested and user name and 
+     *                        password aren't sent
+     *         n bytes        - database name
+     *         2 bytes        - length of user name (optional)

[... 4813 lines stripped ...]


Mime
View raw message