FileDocCategorySizeDatePackage
AVKTasks.javaAPI DocGlassfish v2 API9318Fri May 04 22:34:20 BST 2007org.apache.tools.ant.taskdefs.optional.sun.verification

AVKTasks

public class AVKTasks extends org.apache.tools.ant.Task
This is the base class of all the custom ant tasks. It has the common code required by the tasks.
author
Vikas Awasthi.

Fields Summary
protected String
jvmArgs
protected boolean
failOnError
protected String
j2ee_home
protected String
avk_home
protected String
java_home
protected String
resultDir
protected org.apache.tools.ant.taskdefs.Echo
echo
Constructors Summary
public AVKTasks()


      
        java_home = System.getProperty("java.home")+"/../";//"java.home returns jdk/jre, hence ....
    
Methods Summary
protected voidcleanDir(java.lang.String resultDir)

        Delete delete = (Delete)getProject().createTask("delete");
        delete.setDir(new File(resultDir));
        delete.setQuiet(true);
        delete.setIncludeEmptyDirs(true);
        delete.execute();
    
protected org.apache.tools.ant.types.PathconstructJVMPath()

        StringBuffer classPathBuffer = new StringBuffer();
        classPathBuffer.append(avk_home+"/lib/javke.jar:");
        classPathBuffer.append(j2ee_home+"/lib/appserv-rt.jar:");
        classPathBuffer.append(j2ee_home+"/lib/javaee.jar:");
        classPathBuffer.append(j2ee_home+"/lib/appserv-ext.jar:");
        classPathBuffer.append(j2ee_home+"/lib/appserv-cmp.jar:");
        classPathBuffer.append(j2ee_home+"/lib/appserv-admin.jar:");
        classPathBuffer.append(j2ee_home+"/lib/install/applications/jmsra/imqjmsra.jar:");
        classPathBuffer.append(j2ee_home+"/lib/jhall.jar:");

//        classPathBuffer.append(Path.systemClasspath);
        return new Path(getProject(),classPathBuffer.toString());
    
private voidcreateEchoTask()

        echo = (Echo)getProject().createTask("echo");
    
protected org.apache.tools.ant.taskdefs.JavacreateJavaTask()
Create a java task with classpath and JVM arguments set

return
Java task

        Java java = (Java)project.createTask("java");
        java.setClasspath(constructJVMPath());
        if(jvmArgs == null)
            jvmArgs = "-Xss512k -Xms128m -Xmx256m";
        setCommonVMSettings(java);
        setSystemProperties(java);
        return java;
    
protected voidcreateResultDir(java.lang.String dirName)
creates the directory dirName ( static, scan or translate) in the "avk_home/reporttool" directory.

param
dirName

        if(resultDir == null) 
            resultDir = avk_home+File.separator + "reporttool";
        resultDir = resultDir + File.separator +dirName;
        File file = new File(resultDir);
        try {
            cleanDir(resultDir);
            if ( file.getParent() !=null) {
                (new File (file.getParent())).mkdirs();
                file.mkdir();
            }
        }catch( Exception e) {
            throw new BuildException("Could not create output directory "+resultDir);
        }
    
protected voidgetInstallHomes()

//      create the echo task that displays the messages        
        createEchoTask();        

        if(avk_home == null)
            try {
                avk_home = new File(getProject().getProperty("avk.home")).getCanonicalPath();
            } catch (IOException e) {//we donot expect this exception. Continue with absolutePath anyway
                avk_home = new File(getProject().getProperty("avk.home")).getAbsolutePath();
            }

        try {
            File avkENV = new File(avk_home+File.separatorChar+"config", "avkenv.conf");
            Properties props = new Properties();
            props.load(new FileInputStream(avkENV));
            if(j2ee_home == null)
                try {
                    j2ee_home = new File(props.getProperty("J2EE_HOME")).getCanonicalPath();
                } catch (IOException e) {//we donot expect this exception. Continue with absolutePath anyway
                    j2ee_home = new File(props.getProperty("J2EE_HOME")).getAbsolutePath();
                }
        } catch (IOException e) {
            echo.setMessage("Problem in getting J2EE_HOME. Please ensure that avkenv.conf " +
                    "is kept in the config directory. "+e.getMessage());
            echo.execute();
        }
    
protected voidsetArgs(org.apache.tools.ant.taskdefs.Java java, java.lang.String[] args)

        for (int i = 0; i < args.length; i++) {
            java.createArg().setLine(args[i] + " ");
        }
    
protected voidsetCommonVMSettings(org.apache.tools.ant.taskdefs.Java java)

        java.setFork(true);
        java.setFailonerror(failOnError);
//        java.setDir(new File(avk_home, "bin"));
        java.createJvmarg().setLine(jvmArgs);
    
public voidsetFailOnError(boolean failOnError)

        this.failOnError = failOnError;
    
public voidsetJvmArgs(java.lang.String jvmArgs)

        this.jvmArgs = jvmArgs;
    
protected voidsetResultDir(java.lang.String resultDir)

        this.resultDir = resultDir.trim();
    
protected voidsetSystemProperties(org.apache.tools.ant.taskdefs.Java java)

        Environment.Variable j2ee_app_home = new Environment.Variable();
        j2ee_app_home.setKey("j2ee.appverification.home");
        j2ee_app_home.setValue(avk_home);
        java.addSysproperty(j2ee_app_home);

        Environment.Variable java_ext_dir = new Environment.Variable();
        java_ext_dir.setKey("java.ext.dirs");
        java_ext_dir.setValue(System.getProperty("java.ext.dirs") +
                              File.pathSeparator + j2ee_home +
                              File.separator + "domains" +
                              File.separator + "domain1" +
                              File.separator + "lib" +
                              File.separator + "ext");
        java.addSysproperty(java_ext_dir);

        Environment.Variable installRoot = new Environment.Variable();
        installRoot.setKey("com.sun.aas.installRoot");
        installRoot.setValue(j2ee_home);
        java.addSysproperty(installRoot);

	// following 2 are required for the migration code
        Environment.Variable j2eeHome = new Environment.Variable();
        j2eeHome.setKey("j2ee.home");
        j2eeHome.setValue(j2ee_home);
        java.addSysproperty(j2eeHome);

        Environment.Variable javaHome = new Environment.Variable();
        javaHome.setKey("as.java");
        javaHome.setValue(java_home);
        java.addSysproperty(javaHome);

        Environment.Variable endorsedDir = new Environment.Variable();
        endorsedDir.setKey("java.endorsed.dirs");
        endorsedDir.setValue(j2ee_home+File.separator + "lib" + File.separator + "endorsed");
        java.addSysproperty(endorsedDir);

        Environment.Variable xsl = new Environment.Variable();
        xsl.setKey("com.sun.aas.verifier.xsl");
        xsl.setValue(avk_home + File.separator + "xsl");
        java.addSysproperty(xsl);