Пример #1
0
 @Override
 public synchronized void destroyProcess() {
   if (Util.isWindows()) {
     killWindowsProcess();
   } else {
     killLinuxProcess();
   }
   super.destroyProcess();
 }
Пример #2
0
 public static String replaceForbiddenCharacters(String name) {
   char[] charArray = name.toCharArray();
   if (Character.isDigit(charArray[0])) charArray[0] = '_';
   for (int i = 0; i < charArray.length; i++) {
     if (Util.isForbidden(charArray[i])) {
       charArray[i] = '_';
     }
   }
   return new String(charArray);
 }
Пример #3
0
 private void killWindowsProcess() {
   int pid = -1;
   try {
     pid = Util.getWindowsProcessId(process);
     if (pid != -1) {
       CommandLine command = getWindowsKillCommand(pid);
       DefaultExecutor executor = new DefaultExecutor();
       executor.setStreamHandler(new PumpStreamHandler(System.out));
       executor.execute(command);
     }
   } catch (Exception e) {
     logger.error("No process for pid {}", pid);
   }
 }
Пример #4
0
 private void killLinuxProcess() {
   try {
     int pid = Util.getLinuxProcessId(process);
     File file = new File(currentDir, "killer.run");
     FileUtils.write(file, getLinuxKillScript(pid));
     try {
       file.createNewFile();
     } catch (IOException e) {
       // e.printStackTrace();
       logger.error(e.getMessage());
     }
     file.setExecutable(true);
     Executor.script(file).inService(Executor.newExecutor("Killer")).execAndWait();
   } catch (Exception e) {
     // e.printStackTrace();
     logger.error(e.getMessage());
   }
 }
Пример #5
0
  /**
   * @param stringOfState for example "(steady incompressible ras)"
   * @return for example "simpleFoam"
   */
  public String toPrimalState(State state) {
    String state2String = state.state2String();

    Dictionary statesDict = getStates();

    // System.out.println("AbstractDefaultsProvider.toPrimalState() "+statesDict);

    if (statesDict != null) {
      Map<String, String> STATES = Util.invertMap(statesDict.getFieldsMap());

      if (STATES.containsKey(state2String)) {
        return STATES.get(state2String);
      } else {
        logger.warn("[ {} Provider ]: State '{}' NOT AVAILABLE", getName(), state2String);
        return null;
      }
    } else {
      logger.warn("[ {} Provider ]: State '{}' NOT AVAILABLE", getName(), state2String);
      return null;
    }
  }
Пример #6
0
  public static void main(String[] args) throws Exception {

    info("Set Application Info");
    ApplicationInfo.init();

    printOut(ApplicationInfo.getHeaderInfo());

    info("Initialize Arguments");
    Arguments.init(args);

    info("Initialize Logger");
    if (Arguments.isBatch()) LoggerUtil.initFlatLogger();
    else LoggerUtil.initLogger();

    info("Initialize Locale");
    LocaleUtil.initLocale();

    Util.initScriptStyle();

    info("Loading modules");
    List<Module> modules = Modules.loadSuiteModules();

    if (modules.isEmpty()) {
      if (Arguments.isBatch()) {
        modules = Modules.loadBatchModules(null);

        info("Starting modules");
        Injector injector = Guice.createInjector(modules);

        info("Go to Batch");
        Batch batch = injector.getInstance(Batch.class);

        info("Launch Batch");
        batch.run();
      } else {
        modules = Modules.loadApplicationModules(null);

        info("Starting modules");
        Injector injector = Guice.createInjector(modules);

        info("Loading LookAndFeel");
        ILookAndFeel laf = injector.getInstance(ILookAndFeel.class);
        laf.init();

        info("Check License");
        ApplicationLauncher launcher = injector.getInstance(ApplicationLauncher.class);
        launcher.checkLicense();

        info("Loading Application");
        Application application = injector.getInstance(Application.class);

        UiUtil.renameUIThread();

        info("Layout Application");
        SwingUtilities.invokeLater(application);
      }
    } else {
      info("Starting modules");
      Injector injector = Guice.createInjector(modules);

      info("Loading LookAndFeel");
      ILookAndFeel laf = injector.getInstance(ILookAndFeel.class);
      laf.init();

      info("Loading Suite");
      Suite suite = injector.getInstance(Suite.class);

      if (Arguments.isBatch()) {
        info("Go to Batch");
        suite.batch();
      } else {
        info("Start Suite");
        UiUtil.installExceptionHandler();
        UiUtil.renameUIThread();
        suite.launch();
      }
    }
  }