1 12 package org.aspectj.internal.lang.reflect; 13 14 import org.aspectj.lang.reflect.AjType; 15 import org.aspectj.lang.reflect.AjTypeSystem; 16 import org.aspectj.lang.reflect.DeclareSoft; 17 import org.aspectj.lang.reflect.PointcutExpression; 18 19 23 public class DeclareSoftImpl implements DeclareSoft { 24 25 private AjType<?> declaringType; 26 private PointcutExpression pointcut; 27 private AjType<?> exceptionType; 28 private String missingTypeName; 29 30 31 public DeclareSoftImpl(AjType<?> declaringType, String pcut, String exceptionTypeName) { 32 this.declaringType = declaringType; 33 this.pointcut = new PointcutExpressionImpl(pcut); 34 try { 35 ClassLoader cl = declaringType.getJavaClass().getClassLoader(); 36 this.exceptionType = AjTypeSystem.getAjType(Class.forName(exceptionTypeName,false,cl)); 37 } catch (ClassNotFoundException ex) { 38 this.missingTypeName = exceptionTypeName; 39 } 40 } 41 42 45 public AjType getDeclaringType() { 46 return this.declaringType; 47 } 48 49 52 public AjType getSoftenedExceptionType() throws ClassNotFoundException { 53 if (this.missingTypeName != null) throw new ClassNotFoundException (this.missingTypeName); 54 return this.exceptionType; 55 } 56 57 60 public PointcutExpression getPointcutExpression() { 61 return this.pointcut; 62 } 63 64 public String toString() { 65 StringBuffer sb = new StringBuffer (); 66 sb.append("declare soft : "); 67 if (this.missingTypeName != null) { 68 sb.append(this.exceptionType.getName()); 69 } else { 70 sb.append(this.missingTypeName); 71 } 72 sb.append(" : "); 73 sb.append(getPointcutExpression().asString()); 74 return sb.toString(); 75 } 76 } 77 | Popular Tags |