com.ibm.as400.util
Class AS400ClassPathOptimizer

java.lang.Object
  extended bycom.ibm.as400.util.AS400ClassPathOptimizer

public class AS400ClassPathOptimizer
extends Object

This class is used to optimize an AS400 classpath using the CRTJVAPGM command. The original need was a software update/install procedure that needed to make sure all the classes in the classpath were optimized at the appropriate levels. We needed something that didn't recompile classes if they were already optimized, as our app was large (over 10MB) and it could take several hours and LOTS of cpu to optimize at level 40. We needed something that did "touch up" optimizations. Here is an example of how you can use it...

	public static void main(String args[]) throws Exception {

		String classpath = "/home/toronto/DEV/:/home/toronto/DEV/server.jar:" +
      	"/home/toronto/DEV/preprocessor.jar:/qibm/ProdData/HTTP/Public/jt400/lib/jt400.jar:" +
			"/qibm/proddata/java400/jt400ntv.jar:/home/toronto/DEV/collections.jar:" +
			"/home/toronto/DEV/antlr.jar:/home/toronto/DEV/crimson.jar:/home/toronto/DEV/xalan.jar:" +
			"/home/toronto/DEV/jaxp.jar:";

		AS400 as400 = new AS400( "mysystem", "user", "password" );
		AS400ClassPathOptimizer cpo = new AS400ClassPathOptimizer( as400, classpath );

		cpo.setOptimizationLevel( cpo.LEVEL_40 );
		cpo.setLicensedInternalCodeOptions( cpo.LICOPT_NOPRERESOLVEEXTREF );

		// submit the optimizations and exit since this could take some time
		cpo.setOptimizeInParallel( true );

		// so we can see the details of what it is doing...
		cpo.setOutputLog( System.out );

		// submit the optimizations
		cpo.optimize();

		System.exit( 0 );
	}
 

Author:
Glen Marchesani

Field Summary
static int LEVEL_10
           
static int LEVEL_20
           
static int LEVEL_30
           
static int LEVEL_40
           
static String LICOPT_NOPRERESOLVEEXTREF
           
static int NO_OPTIMIZATION
           
 
Constructor Summary
AS400ClassPathOptimizer()
           
AS400ClassPathOptimizer(AS400 as400)
           
AS400ClassPathOptimizer(AS400 as400, String classpath)
           
 
Method Summary
 String getLicensedInternalCodeOptions()
           
 boolean isOptimizeInParallel()
           
 boolean isWaitForOptimizations()
           
 void optimize()
           
 void run()
           
 void setAS400(AS400 as400)
           
 void setClasspath(String classpath)
          set the AS400 classpath to opimize.
 void setLicensedInternalCodeOptions(String s)
          Sets the value to use on the CRTJVAPGM LICOPT parameter
 void setOptimizationLevel(int level)
          Set the level to optimize classes to.
 void setOptimizeDirectories(boolean b)
           
 void setOptimizeInParallel(boolean s)
          if true run each CRTJVAPGM in a separate job.
 void setOutputLog(PrintStream out)
           
 void setWaitForOptimizations(boolean s)
          if true the optimize() method will wait for all CRTJVAPGM commands to end before it returns.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NO_OPTIMIZATION

public static final int NO_OPTIMIZATION
See Also:
Constant Field Values

LEVEL_10

public static final int LEVEL_10
See Also:
Constant Field Values

LEVEL_20

public static final int LEVEL_20
See Also:
Constant Field Values

LEVEL_30

public static final int LEVEL_30
See Also:
Constant Field Values

LEVEL_40

public static final int LEVEL_40
See Also:
Constant Field Values

LICOPT_NOPRERESOLVEEXTREF

public static final String LICOPT_NOPRERESOLVEEXTREF
See Also:
Constant Field Values
Constructor Detail

AS400ClassPathOptimizer

public AS400ClassPathOptimizer()

AS400ClassPathOptimizer

public AS400ClassPathOptimizer(AS400 as400)

AS400ClassPathOptimizer

public AS400ClassPathOptimizer(AS400 as400,
                               String classpath)
Method Detail

setClasspath

public void setClasspath(String classpath)
set the AS400 classpath to opimize. valid path separators are ; and :


setAS400

public void setAS400(AS400 as400)

setWaitForOptimizations

public void setWaitForOptimizations(boolean s)
if true the optimize() method will wait for all CRTJVAPGM commands to end before it returns. Otherwise


isWaitForOptimizations

public boolean isWaitForOptimizations()

setOptimizeInParallel

public void setOptimizeInParallel(boolean s)
if true run each CRTJVAPGM in a separate job. Using a value of true setting will ignore the "wait for optimizations" attribute. if false will run each CRTJVAPGM in serial waiting for the first to end before the next CRTJBAPGM is run.


setOptimizeDirectories

public void setOptimizeDirectories(boolean b)

isOptimizeInParallel

public boolean isOptimizeInParallel()

getLicensedInternalCodeOptions

public String getLicensedInternalCodeOptions()

setLicensedInternalCodeOptions

public void setLicensedInternalCodeOptions(String s)
Sets the value to use on the CRTJVAPGM LICOPT parameter


setOptimizationLevel

public void setOptimizationLevel(int level)
Set the level to optimize classes to. Note that if a class/jar/zip is currently optimized at say level 30 and you set this at level 20 then no optimization will be done. This is not the case for optimizing a directory. If you optimize a directory the whole directory will be reoptimized to the level set. This is due to performance of checking the optimization level of say 400 classes in a directory versus making a single call to the CRTJVAPGM which. The single call to CRTJVAPGM (to optimize the entire directory) is almost always quicker than checking the 400 classes individually plus the time to optimize the classes individually.


setOutputLog

public void setOutputLog(PrintStream out)

optimize

public void optimize()
              throws Exception
Throws:
Exception

run

public void run()
         throws Exception
Throws:
Exception