⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 workflow_systemconfig.java

📁 用java实现的工作流
💻 JAVA
字号:
package treedoc;

/**本地系统数据库配置文件类,读取一个param.ini文件中的数据库配置
 */

/**
 * 名称       : WORKFLOW_SYSTEMCONFIG
 * 描述       : WWW.FANGFA.NET 工作流管理系统--系统配置参数读取类
 * 版权信息   : Copyright (c) 2004 COMSCI
 * @作者      : COMSCI Sichuan Fangfa Digital
 * @版本      : 0.9 builder 2004091910
 * @日期      : 2004/09/19
 */





import java.util.Properties;
import java.io.FileInputStream;
import java.io.File;


public class workflow_SystemConfig {

  public String driver = null;
  public String url = null;
  public String User = null;
  public String Password = null;


  public workflow_SystemConfig() {  //构造方法
    PFILE = getPath();
    m_file = new File(PFILE);
    m_lastModifiedTime = m_file.lastModified();

    if (m_lastModifiedTime == 0) {
      System.out.println(PFILE + " file does not exist!");
    }
    m_props = new Properties();
    try {
      m_props.load(new FileInputStream(PFILE));
    }
    catch (Exception e) {
      e.printStackTrace();
    }
  }

/**配置文件的路径
 */
   private String getPath() {
    String path =  "param.ini";
    return path;
  }

  /**检索唯一的管理类实例
   */
  synchronized public static workflow_SystemConfig getInstance() {
    return m_instance;
  }

  /**检索指定名字的参数值
   */
  final public String getConfigItem(String name, String defaultVal) {
    long newTime = m_file.lastModified();

    if (newTime == 0) {
      if (m_lastModifiedTime == 0) {
        System.out.println(PFILE + " 没有找到参数配置文件");
      }
      else {
        System.out.println(PFILE + " 文件不存在");
      }
      return defaultVal;
    }
    else if (newTime > m_lastModifiedTime) {
      m_props.clear();
      try {
        m_props.load(new FileInputStream(PFILE));
      }
      catch (Exception e) {
        e.printStackTrace();
      }
    }
    m_lastModifiedTime = newTime;

    String val = (String) m_props.getProperty(name);
    if (val == null) {
      return defaultVal;
    }
    else {
      return val;
    }
  }

  private static String PFILE = null;

  private File m_file = null;

  private long m_lastModifiedTime = 0;

  private Properties m_props = null;

  private static workflow_SystemConfig m_instance = new workflow_SystemConfig();

  /**适配器,提供对Parameter.class的支持
   * @return 属性集
   */

  public Properties getProperties() {
    long newTime = m_file.lastModified();
    if (newTime > m_lastModifiedTime) {
      m_props.clear();
      try {
        m_props.load(new FileInputStream(PFILE));
      }
      catch (Exception e) {
        e.printStackTrace();
      }
    }
    return m_props;

  }
  public void getParameter()  //获得配置参数的方法
    {

      workflow_SystemConfig scm = workflow_SystemConfig.getInstance();

      driver = scm.getConfigItem("driver","");  //数据库驱动字串
      url= scm.getConfigItem("url","");    //连接URL
      User = scm.getConfigItem("User","");  //数据库USER
      Password = scm.getConfigItem("Password",""); //PASSWORD

    }

}

⌨️ 快捷键说明

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