初期化処理

@param terminal Terminal
@throws Exception 実行時例外
337140
private void initialize(final Terminal terminal) throws Exception {
		terminal.writer().println("initialize.");

		ClassLoader currentClassLoader = Thread.currentThread().getContextClassLoader();

		if (currentClassLoader.equals(additionalClassLoader)) {
			// すでに追加クラスローダになっている場合はいったん親に移動しておく
			currentClassLoader = additionalClassLoader.getParent();
		}

		String paths = p("sql.additionalClassPath", ".");
		List<URL> urls = new ArrayList<>();
		Arrays.stream(paths.split(";")).forEach(path -> {
			try {
				Matcher m = SYSPROP_PAT.matcher(path);
				StringBuffer sb = new StringBuffer();
				while (m.find()) {
					String key = m.group(1);
					String val = System.getProperty(key, null);
					if (val == null) {
						val = System.getenv(key);
					}
					if (val == null) {
						throw new IllegalArgumentException("key=" + key + " is not found.");
					}
					m.appendReplacement(sb, val.replace("\\", "/"));
				}
				m.appendTail(sb);

				urls.add(Paths.get(sb.toString()).toUri().toURL());
			} catch (Exception e) {
				e.printStackTrace();
			}
		});
		additionalClassLoader = new URLClassLoader(urls.toArray(new URL[urls.size()]), currentClassLoader);

		Thread.currentThread().setContextClassLoader(additionalClassLoader);

		ServiceLoader<Driver> loader = ServiceLoader.load(Driver.class, additionalClassLoader);
		loader.forEach(driver -> {
			try {
				DriverManager.registerDriver(new DriverShim(driver));
			} catch (Exception e) {
				e.printStackTrace();
			}
		});

		String url = p("db.url", "");
		String user = p("db.user", "");
		String password = p("db.password", "");
		String schema = p("db.schema", null);
		String loadPath = p("sql.loadPath", "sql");
		String fileExtension = p("sql.fileExtension", ".sql");
		Charset charset = Charset.forName(p("sql.encoding", "UTF-8"));
		boolean detectChanges = BooleanUtils.toBoolean(p("sql.detectChanges", "true"));

		// config
		sqlConfig = UroboroSQL.builder(url, user, password, schema)
				.setSqlManager(new NioSqlManagerImpl(loadPath, fileExtension, charset, detectChanges))
				.setSqlFilterManager(new SqlFilterManagerImpl().addSqlFilter(new DumpResultSqlFilter())).build();

		// sqlContextFactory
		SqlContextFactory contextFactory = sqlConfig.getSqlContextFactory();
		List<String> constantClassNames = Arrays
				.asList(p("sqlContextFactory.constantClassNames", "").split("\\s*,\\s*")).stream()
				.filter(s -> StringUtils.isNotEmpty(s)).collect(Collectors.toList());
		if (!constantClassNames.isEmpty()) {
			contextFactory.setConstantClassNames(constantClassNames);
		}

		List<String> enumConstantPackageNames = Arrays
				.asList(p("sqlContextFactory.enumConstantPackageNames", "").split("\\s*,\\s*")).stream()
				.filter(s -> StringUtils.isNotEmpty(s)).collect(Collectors.toList());
		if (!enumConstantPackageNames.isEmpty()) {
			contextFactory.setEnumConstantPackageNames(enumConstantPackageNames);
		}

		if (!constantClassNames.isEmpty() || !enumConstantPackageNames.isEmpty()) {
			contextFactory.initialize();
		}
	}
202685
public static void main(String args[]) throws Exception {
        final StringBuffer buffer = new StringBuffer("The lazy fox");
        Thread t1 = new Thread() {
            public void run() {
                synchronized(buffer) {
                    buffer.delete(0,4);
                    buffer.append(" in the middle");
                    System.err.println("Middle");
                    try { Thread.sleep(4000); } catch(Exception e) {}
                    buffer.append(" of fall");
                    System.err.println("Fall");
                }
            }
        };
        Thread t2 = new Thread() {
            public void run() {
                try { Thread.sleep(1000); } catch(Exception e) {}
                buffer.append(" jump over the fence");
                System.err.println("Fence");
            }
        };
        t1.start();
        t2.start();

        t1.join();
        t2.join();
        System.err.println(buffer);
    }
