de.enough.polish.postcompile
Class PostCompiler

java.lang.Object
  extended by de.enough.polish.Extension
      extended by de.enough.polish.postcompile.PostCompiler
Direct Known Subclasses:
AntCallPostCompiler

public abstract class PostCompiler
extends Extension

Is the base class for any custom post compilers.

Custom post compilers can modify the bytecode of an application before the application is obfuscated and then preverified.

Copyright Enough Software 2005

 history
        24-Mar-2005 - rob creation
 

Author:
Robert Virkus, j2mepolish@enough.de

Field Summary
 
Fields inherited from class de.enough.polish.Extension
antProject, autoStartCondition, environment, extensionDefinition, extensionManager, extensionSetting, extensionTypeDefinition, isBuildStarted
 
Constructor Summary
protected PostCompiler()
          Creates a new instance of a custom post compiler.
 
Method Summary
 void execute(Device device, Locale locale, Environment env)
          Executes this extension.
protected  ArrayList findFiles(File classesDir, FilenameFilter filter)
          Helper method to find all files to post compile in a given directory and all its subdirectories.
static PostCompiler getInstance(PostCompilerSetting postCompilerSetting, ExtensionManager manager, Environment environment)
          Retrieves a new PostCompiler
 PostCompilerSetting getSetting()
          Retrieves the settings for this post compiler.
abstract  void postCompile(File classesDir, Device device)
          Postcompiles the project for the given target device.
 String verifyBootClassPath(Device device, String bootClassPath)
          Subclasses can override this method for setting a different bootclasspath for the current device.
 String verifyClassPath(Device device, String classPath)
          Subclasses can override this method for setting a different classpath for the current device.
 
Methods inherited from class de.enough.polish.Extension
configure, executeAntTarget, executeAntTarget, finalize, getAntProject, getAutoStartCondition, getEnvironment, getExtensionDefinition, getExtensionSetting, getInstance, getParameterValue, getType, init, initialize, isConditionFulfilled, notifyBuildEnd, notifyBuildStart
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PostCompiler

protected PostCompiler()
Creates a new instance of a custom post compiler.

Method Detail

getInstance

public static PostCompiler getInstance(PostCompilerSetting postCompilerSetting,
                                       ExtensionManager manager,
                                       Environment environment)
                                throws BuildException
Retrieves a new PostCompiler

Parameters:
postCompilerSetting - the ant settings
manager - the extension manager
environment - the environment settings
Returns:
a new instance of a post compiler
Throws:
BuildException - when the class could not be loaded or initialized

execute

public void execute(Device device,
                    Locale locale,
                    Environment env)
             throws BuildException
Description copied from class: Extension
Executes this extension. Not all extension types are executed.

Specified by:
execute in class Extension
Parameters:
device - the current device
locale - the current locale, can be null
env - the environment/configuration
Throws:
BuildException - when the execution failed

postCompile

public abstract void postCompile(File classesDir,
                                 Device device)
                          throws BuildException
Postcompiles the project for the given target device.

Parameters:
classesDir - the directory that contains all compiled classes
device - the current target device
Throws:
BuildException - when post-compiling fails

verifyBootClassPath

public String verifyBootClassPath(Device device,
                                  String bootClassPath)
Subclasses can override this method for setting a different bootclasspath for the current device. This method is called before the application is compiled. The default implementation returns the specified bootclasspath. When several postcompilers try to change this path it can result in complications.

Parameters:
device - the current device
bootClassPath - the current bootclasspath
Returns:
the appropriate bootclasspath for the current device, usually the same that has been given.

verifyClassPath

public String verifyClassPath(Device device,
                              String classPath)
Subclasses can override this method for setting a different classpath for the current device. This method is called before the application is compiled. The default implementation returns the specified classpath.

Parameters:
device - the current device
classPath - the current classpath
Returns:
the appropriate classpath for the current device, usually the same that has been given.

getSetting

public PostCompilerSetting getSetting()
Retrieves the settings for this post compiler.

Returns:
the settings

findFiles

protected ArrayList findFiles(File classesDir,
                              FilenameFilter filter)
Helper method to find all files to post compile in a given directory and all its subdirectories.

Parameters:
classesDir - the directory that contains all compiled classes
filter - the filter to apply on the file names, or null
Returns:
an array list of file names