コード例 #1
0
ファイル: ParserVar.java プロジェクト: rhusar/smartfrog
 /** Main processing method for the RunProcess object */
 @Override
 public void run() {
   status = "running";
   try {
     // this.log("Command Start: "+command,3);
     // this.log("RunProcessInfo > " + this.toString(), 5);
     if (log.isDebugEnabled()) {
       log.debug("Parsing > " + this.dataParser.getFileName() + " ");
     }
     ReplaceVar replaceVar =
         new ReplaceVar(dataParser.getFileName(), dataParser.getNewFileName(), false);
     // First: append
     replaceVar.append(dataParser.getDataAppend());
     if (log.isDebugEnabled()) {
       log.debug("Append. > " + dataParser.getFileName() + "");
     }
     // Second: replace
     replaceVar.setSetting(dataParser.getDataReplace());
     if (log.isDebugEnabled()) {
       log.debug("Replace. > " + dataParser.getFileName() + "");
     }
     replaceVar.flush(); // This sould be handle in the component. REVIEW. TODO
     if (log.isDebugEnabled()) {
       log.debug("Finished Parsing > " + dataParser.getFileName() + "");
     }
     Thread.sleep(delay);
   } catch (Exception ex) {
     if (log.isErrorEnabled()) {
       log.error("Problem parsing > " + ex.getMessage() + "", ex);
     }
   }
   finish();
   try {
     if (dataParser.shouldDetach()) {
       detach();
     }
     if (dataParser.shouldTerminate()) {
       terminate();
     }
     if (log.isDebugEnabled()) {
       log.debug("Terminating > " + dataParser.getFileName() + "");
     }
   } catch (Exception e) {
     if (log.isErrorEnabled()) {
       log.error("Error during termination:" + e.getMessage() + "", e);
     }
   }
 }
コード例 #2
0
ファイル: ParserVar.java プロジェクト: rhusar/smartfrog
  /** Terminate */
  public void terminate() {
    if ((sfObj != null) && (sfObj instanceof PrimImpl)) {
      try {
        termR =
            TerminationRecord.normal(
                "ParserFile terminated (" + dataParser.getFileName() + ").", null);
        // Proper termination of a component!
        Runnable terminator =
            new Runnable() {
              public void run() {
                if (log.isDebugEnabled()) {
                  log.debug("ReplaceVar terminated.");
                }
                ((PrimImpl) sfObj).sfTerminate(termR);
              }
            };
        new Thread(terminator).start();

      } catch (Exception ex) {
        if (log.isErrorEnabled()) {
          log.error("Problem during termination > " + ex.getMessage() + "", ex);
        }
      }
      // this.log("ReplaceVar terminated.",2);
    } else {
      if (log.isDebugEnabled()) {
        log.debug("ReplaceVar: Wrong component to terminate.");
      }
    }
  }