5933
public static void main(String[] args) throws Exception {
    ArgP argp = new ArgP();
    CliOptions.addCommon(argp);
    argp.addOption("--use-data-table",
        "Scan against the raw data table instead of the meta data table.");
    args = CliOptions.parse(argp, args);
    if (args == null) {
      usage(argp, "Invalid usage");
      System.exit(2);
    } else if (args.length < 1) {
      usage(argp, "Not enough arguments");
      System.exit(2);
    }
    
    final boolean use_data_table = argp.has("--use-data-table");
    
    Config config = CliOptions.getConfig(argp);
    final TSDB tsdb = new TSDB(config);
    tsdb.checkNecessaryTablesExist().joinUninterruptibly();
    
    int rc;
    try {
      rc = runCommand(tsdb, use_data_table, args);
    } finally {
      try {
        tsdb.getClient().shutdown().joinUninterruptibly();
        LOG.info("Gracefully shutdown the TSD");
      } catch (Exception e) {
        LOG.error("Unexpected exception while shutting down", e);
        rc = 42;
      }
    }
    System.exit(rc);
  }
86867
public static void main(String[] args)
	{
		CommandLineRemoteRunner runner = new CommandLineRemoteRunner();
		LoggingMonitor monitor = new LoggingMonitor(System.out, System.err);
		runner.setMonitor(monitor);

		try
		{
			runner.run(args);
		}
		catch (ParseException e)
		{
			System.err.println(e.getMessage());
			System.err.println("Try '--help' for more information.");

			if (e.getCause() != null)
			{
				System.err.println("Caused by:");
				e.getCause().printStackTrace(System.err);
			}

			System.exit(1);
		}
		catch (Throwable t)
		{
			monitor.exceptionOccured(t);
			System.exit(1);
		}
	}
275601
public static void executeCommand(String[] args) throws Exception {
        String subCmd = (args.length > 0) ? args[0] : "";
        args = AdminToolUtils.copyArrayCutFirst(args);
        if(subCmd.equals("list")) {
            SubCommandAsyncJobList.executeCommand(args);
        } else if(subCmd.equals("stop")) {
            SubCommandAsyncJobStop.executeCommand(args);
        } else {
            printHelp(System.out);
        }
    }
117071
function terminal(devicePath, exitCallback) {
  if (!args.quiet) log("Connecting to '"+devicePath+"'");
  var hadCtrlC = false;
  var hadCR = false;
  var ideServer = undefined;
  process.stdin.setRawMode(true);
  Espruino.Core.Serial.startListening(function(data) {
    data = new Uint8Array(data);
    var dataStr = String.fromCharCode.apply(null, data);
    if (ideServer) ideServer.write(dataStr);

    process.stdout.write(dataStr);
    /* If Espruino responds after a Ctrl-C with anything other
     than a blank prompt, make sure the next Ctrl-C will exit */
    for (var i=0;i<data.length;i++) {
      var ch = data[i];
      if (ch==8) hadCR = true;
      else {
        if (hadCtrlC && (ch!=62 /*>*/ || !hadCR)) {
          //process.stdout.write("\nCTRLC RESET BECAUSE OF "+JSON.stringify(String.fromCharCode.apply(null, data))+"  "+hadCR+" "+ch+"\n");
          hadCtrlC = false;
        }
        hadCR = false;
      }
    }
  });
  Espruino.Core.Serial.open(devicePath, function(status) {
    if (status === undefined) {
      console.error("Unable to connect!");
      return exitCallback();
    }
    if (!args.quiet) log("Connected");
    process.stdin.on('readable', function() {
      var chunk = process.stdin.read();
      if (chunk !== null) {
        chunk = chunk.toString();
        Espruino.Core.Serial.write(chunk);
        // Check for two Ctrl-C in a row (without Espruino doing anything inbetween)
        for (var i=0;i<chunk.length;i++) {
          var ch = chunk.charCodeAt(i);
          if (ch==3) {
            if (hadCtrlC) {
              process.stdout.write("\r\n");
              exitCallback();
            } else {
              // if we had ctrl-c, but didn't receive anything
              setTimeout(function() {
                if (hadCtrlC) process.stdout.write("\nPress Ctrl-C again to exit\n>");
              }, 200);
            }
            hadCtrlC = true;
          }
        }
      }
    });
    process.stdin.on('end', function() {
      console.log("STDIN ended. exiting...");
      exitCallback();
    });

    if (args.ideServer)
      ideServer = startWebIDEServer(function(data) {
        Espruino.Core.Serial.write(data);
      });

    // figure out what code we need to send (if any)
    sendCode(function() {
      if (args.watchFile) sendOnFileChanged();
    });

   }, function() {
     log("\nDisconnected.");
     exitCallback();
   });
}
203928
function(err, exit) {
    // Close the terminal
    if(terminal) terminal.close()

    // If there was an error throw it before exit
    if(err) throw err

    // process.stdin.resume() prevents node from exiting.
    // process.exit() overrides in more cases than stdin.pause() or stdin.end()
    // it also means we don't need to call process.stdin.setRawMode(false)
    if(exit === undefined || exit) {
      process.exit()
    }
    else {
      process.stdin.setRawMode(false)
      process.stdin.end()
    }
  }
