Package net.fp.rp.workflow

Source Code of net.fp.rp.workflow.CommandLine

/*
* Copyright (C) 2004-2006 Paul Browne, http://www.firstpartners.net,
*
* released under terms of the GPL license
* http://www.opensource.org/licenses/gpl-license.php
*
*/
package net.fp.rp.workflow;

import net.fp.rp.spring.SpringStarter;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.FileSystemXmlApplicationContext;

/**
* Kickstarts a workflow process when called from the command line.<br/> <br/>
* To run this from the command line use something like:<br/> java Commandline
* SpringStarterImpl.xml
*
* <br/> To run this from Eclipse do the following:<br/> ul
* <li>Right click on Commandline.java
* <li>
* <li>Select Run As ..
* <li>
* <li>Run.. Java Application
* <li>
* <li>In the Dialog Box - select Java Application</li>
* <li>In the Dialog Box - select the arguments tab - enter 'SpringStarterImpl.xml
* StartWorkFlowBean' without the quotes
* <li>
* <li>Click the Run button
* <li>
*
* @author Paul Browne
*/
public class CommandLine {

  // Logger
  private static Log log = LogFactory.getLog(CommandLine.class);

  // Print a help message
  private static void printHelpMessage() {

    System.out.println("Usage of the command line");
    System.out.println("CommandLine SpringFile");
    System.out
        .println("SpringFile <name of Spring Configuration File> <name of bean with StartWorkFlow> method");

    return;

  }

  /**
   * Called by the user from the command line
   *
   * @param args
   */
  public static void main(String[] args) throws Throwable {

    // Internal Variables
    String configFile;
    String workflowBean;

    // arguments specified but not correctly
    if (args.length == 2) {
      printHelpMessage();
    } else {

      // get the context
      configFile = args[0];
      workflowBean = args[1];

      // load the manager
      ApplicationContext context = new FileSystemXmlApplicationContext(
          configFile);

      // Todo remove the next bit and make more generic
      SpringStarter myBean = (SpringStarter) context
          .getBean(workflowBean);
      myBean.startWorkflow();
    }

  }

}
TOP

Related Classes of net.fp.rp.workflow.CommandLine

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.