org.objectweb.jonathan.tools
Class Kcf2java
java.lang.Object
org.objectweb.jonathan.tools.Kcf2java
public class Kcf2java
extends java.lang.Object
Kcf2java (formerly called XML2Kernel) is a utility that compiles an XML configuration file into a java
class, and possibly compiles it and adds the compiled file to a jar archive.
This utility expects that the
javac
and
jar
commands
are available locally.
The name of the java class to generate should be specified as the "generated"
attribute of the configuration element; the class used to create the actual
bootstrap configuration should be specified using the "bootstrap" attribute,
like in :
...
Usage:
java org.objectweb.jonathan.tools.Kcf2java [options] configuration-file
where options are:
-
-noc
:
if the generated java file should not be compiled.
-
-s srcdir
:
srcdir
is the (existing) directory where
the java file should be generated;
-
-d classdir
:
If classdir ends with ".jar", the java file is compiled locally (with
option -d .
) and the generated file is added to the mentioned
jar file; otherwise, this option is passed to javac when compilation
occurs.
-
-p properties_file
:
where Kcf2java finds which custom XML tag compilers it should
also use.
-
-verbose
:
tells Kcf2java to output messages on stderr.
Kcf2java has already a built-in configuration decoder, and already
knows the following default tag compilers:
A custom tag compiler has to implement the
TagCompiler
interface
and to be provided as a line like the next one in the Kcf2java
properties file:
CUSTOM_XML_TAG_TO_COMPILE my.custom.tag.Compiler
static void | compile(InputStream _is, String _src_dir, boolean _add_package_path_to_src_dir, Properties _custom_properties, boolean _verbose, boolean _compile) - Compilation method to be used when Kcf2java is embedded in some application.
|
static void | main(String[] args) - The main method.
|
static String | normalize(String str) - Normalizes the provided string, by trimming and handling backslashes
|
static String | writeComponent(XMLElement _current_component, String _element_name, String _configuration_var_name, Writer _writer, String _configuration_name) - Compiles the provided component using the provided writer.
|
compile
public static void compile(InputStream _is,
String _src_dir,
boolean _add_package_path_to_src_dir,
Properties _custom_properties,
boolean _verbose,
boolean _compile)
throws JonathanException
Compilation method to be used when Kcf2java is embedded in some application.
_is
- an InputStream to the configuration to compile;_src_dir
- the directory where the source files should be generated;_add_package_path_to_src_dir
- true if Kcf2java should generate
the file taking into account the package name of the class to
generate, false if the file should be generated directly in _src_dir
_custom_properties
- the properties representing custom tag decoders;_verbose
- indicates whether error messages and warnings should be
output to stderr_compile
- indicates whether the generated Java file should be compiled.
JonathanException
- if something goes wrong.
main
public static void main(String[] args)
The main method.
args
- see the description of the Kcf2java
class.
normalize
public static String normalize(String str)
Normalizes the provided string, by trimming and handling backslashes
str
- the string to normalize
- the normalized string
writeComponent
public static String writeComponent(XMLElement _current_component,
String _element_name,
String _configuration_var_name,
Writer _writer,
String _configuration_name)
throws IOException
Compiles the provided component using the provided writer.
_current_component
- the component to compile_element_name
- its name in the current configuration_configuration_var_name
- the variable name of the current configuration (may be null)_writer
- the writer to which the compiled version is output_configuration_name
- the absolute name of the current configuration
- the name of the variable used in the Java compiled file to represent the compiled component