org.apache.jdo.enhancer
Class EnhancerMain

java.lang.Object
  extended byorg.apache.jdo.impl.enhancer.util.Assertion
      extended byorg.apache.jdo.impl.enhancer.util.Support
          extended byorg.apache.jdo.impl.enhancer.LogSupport
              extended byorg.apache.jdo.impl.enhancer.GenericMain
                  extended byorg.apache.jdo.impl.enhancer.ClassArgMain
                      extended byorg.apache.jdo.impl.enhancer.JdoMetaMain
                          extended byorg.apache.jdo.enhancer.EnhancerMain

public class EnhancerMain
extends JdoMetaMain

JDO command line enhancer.

Author:
Martin Zaun

Field Summary
protected  ClassFileEnhancer enhancer
          The byte code enhancer.
protected  EnhancerOptions options
          The options and arguments.
 
Fields inherited from class org.apache.jdo.impl.enhancer.JdoMetaMain
jdoMeta
 
Fields inherited from class org.apache.jdo.impl.enhancer.ClassArgMain
classes
 
Fields inherited from class org.apache.jdo.impl.enhancer.GenericMain
err, INTERNAL_ERROR, OK, out, USAGE_ERROR, USER_EXCEPTION
 
Fields inherited from class org.apache.jdo.impl.enhancer.util.Support
timer
 
Constructor Summary
EnhancerMain(java.io.PrintWriter out, java.io.PrintWriter err)
          Creates an instance.
EnhancerMain(java.io.PrintWriter out, java.io.PrintWriter err, EnhancerOptions options)
          Creates an instance.
 
Method Summary
private  void closeOutputStream(java.io.OutputStream out)
          Closes an output stream.
private  java.io.File createArchiveOutputFile(java.lang.String archiveFileName)
          Creates a file object that represents the output archive file for a given archive file to enhance.
private  void createOutputFile(boolean enhanced, java.lang.String fileName, java.io.File temp)
          Creates the output file for an enhanced class- or archive file.
private  void enhanceArchiveFile(java.lang.String fileName)
          Enhances a archive file.
private  void enhanceClassFile(java.io.InputStream in)
          Enhances a classfile.
private  int enhanceInputFiles(java.util.List classNames, java.util.List classFileNames, java.util.List archiveFileNames)
          Enhances all files entered in the command line.
protected  void init()
          Initializes all components.
static void main(java.lang.String[] args)
          Runs this class
protected  int process()
          Run the enhancer.
 
Methods inherited from class org.apache.jdo.impl.enhancer.JdoMetaMain
initJdoMetaData
 
Methods inherited from class org.apache.jdo.impl.enhancer.ClassArgMain
closeInputStream, getClassFileName, initClassLocator, openClassInputStream, openFileInputStream
 
Methods inherited from class org.apache.jdo.impl.enhancer.GenericMain
flush, print, println, println, printlnErr, printlnErr, printlnErr, printlnErr, run
 
Methods inherited from class org.apache.jdo.impl.enhancer.util.Support
getI18N, getI18N, getI18N, getI18N, getI18N, getI18N
 
Methods inherited from class org.apache.jdo.impl.enhancer.util.Assertion
affirm, affirm, affirm, affirm
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

options

protected EnhancerOptions options
The options and arguments.


enhancer

protected ClassFileEnhancer enhancer
The byte code enhancer.

Constructor Detail

EnhancerMain

public EnhancerMain(java.io.PrintWriter out,
                    java.io.PrintWriter err)
Creates an instance.


EnhancerMain

public EnhancerMain(java.io.PrintWriter out,
                    java.io.PrintWriter err,
                    EnhancerOptions options)
Creates an instance.

Method Detail

enhanceInputFiles

private int enhanceInputFiles(java.util.List classNames,
                              java.util.List classFileNames,
                              java.util.List archiveFileNames)
Enhances all files entered in the command line.

Parameters:
classNames - List of class names.
classFileNames - List of class file names.
archiveFileNames - List of archive file names.

enhanceClassFile

private void enhanceClassFile(java.io.InputStream in)
                       throws java.io.IOException,
                              EnhancerUserException,
                              EnhancerFatalError
Enhances a classfile.

Parameters:
in - The input stream of the classfile.
Throws:
java.io.IOException
EnhancerUserException
EnhancerFatalError

enhanceArchiveFile

private void enhanceArchiveFile(java.lang.String fileName)
                         throws java.io.IOException,
                                EnhancerUserException,
                                EnhancerFatalError
Enhances a archive file.

Parameters:
fileName - The filename of the archive file.
Throws:
java.io.IOException
EnhancerUserException
EnhancerFatalError

createArchiveOutputFile

private java.io.File createArchiveOutputFile(java.lang.String archiveFileName)
Creates a file object that represents the output archive file for a given archive file to enhance.

Parameters:
archiveFileName - the input archive file name
Returns:
the output archive file

createOutputFile

private void createOutputFile(boolean enhanced,
                              java.lang.String fileName,
                              java.io.File temp)
                       throws java.io.IOException
Creates the output file for an enhanced class- or archive file. If the enhanced file is written back depends on the command line options.

Parameters:
enhanced - Has the input file been enhanced?
fileName - The name of the output file.
temp - The temp file, the output is written to.
Throws:
java.io.IOException - If the file could not be created.

closeOutputStream

private void closeOutputStream(java.io.OutputStream out)
Closes an output stream.

Parameters:
out - the output stream

init

protected void init()
             throws EnhancerFatalError,
                    EnhancerUserException
Initializes all components.

Overrides:
init in class JdoMetaMain
Throws:
EnhancerFatalError
EnhancerUserException

process

protected int process()
Run the enhancer.

Overrides:
process in class GenericMain

main

public static void main(java.lang.String[] args)
Runs this class