FileDocCategorySizeDatePackage
BundledOptPkgHasDependencies.javaAPI DocGlassfish v2 API4374Fri May 04 22:34:08 BST 2007com.sun.enterprise.tools.verifier.tests.util

BundledOptPkgHasDependencies

public class BundledOptPkgHasDependencies extends Object
author
ss141213 This as per J2EE 1.4 spec section#8.2. Contents from spec is given below... Only Jar format files containing class files or resources to be loaded directly by a standard ClassLoader should be the target of a Class-Path reference; such files are always named with a .jar extension. Top level Jar files that are processed by a deployment tool should not contain Class-Path entries; such entries would, by definition, reference other files external to the deployment unit. A deployment tool is not required to process such external references.

Fields Summary
Constructors Summary
Methods Summary
public static voidtest(java.lang.String explodedJarPath, com.sun.enterprise.tools.verifier.Result result)

        try{
            boolean failed=false;
            Manifest manifest=new Manifest(new FileInputStream(new File(explodedJarPath+File.separator+JarFile.MANIFEST_NAME)));
            String depClassPath=manifest.getMainAttributes().getValue(Attributes.Name.CLASS_PATH);
            if(depClassPath!=null){
                for(StringTokenizer st=new StringTokenizer(depClassPath);st.hasMoreTokens();){
                    String entry=st.nextToken();
                    String entryPath=new File(explodedJarPath).getParent()+File.separator+entry;
                    File bundledOptPkg=new File(entryPath);
                    if(!bundledOptPkg.isDirectory()){
                        Manifest bundledManifest=new JarFile(bundledOptPkg).getManifest();
                        String bundledCP=bundledManifest.getMainAttributes().getValue(Attributes.Name.CLASS_PATH);
                        if(bundledCP!=null && bundledCP.length()!=0){
                            failed=true;
                            result.failed(entry + " contains Class-Path in it's manifest.");
                        }
                    }
                }
            }//if
            if(!failed){
                result.setStatus(Result.PASSED);
            }
        }catch(Exception e){
            result.failed(e.toString());
        }