1 22 package org.jboss.iiop.rmi; 23 24 33 public class ExceptionAnalysis 34 extends ValueAnalysis 35 { 36 38 40 42 private static final org.jboss.logging.Logger logger = 43 org.jboss.logging.Logger.getLogger(ExceptionAnalysis.class); 44 45 private static WorkCacheManager cache 46 = new WorkCacheManager(ExceptionAnalysis.class); 47 48 public static ExceptionAnalysis getExceptionAnalysis(Class cls) 49 throws RMIIIOPViolationException 50 { 51 return (ExceptionAnalysis)cache.getAnalysis(cls); 52 } 53 54 56 protected ExceptionAnalysis(Class cls) 57 { 58 super(cls); 59 logger.debug("ExceptionAnalysis(\""+cls.getName()+"\") entered."); 60 } 61 62 protected void doAnalyze() 63 throws RMIIIOPViolationException 64 { 65 super.doAnalyze(); 66 67 if (!Exception .class.isAssignableFrom(cls) || 68 RuntimeException .class.isAssignableFrom(cls)) 69 throw new RMIIIOPViolationException( 70 "Exception type " + cls.getName() + 71 " must be a checked exception class.", "1.2.6"); 72 73 StringBuffer b = new StringBuffer ("IDL:"); 75 String pkgName = cls.getPackage().getName(); 76 77 while (!"".equals(pkgName)) { 78 int idx = pkgName.indexOf('.'); 79 String n = (idx == -1) ? pkgName : pkgName.substring(0, idx); 80 b.append(Util.javaToIDLName(n)).append('/'); 81 pkgName = (idx == -1) ? "" : pkgName.substring(idx+1); 82 } 83 84 String base = cls.getName(); 85 base = base.substring(base.lastIndexOf('.')+1); 86 if (base.endsWith("Exception")) 87 base = base.substring(0, base.length()-9); 88 base = Util.javaToIDLName(base + "Ex"); 89 90 b.append(base).append(":1.0"); 91 exceptionRepositoryId = b.toString(); 92 } 93 94 96 100 public String getExceptionRepositoryId() 101 { 102 return exceptionRepositoryId; 103 } 104 105 107 109 private String exceptionRepositoryId; 110 111 113 } 114 115 | Popular Tags |