Package org.openeai.afa

Source Code of org.openeai.afa.GenericAppRunner

/*******************************************************************************
$Source: /cvs/repositories/openii3/project/java/source/org/openeai/afa/GenericAppRunner.java,v $
$Revision: 1.9 $
*******************************************************************************/

/**********************************************************************
This file is part of the OpenEAI sample, reference implementation,
and deployment management suite created by Tod Jackson
(tod@openeai.org) and Steve Wheat (steve@openeai.org) at
the University of Illinois Urbana-Champaign..

Copyright (C) 2002 The OpenEAI Software Foundation

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

For specific licensing details and examples of how this software
can be used to implement integrations for your enterprise, visit
http://www.OpenEai.org/licensing.
*/

package org.openeai.afa;

// General
import java.util.Properties;
import java.io.*;

import org.openeai.*;
import org.openeai.config.AppConfig;

/**
* This is the runnable class that allows us to generalize our applications.  This
* is the class that will be executed which then executes any number of scheduled
* commands at a specified time according to business rules.  This class is similar
* to the MessageConsumerClient which is our "Gateway" consumer.
* <P>
  * @author      Tod Jackson (tod@openeai.org)
  * @author      Steve Wheat (steve@openeai.org)
  * @version     3.0  - 28 January 2003
*/
public class GenericAppRunner extends OpenEaiObject {

  /**
   * Constructor
   */
  public GenericAppRunner(String[] args) {
    new ReleaseTag();
    try {
      String propFileName = args[0];
      Properties props = new Properties();
      AppConfig aConfig = null;
      InputStream in = null;

      // try it as a URL first, if that doens't work,
      // try it as a file.
      boolean isUrl = false;
      java.net.URL url = null;
      try {
        url = new java.net.URL(propFileName);
        isUrl = true;
      }
      catch (Exception e) {
        isUrl = false;
      }
      if (isUrl) {
        in = url.openStream();
      }
      else {
        in = new FileInputStream(propFileName);
      }
      props.load(in);
      in.close();
      aConfig = new AppConfig(props);
    }
    catch (Exception e) {
      logger.fatal("GenericAppRunner:  Error initializing AppConfig.  Exception: " + e.getMessage());
      System.exit(-1);
    }
  }

  public static void main(String[] args) {

    GenericAppRunner mRunner = new GenericAppRunner(args);
  }
}
TOP

Related Classes of org.openeai.afa.GenericAppRunner

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.