1 13 14 15 package org.aspectj.runtime.reflect; 16 17 import org.aspectj.lang.JoinPoint; 18 import org.aspectj.lang.ProceedingJoinPoint; 19 import org.aspectj.lang.Signature; 20 import org.aspectj.lang.reflect.SourceLocation; 21 import org.aspectj.runtime.internal.AroundClosure; 22 23 class JoinPointImpl implements ProceedingJoinPoint { 24 static class StaticPartImpl implements JoinPoint.StaticPart { 25 String kind; 26 Signature signature; 27 SourceLocation sourceLocation; 28 29 public StaticPartImpl(String kind, Signature signature, SourceLocation sourceLocation) { 30 this.kind = kind; 31 this.signature = signature; 32 this.sourceLocation = sourceLocation; 33 } 34 35 public String getKind() { return kind; } 36 public Signature getSignature() { return signature; } 37 public SourceLocation getSourceLocation() { return sourceLocation; } 38 39 String toString(StringMaker sm) { 40 StringBuffer buf = new StringBuffer (); 41 buf.append(sm.makeKindName(getKind())); 42 buf.append("("); 43 buf.append(((SignatureImpl)getSignature()).toString(sm)); 44 buf.append(")"); 45 return buf.toString(); 46 } 47 48 public final String toString() { return toString(StringMaker.middleStringMaker); } 49 public final String toShortString() { return toString(StringMaker.shortStringMaker); } 50 public final String toLongString() { return toString(StringMaker.longStringMaker); } 51 } 52 53 static class EnclosingStaticPartImpl extends StaticPartImpl implements EnclosingStaticPart { 54 public EnclosingStaticPartImpl(String kind, Signature signature, SourceLocation sourceLocation) { 55 super(kind, signature, sourceLocation); 56 } 57 } 58 59 Object _this; 60 Object target; 61 Object [] args; 62 org.aspectj.lang.JoinPoint.StaticPart staticPart; 63 64 public JoinPointImpl(org.aspectj.lang.JoinPoint.StaticPart staticPart, Object _this, Object target, Object [] args) { 65 this.staticPart = staticPart; 66 this._this = _this; 67 this.target = target; 68 this.args = args; 69 } 70 71 public Object getThis() { return _this; } 72 public Object getTarget() { return target; } 73 public Object [] getArgs() { 74 if (args == null) { args = new Object [0]; } 75 Object [] argsCopy = new Object [args.length]; 76 System.arraycopy(args,0,argsCopy,0,args.length); 77 return argsCopy; 78 } 79 80 public org.aspectj.lang.JoinPoint.StaticPart getStaticPart() { return staticPart; } 81 82 public String getKind() { return staticPart.getKind(); } 83 public Signature getSignature() { return staticPart.getSignature(); } 84 public SourceLocation getSourceLocation() { return staticPart.getSourceLocation(); } 85 86 public final String toString() { return staticPart.toString(); } 87 public final String toShortString() { return staticPart.toShortString(); } 88 public final String toLongString() { return staticPart.toLongString(); } 89 90 private AroundClosure arc; 92 public void set$AroundClosure(AroundClosure arc) { 93 this.arc = arc; 94 } 95 96 public Object proceed() throws Throwable { 97 if (arc == null) 99 return null; 100 else 101 return arc.run(arc.getState()); 102 } 103 104 public Object proceed(Object [] adviceBindings) throws Throwable { 105 if (arc == null) 107 return null; 108 else { 109 110 int flags = arc.getFlags(); 114 boolean unset = (flags &0x100000)!=0; 115 boolean thisTargetTheSame = (flags &0x010000)!=0; 116 boolean hasThis = (flags &0x001000)!=0; 117 boolean bindsThis = (flags &0x000100)!=0; 118 boolean hasTarget = (flags &0x000010)!=0; 119 boolean bindsTarget = (flags &0x000001)!=0; 120 121 Object [] state = arc.getState(); 123 124 128 130 int firstArgumentIndexIntoAdviceBindings = 0; 131 int firstArgumentIndexIntoState = 0; 132 firstArgumentIndexIntoState+=(hasThis?1:0); 133 firstArgumentIndexIntoState+=(hasTarget&&!thisTargetTheSame?1:0); 134 if (hasThis) { 135 if (bindsThis) { 136 firstArgumentIndexIntoAdviceBindings=1; 138 state[0]=adviceBindings[0]; 139 } else { 140 } 142 } 143 if (hasTarget) { 144 if (bindsTarget) { 145 if (thisTargetTheSame) { 146 firstArgumentIndexIntoAdviceBindings=1+(bindsThis?1:0); 148 state[0]=adviceBindings[(bindsThis?1:0)]; 149 } else { 150 firstArgumentIndexIntoAdviceBindings=(hasThis?1:0)+1; 154 state[hasThis?1:0]=adviceBindings[hasThis?1:0]; 155 } 156 } else { 157 } 159 } 160 161 for (int i=firstArgumentIndexIntoAdviceBindings;i<adviceBindings.length;i++) { 163 state[firstArgumentIndexIntoState+(i-firstArgumentIndexIntoAdviceBindings)]=adviceBindings[i]; 164 } 165 166 return arc.run(state); 174 } 175 } 176 177 178 } 179 | Popular Tags |