FileDocCategorySizeDatePackage
Verifier.javaAPI DocGlassfish v2 API9888Fri May 04 22:33:24 BST 2007com.sun.enterprise.tools.verifier

Verifier

public class Verifier extends Object
This class is the main class to invoke the verification process. It is directly called by the scripts in AVK and verifier in appserver. The deployment backend invokes verifier in a separate process. Deploytool GUI invokes verifier by calling the verify() and generateReports() APIs.

Fields Summary
private static boolean
debug
private static Logger
logger
private FrameworkContext
frameworkContext
contains arguments data. It is used throughout the verification framework
Constructors Summary
public Verifier(String[] args)
Constructor that does the initialization. It parses and validates the arguments and creates the frameworkContext that is used throughout the verification framework.

param
args



                                 
       
        StringManagerHelper.setLocalStringsManager(this.getClass());
        frameworkContext = new Initializer(args).getFrameworkContext();
    
public Verifier()
This constructor is called by the deployment backend. The invocation of this method is in the server's process.

        StringManagerHelper.setLocalStringsManager(this.getClass());
        frameworkContext = new FrameworkContext();
        frameworkContext.setUseTimeStamp(true);
        frameworkContext.setOutputDirName(System.getProperty("com.sun.aas.instanceRoot") + // NOI18N
                                                            File.separator +
                                                            "logs" + // NOI18N
                                                            File.separator + 
                                                            "verifier-results"); // NOI18N
    
Methods Summary
public static voiddebug(java.lang.Throwable t)
debug messages are logged here.

param
t

        logger.log(Level.FINEST, "Exception occurred", t);
    
public voidgenerateReports()
It generates the reports using the ResultManager

throws
IOException

        new ReportHandler(frameworkContext).generateAllReports();
    
public static booleanisDebug()
checks if verifier is running in debug mode

return
debug status

        return debug;
    
public static voidmain(java.lang.String[] args)
Main verifier method

param
args Arguments to pass to verifier returns 0 if successfully verified with ZERO failures & ZERO errors. returns failure_count+error_count otherwise.

        Verifier verifier = new Verifier(args);
        if (verifier.frameworkContext.isUsingGui()) {
            MainFrame mf = new MainFrame(
                    verifier.frameworkContext.getJarFileName(), true, verifier);
            mf.setSize(800, 600);
            mf.setVisible(true);
        } else {
            LocalStringManagerImpl smh = StringManagerHelper.getLocalStringsManager();
            try {
                verifier.verify();
            } catch (Exception e) {
                LogRecord logRecord = new LogRecord(Level.SEVERE,
                        smh.getLocalString(
                                verifier.getClass().getName() +
                                ".verifyFailed", // NOI18N
                                "Could not verify successfully.")); // NOI18N
                logRecord.setThrown(e);
                verifier.frameworkContext.getResultManager().log(logRecord);
            }
            verifier.generateReports();
            int failedCount = verifier.frameworkContext.getResultManager()
                    .getFailedCount() +
                    verifier.frameworkContext.getResultManager().getErrorCount();
            if (failedCount != 0)
                System.exit(failedCount);
        }
    
private ResultManagerverify()
This method does the verification by running all the verifier tests

return
ResultManager that contains all the test results.
throws
IOException

        VerificationHandler verificationHandler = 
                        new VerificationHandler(frameworkContext);
        ResultManager resultManager;
        try {
            resultManager = verificationHandler.verifyArchive();
        } finally {
            verificationHandler.cleanup();
        }
        return resultManager;
    
public ResultManagerverify(java.lang.String jarFile)

param
jarFile This method is called from gui MainPanel to run verifier on selected archive
return
ResultManager Object containing all test results
throws
IOException

        frameworkContext.setJarFileName(jarFile);
        return verify();
    
public intverify(com.sun.enterprise.deployment.Application application, com.sun.enterprise.deployment.deploy.shared.AbstractArchive abstractArchive, java.util.List classPath, java.io.File jspOutDir)
Call from deployment backend. This call is in the appserver process. Verifier will run in appserver mode for this invocation. If parameter application is null then this api is equivalent to invoking a standalone verifier. Parameter abstractArchive must not be null.

return
status of the invocation. A non zero value will denote a failure.
throws
IOException

        boolean originalBoundsChecking = Descriptor.isBoundsChecking();
        Descriptor.setBoundsChecking(false);
        ResultManager rmanager=null;
        frameworkContext.setJspOutDir(jspOutDir);
        frameworkContext.setIsBackend(true);
        VerificationHandler verificationHandler = null;
        try {
            if(application == null) { //can be a standalone connector deployment
                frameworkContext.setJarFileName(abstractArchive.getArchiveUri());
                verificationHandler = new VerificationHandler(frameworkContext); 
            } else
                verificationHandler = new VerificationHandler(frameworkContext,
                                                              application,
                                                              abstractArchive,
                                                              classPath);
            rmanager = verificationHandler.verifyArchive();
        } catch(Exception e) {
            LocalStringManagerImpl smh = StringManagerHelper.getLocalStringsManager();
            LogRecord logRecord = 
                    new LogRecord(Level.SEVERE,
                                 smh.getLocalString(getClass().getName() +
                                                   ".verifyFailed", // NOI18N
                                                   "Could not verify successfully.")); // NOI18N
            logRecord.setThrown(e);
            frameworkContext.getResultManager().log(logRecord);
        } finally { // restore the original values
            Descriptor.setBoundsChecking(originalBoundsChecking);
            if(verificationHandler!=null)
                verificationHandler.cleanup();
        }
        generateReports();
        return rmanager.getErrorCount() + rmanager.getFailedCount();