workflowutil.java

来自「公司自己开发的工作流引擎」· Java 代码 · 共 76 行

JAVA
76
字号
package cn.com.iaspec.workflow.util;

import org.apache.log4j.*;
import cn.com.iaspec.workflow.exception.*;
import com.sunyard.sunflow.client.*;

public class WorkflowUtil{
  static Logger logger=Logger.getLogger(WorkflowUtil.class);
  public static String hostName="";
  public static int portName=1093;

  public WorkflowUtil(String hostName,int portName){
    this.hostName=hostName;
    this.portName=portName;
  }

  public static SunflowClient getSunflowClient(String sessionId)
      throws CannotLinkToSunflowServerException{
    //连接到信雅达工作流引擎
    try{
      logger.debug("begin getSunflowClient");
      SunflowClient sunflowClient=new SunflowClient(hostName,portName,sessionId);
      logger.debug("end getSunflowClient");
      return sunflowClient;
    }
    catch(Exception ex){
      logger.error(ex);
      throw new CannotLinkToSunflowServerException("不能连接到工作流引擎。");
    }

  }

  public static SunflowClient getSunflowClient()
      throws CannotLinkToSunflowServerException{
    //连接到信雅达工作流引擎
    try{
      logger.info(" hostName is "+hostName+" and portName is "+portName);
      long startTime=System.currentTimeMillis();
      SunflowClient sunflowClient=new SunflowClient(hostName,portName);
      logger.info("Execution new SunflowClient time: "+(System.currentTimeMillis()-
        startTime)+" ms.");
      return sunflowClient;
    }
    catch(Exception ex){
      logger.error(ex);
      throw new CannotLinkToSunflowServerException("不能连接到工作流引擎。");
    }

  }

  public static SunflowClient getSunflowClient(String loginName,String password)
      throws CannotLinkToSunflowServerException,IncorrectUserInfoException{
    //连接到信雅达工作流引擎
    SunflowClient sunflowClient=null;
    try{
      logger.info(" hostName is "+hostName+" and portName is "+portName);
      sunflowClient=new SunflowClient(hostName,portName);

    }
    catch(Exception ex){
      logger.error(ex);
      throw new CannotLinkToSunflowServerException("不能连接到工作流引擎。");
    }
    //登录验证
    try{
      sunflowClient.connect(loginName,password);
    }
    catch(Exception ex){
      logger.error(ex);
      throw new IncorrectUserInfoException("登录验证失败。");
    }
    return sunflowClient;
  }

}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?