KickJava   Java API By Example, From Geeks To Geeks.

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


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  * OptPkgDependencySatisfied.java
26  *
27  * Created on August 30, 2004, 9:39 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 com.sun.enterprise.tools.verifier.apiscan.packaging.ExtensionRef;
35 import java.io.File JavaDoc;
36 import java.io.IOException JavaDoc;
37 import java.util.ArrayList JavaDoc;
38 import java.util.Iterator JavaDoc;
39
40 /**
41  *
42  * @author ss141213
43  * This checks to see that all the installed optional packages that this ear depends on are indeed
44  * available in the system or not.
45  */

46 public class OptPkgDependencySatisfied extends ApplicationTest implements AppCheck {
47     public Result check(Application descriptor){
48         Result result = getInitializedResult();
49         try{
50             String JavaDoc earURI=getAbstractArchiveUri(descriptor);
51             com.sun.enterprise.tools.verifier.apiscan.packaging.Archive jar=new com.sun.enterprise.tools.verifier.apiscan.packaging.Archive(new File JavaDoc(earURI));
52             //See we do not care about bundled opt packages, as for an ear file
53
//there should not be any Class-Path entry.
54
com.sun.enterprise.tools.verifier.apiscan.packaging.ExtensionRef[] extRefs=jar.getExtensionRefs();
55             com.sun.enterprise.tools.verifier.apiscan.packaging.Archive[] allOptPkgs=com.sun.enterprise.tools.verifier.apiscan.packaging.Archive.getAllOptPkgsInstalledInJRE();
56             ArrayList JavaDoc<ExtensionRef> notFounds=new ArrayList JavaDoc<ExtensionRef>();
57             for(int i=0;i<extRefs.length;++i){
58                 ExtensionRef ref=extRefs[i];
59                 boolean found=false;
60                 for(int j=0;j<allOptPkgs.length;++j){
61                     if(ref.isSatisfiedBy(allOptPkgs[j])) {
62                         found=true;
63                         break;
64                     }
65                 }
66                 if(!found) notFounds.add(ref);
67             }//for
68

69             if(notFounds.isEmpty()){
70                 result.passed(smh.getLocalString(getClass().getName() + ".passed",
71                                              "All opt package dependency satisfied for this ear file."));
72                 result.passed("");
73             }else{
74                 result.failed(smh.getLocalString(getClass().getName() + ".failed","Some dependencies could not be satisfied for this ear file. See info below..."));
75                 for(Iterator JavaDoc i=notFounds.iterator();i.hasNext();){
76                     result.addErrorDetails(i.next().toString());
77                 }
78             }
79         }catch(IOException JavaDoc e){
80             result.failed(e.toString());
81         }
82         return result;
83     }
84 }
85
Popular Tags