gate.util
Class Javac

java.lang.Object
  extended by gate.util.Javac
All Implemented Interfaces:
GateConstants
Direct Known Subclasses:
Eclipse, Sun

public abstract class Javac
extends Object
implements GateConstants

This class compiles a set of java sources using the user's preferred Java compiler. The default compiler used is the Eclipse JDT compiler, but this can be overridden by the user via an option in gate.xml.


Field Summary
private static GateClassLoader classLoader
          The GATE class loader.
private static Javac compiler
          The compiler to use.
static String DEFAULT_COMPILER
          The default compiler to use.
 
Fields inherited from interface gate.GateConstants
ABOUT_URL_JAVA_PROPERTY_NAME, ADD_NAMESPACE_FEATURES, ANNOT_TYPE_TO_EXPORT, APP_ICON_JAVA_PROPERTY_NAME, APP_SPLASH_JAVA_PROPERTY_NAME, APPLICATION_JAVA_PROPERTY_NAME, AUTOLOAD_PLUGIN_PATH_KEY, AUTOLOAD_PLUGIN_PATH_PROPERTY_NAME, BUILTIN_CREOLE_DIR_PROPERTY_NAME, COMPILER_TYPE_KEY, CORPUS_INDEX_DEFINITION_FEATURE_KEY, CORPUS_INDEX_STATISTICS_FEATURE_KEY, DOCEDIT_INSERT_APPEND, DOCEDIT_INSERT_PREPEND, DOCEDIT_READ_ONLY, DOCUMENT_ADD_SPACE_ON_UNPACK_FEATURE_NAME, DOCUMENT_NEW_LINE_TYPE, DOCUMENT_REPOSITIONING_INFO_FEATURE_NAME, ELEMENT_NAMESPACE_PREFIX, ELEMENT_NAMESPACE_URI, GATE_CONFIG_PROPERTY, GATE_DOT_SER, GATE_DOT_XML, GATE_HOME_PROPERTY_NAME, GATE_SITE_CONFIG_PROPERTY_NAME, GATE_USER_CONFIG_PROPERTY_NAME, GATE_USER_SESSION_PROPERTY_NAME, HIDDEN_FEATURE_KEY, KNOWN_PLUGIN_PATH_KEY, LOOK_AND_FEEL, MAIN_FRAME_HEIGHT, MAIN_FRAME_WIDTH, MENU_PATH_KEY, MENUS_FONT, ORIGINAL_DOCUMENT_CONTENT_FEATURE_NAME, ORIGINAL_MARKUPS_ANNOT_SET_NAME, OTHER_COMPONENTS_FONT, PLUGINS, PLUGINS_HOME_PROPERTY_NAME, SAVE_FEATURES_WHEN_PRESERVING_FORMAT, SAVE_OPTIONS_ON_EXIT, SAVE_SESSION_ON_EXIT, SITE_CONFIG_PROPERTY_NAME, TEXT_COMPONENTS_FONT, THROWEX_FORMAT_PROPERTY_NAME, TITLE_JAVA_PROPERTY_NAME, USER_CONFIG_PROPERTY_NAME, WORDNET_CONFIG_FILE
 
Constructor Summary
Javac()
           
 
Method Summary
abstract  void compile(Map sources)
          Compile a set of Java sources, and load the resulting classes into the GATE class loader.
private static Javac createCompilerInstance(String compilerType)
           
static void loadClasses(Map sources)
          Compiles a set of java sources and loads the compiled classes in the gate class loader.
private static void setCompilerTypeFromUserConfig()
          Sets the type of compiler to be used, based on the user's configuration.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

compiler

private static Javac compiler
The compiler to use.


classLoader

private static GateClassLoader classLoader
The GATE class loader.


DEFAULT_COMPILER

public static final String DEFAULT_COMPILER
The default compiler to use.

See Also:
Constant Field Values
Constructor Detail

Javac

public Javac()
Method Detail

loadClasses

public static void loadClasses(Map sources)
                        throws GateException
Compiles a set of java sources and loads the compiled classes in the gate class loader.

Parameters:
sources - a map from fully qualified classname to java source
Throws:
GateException - in case of a compilation error or warning. In the case of warnings the compiled classes are loaded before the error is raised.

setCompilerTypeFromUserConfig

private static void setCompilerTypeFromUserConfig()
                                           throws GateException
Sets the type of compiler to be used, based on the user's configuration. The default is to use the Eclipse compiler unless the user requests otherwise.

Throws:
GateException

createCompilerInstance

private static Javac createCompilerInstance(String compilerType)
                                     throws GateException
Throws:
GateException

compile

public abstract void compile(Map sources)
                      throws GateException
Compile a set of Java sources, and load the resulting classes into the GATE class loader.

Parameters:
sources - a map from fully qualified classname to java source
Throws:
GateException - in case of a compilation error or warning. In the case of warnings, the compiled classes are loaded before the exception is thrown.