Class AbstractTranslator
java.lang.Object
org.codehaus.mojo.idlj.AbstractTranslator
- All Implemented Interfaces:
CompilerTranslator
- Direct Known Subclasses:
IdljTranslator, JacorbTranslator
Shared capabilities for translators.
- Version:
- $Id: AbstractIDLJMojo.java 9189 2009-03-10 21:47:46Z aheritier $
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static interfaceAn interface for loading the proper IDL compiler class.private static classThe implementation of ClassLoaderFacade used at runtime. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static AbstractTranslator.ClassLoaderFacadeprivate booleanenable/disable debug messagesprivate booleanSet to true to fail the build if an error occur while compiling the IDL.private static booleanDetermines if the compiler can fork a process to run.private org.apache.maven.plugin.logging.LogtheLogthat will used for the messages -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) static AbstractTranslator.ClassLoaderFacadeReturns the object to use for classloading.private StringgetCommandLine(Class<?> compilerClass, String[] arguments) (package private) org.apache.maven.plugin.logging.LoggetLog()private boolean(package private) voidinvokeCompilerInProcess(Class<?> compilerClass, List<String> args) Invokes the configured compiler and throws an exception if anything goes wrongprivate booleanisCompilationFailed(ByteArrayOutputStream err, int exitCode) booleanisDebug()(package private) boolean(package private) static booleanisFork()Returns true if the translator is allowed to create a new forked process.private booleanisNotEmpty(ByteArrayOutputStream outputStream) private voidprotected abstract intrunCompiler(Class<?> compilerClass, String... arguments) Runs the IDL compilerprivate intrunCompilerAndRecordOutput(Class<?> compilerClass, String[] arguments, ByteArrayOutputStream err, ByteArrayOutputStream out) (package private) static voidsetClassLoaderFacade(AbstractTranslator.ClassLoaderFacade classLoaderFacade) Specifies the implementation of the classloader facade to usevoidsetDebug(boolean debug) Enable/disable debug messages.voidsetFailOnError(boolean failOnError) Set to true to fail the build if an error occur while compiling the IDL.voidsetLog(org.apache.maven.plugin.logging.Log log) TheLogthat will used for the messagesMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface CompilerTranslator
invokeCompiler
-
Field Details
-
debug
private boolean debugenable/disable debug messages -
failOnError
private boolean failOnErrorSet to true to fail the build if an error occur while compiling the IDL. -
log
private org.apache.maven.plugin.logging.Log logtheLogthat will used for the messages -
classLoaderFacade
-
fork
private static boolean forkDetermines if the compiler can fork a process to run. Not all compilers support this.
-
-
Constructor Details
-
AbstractTranslator
AbstractTranslator()
-
-
Method Details
-
isDebug
public boolean isDebug()- Returns:
- the debug
-
setDebug
public void setDebug(boolean debug) Description copied from interface:CompilerTranslatorEnable/disable debug messages.- Specified by:
setDebugin interfaceCompilerTranslator- Parameters:
debug- the debug to set
-
getLog
org.apache.maven.plugin.logging.Log getLog()- Returns:
- the log
-
setLog
public void setLog(org.apache.maven.plugin.logging.Log log) Description copied from interface:CompilerTranslatorTheLogthat will used for the messages- Specified by:
setLogin interfaceCompilerTranslator- Parameters:
log- the log to set
-
isFailOnError
boolean isFailOnError()- Returns:
- the failOnError
-
setFailOnError
public void setFailOnError(boolean failOnError) Description copied from interface:CompilerTranslatorSet to true to fail the build if an error occur while compiling the IDL.- Specified by:
setFailOnErrorin interfaceCompilerTranslator- Parameters:
failOnError- the failOnError to set
-
isFork
static boolean isFork()Returns true if the translator is allowed to create a new forked process.- Returns:
- true if forking is permitted
-
setClassLoaderFacade
Specifies the implementation of the classloader facade to use- Parameters:
classLoaderFacade- a wrapper for class loading.
-
getClassLoaderFacade
Returns the object to use for classloading.- Returns:
- the appropriate loader facade
-
invokeCompilerInProcess
void invokeCompilerInProcess(Class<?> compilerClass, List<String> args) throws org.apache.maven.plugin.MojoExecutionException Invokes the configured compiler and throws an exception if anything goes wrong- Parameters:
compilerClass- the class representing the compiler to invokeargs- the arguments to pass to the compiler- Throws:
org.apache.maven.plugin.MojoExecutionException- if any error occurs
-
runCompilerAndRecordOutput
private int runCompilerAndRecordOutput(Class<?> compilerClass, String[] arguments, ByteArrayOutputStream err, ByteArrayOutputStream out) throws org.apache.maven.plugin.MojoExecutionException - Throws:
org.apache.maven.plugin.MojoExecutionException
-
runCompiler
protected abstract int runCompiler(Class<?> compilerClass, String... arguments) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException Runs the IDL compiler- Parameters:
compilerClass- the class which implements the compilerarguments- the arguments to pass to the compiler- Returns:
- the return status (a non-zero value indicates an error)
- Throws:
NoSuchMethodException- if the method which should run the compiler does not existIllegalAccessException- if no constructor is availableInvocationTargetException- if an error occurs while invoking the compiler
-
isCompilationFailed
-
hasErrors
-
logOutputMessages
-
isNotEmpty
-
getCommandLine
-