1 8 package org.codehaus.aspectwerkz.joinpoint.management; 9 10 import java.util.List ; 11 import java.util.ArrayList ; 12 13 import org.codehaus.aspectwerkz.aspect.AdviceInfo; 14 import org.codehaus.aspectwerkz.aspect.AdviceInfo; 15 import org.codehaus.aspectwerkz.aspect.AdviceInfo; 16 17 23 public class AdviceInfoContainer { 24 25 28 public static final AdviceInfoContainer NULL; 29 30 static { 31 NULL = new AdviceInfoContainer( 32 new ArrayList (), new ArrayList (), new ArrayList (), new ArrayList (), new ArrayList () 33 ); 34 } 35 36 private final AdviceInfo[] m_aroundAdvices; 37 private final AdviceInfo[] m_beforeAdvices; 38 private final AdviceInfo[] m_afterFinallyAdvices; 39 private final AdviceInfo[] m_afterReturningAdvices; 40 private final AdviceInfo[] m_afterThrowingAdvices; 41 42 51 public AdviceInfoContainer(final List aroundAdvices, 52 final List beforeAdvices, 53 final List afterFinallyAdvices, 54 final List afterReturningAdvices, 55 final List afterThrowingAdvices) { 56 m_aroundAdvices = (AdviceInfo[]) aroundAdvices.toArray(AdviceInfo.EMPTY_ADVICE_INFO_ARRAY); 57 m_beforeAdvices = (AdviceInfo[]) beforeAdvices.toArray(AdviceInfo.EMPTY_ADVICE_INFO_ARRAY); 58 m_afterFinallyAdvices = (AdviceInfo[]) afterFinallyAdvices.toArray(AdviceInfo.EMPTY_ADVICE_INFO_ARRAY); 59 m_afterReturningAdvices = (AdviceInfo[]) afterReturningAdvices.toArray(AdviceInfo.EMPTY_ADVICE_INFO_ARRAY); 60 m_afterThrowingAdvices = (AdviceInfo[]) afterThrowingAdvices.toArray(AdviceInfo.EMPTY_ADVICE_INFO_ARRAY); 61 } 62 63 68 public AdviceInfo[] getAroundAdviceInfos() { 69 return m_aroundAdvices; 70 } 71 72 77 public AdviceInfo[] getBeforeAdviceInfos() { 78 return m_beforeAdvices; 79 } 80 81 86 public AdviceInfo[] getAfterFinallyAdviceInfos() { 87 return m_afterFinallyAdvices; 88 } 89 90 95 public AdviceInfo[] getAfterReturningAdviceInfos() { 96 return m_afterReturningAdvices; 97 } 98 99 104 public AdviceInfo[] getAfterThrowingAdviceInfos() { 105 return m_afterThrowingAdvices; 106 } 107 108 113 public AdviceInfo[] getAllAdviceInfos() { 114 int size = m_beforeAdvices.length + m_aroundAdvices.length + m_afterReturningAdvices.length 115 + m_afterThrowingAdvices.length + m_afterFinallyAdvices.length; 116 AdviceInfo[] advices = new AdviceInfo[size]; 117 118 int destPos = 0; 119 System.arraycopy(m_beforeAdvices, 0, advices, destPos, m_beforeAdvices.length); 120 destPos += m_beforeAdvices.length; 121 System.arraycopy(m_aroundAdvices, 0, advices, destPos, m_aroundAdvices.length); 122 destPos += m_aroundAdvices.length; 123 System.arraycopy(m_afterReturningAdvices, 0, advices, destPos, m_afterReturningAdvices.length); 124 destPos += m_afterReturningAdvices.length; 125 System.arraycopy(m_afterThrowingAdvices, 0, advices, destPos, m_afterThrowingAdvices.length); 126 destPos += m_afterThrowingAdvices.length; 127 System.arraycopy(m_afterFinallyAdvices, 0, advices, destPos, m_afterFinallyAdvices.length); 128 destPos += m_afterFinallyAdvices.length; 129 130 return advices; 131 } 132 133 } | Popular Tags |