610732
public static void main(String[] args) throws Exception {
    int result = ToolRunner.run(new CoronaAdmin(), args);
    System.exit(result);
  }
644348
public static void main(String[] args) throws Exception {
        if (args.length > 0) {
            PID p = new PID(args[0]);
            System.out.println("Normalized    : " + p.toString());
            System.out.println("To filename   : " + p.toFilename());
            System.out.println("From filename : "
                    + PID.fromFilename(p.toFilename()).toString());
        } else {
            System.out.println("--------------------------------------");
            System.out.println("PID Syntax Checker - Interactive mode");
            System.out.println("--------------------------------------");
            boolean done = false;
            BufferedReader reader =
                    new BufferedReader(new InputStreamReader(System.in));
            while (!done) {
                try {
                    System.out.print("Enter a PID (ENTER to exit): ");
                    String line = reader.readLine();
                    if (line.isEmpty()) {
                        done = true;
                    } else {
                        PID p = new PID(line);
                        System.out.println("Normalized    : " + p.toString());
                        System.out.println("To filename   : " + p.toFilename());
                        System.out.println("From filename : "
                                + PID.fromFilename(p.toFilename()).toString());
                    }
                } catch (MalformedPIDException e) {
                    System.out.println("ERROR: " + e.getMessage());
                }
            }
        }
    }
902909
public static void mainInternal(String[] args) throws Exception {

        Options options = new Options();
        CmdLineParser parser = new CmdLineParser(options);
        try {
            parser.parseArgument(args);
        } catch (CmdLineException e) {
            helpScreen(parser);
            return;
        }

        try {
            List<String> configs = new ArrayList<>();
            if (options.configs != null) {
                configs.addAll(Arrays.asList(options.configs.split(",")));
            }
            ConfigSupport.applyConfigChange(ConfigSupport.getJBossHome(), configs, options.enable);
        } catch (ConfigException ex) {
            ConfigLogger.error(ex);
            throw ex;
        } catch (Throwable th) {
            ConfigLogger.error(th);
            throw th;
        }
    }
1262641
public void init() {
        try {
            String[] names = tgtools.web.platform.Platform.getBeanFactory().getBeanDefinitionNames();
            for (String name : names) {
                if (name.endsWith("CommandImpl") && tgtools.web.platform.Platform.getBean(name) instanceof Command && mType.equals(((Command) tgtools.web.platform.Platform.getBean(name)).getType())) {
                    addCommand((Command)tgtools.web.platform.Platform.getBean(name));
                }
            }
        } catch (Exception e) {
            LogHelper.error("","CommandFactory 初始化失败；原因："+e.toString(),"CommandFactory.init",e);
        }
    }
292525
public void loadData() throws Exception{

		System.out.print("Loading training data ...");
		long beginTime = System.currentTimeMillis();

		Pipe pipe = createProcessor();


		trainSet = new InstanceSet(pipe, factory);
		labels = factory.DefaultLabelAlphabet();
		features = factory.DefaultFeatureAlphabet();
		features.setStopIncrement(false);
		labels.setStopIncrement(false);

		// 训练集
		trainSet.loadThruStagePipes(new SequenceReader(train, true));

		long endTime = System.currentTimeMillis();
		System.out.println(" done!");
		System.out.println("Time escape: " + (endTime - beginTime) / 1000 + "s");
		System.out.println();

		// 输出
		System.out.println("Training Number: " + trainSet.size());
		System.out.println("Label Number: " + labels.size()); // 标签个数
		System.out.println("Feature Number: " + features.size()); // 特征个数
		System.out.println();

		// 冻结特征集
		features.setStopIncrement(true);
		labels.setStopIncrement(true);


		// 读入测试数据
		if (testfile != null) {
			System.out.print("Loading test data ...");
			boolean hasTarget = true;;
			if (!hasTarget) {// 如果test data没有标注
				pipe = featurePipe;
			} 

			// 测试集
			testSet = new InstanceSet(pipe);
			testSet.loadThruStagePipes(new SequenceReader(testfile, hasTarget, "utf8"));
			System.out.println("Test Number: " + testSet.size()); // 样本个数
		}
	}
