FileDocCategorySizeDatePackage
DatabaseCommand.javaAPI DocGlassfish v2 API6221Fri May 04 22:25:08 BST 2007com.sun.enterprise.cli.commands

DatabaseCommand

public abstract class DatabaseCommand extends S1ASCommand
This is an abstract class to be inherited by StartDatabaseCommand and StopDatabaseCommand. This classes prepares the variables that is used to to invoke DerbyControl. It also contains a pingDatabase method that is used by both start/stop database command.
author
Jane Young
version
$Revision: 1.5 $

Fields Summary
private static final String
DB_HOST
private static final String
DB_PORT
protected String
dbHost
protected String
dbPort
protected String
dbLocation
protected String
sJavaHome
protected String
sInstallRoot
protected String
sClasspath
protected String
sDatabaseClasspath
Constructors Summary
Methods Summary
private voidcheckIfPortIsValid(java.lang.String port)
check if database port is valid. Derby does not check this so need to add code to check the port number.

        try
        {
            Integer.parseInt(port);
        }
        catch(Exception e)
        {
            throw new CommandValidationException(getLocalizedString("InvalidPortNumber", new Object[] {port}));
        }
    
protected java.lang.String[]pingDatabaseCmd(boolean bRedirect)
defines the command to ping the derby database Note that when using Darwin (Mac), the property, "-Dderby.storage.fileSyncTransactionLog=True" is defined.

        if (OS.isDarwin()) {
            return new String[]{sJavaHome + File.separator + "bin" + File.separator +
                         "java",
                    "-Djava.library.path=" + sInstallRoot + File.separator +
                    "lib", "-Dderby.storage.fileSyncTransactionLog=True", "-cp",
                    sClasspath + File.pathSeparator + sDatabaseClasspath,
                    "com.sun.enterprise.cli.commands.DerbyControl", "ping",
                    dbHost, dbPort, Boolean.valueOf(bRedirect).toString()};
        }
        else {
            return new String[]{sJavaHome + File.separator + "bin" + File.separator +
                         "java",
                    "-Djava.library.path=" + sInstallRoot + File.separator +
                    "lib", "-cp",
                    sClasspath + File.pathSeparator + sDatabaseClasspath,
                    "com.sun.enterprise.cli.commands.DerbyControl", "ping",
                    dbHost, dbPort, Boolean.valueOf(bRedirect).toString()};
        }
    
protected voidprepareProcessExecutor()
Prepare variables to invoke start/ping database command DatabaseCommand.


                 
        
    
        dbHost = getOption(DB_HOST);
        dbPort = getOption(DB_PORT);
	checkIfPortIsValid(dbPort);
        dbLocation = System.getProperty(SystemPropertyConstants.DERBY_ROOT_PROPERTY);
        sJavaHome = System.getProperty(SystemPropertyConstants.JAVA_ROOT_PROPERTY);
        sInstallRoot = System.getProperty(SystemPropertyConstants.INSTALL_ROOT_PROPERTY);
	//	sClasspath = System.getProperty("java.class.path");
	sClasspath = sInstallRoot+File.separator+"lib"+File.separator+
                     "appserv-rt.jar"+File.pathSeparator+sInstallRoot+
	             File.separator+"lib"+File.separator+"admin-cli.jar";
        sDatabaseClasspath = dbLocation+File.separator+"lib"+
                                       File.separator+"derby.jar"+
                                       File.pathSeparator+dbLocation+
                                       File.separator+"lib"+File.separator+
                                       "derbytools.jar"+File.pathSeparator+
                                       dbLocation+File.separator+"lib"+
                                       File.separator+"derbynet.jar"+
                                       File.pathSeparator+dbLocation+File.separator+
                                       "lib"+File.separator+"derbyclient.jar";