1 2 package ch.ethz.prose.crosscut; 3 4 import java.util.HashMap ; 6 7 import ch.ethz.jvmai.ExceptionCatchJoinPoint; 8 import ch.ethz.jvmai.FieldAccessJoinPoint; 9 import ch.ethz.jvmai.FieldModificationJoinPoint; 10 import ch.ethz.jvmai.JoinPoint; 11 import ch.ethz.jvmai.MethodEntryJoinPoint; 12 import ch.ethz.jvmai.MethodExitJoinPoint; 13 import ch.ethz.prose.engine.ExceptionCatchRequest; 14 15 34 public abstract class CatchCut extends AbstractCrosscut implements java.io.Serializable { 35 36 private transient CatchHandleSignaturePattern advicePattern; 37 38 private static Class throwableClass; 40 41 42 43 46 protected CatchCut() 47 { 48 initState(); 49 } 50 51 public void insertionAction(boolean isBeforeInsertion) 52 { 53 if (isBeforeInsertion) 54 initState(); 55 } 56 57 private void initState() 58 { 59 if (advicePattern == null) 60 { 61 advicePattern= new CatchHandleSignaturePattern(this); 62 } 63 } 64 65 66 69 public void CATCH_ARGS(){} 70 71 72 73 protected void joinPointAction(ExceptionCatchJoinPoint ecjp) 74 throws IllegalAccessException 75 { 76 77 try 78 { 79 switch(advicePattern.signatureCathegory&(SignaturePattern.WILDCARD_1|SignaturePattern.CONCRETE_1|SignaturePattern.SIGNATURE__EMPTY)) 80 { 81 case SignaturePattern.SIGNATURE__EMPTY: 82 CATCH_ARGS(); 83 break; 84 case SignaturePattern.WILDCARD_1: 85 ANY x = new ANY(); 86 x.setObject(ecjp.getException()); 87 advicePattern.methodObj.invoke(this,new Object []{x}); 88 break; 89 case SignaturePattern.CONCRETE_1: 90 advicePattern.methodObj.invoke(this,new Object []{ecjp.getException()}); 91 break; 92 default: 93 throw new Error ("CatchCut.joinPointAction: illegal signature pattern"); 94 } 95 } 96 catch (java.lang.reflect.InvocationTargetException e) 97 { 98 throw new Error ("CatchCut.joinPointAction: wrong arguments; static check failure:" + e); 99 } 100 101 102 } 103 104 105 106 109 protected boolean isPotentialCrosscutClass(Class c) 110 { 111 return Throwable .class.isAssignableFrom(c); 112 } 113 114 115 121 protected CrosscutRequest doCreateRequest(Class cls) 122 { 123 CrosscutRequest result = new CrosscutRequest(); 124 if( (advicePattern.signatureCathegory&(SignaturePattern.CONCRETE_1)) != 0 125 && 126 (!advicePattern.signature[0].isAssignableFrom(cls))) 127 return result; 128 129 result.add(requestFactory.createJoinPointRequest(ExceptionCatchJoinPoint.KIND,cls)); 130 131 return result; 132 } 133 134 137 public String toString() 138 { 139 return "Crosscut 'CatchCut' [class '" + getClass().getName() + 140 "'] specialized with [" + getSpecializer() + "]"; 141 } 142 143 } 144
| Popular Tags
|