1345785
private void listen(final Terminal terminal) throws IOException {
		List<Completer> completers = new ArrayList<>();

		// コマンドのコード補完
		completers.add(new ReplCommandCompleter(commands));
		// SQL名のコード補完
		completers.add(new SqlNameCompleter(commands, sqlConfig.getSqlManager()));
		// バインドパラメータのコード補完
		completers.add(new BindParamCompleter(commands, sqlConfig.getSqlManager()));
		// テーブル名のコード補完
		completers.add(new TableNameCompleter(commands, sqlConfig.getConnectionSupplier()));
		// SQLキーワードのコード補完
		completers.add(new SqlKeywordCompleter(commands));

		LineReader reader = LineReaderBuilder.builder()
				.appName("uroborosql")
				.terminal(terminal)
				.completer(new AggregateCompleter(completers))
				.highlighter(new DefaultHighlighter())
				.option(LineReader.Option.CASE_INSENSITIVE, true)
				.build();
		while (true) { // ユーザの一行入力を待つ
			try {
				if (!executeCommand(reader)) {
					break;
				}
			} catch (UserInterruptException | EndOfFileException ex) {
				break;
			} catch (Exception e) {
				e.printStackTrace(System.err);
			}
		}
	}
770925
public static void main(String[] args) {
		try {
			int result = new EasyJaSubCommandLineApp(new EasyJaSubCommandLine())
					.run(args, new PrintWriter(System.out), new PrintWriter(
							System.err));
			System.exit(result);
		} catch (Exception e) {
			System.err.println("Unhandled application error:");
			e.printStackTrace(System.err);
			System.exit(-1000);
		}
	}
1147670
public void connect() throws Exception {
        if (!connected) {
            terminal = new UDPMasterTerminal(address);
            terminal.setPort(port);
            terminal.setTimeout(timeout);
            terminal.activate();
            connected = true;
        }
    }
746886
public static void main(String[] args) throws Exception {

		prepareTestDb();
		JDBCExample tut = new JDBCExample();
		JobExecutionResult res = LocalExecutor.execute(tut, args);
		System.out.println("runtime: " + res.getNetRuntime());

		System.exit(0);
	}
883958
protected void execute(final String[] args) throws Exception {
		// Process command-line.
		if (args.length == 0 || args.length == 1) {
			usage();
		}
		String userpass = args[0];
		String hostportOrPid = args[1];
		String beanname = null;// vGCutil
		String[] command = null;
		if (args.length > 2) {
			beanname = args[2];
		}
		if (args.length > 3) {
			command = new String[args.length - 3];
			for (int i = 3; i < args.length; i++) {
				command[i - 3] = args[i];
			}
		}
		String[] loginPassword = parseUserpass(userpass);

		// 模拟GC Util命令的扩展
		if (V_GCUTIL_BEAN_NAME.equalsIgnoreCase(beanname)) {
			// 支持配置interval 固定事件间隔连续输出
			int interval = 0;
			if (command != null && command.length > 0) {
				try {
					interval = Math.abs(Integer.parseInt(command[0]));// 拿绝对值, 避免负数的情况
				} catch (NumberFormatException e) {// NOSONAR
				}
			}

			ExtraCommand extraCommand = new ExtraCommand();
			extraCommand.execute(hostportOrPid, ((loginPassword == null) ? null : loginPassword[0]),
					((loginPassword == null) ? null : loginPassword[1]), beanname, interval);
			return;
		}

		Object[] result = execute(hostportOrPid, ((loginPassword == null) ? null : loginPassword[0]),
				((loginPassword == null) ? null : loginPassword[1]), beanname, command);
		if (result != null) {
			for (int i = 0; i < result.length; i++) {
				if (result[i] != null && result[i].toString().length() > 0) {
					if (command != null) {
						logger.info(command[i] + ": " + result[i]);
					} else {
						logger.info("\n" + result[i].toString());
					}
				}
			}
		}
	}