/*
* Copyright 2007 Kevin Roe, Daniel Mccarney
* This file is part of Jriver.
*
* Jriver 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 3 of the License, or
* (at your option) any later version.
*
* Jriver 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, see <http://www.gnu.org/licenses/>.
*/
package org.jriver.lib.daemon;
/*
import org.apache.log4j.Logger;
*/
import org.jriver.lib.daemon.*;
import org.jriver.lib.std.*;
/**
* The class responsible for compiling/loading classes
* The CommandLoader class attempts to load and compile any classes
* that are attempted to be accessed by the CommandD parser but are
* unable to be located.
* @author Enigma
* @author Zanz
*/
public class CommandLoader
{
/*
private static Logger m_log = Logger.getLogger("org.jriver.lib.daemon.CommandLoader");
*/
/**
* The compile method takes our string command (i.e. the class name we
* are trying to load) and makes an attempt to compile and load the class.
* It will return the error code generated by the java compiler
* @param command The command (i.e. class name) we are trying to compile and load
* @return An integer representing the error code returned by javac
*/
public static int compile(String command)
{
command = command + ".java";
/*
command = Command.COMMAND_DIR + command + ".java";
*/
int errorCode = 0;
/*
m_log.debug("ClassNotFound. Compiling...");
*/
System.out.println("Attempting to compile "+command);
command = "/org/jriver/lib/bin/shout.java";
errorCode = com.sun.tools.javac.Main.compile(
new String[] { "-classpath", "../bin", command});
return errorCode;
}
}