Package org.huihoo.willow.startup

Source Code of org.huihoo.willow.startup.WorkflowProperties

//----------------------------BEGIN LICENSE----------------------------
/*
* Willow : the Open Source WorkFlow Project
* Distributable under GNU LGPL license by gun.org
*
* Copyright (C) 2004-2010 huihoo.org
* Copyright (C) 2004-2010  ZosaTapo <dertyang@hotmail.com>
*
* ====================================================================
* Project Homepage : http://www.huihoo.org/willow
* Source Forge     : http://sourceforge.net/projects/huihoo
* Mailing list     : willow@lists.sourceforge.net
*/
//----------------------------END  LICENSE-----------------------------
package org.huihoo.willow.startup;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Properties;
import org.huihoo.willow.Globals;
import com.zosatapo.commons.store.Store;
/**
* @author reic
*
* To change the template for this generated type comment go to
* Window - Preferences - Java - Code Generation - Code and Comments
*/
public class WorkflowProperties
{
  //---------------------------------------------------
  private static Store xpdlStore = null;
  private static Store caseStore = null;
  private static Store userStore = null;
  private static String schemaContextFile = null;
  private static Properties props = null;
  //--------------------------------------------------- 
  static {
    load();
  }
  private WorkflowProperties()
  {
  }
  public static Store getXPDLStore()
  {
    return xpdlStore;
  }
  public static Store getCaseStore()
  {
    return caseStore;
  }
  public static Store getUserStore()
  {
    return userStore;
  }
  public static String getSchemaContextFile()
  {
    return schemaContextFile;
  }
  public static String getProperty(String key)
  {
    return props.getProperty(key);
  }
  //---------------------------------------------------------------
  //---------------------------------------------------------------- 
  private static void load()
  {
    File schemaFile = new File(System.getProperty(Globals.PROPS_WILLOW_HOME), Constants.SchemaProperties);
    if (schemaFile.exists() && schemaFile.isFile())
    {
      schemaContextFile = schemaFile.getAbsolutePath();
    }
   
    File storeFile = new File(System.getProperty(Globals.PROPS_WILLOW_HOME), Constants.StoreProperties);
    if (!storeFile.exists() || !storeFile.isFile())
    {
      String sysPropStore = System.getProperty(org.huihoo.willow.store.Constants.PROPS_WILLOW_STORE);
      if (sysPropStore != null)
      {
        storeFile = new File(sysPropStore);
      }
      else
      {
        storeFile = null;
      }
    }
    if (storeFile == null || !storeFile.exists() || !storeFile.isFile())
    {
      return;
    }
    FileInputStream fin = null;
    try
    {
      fin = new FileInputStream(storeFile);
      props = new Properties();
      props.load(fin);
      xpdlStore = loadStore(props, "xpdl");
      caseStore = loadStore(props, "case");
      userStore = loadStore(props, "user");
    }
    catch (Exception e)
    {
      ;
    }
    finally
    {
      try
      {
        if (fin != null)
        {
          fin.close();
        }
      }
      catch (IOException e1)
      {
        ;
      }
    }
  }
  private static Store loadStore(Properties props, String prefix)
  {
    String connURL = props.getProperty(prefix + "." + Store.STORE_URL);
    String connType = props.getProperty(prefix + "." + Store.STORE_TYPE);
    if (connURL == null || connURL.length() == 0 || connType == null || connType.length() == 0)
    {
      return null;
    }
    String connDriver = props.getProperty(prefix + "." + Store.STORE_DRIVER);
    String connUSR = props.getProperty(prefix + "." + Store.STORE_USERNAME);
    String connPWD = props.getProperty(prefix + "." + Store.STORE_PASSWORD);
    return new Store(connType, connURL, connUSR, connPWD, connDriver);
  }
}
TOP

Related Classes of org.huihoo.willow.startup.WorkflowProperties

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.