001: /**************************************************************************************
002: * Copyright (c) Jonas BonŽr, Alexandre Vasseur. All rights reserved. *
003: * http://aspectwerkz.codehaus.org *
004: * ---------------------------------------------------------------------------------- *
005: * The software in this package is published under the terms of the LGPL license *
006: * a copy of which has been included with this distribution in the license.txt file. *
007: **************************************************************************************/package org.codehaus.aspectwerkz.joinpoint.management;
008:
009: import java.util.List;
010: import java.util.ArrayList;
011:
012: import org.codehaus.aspectwerkz.aspect.AdviceInfo;
013: import org.codehaus.aspectwerkz.aspect.AdviceInfo;
014: import org.codehaus.aspectwerkz.aspect.AdviceInfo;
015:
016: /**
017: * Container for the advice infos that belongs to a specific join point.
018: *
019: * @author <a href="mailto:jboner@codehaus.org">Jonas BonŽr </a>
020: * @author <a href="mailto:alex AT gnilux DOT com">Alexandre Vasseur</a>
021: */
022: public class AdviceInfoContainer {
023:
024: /**
025: * Null AdviceInfoContainer instance
026: */
027: public static final AdviceInfoContainer NULL;
028:
029: static {
030: NULL = new AdviceInfoContainer(new ArrayList(),
031: new ArrayList(), new ArrayList(), new ArrayList(),
032: new ArrayList());
033: }
034:
035: private final AdviceInfo[] m_aroundAdvices;
036: private final AdviceInfo[] m_beforeAdvices;
037: private final AdviceInfo[] m_afterFinallyAdvices;
038: private final AdviceInfo[] m_afterReturningAdvices;
039: private final AdviceInfo[] m_afterThrowingAdvices;
040:
041: /**
042: * Creates a advice info container.
043: *
044: * @param aroundAdvices
045: * @param beforeAdvices
046: * @param afterFinallyAdvices
047: * @param afterReturningAdvices
048: * @param afterThrowingAdvices
049: */
050: public AdviceInfoContainer(final List aroundAdvices,
051: final List beforeAdvices, final List afterFinallyAdvices,
052: final List afterReturningAdvices,
053: final List afterThrowingAdvices) {
054: m_aroundAdvices = (AdviceInfo[]) aroundAdvices
055: .toArray(AdviceInfo.EMPTY_ADVICE_INFO_ARRAY);
056: m_beforeAdvices = (AdviceInfo[]) beforeAdvices
057: .toArray(AdviceInfo.EMPTY_ADVICE_INFO_ARRAY);
058: m_afterFinallyAdvices = (AdviceInfo[]) afterFinallyAdvices
059: .toArray(AdviceInfo.EMPTY_ADVICE_INFO_ARRAY);
060: m_afterReturningAdvices = (AdviceInfo[]) afterReturningAdvices
061: .toArray(AdviceInfo.EMPTY_ADVICE_INFO_ARRAY);
062: m_afterThrowingAdvices = (AdviceInfo[]) afterThrowingAdvices
063: .toArray(AdviceInfo.EMPTY_ADVICE_INFO_ARRAY);
064: }
065:
066: /**
067: * Returns the around advice infos.
068: *
069: * @return
070: */
071: public AdviceInfo[] getAroundAdviceInfos() {
072: return m_aroundAdvices;
073: }
074:
075: /**
076: * Returns the before advice infos.
077: *
078: * @return
079: */
080: public AdviceInfo[] getBeforeAdviceInfos() {
081: return m_beforeAdvices;
082: }
083:
084: /**
085: * Returns the after finally advice infos.
086: *
087: * @return
088: */
089: public AdviceInfo[] getAfterFinallyAdviceInfos() {
090: return m_afterFinallyAdvices;
091: }
092:
093: /**
094: * Returns the after returning advice infos.
095: *
096: * @return
097: */
098: public AdviceInfo[] getAfterReturningAdviceInfos() {
099: return m_afterReturningAdvices;
100: }
101:
102: /**
103: * Returns the after throwing advice infos.
104: *
105: * @return
106: */
107: public AdviceInfo[] getAfterThrowingAdviceInfos() {
108: return m_afterThrowingAdvices;
109: }
110:
111: /**
112: * Return all advice infos.
113: *
114: * @return
115: */
116: public AdviceInfo[] getAllAdviceInfos() {
117: int size = m_beforeAdvices.length + m_aroundAdvices.length
118: + m_afterReturningAdvices.length
119: + m_afterThrowingAdvices.length
120: + m_afterFinallyAdvices.length;
121: AdviceInfo[] advices = new AdviceInfo[size];
122:
123: int destPos = 0;
124: System.arraycopy(m_beforeAdvices, 0, advices, destPos,
125: m_beforeAdvices.length);
126: destPos += m_beforeAdvices.length;
127: System.arraycopy(m_aroundAdvices, 0, advices, destPos,
128: m_aroundAdvices.length);
129: destPos += m_aroundAdvices.length;
130: System.arraycopy(m_afterReturningAdvices, 0, advices, destPos,
131: m_afterReturningAdvices.length);
132: destPos += m_afterReturningAdvices.length;
133: System.arraycopy(m_afterThrowingAdvices, 0, advices, destPos,
134: m_afterThrowingAdvices.length);
135: destPos += m_afterThrowingAdvices.length;
136: System.arraycopy(m_afterFinallyAdvices, 0, advices, destPos,
137: m_afterFinallyAdvices.length);
138: destPos += m_afterFinallyAdvices.length;
139:
140: return advices;
141: }
142:
143: }
|