public class PostCompilationOpsDriver
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
private static java.lang.String[] |
classesDirectories
The directories where all target .class files are located.
|
private static java.net.URLClassLoader |
classLoader
A URL class loader used for loading the DMO interface classes from any provided path.
|
private static java.lang.String |
dmoBlacklistSeparator
Character used to separate paths in the blacklist given as argument.
|
private static java.lang.String[] |
dmoBufImplClassesDirectories
The directories in which all the DMO implementation classes will be saved.
|
private static java.lang.String |
dmoBufProxiesJarPath
Path to the jar containing the DMO buffer proxy classes.
|
private static java.lang.String[] |
dmoImplClassesDirectories
The directories in which all the DMO implementation classes will be saved.
|
private static java.lang.String |
dmoImplsJarPath
Path to the jar containing the DMO implementations.
|
private static java.util.Set<java.lang.String> |
dmoPathsBlacklist
A set of folders to skip processing.
|
private static java.lang.String |
dmosDirectory
A relative path from a
classesDirectories path to the folder containing the DMO classes. |
private static CentralLogger |
log
Logger
|
private static boolean |
LOG_FINE
Do we log FINE-level events ?
|
private static boolean |
LOG_WARNING
Do we log WARNING-level events ?
|
private static java.util.Map<java.lang.String,java.lang.String> |
proxyCache
Cache mapping a string representation of a
ProxyFactory.CacheKey to the name of a new proxy class. |
private static java.io.File |
proxyCacheFile
The file/path where the
proxyCache will be saved on disk. |
| Constructor and Description |
|---|
PostCompilationOpsDriver() |
| Modifier and Type | Method and Description |
|---|---|
private static void |
createImplementations()
Method responsible for searching for all DMO interfaces and DMO buffer interfaces
in the provided directory and attempt to create an implementation/proxy class
and save that class to disk.
|
private static void |
createJar(java.lang.String jarPath,
java.lang.String[] classesFolders)
Method used to create a jar from a given list of directories.
|
private static void |
createJarHelper(java.io.File source,
java.util.jar.JarOutputStream target,
java.lang.Integer nameSubstringIndex,
java.util.Set<java.lang.String> packages)
Helper method for creating a jar.
|
private static DmoClass |
generateImplementationDmo(java.lang.Class<? extends DataModelObject> dmoIface)
This method is responsible for setting up objects needed to generate a DMO implementation class
for a DMO interface provided, and use
DmoClass to create and provide the DMO class object. |
private static void |
handleDmoBufInterface(java.lang.String dmoBufBinaryName,
java.lang.String classDestination)
This method is responsible for trying to create a proxy class for a DMO buffer interface.
|
private static void |
handleDmoInterface(java.lang.String dmoBinaryName,
java.lang.String classDestination)
This method is responsible for attempting to load a DMO interface class with the
given binary name (package name, with dot separator), generate for it
an implementation class object and save the new class to a file on disk.
|
private static boolean |
isDmoBufInterface(java.lang.String fileName,
java.lang.String schemaDirectory)
Check whether the name given respects a minimum of conditions to be
considered the name of a DMO buffer interface.
|
private static boolean |
isDmoInterface(java.lang.String fileName,
java.lang.String schemaDirectory)
Check whether the name given respects a minimum of conditions to be
considered the name of a DMO interface.
|
static void |
main(java.lang.String[] args)
Main method of entry point where post compilation operations are started.
|
private static void |
writeClassToDisk(java.lang.String internalName,
byte[] code,
java.lang.String destinationFolder)
This method is used to write to disk the bytecode of a class, with all necessary information
required given as parameter.
|
private static void |
writeJarIndex(java.util.jar.JarOutputStream jos,
java.util.Set<java.lang.String> packages)
Writes the jar index to the jar file's META-INF directory.
|
private static void |
writeProxyCacheToDisk()
This method is responsible for writing to disk the
proxyCache map object,
meant to be retrieved by ProxyFactory at server runtime. |
private static final CentralLogger log
private static final boolean LOG_WARNING
private static final boolean LOG_FINE
private static java.lang.String[] classesDirectories
private static java.lang.String[] dmoImplClassesDirectories
private static java.lang.String[] dmoBufImplClassesDirectories
private static java.lang.String dmosDirectory
classesDirectories path to the folder containing the DMO classes.private static java.util.Set<java.lang.String> dmoPathsBlacklist
private static java.lang.String dmoBlacklistSeparator
private static java.net.URLClassLoader classLoader
private static java.util.Map<java.lang.String,java.lang.String> proxyCache
ProxyFactory.CacheKey to the name of a new proxy class.private static java.io.File proxyCacheFile
proxyCache will be saved on disk.private static java.lang.String dmoImplsJarPath
private static java.lang.String dmoBufProxiesJarPath
public static void main(java.lang.String[] args)
args - List of command line arguments. The arguments are as follow:
args[0] - folders containing .class files, separated by :
example: ${build.home}/classes/:${build.home}/classes2/:${build.home}/classes3/
args[1] - relative path from any of the folders in args[0] to a folder containing DMOs
args[2] - blacklist paths, won't process these schema folders, separated by :
args[3] - where to save all the dmo implementations
args[4] - where to save all the dmo buf proxies
args[5] - where to save the map file that helps associate a Proxy class file name to the
interfaces/classes names that were used to generate it.
args[6] - where the jar with the dmo implementations will be saved
args[7] - where the jar with the dmo buffer proxies will be savedprivate static void createImplementations()
private static void createJar(java.lang.String jarPath,
java.lang.String[] classesFolders)
jarPath - The path of the new jar.classesFolders - The folders to be jarred.private static void writeJarIndex(java.util.jar.JarOutputStream jos,
java.util.Set<java.lang.String> packages)
throws java.io.IOException
jos - The JarOutputStream to write the index to.packages - The set of package names to include in the index.java.io.IOException - Exception that can be thrown by the JarOutputStream object, not handled here.private static void createJarHelper(java.io.File source,
java.util.jar.JarOutputStream target,
java.lang.Integer nameSubstringIndex,
java.util.Set<java.lang.String> packages)
throws java.io.IOException
source - The class file or directory containing class files that will be added to the jar.target - The stream used to add files to the jar.nameSubstringIndex - How much of the sources path name to skip when adding the new entry to the jar.packages - The set to collect package names.java.io.IOException - Exception that can be thrown by the JarOutputStream object, not handled here.private static void handleDmoBufInterface(java.lang.String dmoBufBinaryName,
java.lang.String classDestination)
dmoBufBinaryName - The name of the DMO buffer interface, with dot separators between packages.classDestination - The folder where the .class file and it's packages will be created.private static void handleDmoInterface(java.lang.String dmoBinaryName,
java.lang.String classDestination)
dmoBinaryName - The name of a DMO buffer interface, with dot separators between packages.classDestination - The folder where the .class file and it's packages will be created.private static boolean isDmoBufInterface(java.lang.String fileName,
java.lang.String schemaDirectory)
fileName - The name of a class file, with the extension.schemaDirectory - The name of the schema directory that contains this class file.private static boolean isDmoInterface(java.lang.String fileName,
java.lang.String schemaDirectory)
fileName - The name of a class file, with the extension.schemaDirectory - The name of the schema directory that contains this class file.private static DmoClass generateImplementationDmo(java.lang.Class<? extends DataModelObject> dmoIface)
DmoClass to create and provide the DMO class object.dmoIface - The class of a DMO interface for which we generate an implementation class.private static void writeProxyCacheToDisk()
proxyCache map object,
meant to be retrieved by ProxyFactory at server runtime.private static void writeClassToDisk(java.lang.String internalName,
byte[] code,
java.lang.String destinationFolder)
internalName - The internal name of the class to write to file, containing the class name and package
with slash separators.code - The bytecode of the class that needs to be written to file.destinationFolder - The folder path where the new .class file will be saved.
Additional directories will be created for the packages that appear in the internalName argument.