1 23 24 package com.sun.enterprise.tools.verifier.tests.util; 25 26 import java.io.File ; 27 import java.util.Map ; 28 import java.util.List ; 29 import java.util.Iterator ; 30 import java.util.StringTokenizer ; 31 import java.util.Stack ; 32 33 import com.sun.enterprise.tools.verifier.apiscan.classfile.ClosureCompiler; 34 import com.sun.enterprise.tools.verifier.StringManagerHelper; 35 import com.sun.enterprise.util.LocalStringManagerImpl; 36 37 40 public class WebArchiveLoadableHelper { 41 42 public static String getFailedResults(ClosureCompiler cc, File jspDir) { 43 StringBuilder sb = new StringBuilder (); 44 sb.append("\n"); 45 for (Object o : cc.getFailed().entrySet()) { 46 Map.Entry <String , List <String >> referencingPathToFailedList = 47 (Map.Entry <String , List <String >>)o; 48 LocalStringManagerImpl smh = StringManagerHelper.getLocalStringsManager(); 49 String classes = "Failed to find following classes:"; 50 if (smh != null) { 51 classes = smh.getLocalString( 52 WebArchiveLoadableHelper.class.getName() + ".classes", 53 classes); 54 } 55 sb.append(classes).append("\n["); 56 for (Iterator <String > iii = referencingPathToFailedList.getValue().iterator(); 57 iii.hasNext();) { 58 sb.append("\n\t").append(iii.next()); 59 if(iii.hasNext()) sb.append(","); 60 } 61 sb.append("\n]"); 62 String referencingPath = referencingPathToFailedList.getKey(); 63 if(referencingPath.length()==0) continue; String ref = "referenced in the following call stack :"; 65 String reference = "at"; 66 if (smh != null) { 67 ref = smh.getLocalString( 68 WebArchiveLoadableHelper.class.getName() + ".ref", 69 ref); 70 reference = smh.getLocalString( 71 WebArchiveLoadableHelper.class.getName() + ".reference", 72 reference); 73 } 74 StringTokenizer st = new StringTokenizer (referencingPath, File.separator); 75 Stack <String > referencingClassStack = new Stack <String >(); 76 boolean jspDirExists = (jspDir != null && jspDir.exists()); 77 final String jspPkgName = "org.apache.jsp."; 78 while(st.hasMoreTokens()) { 79 String className = st.nextToken(); 80 String fileName = className.replace(".", File.separator)+".class"; 84 if (jspDirExists && 85 className.startsWith(jspPkgName) && 86 new File (jspDir, fileName).exists()) { 87 StringBuilder jspName = new StringBuilder ( 88 className.substring(jspPkgName.length())); 89 int innerClassIndex = jspName.indexOf("$"); 90 if (innerClassIndex != -1) { 91 jspName = jspName.replace(innerClassIndex, jspName.length(), ""); 92 } 93 if(jspName.toString().endsWith("_jsp")) { 94 jspName = jspName.replace(jspName.lastIndexOf("_jsp"), 95 jspName.length(), ".jsp"); 96 } else if(jspName.toString().endsWith("_jspx")) { 97 jspName = jspName.replace(jspName.lastIndexOf("_jspx"), 98 jspName.length(), ".jspx"); 99 } 100 className = jspName.toString(); 101 } 102 referencingClassStack.push(className); 103 } 104 if ((!referencingClassStack.isEmpty())) 105 sb.append("\n\n"+ref); 106 while(!referencingClassStack.isEmpty()){ 107 sb.append("\n\t").append(reference).append(" "); 108 sb.append(referencingClassStack.pop()); 109 } 110 sb.append("\n\n"); 111 } 112 return sb.toString(); 113 } 114 } 115 116 | Popular Tags |