org.quattor.pan
Class Compiler

java.lang.Object
  extended by org.quattor.pan.Compiler

public class Compiler
extends java.lang.Object

Primary java interface for invoking the pan compiler. All external methods of running the compiler (ant tasks, scripts, etc.) should make use of an instance of this class. Instances of this class are thread-safe (the underlying implementation uses threads in the compilation and build of machine templates). However, the process method should only be invoked only by a single thread; the method is synchronized to ensure this. The submit method should be called only by tasks created internally by the compiler.

Author:
loomis

Nested Class Summary
static class Compiler.ThrowableComparator
          This class orders Throwables allowing duplicates to be removed.
 
Field Summary
 CompilerOptions options
          This holds a reference to the compiler options.
static java.lang.String version
          The version of this compiler.
 
Constructor Summary
Compiler(CompilerOptions options, java.util.List<java.lang.String> objectNames, java.util.Collection<java.io.File> tplFiles)
          Create a compiler object with the given options and that will process the given templates (either by name or absolute path).
 
Method Summary
 void ensureMinimumBuildThreadLimit(int minLimit)
          Ensures that the number of threads in the build pool is at least as large as the number given.
 BuildCache getBuildCache()
          Returns a reference to objects (machine profiles) which have already been built.
 CompileCache getCompileCache()
          Returns a reference to the compile cache used to store compiled templates.
 SourceRepository getSourceRepository()
           
 Valid1Cache getValid1Cache()
           
 Valid2Cache getValid2Cache()
           
static void main(java.lang.String[] args)
          Extracts the version of the compiler and prints the value on the standard output.
 CompilerResults process()
          Process the templates referenced by the CompilerOptions object used to initialize this instance.
static CompilerResults run(CompilerOptions options, java.util.List<java.lang.String> objectNames, java.util.Collection<java.io.File> tplFiles)
          This is a convenience method which creates a compiler and then invokes the process method.
 void submit(Task<? extends TaskResult> task)
          Submits a task to one of the compiler's task queues for processing.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

version

public static final java.lang.String version
The version of this compiler.


options

public final CompilerOptions options
This holds a reference to the compiler options. The options are immutable and hence visible to all threads.

Constructor Detail

Compiler

public Compiler(CompilerOptions options,
                java.util.List<java.lang.String> objectNames,
                java.util.Collection<java.io.File> tplFiles)
Create a compiler object with the given options and that will process the given templates (either by name or absolute path).

Parameters:
options - compiler options to use for the created compiler
objectNames - template names to compile/build; these will be looked-up on the load path
tplFiles - absolute file names of templates to process
Method Detail

run

public static CompilerResults run(CompilerOptions options,
                                  java.util.List<java.lang.String> objectNames,
                                  java.util.Collection<java.io.File> tplFiles)
This is a convenience method which creates a compiler and then invokes the process method.

Parameters:
options - compiler options to use for the created compiler
objectNames - object template names to compile/build; these will be looked-up on the load path
tplFiles - absolute file names of templates to process
Returns:
results from the compilation/build

main

public static void main(java.lang.String[] args)
Extracts the version of the compiler and prints the value on the standard output. This is useful for packaging of the compiler.

Parameters:
args - all arguments are ignored

ensureMinimumBuildThreadLimit

public void ensureMinimumBuildThreadLimit(int minLimit)
Ensures that the number of threads in the build pool is at least as large as the number given. Because object templates can have dependencies on each other, it is possible to deadlock the compilation with a rigidly fixed build queue. To avoid this, allow the build queue limit to be increased.

Parameters:
minLimit - minimum build queue limit

process

public CompilerResults process()
Process the templates referenced by the CompilerOptions object used to initialize this instance. This will run through the complete compiling, building, and validation stages as requested. This method should only be invoked once per instance.

Returns:
the statistics of the compilation and any exceptions which were thrown

getCompileCache

public CompileCache getCompileCache()
Returns a reference to the compile cache used to store compiled templates.

Returns:
reference to compile cache

getBuildCache

public BuildCache getBuildCache()
Returns a reference to objects (machine profiles) which have already been built. This allows cross-validation of templates.

Returns:
reference to object cache

getValid1Cache

public Valid1Cache getValid1Cache()

getValid2Cache

public Valid2Cache getValid2Cache()

getSourceRepository

public SourceRepository getSourceRepository()

submit

public void submit(Task<? extends TaskResult> task)
Submits a task to one of the compiler's task queues for processing. Although public, this method should only be called by tasks started by the compiler itself.

Parameters:
task - task to run on one of the compiler's task queues


Copyright © 2011 Quattor. All Rights Reserved.