|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.deduced.dynamic.AbstractDynamicExecutionCompiler
public abstract class AbstractDynamicExecutionCompiler

DynamicExecutionCompiler is used to compile the code in a compiled model and associate the java class that goes with it.
| Nested Class Summary | |
|---|---|
static class |
AbstractDynamicExecutionCompiler.DynamicFileNameGenerator
DynamicFileNameFinder |
static interface |
AbstractDynamicExecutionCompiler.FileNameGenerator
FileNameGenerator |
static class |
AbstractDynamicExecutionCompiler.LocalClassLoader
LocalClassLoader is used to load locally compiled files. |
| Field Summary | |
|---|---|
private static boolean |
AUTOMATICALLY_DELETING_GENERATED_CLASS_FILES
option to automatically delete the compiled class file after they are loaded |
private static boolean |
AUTOMATICALLY_DELETING_GENERATED_JAVA_FILES
option to automatically delete generated JAVA files after compilation |
private static boolean |
AUTOMATICALLY_DELETING_GENERATED_JAVA_FILES_IF_COMPILE_FAILS
option to automatically delete java files when compilation fails |
static java.lang.String |
CLASS_FILE_EXTENSION
class file extension |
private static int |
CLASS_NAME_STRING_TRIM_LENGTH
The number of characters to use in a type name when generating dynamic code |
private java.util.IdentityHashMap<PropertyCollection<?,?>,DeductionRuleAnalyzer<java.lang.Object>> |
compiledModelToAnalyzerMap
map that associates compiled models to the analyzer that executes them |
private static java.lang.String[] |
COMPILER_ARGUMENTS
additional compiler arguments |
private static int |
COUNTER
counter used to increment the dynamic class name |
static java.lang.String |
DEDUCED_DYNAMIC_CLASS_NAME
dynamic class name prefix |
static java.lang.String |
DYNAMIC_CODE_PACKAGE_NAME
default dynamic code package name |
static AbstractDynamicExecutionCompiler.FileNameGenerator |
FILE_NAME_GENERATOR
File name finder |
private static int |
FIND_AVAILABLE_FILE_MAX_ATTEMPT_COUNT
The maximum number of attempts at finding an available file |
static java.lang.String |
JAVA_FILE_EXTENSION
java file extension |
private static AbstractDynamicExecutionCompiler.LocalClassLoader |
LOADER
class loader used to load dynamically generated classes |
private static java.util.logging.Logger |
LOGGER
logger |
private static java.lang.String |
OUTPUT_FOLDER_NAME
dynamic code output folder name |
| Constructor Summary | |
|---|---|
AbstractDynamicExecutionCompiler()
|
|
| Method Summary | |
|---|---|
boolean |
attemptToLoadClassFromCache(java.lang.String packageName,
java.lang.String folderName,
java.lang.String className,
CompileResult result)
attempt To Load Class From Cache |
abstract void |
buildClassContent(PropertyCollection compiledModel,
java.lang.String className,
java.lang.String packageName,
java.lang.StringBuilder builder)
build a Class Content based on the compiled model |
static void |
compileClass(java.lang.String folderName,
java.lang.String className,
java.lang.String javaFileName,
java.lang.String classFileName,
java.lang.String packageName,
CompileResult result)
compile a class |
static void |
compileFile(java.io.File outFile,
CompileResult result)
compile a file |
DeductionRuleAnalyzer<java.lang.Object> |
createAnalyzerFromCompiledModel(PropertyCollection compiledModel)
create Analyzer From Compiled Model |
static void |
deleteAllGeneratedClassFiles()
delete All Generated Class Files |
static void |
deleteAllGeneratedFiles()
delete All Generated Files |
static void |
deleteAllGeneratedJavaFiles()
delete All Generated Java Files |
void |
deleteClassCachedFiles(DeductionRuleAnalyzer<java.lang.Object> deleteAnalyzer)
delete Class Cached Files if they exist |
static void |
deleteFileAssertIfFailed(java.io.File fileToDelete)
delete File Assert If Failed |
static void |
deleteInnerClasses(java.lang.String folderName,
java.lang.String className)
delete all generated Inner Classes for a specific class |
void |
disableCompiledModel(PropertyCollection compiledModel)
disable Compiled Model |
static boolean |
doesClassExist(java.lang.String className)
does Class Exist |
static java.lang.String |
filterIllegalJavaCharacters(java.lang.String str)
filter Illegal Java Characters from a string |
DeductionRuleAnalyzer<java.lang.Object> |
getAnalyzerFromCompiledModel(PropertyCollection compiledModel)
(non-JSDoc) |
void |
getClassFromCompiledModel(PropertyCollection compiledModel,
CompileResult result)
get Class From Compiled Model |
java.lang.String |
getClassNameForCompiledModel(java.lang.String packageName,
PropertyCollection compiledModel)
get Class Name For Compiled Model |
static java.lang.String |
getClassNameFromCompiledModel(PropertyCollection compiledModel)
get Class Name From compiled Model |
private static java.lang.String[] |
getCompileFileCompilerArgument(java.lang.String fileToCompilePath)
get Compile File Compiler Argument |
static java.lang.String[] |
getCompilerArguments()
get Compiler Arguments |
static AbstractDynamicExecutionCompiler.LocalClassLoader |
getDynamicClassLoader()
get dynamic Class Loader |
static java.util.List<java.io.File> |
getInnerClassList(java.lang.String folderName,
java.lang.String className)
get the list of inner class files generated by a class |
static java.lang.String |
getNextAvailableClassName(java.lang.String packageName,
java.lang.String className)
get Next Available Class Name by starting with a class name and verifying if it exists. |
static java.lang.String |
getNextAvailableDynamicFileName()
get Next Available Dynamic File Name will test if a file name is already in use before returning it. |
static java.lang.String |
getNextAvailableFileName(AbstractDynamicExecutionCompiler.FileNameGenerator generator)
get Next Available File Name |
static java.lang.String |
getNextDynamicFileName()
get a dynamic file name used to store dynamic class names |
static java.lang.String |
getOutputFolderName()
get Output Folder Name |
private java.lang.String |
getOutputFolderName(java.lang.String packageName)
get Output Folder Name |
static boolean |
isAutomaticallyDeletingGeneratedClassFiles()
|
static boolean |
isAutomaticallyDeletingGeneratedJavaFiles()
|
static boolean |
isAutomaticallyDeletingGeneratedJavaFilesIfCompileFails()
|
static boolean |
isClassName(java.lang.String codeClassName)
test if the code points to a class name or not. |
static boolean |
isCompiledModelEnabled(PropertyCollection compiledModel)
is Compiled Model Enabled |
static boolean |
isValidMethodNameCharacter(char value)
test if a character is valid for a java method name |
static java.lang.Class<?> |
loadClassAndInnerClass(java.lang.String folderName,
java.lang.String className,
java.lang.String packageName)
load a Class And all it's Inner Classes |
private static void |
loadInnerClasses(java.lang.String folderName,
java.lang.String className,
java.lang.String packageName)
load all the compiled inner classes in the class loader |
void |
logAnalyzerCreationResult(PropertyCollection compiledModel,
CompileResult result)
log Rule Creation Result |
void |
resetAnalyzerFromCompiledModel(PropertyCollection<?,?> compiledModel)
(non-JSDoc) |
static void |
setAutomaticallyDeletingGeneratedClassFiles(boolean setAutomaticallyDeletingGeneratedClassFiles)
|
static void |
setAutomaticallyDeletingGeneratedJavaFiles(boolean setAutomaticallyDeletingGeneratedJavaFiles)
|
static void |
setAutomaticallyDeletingGeneratedJavaFilesIfCompileFails(boolean setAutomaticallyDeletingGeneratedJavaFilesIfCompileFails)
|
static void |
setCompilerArguments(java.lang.String[] newCompilerArguments)
set Compiler Arguments |
static void |
setDynamicClassLoader(AbstractDynamicExecutionCompiler.LocalClassLoader loader)
set Dynamic Class Loader |
static void |
setOutputFolderName(java.lang.String newOutputFolderName)
set Output Folder Name |
void |
validateCompilationModelForCompilation(PropertyCollection compiledModel,
CompileResult result)
validate Compilation Model For Compilation |
static void |
validateCompilationModelIsEnabled(PropertyCollection compiledModel)
validate Compilation Model Is Enabled |
private void |
validateCreatedAnalyzerClass(java.lang.Object newInstance)
validate Created Analyzer Class |
static java.io.File |
writeJavaClass(java.lang.String fileName,
java.lang.String classContent)
write a Java Class |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private static final int CLASS_NAME_STRING_TRIM_LENGTH
public static final java.lang.String DYNAMIC_CODE_PACKAGE_NAME
private static final java.util.logging.Logger LOGGER
private static final int FIND_AVAILABLE_FILE_MAX_ATTEMPT_COUNT
public static final java.lang.String DEDUCED_DYNAMIC_CLASS_NAME
public static final java.lang.String CLASS_FILE_EXTENSION
public static final java.lang.String JAVA_FILE_EXTENSION
private static AbstractDynamicExecutionCompiler.LocalClassLoader LOADER
private static java.lang.String[] COMPILER_ARGUMENTS
private static java.lang.String OUTPUT_FOLDER_NAME
private static boolean AUTOMATICALLY_DELETING_GENERATED_JAVA_FILES
private static boolean AUTOMATICALLY_DELETING_GENERATED_CLASS_FILES
private static boolean AUTOMATICALLY_DELETING_GENERATED_JAVA_FILES_IF_COMPILE_FAILS
private static int COUNTER
private java.util.IdentityHashMap<PropertyCollection<?,?>,DeductionRuleAnalyzer<java.lang.Object>> compiledModelToAnalyzerMap
public static final AbstractDynamicExecutionCompiler.FileNameGenerator FILE_NAME_GENERATOR
| Constructor Detail |
|---|
public AbstractDynamicExecutionCompiler()
| Method Detail |
|---|
public static java.lang.String getOutputFolderName()
public static void setOutputFolderName(java.lang.String newOutputFolderName)
newOutputFolderName - the new output folder namepublic static void deleteAllGeneratedFiles()
public static void deleteAllGeneratedJavaFiles()
public static void deleteAllGeneratedClassFiles()
public static java.lang.String[] getCompilerArguments()
public static void setCompilerArguments(java.lang.String[] newCompilerArguments)
newCompilerArguments - the arguments to pass to the java compilerpublic static java.lang.String getNextDynamicFileName()
public static AbstractDynamicExecutionCompiler.LocalClassLoader getDynamicClassLoader()
public static void setDynamicClassLoader(AbstractDynamicExecutionCompiler.LocalClassLoader loader)
loader - the new dynamic class loaderpublic void resetAnalyzerFromCompiledModel(PropertyCollection<?,?> compiledModel)
resetAnalyzerFromCompiledModel in interface DynamicExecutionCompilercompiledModel - the compiled model to resetDynamicExecutionCompiler.resetAnalyzerFromCompiledModel(org.deduced.PropertyCollection)public void deleteClassCachedFiles(DeductionRuleAnalyzer<java.lang.Object> deleteAnalyzer)
deleteAnalyzer - the analyzer to delete
public DeductionRuleAnalyzer<java.lang.Object> getAnalyzerFromCompiledModel(PropertyCollection compiledModel)
throws java.lang.IllegalStateException,
CompilationFailedException
getAnalyzerFromCompiledModel in interface DynamicExecutionCompilercompiledModel - the compiled model
java.lang.IllegalStateException - if the compilation model isn't enabled.
CompilationFailedException - if the compilation operation failsDynamicExecutionCompiler.getAnalyzerFromCompiledModel(org.deduced.PropertyCollection)
public DeductionRuleAnalyzer<java.lang.Object> createAnalyzerFromCompiledModel(PropertyCollection compiledModel)
throws CompilationFailedException,
java.lang.IllegalStateException
compiledModel - the compiled model to compile
CompilationFailedException - if the compilation operation fails.
java.lang.IllegalStateException - if the compilation model is disabled
public static void validateCompilationModelIsEnabled(PropertyCollection compiledModel)
throws java.lang.IllegalStateException
compiledModel - the compiled model to validate
java.lang.IllegalStateException - if the model isn't enabled.
public void validateCompilationModelForCompilation(PropertyCollection compiledModel,
CompileResult result)
throws java.lang.IllegalArgumentException
compiledModel - the compiled modelresult - the compilation result to fill
java.lang.IllegalArgumentException - when the compilation model is invalidpublic static boolean isCompiledModelEnabled(PropertyCollection compiledModel)
compiledModel - the compiled model
public void getClassFromCompiledModel(PropertyCollection compiledModel,
CompileResult result)
throws CompilationFailedException,
java.io.IOException
compiledModel - the compiled modelresult - the compilation result
CompilationFailedException - if the class compilation failed
java.io.IOException - if the folder creation failedprivate java.lang.String getOutputFolderName(java.lang.String packageName)
packageName - the package name to output to
public boolean attemptToLoadClassFromCache(java.lang.String packageName,
java.lang.String folderName,
java.lang.String className,
CompileResult result)
packageName - package namefolderName - folder where the class is storedclassName - name of the classresult - class compilation result
public java.lang.String getClassNameForCompiledModel(java.lang.String packageName,
PropertyCollection compiledModel)
packageName - the package name storing the classcompiledModel - the compiled model to use
public static java.lang.String filterIllegalJavaCharacters(java.lang.String str)
str - the string to filter
public static java.lang.String getNextAvailableClassName(java.lang.String packageName,
java.lang.String className)
packageName - package nameclassName - the class name to verify
public static boolean doesClassExist(java.lang.String className)
className - the class name to find
public static java.lang.String getClassNameFromCompiledModel(PropertyCollection compiledModel)
compiledModel - the compiled model
public abstract void buildClassContent(PropertyCollection compiledModel,
java.lang.String className,
java.lang.String packageName,
java.lang.StringBuilder builder)
compiledModel - the compiled modelclassName - the class name to usepackageName - the package name to usebuilder - the string builder containing the class contentpublic static boolean isClassName(java.lang.String codeClassName)
codeClassName - the class name to test
public static void compileClass(java.lang.String folderName,
java.lang.String className,
java.lang.String javaFileName,
java.lang.String classFileName,
java.lang.String packageName,
CompileResult result)
throws CompilationFailedException
folderName - where the class and java files are storedclassName - the name of the class to compilejavaFileName - name of the java file to useclassFileName - name of the class file to usepackageName - name of the package for the classresult - the compilation result to fill while compiling
CompilationFailedException - any error detected while compiling the
class
public static java.lang.Class<?> loadClassAndInnerClass(java.lang.String folderName,
java.lang.String className,
java.lang.String packageName)
throws java.lang.Exception
folderName - the folder where the class is storedclassName - the class name to loadpackageName - the package name of the class
java.lang.Exception - if any error occurs.
private static void loadInnerClasses(java.lang.String folderName,
java.lang.String className,
java.lang.String packageName)
throws java.lang.Exception
folderName - folder where the classes are storedclassName - the class name that was generatedpackageName - the package used to generate the class
java.lang.Exception - any unexpected
public static void compileFile(java.io.File outFile,
CompileResult result)
throws CompilationFailedException
outFile - file to compileresult - the compilation result to fill
CompilationFailedException - any exception generated while running
the compilerprivate static java.lang.String[] getCompileFileCompilerArgument(java.lang.String fileToCompilePath)
fileToCompilePath - the file to compile
public static java.io.File writeJavaClass(java.lang.String fileName,
java.lang.String classContent)
throws java.io.IOException
fileName - the file name to useclassContent - the class content
java.io.IOException - if writing the file fails
public static void deleteInnerClasses(java.lang.String folderName,
java.lang.String className)
folderName - folder storing the classclassName - the class namepublic static void deleteFileAssertIfFailed(java.io.File fileToDelete)
fileToDelete - file to delete
public static java.util.List<java.io.File> getInnerClassList(java.lang.String folderName,
java.lang.String className)
folderName - name of the folder storing the classesclassName - the class name
public static boolean isValidMethodNameCharacter(char value)
value - the character to test
public static java.lang.String getNextAvailableFileName(AbstractDynamicExecutionCompiler.FileNameGenerator generator)
generator - name finder
public static java.lang.String getNextAvailableDynamicFileName()
public static void setAutomaticallyDeletingGeneratedJavaFiles(boolean setAutomaticallyDeletingGeneratedJavaFiles)
setAutomaticallyDeletingGeneratedJavaFiles - the Automatically
Deleting Generated Java Files flagpublic static boolean isAutomaticallyDeletingGeneratedJavaFiles()
public static void setAutomaticallyDeletingGeneratedClassFiles(boolean setAutomaticallyDeletingGeneratedClassFiles)
setAutomaticallyDeletingGeneratedClassFiles - the Automatically
Deleting Generated Class Files flagpublic static boolean isAutomaticallyDeletingGeneratedClassFiles()
public static void setAutomaticallyDeletingGeneratedJavaFilesIfCompileFails(boolean setAutomaticallyDeletingGeneratedJavaFilesIfCompileFails)
setAutomaticallyDeletingGeneratedJavaFilesIfCompileFails - the
Automatically Deleting Generated Java Files if compile fails
flagpublic static boolean isAutomaticallyDeletingGeneratedJavaFilesIfCompileFails()
public void logAnalyzerCreationResult(PropertyCollection compiledModel,
CompileResult result)
compiledModel - the rule we tried to createresult - the compilation resultpublic void disableCompiledModel(PropertyCollection compiledModel)
compiledModel - the model to disable
private void validateCreatedAnalyzerClass(java.lang.Object newInstance)
throws java.lang.IllegalArgumentException
newInstance - the potential analyzer
java.lang.IllegalArgumentException - if the object isn't an instance of
DeductionRuleAnalyzer
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||