com.caucho.java.gen
Class JavaClassGenerator

java.lang.Object
  extended by com.caucho.java.gen.JavaClassGenerator

public class JavaClassGenerator
extends java.lang.Object

Factory for generating Java classes.


Constructor Summary
JavaClassGenerator()
           
 
Method Summary
 void addPendingFile(java.lang.String javaPath)
           
 void addPendingFiles(java.lang.String[] files)
           
static java.lang.String cleanClassName(java.lang.String className)
          Sets the full generated class.
 java.lang.Class compile(java.lang.String fullClassName)
          Compiles the Java code
 void compileJava(java.lang.String fullClassName)
          Compiles the class.
 void compilePendingJava()
          Compiles the pending files
 void generate(GenClass javaClass)
          Call to generate the java source.
 Path getClassFilePath(java.lang.String className)
           
 java.lang.ClassLoader getClassLoader()
          Gets the class loader.
static Path getDefaultSearchPath()
          Returns the default merge path
 java.lang.ClassLoader getParentLoader()
          Sets the parent class loader.
 java.lang.String[] getPendingFiles()
          Returns the pending Java files.
 java.lang.ClassLoader getPreloadLoader()
          Sets the parent class loader.
 Path getSearchPath()
          Returns the assigned search path.
 Path getWorkDir()
          Returns the class dir for the generated class.
 boolean isModified(java.lang.Class<?> cl)
          Returns true if the class is modified.
 java.lang.Class<?> load(java.lang.String fullClassName)
          Try to preload the class.
 java.lang.Class<?> loadClass(java.lang.String fullClassName)
          Loads the generated class.
 java.lang.Class<?> loadClass(java.lang.String fullClassName, boolean preload)
          Loads the generated class.
 java.lang.Class<?> loadClassParentLoader(java.lang.String fullClassName, java.lang.Class<?> parentClass)
          Loads the generated class into the parent loader.
 java.lang.Class<?> preload(java.lang.String fullClassName)
          Try to preload the class.
 java.lang.Class<?> preloadClassParentLoader(java.lang.String fullClassName, java.lang.Class<?> parentClass)
          Loads the generated class into the parent loader.
 boolean preloadExists(java.lang.String fullClassName)
          Checks if the preload exists
 void setEncoding(java.lang.String encoding)
           
 void setLoader(java.lang.ClassLoader loader)
          Sets the class loader.
 void setParentLoader(java.lang.ClassLoader loader)
          Sets the parent class loader.
 void setSearchPath(Path path)
          Sets the search path.
 void setWorkDir(Path workPath)
          Sets the work path for the generated class.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JavaClassGenerator

public JavaClassGenerator()
Method Detail

cleanClassName

public static java.lang.String cleanClassName(java.lang.String className)
Sets the full generated class.


getDefaultSearchPath

public static Path getDefaultSearchPath()
Returns the default merge path


setSearchPath

public void setSearchPath(Path path)
Sets the search path.


getSearchPath

public Path getSearchPath()
Returns the assigned search path.


setEncoding

public void setEncoding(java.lang.String encoding)

setParentLoader

public void setParentLoader(java.lang.ClassLoader loader)
Sets the parent class loader.

Parameters:
loader - parent class loader

setLoader

public void setLoader(java.lang.ClassLoader loader)
Sets the class loader.

Parameters:
loader - parent class loader

getClassLoader

public java.lang.ClassLoader getClassLoader()
Gets the class loader.


getParentLoader

public java.lang.ClassLoader getParentLoader()
Sets the parent class loader.

Returns:
the parent class loader

getPreloadLoader

public java.lang.ClassLoader getPreloadLoader()
Sets the parent class loader.

Returns:
the parent class loader

setWorkDir

public void setWorkDir(Path workPath)
Sets the work path for the generated class.


getWorkDir

public Path getWorkDir()
Returns the class dir for the generated class.


preload

public java.lang.Class<?> preload(java.lang.String fullClassName)
Try to preload the class.

Returns:
true if the preloaded class is still valid.

load

public java.lang.Class<?> load(java.lang.String fullClassName)
Try to preload the class.

Returns:
true if the preloaded class is still valid.

getClassFilePath

public Path getClassFilePath(java.lang.String className)

generate

public void generate(GenClass javaClass)
              throws java.lang.Exception
Call to generate the java source.

Throws:
java.lang.Exception

addPendingFile

public void addPendingFile(java.lang.String javaPath)

compile

public java.lang.Class compile(java.lang.String fullClassName)
                        throws java.lang.Exception
Compiles the Java code

Throws:
java.lang.Exception

compileJava

public void compileJava(java.lang.String fullClassName)
                 throws java.io.IOException,
                        java.lang.ClassNotFoundException
Compiles the class.

Throws:
java.io.IOException
java.lang.ClassNotFoundException

getPendingFiles

public java.lang.String[] getPendingFiles()
Returns the pending Java files.


addPendingFiles

public void addPendingFiles(java.lang.String[] files)

compilePendingJava

public void compilePendingJava()
                        throws java.io.IOException,
                               java.lang.ClassNotFoundException
Compiles the pending files

Throws:
java.io.IOException
java.lang.ClassNotFoundException

loadClass

public java.lang.Class<?> loadClass(java.lang.String fullClassName)
                             throws java.lang.ClassNotFoundException
Loads the generated class. If any class dependencies have changed, return null.

Throws:
java.lang.ClassNotFoundException

preloadExists

public boolean preloadExists(java.lang.String fullClassName)
Checks if the preload exists


loadClass

public java.lang.Class<?> loadClass(java.lang.String fullClassName,
                                    boolean preload)
                             throws java.lang.ClassNotFoundException
Loads the generated class. If any class dependencies have changed, return null.

Throws:
java.lang.ClassNotFoundException

preloadClassParentLoader

public java.lang.Class<?> preloadClassParentLoader(java.lang.String fullClassName,
                                                   java.lang.Class<?> parentClass)
Loads the generated class into the parent loader.


loadClassParentLoader

public java.lang.Class<?> loadClassParentLoader(java.lang.String fullClassName,
                                                java.lang.Class<?> parentClass)
                                         throws java.lang.ClassNotFoundException
Loads the generated class into the parent loader.

Throws:
java.lang.ClassNotFoundException

isModified

public boolean isModified(java.lang.Class<?> cl)
Returns true if the class is modified.