Exemplo n.º 1
0
 /** Action Handler 실행중 에러가 발생한 경우 에러를 처리한다. */
 private void fail() {
   try {
     actionContext.changeState(State.FAIL);
   } catch (Exception fe) {
     logger.warn("Action의 상태를 Fail로 기록할 수 없습니다. Data Store가 정상적이지 않을 수 있습니다.", fe);
   }
 }
Exemplo n.º 2
0
  @Override
  public void execute(WorkflowContext context) {
    this.actionContext = context.getCurrentActionContext();

    ELService service = this.actionContext.getWorkflowContext().getBean(ELService.class);
    this.evaluator = service.createEvaluator();
    this.globalVariables = actionContext.getWorkflowContext().getGlobalVariables();

    this.actionBasePath = ActionBasePathGenerator.getActionBasePath(actionContext);
    FileSystemUtils.testCorrentAndCreateDir(actionBasePath);

    this.logPath = actionBasePath + "/action.log";

    long actionLogMaxSize =
        ConfigurationManagerHelper.getConfigurationManagerHelper()
            .getConfigurationManager()
            .getLong("action.log.max.size");
    this.fileWriter = new FileWriter(logger, logPath, actionLogMaxSize);

    try {
      actionContext.changeState(State.PREPARE);
      before();

      actionContext.changeState(State.RUNNING);
      executeInternal();

      after();
      actionContext.changeState(State.SUCCESS);
    } catch (Exception ex) {
      actionContext.setObject(JobVariable.ACTION_EXCEPTION, ex);
      fail();
      String message =
          MessageFormatter.format(
                  "Cannot execute '{}' of action",
                  new String[] {context.getCurrentActionDescription()})
              .getMessage();
      throw new WorkflowException(message, ex);
    } finally {
      if (fileWriter != null) {
        try {
          fileWriter.close();
        } catch (Exception ex) {
        }
      }
    }
  }