1 23 24 package com.sun.enterprise.cli.commands; 25 26 import com.sun.enterprise.cli.framework.CLILogger; 27 import com.sun.enterprise.cli.framework.CommandException; 28 import com.sun.enterprise.cli.framework.CommandValidationException; 29 import com.sun.enterprise.util.SystemPropertyConstants; 30 import com.sun.enterprise.util.OS; 31 import java.io.File ; 32 33 40 public final class StopDatabaseCommand extends DatabaseCommand 41 { 42 private final static String DB_HOST = "dbhost"; 43 private final static String DB_PORT = "dbport"; 44 45 52 public boolean validateOptions() throws CommandValidationException 53 { 54 return super.validateOptions(); 55 } 56 57 58 63 public String [] stopDatabaseCmd() throws Exception 64 { 65 if (OS.isDarwin()) { 66 return new String [] { 67 sJavaHome+File.separator+"bin"+File.separator+"java", 68 "-Djava.library.path="+sInstallRoot+File.separator+"lib", 69 "-Dderby.storage.fileSyncTransactionLog=True", 70 "-cp", 71 sClasspath + File.pathSeparator + sDatabaseClasspath, 72 "com.sun.enterprise.cli.commands.DerbyControl", 73 "shutdown", 74 dbHost, dbPort, "false" 75 }; 76 } 77 return new String [] { 78 sJavaHome+File.separator+"bin"+File.separator+"java", 79 "-Djava.library.path="+sInstallRoot+File.separator+"lib", 80 "-cp", 81 sClasspath + File.pathSeparator + sDatabaseClasspath, 82 "com.sun.enterprise.cli.commands.DerbyControl", 83 "shutdown", 84 dbHost, dbPort, "false" 85 }; 86 } 87 88 89 90 94 public void runCommand() throws CommandException, CommandValidationException 95 { 96 if (!validateOptions()) 97 throw new CommandValidationException("Validation is false"); 98 99 try { 100 prepareProcessExecutor(); 101 CLIProcessExecutor cpe = new CLIProcessExecutor(); 102 cpe.execute(pingDatabaseCmd(false), true); 103 if (cpe.exitValue() > 0) { 104 throw new CommandException(getLocalizedString("StopDatabaseStatus", new Object []{dbHost, dbPort})); 106 } 107 else if (cpe.exitValue() <0) { 108 throw new CommandException(getLocalizedString("CommandUnSuccessful", 110 new Object [] {name} )); 111 } 112 else { 113 cpe.execute(stopDatabaseCmd(), true); 115 if (cpe.exitValue() > 0) { 116 throw new CommandException(getLocalizedString("CommandUnSuccessful", 117 new Object [] {name} )); 118 } 119 CLILogger.getInstance().printDetailMessage(getLocalizedString( 120 "CommandSuccessful", 121 new Object [] {name})); 122 } 123 } 124 catch (Exception e) { 125 displayExceptionMessage(e); 126 } 127 } 128 } 129 | Popular Tags |