1 4 package com.tc.aspectwerkz.joinpoint.management; 5 6 import java.util.List ; 7 import java.util.ArrayList ; 8 9 import com.tc.aspectwerkz.aspect.AdviceInfo; 10 11 17 public class AdviceInfoContainer { 18 19 22 public static final AdviceInfoContainer NULL; 23 24 static { 25 NULL = new AdviceInfoContainer( 26 new ArrayList (), new ArrayList (), new ArrayList (), new ArrayList (), new ArrayList () 27 ); 28 } 29 30 private final AdviceInfo[] m_aroundAdvices; 31 private final AdviceInfo[] m_beforeAdvices; 32 private final AdviceInfo[] m_afterFinallyAdvices; 33 private final AdviceInfo[] m_afterReturningAdvices; 34 private final AdviceInfo[] m_afterThrowingAdvices; 35 36 45 public AdviceInfoContainer(final List aroundAdvices, 46 final List beforeAdvices, 47 final List afterFinallyAdvices, 48 final List afterReturningAdvices, 49 final List afterThrowingAdvices) { 50 m_aroundAdvices = (AdviceInfo[]) aroundAdvices.toArray(AdviceInfo.EMPTY_ADVICE_INFO_ARRAY); 51 m_beforeAdvices = (AdviceInfo[]) beforeAdvices.toArray(AdviceInfo.EMPTY_ADVICE_INFO_ARRAY); 52 m_afterFinallyAdvices = (AdviceInfo[]) afterFinallyAdvices.toArray(AdviceInfo.EMPTY_ADVICE_INFO_ARRAY); 53 m_afterReturningAdvices = (AdviceInfo[]) afterReturningAdvices.toArray(AdviceInfo.EMPTY_ADVICE_INFO_ARRAY); 54 m_afterThrowingAdvices = (AdviceInfo[]) afterThrowingAdvices.toArray(AdviceInfo.EMPTY_ADVICE_INFO_ARRAY); 55 } 56 57 62 public AdviceInfo[] getAroundAdviceInfos() { 63 return m_aroundAdvices; 64 } 65 66 71 public AdviceInfo[] getBeforeAdviceInfos() { 72 return m_beforeAdvices; 73 } 74 75 80 public AdviceInfo[] getAfterFinallyAdviceInfos() { 81 return m_afterFinallyAdvices; 82 } 83 84 89 public AdviceInfo[] getAfterReturningAdviceInfos() { 90 return m_afterReturningAdvices; 91 } 92 93 98 public AdviceInfo[] getAfterThrowingAdviceInfos() { 99 return m_afterThrowingAdvices; 100 } 101 102 107 public AdviceInfo[] getAllAdviceInfos() { 108 int size = m_beforeAdvices.length + m_aroundAdvices.length + m_afterReturningAdvices.length 109 + m_afterThrowingAdvices.length + m_afterFinallyAdvices.length; 110 AdviceInfo[] advices = new AdviceInfo[size]; 111 112 int destPos = 0; 113 System.arraycopy(m_beforeAdvices, 0, advices, destPos, m_beforeAdvices.length); 114 destPos += m_beforeAdvices.length; 115 System.arraycopy(m_aroundAdvices, 0, advices, destPos, m_aroundAdvices.length); 116 destPos += m_aroundAdvices.length; 117 System.arraycopy(m_afterReturningAdvices, 0, advices, destPos, m_afterReturningAdvices.length); 118 destPos += m_afterReturningAdvices.length; 119 System.arraycopy(m_afterThrowingAdvices, 0, advices, destPos, m_afterThrowingAdvices.length); 120 destPos += m_afterThrowingAdvices.length; 121 System.arraycopy(m_afterFinallyAdvices, 0, advices, destPos, m_afterFinallyAdvices.length); 122 destPos += m_afterFinallyAdvices.length; 123 124 return advices; 125 } 126 127 } | Popular Tags |