1 /*************************************************************************************** 2 * Copyright (c) Jonas Bonér, Alexandre Vasseur. All rights reserved. * 3 * http://aspectwerkz.codehaus.org * 4 * ---------------------------------------------------------------------------------- * 5 * The software in this package is published under the terms of the LGPL license * 6 * a copy of which has been included with this distribution in the license.txt file. * 7 **************************************************************************************/ 8 package org.codehaus.aspectwerkz.joinpoint.management; 9 10 import org.codehaus.aspectwerkz.joinpoint.CatchClauseRtti; 11 import org.codehaus.aspectwerkz.joinpoint.CatchClauseSignature; 12 import org.codehaus.aspectwerkz.joinpoint.Rtti; 13 import org.codehaus.aspectwerkz.joinpoint.Signature; 14 15 /*** 16 * Abstraction of a catch clause join point. 17 * 18 * @author <a href="mailto:jboner@codehaus.org">Jonas Bonér </a> 19 */ 20 class CatchClauseJoinPoint extends JoinPointBase { 21 private final CatchClauseSignature m_signature; 22 23 private transient CatchClauseRtti m_rtti; 24 25 /*** 26 * Creates a new join point. 27 * 28 * @param targetClass 29 * @param signature 30 * @param rtti 31 * @param joinPointMetaData 32 * @param aroundAdviceExecutor 33 * @param beforeAdviceExecutor 34 * @param afterAdviceExecutor 35 */ 36 public CatchClauseJoinPoint(final Class targetClass, 37 final Signature signature, 38 final Rtti rtti, 39 final JoinPointMetaData joinPointMetaData, 40 final AroundAdviceExecutor aroundAdviceExecutor, 41 final BeforeAdviceExecutor beforeAdviceExecutor, 42 final AfterAdviceExecutor afterAdviceExecutor) { 43 super( 44 JoinPointType.HANDLER, 45 targetClass, 46 joinPointMetaData, 47 aroundAdviceExecutor, 48 beforeAdviceExecutor, 49 afterAdviceExecutor); 50 m_signature = (CatchClauseSignature) signature; 51 m_rtti = (CatchClauseRtti) rtti; 52 } 53 54 /*** 55 * Walks through the pointcuts and invokes all its advices. When the last advice of the last pointcut has been 56 * invoked, the original method is invoked. Is called recursively. 57 * 58 * @return the result from the next invocation 59 * @throws Throwable 60 * @TODO: which advices should we support for catch handlers? AspectJ only supports before, due to bytecode problems 61 * (not possible to detect the end of a catch clause with 100% accuracy). 62 */ 63 public Object proceed() throws Throwable { 64 if (m_beforeAdviceExecutor.hasAdvices()) { 65 m_beforeAdviceExecutor.proceed(this); 66 } 67 return null; 68 } 69 70 /*** 71 * Returns the signature for the join point. 72 * 73 * @return the signature 74 */ 75 public Signature getSignature() { 76 return m_signature; 77 } 78 79 /*** 80 * Returns the RTTI for the join point. 81 * 82 * @return the RTTI 83 */ 84 public Rtti getRtti() { 85 return m_rtti; 86 } 87 88 /*** 89 * Returns a string representation of the join point. 90 * 91 * @return a string representation 92 * @TODO: implement toString to something meaningful 93 */ 94 public String toString() { 95 return super.toString(); 96 } 97 98 public Object[] extractArguments(int[] methodToArgIndexes) { 99 return new Object[]{this}; 100 } 101 102 /*** 103 * Allows to pass the RTTI to the JP. The JPBase implementation delegates getTarget to the RTTI. 104 * Since in 1.0 engine, JP are cached and shared, while the RTTI is not, we need to set the RTTI (AW-265). 105 * This method MUST not be called by the user. 106 * 107 * @param rtti 108 */ 109 protected void setRtti(Rtti rtti) { 110 m_rtti = (CatchClauseRtti)rtti; 111 } 112 }