ma.glasnost.orika.impl.generator
Class JavassistCompilerStrategy

java.lang.Object
  extended by ma.glasnost.orika.impl.generator.CompilerStrategy
      extended by ma.glasnost.orika.impl.generator.JavassistCompilerStrategy

public class JavassistCompilerStrategy
extends CompilerStrategy

Uses Javassist to generate compiled class for the passed GeneratedSourceCode object.

By default this compiler strategy writes no source or class files.

Author:
matt.deboer@gmail.com

Nested Class Summary
 
Nested classes/interfaces inherited from class ma.glasnost.orika.impl.generator.CompilerStrategy
CompilerStrategy.SourceCodeGenerationException
 
Field Summary
 
Fields inherited from class ma.glasnost.orika.impl.generator.CompilerStrategy
pathToWriteClassFiles, pathToWriteSourceFiles, WRITE_RELATIVE_TO_CLASSPATH, writeClassFiles, writeSourceFiles
 
Constructor Summary
JavassistCompilerStrategy()
           
 
Method Summary
 void assureTypeIsAccessible(Class<?> type)
          Verify that the Class provided is accessible to the compiler/generator.
 Class<?> compileClass(SourceCodeContext sourceCode)
          Compile and return the (generated) class; this will also cause the generated class to be detached from the class-pool, and any (optional) source and/or class files to be written.
protected  void writeClassFile(SourceCodeContext sourceCode, javassist.CtClass byteCodeClass)
          Produces the requested class files for debugging purposes.
protected  void writeSourceFile(SourceCodeContext sourceCode)
          Produces the requested source file for debugging purposes.
 
Methods inherited from class ma.glasnost.orika.impl.generator.CompilerStrategy
preparePackageOutputPath
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JavassistCompilerStrategy

public JavassistCompilerStrategy()
Method Detail

writeClassFile

protected void writeClassFile(SourceCodeContext sourceCode,
                              javassist.CtClass byteCodeClass)
                       throws IOException
Produces the requested class files for debugging purposes.

Throws:
javassist.CannotCompileException
IOException

writeSourceFile

protected void writeSourceFile(SourceCodeContext sourceCode)
                        throws IOException
Produces the requested source file for debugging purposes.

Throws:
IOException

assureTypeIsAccessible

public void assureTypeIsAccessible(Class<?> type)
                            throws CompilerStrategy.SourceCodeGenerationException
Description copied from class: CompilerStrategy
Verify that the Class provided is accessible to the compiler/generator.

Specified by:
assureTypeIsAccessible in class CompilerStrategy
Throws:
CompilerStrategy.SourceCodeGenerationException - if the type is not accessible

compileClass

public Class<?> compileClass(SourceCodeContext sourceCode)
                      throws CompilerStrategy.SourceCodeGenerationException
Description copied from class: CompilerStrategy
Compile and return the (generated) class; this will also cause the generated class to be detached from the class-pool, and any (optional) source and/or class files to be written.

Specified by:
compileClass in class CompilerStrategy
Returns:
the (generated) compiled class
Throws:
CompilerStrategy.SourceCodeGenerationException


Copyright © 2013 Glasnost. All Rights Reserved.