Package org.codehaus.mojo.idlj
Class AbstractTranslator
- java.lang.Object
-
- org.codehaus.mojo.idlj.AbstractTranslator
-
- All Implemented Interfaces:
CompilerTranslator
- Direct Known Subclasses:
IdljTranslator
,JacorbTranslator
abstract class AbstractTranslator extends java.lang.Object implements CompilerTranslator
Shared capabilities for translators.- Version:
- $Id: AbstractIDLJMojo.java 9189 2009-03-10 21:47:46Z aheritier $
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static interface
AbstractTranslator.ClassLoaderFacade
An interface for loading the proper IDL compiler class.private static class
AbstractTranslator.ClassLoaderFacadeImpl
The implementation of ClassLoaderFacade used at runtime.
-
Field Summary
Fields Modifier and Type Field Description private static AbstractTranslator.ClassLoaderFacade
classLoaderFacade
private boolean
debug
enable/disable debug messagesprivate boolean
failOnError
Set to true to fail the build if an error occur while compiling the IDL.private static boolean
fork
Determines if the compiler can fork a process to run.private org.apache.maven.plugin.logging.Log
log
theLog
that will used for the messages
-
Constructor Summary
Constructors Constructor Description AbstractTranslator()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description (package private) static AbstractTranslator.ClassLoaderFacade
getClassLoaderFacade()
Returns the object to use for classloading.private java.lang.String
getCommandLine(java.lang.Class<?> compilerClass, java.lang.String[] arguments)
(package private) org.apache.maven.plugin.logging.Log
getLog()
private boolean
hasErrors(java.io.ByteArrayOutputStream err)
(package private) void
invokeCompilerInProcess(java.lang.Class<?> compilerClass, java.util.List<java.lang.String> args)
Invokes the configured compiler and throws an exception if anything goes wrongprivate boolean
isCompilationFailed(java.io.ByteArrayOutputStream err, int exitCode)
boolean
isDebug()
(package private) boolean
isFailOnError()
(package private) static boolean
isFork()
Returns true if the translator is allowed to create a new forked process.private boolean
isNotEmpty(java.io.ByteArrayOutputStream outputStream)
private void
logOutputMessages(java.io.ByteArrayOutputStream err, java.io.ByteArrayOutputStream out)
protected abstract int
runCompiler(java.lang.Class<?> compilerClass, java.lang.String... arguments)
Runs the IDL compilerprivate int
runCompilerAndRecordOutput(java.lang.Class<?> compilerClass, java.lang.String[] arguments, java.io.ByteArrayOutputStream err, java.io.ByteArrayOutputStream out)
(package private) static void
setClassLoaderFacade(AbstractTranslator.ClassLoaderFacade classLoaderFacade)
Specifies the implementation of the classloader facade to usevoid
setDebug(boolean debug)
Enable/disable debug messages.void
setFailOnError(boolean failOnError)
Set to true to fail the build if an error occur while compiling the IDL.void
setLog(org.apache.maven.plugin.logging.Log log)
TheLog
that will used for the messages-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.codehaus.mojo.idlj.CompilerTranslator
invokeCompiler
-
-
-
-
Field Detail
-
debug
private boolean debug
enable/disable debug messages
-
failOnError
private boolean failOnError
Set to true to fail the build if an error occur while compiling the IDL.
-
log
private org.apache.maven.plugin.logging.Log log
theLog
that will used for the messages
-
classLoaderFacade
private static AbstractTranslator.ClassLoaderFacade classLoaderFacade
-
fork
private static boolean fork
Determines if the compiler can fork a process to run. Not all compilers support this.
-
-
Method Detail
-
isDebug
public boolean isDebug()
- Returns:
- the debug
-
setDebug
public void setDebug(boolean debug)
Description copied from interface:CompilerTranslator
Enable/disable debug messages.- Specified by:
setDebug
in 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:CompilerTranslator
TheLog
that will used for the messages- Specified by:
setLog
in interfaceCompilerTranslator
- Parameters:
log
- the log to set
-
isFailOnError
boolean isFailOnError()
- Returns:
- the failOnError
-
setFailOnError
public void setFailOnError(boolean failOnError)
Description copied from interface:CompilerTranslator
Set to true to fail the build if an error occur while compiling the IDL.- Specified by:
setFailOnError
in 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
static void setClassLoaderFacade(AbstractTranslator.ClassLoaderFacade classLoaderFacade)
Specifies the implementation of the classloader facade to use- Parameters:
classLoaderFacade
- a wrapper for class loading.
-
getClassLoaderFacade
static AbstractTranslator.ClassLoaderFacade getClassLoaderFacade()
Returns the object to use for classloading.- Returns:
- the appropriate loader facade
-
invokeCompilerInProcess
void invokeCompilerInProcess(java.lang.Class<?> compilerClass, java.util.List<java.lang.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(java.lang.Class<?> compilerClass, java.lang.String[] arguments, java.io.ByteArrayOutputStream err, java.io.ByteArrayOutputStream out) throws org.apache.maven.plugin.MojoExecutionException
- Throws:
org.apache.maven.plugin.MojoExecutionException
-
runCompiler
protected abstract int runCompiler(java.lang.Class<?> compilerClass, java.lang.String... arguments) throws java.lang.NoSuchMethodException, java.lang.IllegalAccessException, java.lang.reflect.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:
java.lang.NoSuchMethodException
- if the method which should run the compiler does not existjava.lang.IllegalAccessException
- if no constructor is availablejava.lang.reflect.InvocationTargetException
- if an error occurs while invoking the compiler
-
isCompilationFailed
private boolean isCompilationFailed(java.io.ByteArrayOutputStream err, int exitCode)
-
hasErrors
private boolean hasErrors(java.io.ByteArrayOutputStream err)
-
logOutputMessages
private void logOutputMessages(java.io.ByteArrayOutputStream err, java.io.ByteArrayOutputStream out)
-
isNotEmpty
private boolean isNotEmpty(java.io.ByteArrayOutputStream outputStream)
-
getCommandLine
private java.lang.String getCommandLine(java.lang.Class<?> compilerClass, java.lang.String[] arguments)
-
-