public void execute() throws Exception { @SuppressWarnings("unused") File home_dir = ARG_HOME.getValue(); String command = FLAG_START.isSet() ? "start" : FLAG_STOP.isSet() ? "stop" : "?"; // FIXME ... this needs to be passed to the server somehow. @SuppressWarnings("unused") int port = ARG_PORT.isSet() ? ARG_PORT.getValue() : 1527; NetworkServerControlImpl server = new NetworkServerControlImpl(); int server_command = server.parseArgs(new String[] {command}); if (server_command == NetworkServerControlImpl.COMMAND_START) { PrintWriter printWriter = getOutput().getPrintWriter(); server.setLogWriter(printWriter); server.start(printWriter); } else if (server_command == NetworkServerControlImpl.COMMAND_SHUTDOWN) { server.shutdown(); } // server.executeWork(server_command); // NetworkServerControl.main(new String[]{command}); }
/** Execute this command */ public void execute() throws Exception { // If threadName is null, we'll print all threads String threadName = (argName.isSet()) ? argName.getValue() : null; boolean dump = argDump.isSet(); // Find the root of the ThreadGroup tree ThreadGroup grp = Thread.currentThread().getThreadGroup(); while (grp.getParent() != null) { grp = grp.getParent(); } if (dump) { // Produce an ugly (but useful) ThreadGroup dump. Unfortunately, // it goes to System.out, and we cannot fix it w/o changing a Java // standard API. grp.list(); } else { if (!argVerbose.isSet() && !argName.isSet()) { showDefaultInfo(grp); } else { // Show the threads in the ThreadGroup tree. showThreads(grp, getOutput().getPrintWriter(), threadName); } } }
@Override public void execute() throws NameNotFoundException, IsolateStartupException, ShellException { final PrintWriter out = getOutput().getPrintWriter(); final ShellManager sm = InitialNaming.lookup(ShellManager.NAME); final ConsoleManager conMgr = sm.getCurrentShell().getConsole().getManager(); boolean listConsoles = FLAG_LIST.isSet(); boolean newConsole = FLAG_NEW.isSet(); boolean isolateNewConsole = FLAG_ISOLATED.isSet(); boolean test = FLAG_TEST.isSet(); if (listConsoles) { conMgr.printConsoles(out); } else if (newConsole) { if (isolateNewConsole) { try { Isolate newIsolate = new Isolate(ConsoleCommand.IsolatedConsole.class.getName(), new String[0]); newIsolate.start(); out.println("Started new isolated console"); } catch (IsolateStartupException ex) { out.println("Failed to start new isolated console"); throw ex; } } else { createConsoleWithShell(conMgr, out); } } else if (test) { out.println("test RawTextConsole"); final TextConsole console = (TextConsole) conMgr.createConsole( null, ConsoleManager.CreateOptions.TEXT | ConsoleManager.CreateOptions.NO_LINE_EDITTING); conMgr.registerConsole(console); conMgr.focus(console); console.clear(); } }
public void execute() throws NoSuchProtocolException, NetworkException { ARPNetworkLayer arp = (ARPNetworkLayer) NetUtils.getNLM().getNetworkLayer(EthernetConstants.ETH_P_ARP); PrintWriter out = getOutput().getPrintWriter(); if (argClear.isSet()) { arp.getCache().clear(); out.println(str_cleared); } else { for (ARPCacheEntry entry : arp.getCache().entries()) { out.println(entry); } } }
@Override public void execute() throws Exception { PrintWriter out = getOutput().getPrintWriter(); if (argLanguage.isSet()) { final String language = argLanguage.getValue(); String country = (argCountry.isSet()) ? argCountry.getValue() : ""; String variant = (argVariant.isSet()) ? argVariant.getValue() : ""; Locale locale = findLocale(language, country, variant); if (locale == null) { getError().getPrintWriter().format(err_no_locale, language, country, variant); exit(1); } out.format(fmt_set, formatLocale(locale)); Locale.setDefault(locale); } else if (argList.isSet()) { listLocales(out); } else { out.format(fmt_get, formatLocale(Locale.getDefault())); } }
/** * Checks which operational mode was selected. * * <p>If no mode was selected, or more than one mode was selected, the return value will be false, * otherwise the return value is true, and this.mode will be set with the selected mode. */ private boolean checkMode() { int check = 0; if (DoAppend.isSet()) { mode = TAR_APPEND; check++; } if (DoCreate.isSet()) { mode = TAR_CREATE; check++; } if (DoConcat.isSet()) { mode = TAR_CONCAT; check++; } if (DoDelete.isSet()) { mode = TAR_DELETE; check++; } if (DoDiff.isSet()) { mode = TAR_DIFF; check++; } if (DoExtract.isSet()) { mode = TAR_EXTRACT; check++; } if (DoList.isSet()) { mode = TAR_LIST; check++; } if (DoUpdate.isSet()) { mode = TAR_UPDATE; check++; } return check == 1; }
// TODO Allow working directory to be changed public void execute() { super.execute("tar"); if (!checkMode()) { fatal(err_options, 1); } if (Archive.isSet()) archive = Archive.getValue(); if (Suffix.isSet()) suffix = Suffix.getValue(); if (Exclude.isSet()) exclude = Exclude.getValue(); if (ExcludeFile.isSet()) excludeFile = ExcludeFile.getValue(); if (FileList.isSet()) fileList = FileList.getValue(); backup = Backup.isSet(); bzip = UseBzip.isSet(); gzip = UseGzip.isSet(); interact = Interact.isSet(); verify = Verify.isSet(); showTotals = ShowTotals.isSet(); keepOld = KeepOld.isSet(); keepNew = KeepNew.isSet(); recurse = !NoRecurse.isSet(); unlink = Unlink.isSet(); try { if ((mode & TAR_REQ_ARCH) != 0 && archive == null) { fatal("Archive required for -Acdtru", 1); } if ((mode & TAR_DECOMPRESS) != 0 && archive != null) { if (checkCompressed(archive) == -1) { // happens when -j or -z were specified, but the archive is not // in the given format. if (bzip) { fatal("Archive is not compressed with bzip2.", 1); } if (gzip) { fatal("Archive is not compressed with gzip.", 1); } fatal("Internal Error: checkCompressed() returned -1", -1); } } if ((mode & TAR_COMPRESS) != 0) { if (bzip) { compress = USE_BZIP; } else if (gzip) { compress = USE_GZIP; } else { compress = decompress; } } if ((mode & TAR_VERIFY) != 0 && verify) { // backup original archive } if ((mode & TAR_CREATE) != 0 && compress == 0) { compress = checkSuffix(archive); } if ((mode & TAR_INSERT) != 0) { insert(processFiles(Paths.getValues(), recurse)); } if ((mode & TAR_UPDATE) != 0) { update(processFiles(Paths.getValues(), recurse)); } if ((mode & TAR_CONCAT) != 0) { concat(processArchives(Paths.getValues())); } if ((mode & TAR_DELETE) != 0) { // delete(); } if ((mode & TAR_EXTRACT) != 0) { if (decompress == 0 && archive == null) { if (bzip) { decompress = USE_BZIP; } else if (gzip) { decompress = USE_GZIP; } } extract(); } if ((mode & TAR_LIST) != 0) { list(); } if ((mode & TAR_DIFF) != 0) { diff(); } } catch (Exception e) { e.printStackTrace(); fatal(err_exception_uncaught, 1); } }