KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > tools > verifier > tests > app > EARFileUsesClassPath


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23
24 /*
25  * EARFileUsesClassPath.java
26  *
27  * Created on August 30, 2004, 9:15 AM
28  */

29
30 package com.sun.enterprise.tools.verifier.tests.app;
31
32 import com.sun.enterprise.deployment.Application;
33 import com.sun.enterprise.tools.verifier.Result;
34 import java.io.IOException JavaDoc;
35 import java.util.jar.Attributes JavaDoc;
36 import java.util.jar.Manifest JavaDoc;
37
38 /**
39  *
40  * @author ss141213
41  * An ear file should not contain Class-Path reference.
42  * This as per J2EE 1.4 spec section#8.2. Contents from spec is given below...
43  * A JAR format file (such as a .jar file, .war file, or .rar file)
44  * can reference a .jar file by naming the referenced .jar file in a Class-Path header
45  * in the referencing Jar file s Manifest file.
46  */

47
48 public class EARFileUsesClassPath extends ApplicationTest implements AppCheck {
49     public Result check(Application descriptor){
50         Result result = getInitializedResult();
51         result.setStatus(Result.FAILED);
52         try{
53             Manifest JavaDoc manifest=getVerifierContext().getAbstractArchive().getManifest();
54             String JavaDoc cp=null;
55             if (manifest!=null)
56                 cp=manifest.getMainAttributes().getValue(Attributes.Name.CLASS_PATH);
57             if(cp==null || cp.length()==0){
58                 result.passed(smh.getLocalString(getClass().getName() + ".passed",
59                     "Manifest file of this EAR file does not contain any Class-Path entry."));
60             }else{
61                 result.failed(smh.getLocalString(getClass().getName() + ".failed",
62                     "Manifest file of this EAR file contains [ {0} ] as the Class-Path entry.",
63                     new Object JavaDoc[]{cp}));
64             }
65         }catch(IOException JavaDoc e){
66             result.addErrorDetails(e.toString());
67         }
68         return result;
69     }
70 }
71
Popular Tags