Package edu.neu.ccs.task.agent

Source Code of edu.neu.ccs.task.agent.AgentMain

package edu.neu.ccs.task.agent;

import java.io.File;
import java.io.IOException;

import webframe.Configuration;
import edu.neu.ccs.task.util.PropertiesConfig;

/**
* Main entry point for dtask.jar
*
* @author Dan Schulman
* @version $Id: AgentMain.java 724 2009-09-29 14:23:02Z schulman $
*/
public class AgentMain {
  private AgentMain() {} // not instantiable
 
  public static void main(String[] args) throws Exception {
    boolean isConsole = true;
   
    if (args.length > 0) {
      if ("-console".equals(args[0])) {
        args = removeFirstArg(args);
      } else if ("-server".equals(args[0])) {
        isConsole = false;
        args = removeFirstArg(args);
      }
    }
   
    if (isConsole)
      consoleMain(args);
    else
      serverMain(args);
  }
 
  private static String[] removeFirstArg(String[] args) {
    String[] newArgs = new String[args.length - 1];
    System.arraycopy(args, 1, newArgs, 0, newArgs.length);
    return newArgs;
  }
 
  public static void consoleMain(String[] args) throws IOException {
    String logFile = "dtask.log";
    String srcFile = null;
   
    for (int i=0; i<args.length; i++) {
      if ("-log".equals(args[i]))
        logFile = args[++i];
      else {
        srcFile = args[i];
        break;
      }
    }
   
    AgentConsole console = new AgentConsole(logFile);
    if (srcFile != null)
      console._source(srcFile);
    console.run();
  }
 
  public static void serverMain(String[] args) throws Exception {
    Configuration c;
    if (args.length > 0)
      c = new PropertiesConfig(new File(args[0]));
    else
      c = new PropertiesConfig();

    AgentServer server = new AgentServer(c);
    server.run();
    /*
    int port = 7070;
    List<String> models = new ArrayList<String>();
    String top = null;
    Map<String, String> slots = new HashMap<String, String>();
    String voice = null;
   
    for (int i=0; i<args.length; i++) {
      if ("-port".equals(args[i]))
        port = Integer.parseInt(args[++i]);
      else if ("-model".equals(args[i]))
        models.add(args[++i]);
      else if ("-task".equals(args[i]))
        top = parseTask(args[++i], slots);
      else if ("-voice".equals(args[i]))
        voice = args[++i];
    }
   
    for (String model : models)
      if ( ! XMLUtil.validate(model, XMLUtil.getDialogueSchema()))
        return;
   
    AgentServer server = flash ?
      new FlashAgentServer(port, models, top, slots, voice) :
      new AgentServer(port, models, top, slots);
    server.run();*/
  }
}
 
TOP

Related Classes of edu.neu.ccs.task.agent.AgentMain

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.