Class AS400ClassPathOptimizer

  • java.lang.Object

  • public class AS400ClassPathOptimizer
    extends java.lang.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:" +
                    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
                    System.exit( 0 );
    Glen Marchesani
    • Constructor Detail

      • AS400ClassPathOptimizer

        public AS400ClassPathOptimizer()
      • AS400ClassPathOptimizer

        public AS400ClassPathOptimizer(AS400 as400)
      • AS400ClassPathOptimizer

        public AS400ClassPathOptimizer(AS400 as400,
                               java.lang.String classpath)
    • Method Detail

      • setClasspath

        public void setClasspath(java.lang.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 java.lang.String getLicensedInternalCodeOptions()
      • setLicensedInternalCodeOptions

        public void setLicensedInternalCodeOptions(java.lang.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( out)
      • optimize

        public void optimize()
                      throws java.lang.Exception
      • run

        public void run()
                 throws java.lang.Exception