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.aspect.management;
9
10 import org.codehaus.aspectwerkz.AdviceInfo;
11 import org.codehaus.aspectwerkz.NameIndexTuple;
12 import org.codehaus.aspectwerkz.expression.ExpressionInfo;
13
14 import java.io.ObjectInputStream;
15 import java.io.Serializable;
16 import java.util.ArrayList;
17 import java.util.Iterator;
18 import java.util.List;
19
20 /***
21 * Implementation of the pointcut concept. I.e. an abstraction of a well defined point of execution in the program.
22 * <p/>Could matches one or many as long at it is well defined. <br/>Stores the advices for the specific pointcut. <p/>
23 *
24 * @author <a href="mailto:jboner@codehaus.org">Jonas Bonér </a>
25 * @author <a href="mailto:alex@gnilux.com">Alexandre Vasseur </a>
26 *
27 * TODO this class has transient fields that might cause pbms after serialization
28 *
29 * TODO change addXXAdvice to allow 'aspectName, adviceName' params
30 */
31 public class
32 Pointcut implements Serializable {
33 /***
34 * The expression for the pointcut.
35 */
36 protected transient ExpressionInfo m_expressionInfo;
37
38 /***
39 * The names of the around advices.
40 */
41 protected String[] m_aroundAdviceNames = new String[0];
42
43 /***
44 * The names of the around advices.
45 */
46 protected String[] m_beforeAdviceNames = new String[0];
47
48 /***
49 * The names of the after finally advices.
50 */
51 protected String[] m_afterFinallyAdviceNames = new String[0];
52
53 /***
54 * The names of the after returning advices.
55 */
56 protected String[] m_afterReturningAdviceNames = new String[0];
57
58 /***
59 * The names of the after throwing advices.
60 */
61 protected String[] m_afterThrowingAdviceNames = new String[0];
62
63 /***
64 * The indexes of the around advices.
65 */
66 protected AdviceInfo[] m_aroundAdviceIndexes = new AdviceInfo[0];
67
68 /***
69 * The indexes of the before advices.
70 */
71 protected AdviceInfo[] m_beforeAdviceIndexes = new AdviceInfo[0];
72
73 /***
74 * The indexes of the after finally advices.
75 */
76 protected AdviceInfo[] m_afterFinallyAdviceIndexes = new AdviceInfo[0];
77
78 /***
79 * The indexes of the after returning advices.
80 */
81 protected AdviceInfo[] m_afterReturningAdviceIndexes = new AdviceInfo[0];
82
83 /***
84 * The indexes of the after throwing advices.
85 */
86 protected AdviceInfo[] m_afterThrowingAdviceIndexes = new AdviceInfo[0];
87
88 /***
89 * The AspectManager for the AspectWerkz system.
90 *
91 * TODO if the manager is needed after serialization it can be rebuild using UUID, see AdviceInfo.java
92 */
93 protected transient final AspectManager m_aspectManager;
94
95 /***
96 * Creates a new pointcut.
97 *
98 * @param aspectManager the aspectManager for the AspectWerkz system
99 * @param expressionInfo the pattern for the pointcut
100 */
101 public Pointcut(final AspectManager aspectManager, final ExpressionInfo expressionInfo) {
102 if (aspectManager == null) {
103 throw new IllegalArgumentException("aspect manager can not be null");
104 }
105 if (expressionInfo == null) {
106 throw new IllegalArgumentException("expression info can not be null");
107 }
108 m_aspectManager = aspectManager;
109 m_expressionInfo = expressionInfo;
110 }
111
112 /***
113 * Adds an around advice to the pointcut.
114 *
115 * @param advice the name of the advice to add
116 */
117 public void addAroundAdvice(final String advice) {
118 if ((advice == null) || (advice.trim().length() == 0)) {
119 throw new IllegalArgumentException("name of advice to add can not be null or an empty string");
120 }
121
122
123
124 for (int i = 0; i < m_aroundAdviceNames.length; i++) {
125 if (advice.equals(m_aroundAdviceNames[i])) {
126 return;
127 }
128 }
129 synchronized (m_aroundAdviceNames) {
130 synchronized (m_aroundAdviceIndexes) {
131 final String[] tmp = new String[m_aroundAdviceNames.length + 1];
132 System.arraycopy(m_aroundAdviceNames, 0, tmp, 0, m_aroundAdviceNames.length);
133 tmp[m_aroundAdviceNames.length] = advice;
134 m_aroundAdviceNames = new String[m_aroundAdviceNames.length + 1];
135 System.arraycopy(tmp, 0, m_aroundAdviceNames, 0, tmp.length);
136
137
138 m_aroundAdviceIndexes = new AdviceInfo[m_aroundAdviceNames.length];
139 for (int i = 0, j = m_aroundAdviceNames.length; i < j; i++) {
140 m_aroundAdviceIndexes[i] = m_aspectManager.getAdviceIndexFor(m_aroundAdviceNames[i]);
141 }
142 }
143 }
144 }
145
146 /***
147 * Adds a before advice to the pointcut.
148 *
149 * @param advice the name of the advice to add
150 */
151 public void addBeforeAdvice(final String advice) {
152 if ((advice == null) || (advice.trim().length() == 0)) {
153 throw new IllegalArgumentException("name of advice to add can not be null or an empty string");
154 }
155 synchronized (m_beforeAdviceNames) {
156 synchronized (m_beforeAdviceIndexes) {
157 final String[] tmp = new String[m_beforeAdviceNames.length + 1];
158 System.arraycopy(m_beforeAdviceNames, 0, tmp, 0, m_beforeAdviceNames.length);
159 tmp[m_beforeAdviceNames.length] = advice;
160 m_beforeAdviceNames = new String[m_beforeAdviceNames.length + 1];
161 System.arraycopy(tmp, 0, m_beforeAdviceNames, 0, tmp.length);
162
163
164 m_beforeAdviceIndexes = new AdviceInfo[m_beforeAdviceNames.length];
165 for (int i = 0, j = m_beforeAdviceNames.length; i < j; i++) {
166 m_beforeAdviceIndexes[i] = m_aspectManager.getAdviceIndexFor(m_beforeAdviceNames[i]);
167 }
168 }
169 }
170 }
171
172 /***
173 * Adds an after finally advice to the pointcut.
174 *
175 * @param advice the name of the advice to add
176 */
177 public void addAfterFinallyAdvices(final String advice) {
178 if ((advice == null) || (advice.trim().length() == 0)) {
179 throw new IllegalArgumentException("name of advice to add can not be null or an empty string");
180 }
181 synchronized (m_afterFinallyAdviceNames) {
182 synchronized (m_afterFinallyAdviceIndexes) {
183 final String[] tmp = new String[m_afterFinallyAdviceNames.length + 1];
184 System.arraycopy(m_afterFinallyAdviceNames, 0, tmp, 0, m_afterFinallyAdviceNames.length);
185 tmp[m_afterFinallyAdviceNames.length] = advice;
186 m_afterFinallyAdviceNames = new String[m_afterFinallyAdviceNames.length + 1];
187 System.arraycopy(tmp, 0, m_afterFinallyAdviceNames, 0, tmp.length);
188
189
190 m_afterFinallyAdviceIndexes = new AdviceInfo[m_afterFinallyAdviceNames.length];
191 for (int i = 0, j = m_afterFinallyAdviceNames.length; i < j; i++) {
192 m_afterFinallyAdviceIndexes[i] = m_aspectManager.getAdviceIndexFor(m_afterFinallyAdviceNames[i]);
193 }
194 }
195 }
196 }
197
198 /***
199 * Adds an after returning advice to the pointcut.
200 *
201 * @param advice the name of the advice to add
202 */
203 public void addAfterReturningAdvices(final String advice) {
204 if ((advice == null) || (advice.trim().length() == 0)) {
205 throw new IllegalArgumentException("name of advice to add can not be null or an empty string");
206 }
207 synchronized (m_afterReturningAdviceNames) {
208 synchronized (m_afterReturningAdviceIndexes) {
209 final String[] tmp = new String[m_afterReturningAdviceNames.length + 1];
210 System.arraycopy(m_afterReturningAdviceNames, 0, tmp, 0, m_afterReturningAdviceNames.length);
211 tmp[m_afterReturningAdviceNames.length] = advice;
212 m_afterReturningAdviceNames = new String[m_afterReturningAdviceNames.length + 1];
213 System.arraycopy(tmp, 0, m_afterReturningAdviceNames, 0, tmp.length);
214
215
216 m_afterReturningAdviceIndexes = new AdviceInfo[m_afterReturningAdviceNames.length];
217 for (int i = 0, j = m_afterReturningAdviceNames.length; i < j; i++) {
218 m_afterReturningAdviceIndexes[i] = m_aspectManager.getAdviceIndexFor(m_afterReturningAdviceNames[i]);
219 }
220 }
221 }
222 }
223
224 /***
225 * Adds an after throwing advice to the pointcut.
226 *
227 * @param advice the name of the advice to add
228 */
229 public void addAfterThrowingAdvices(final String advice) {
230 if ((advice == null) || (advice.trim().length() == 0)) {
231 throw new IllegalArgumentException("name of advice to add can not be null or an empty string");
232 }
233 synchronized (m_afterThrowingAdviceNames) {
234 synchronized (m_afterThrowingAdviceIndexes) {
235 final String[] tmp = new String[m_afterThrowingAdviceNames.length + 1];
236 System.arraycopy(m_afterThrowingAdviceNames, 0, tmp, 0, m_afterThrowingAdviceNames.length);
237 tmp[m_afterThrowingAdviceIndexes.length] = advice;
238 m_afterThrowingAdviceNames = new String[m_afterThrowingAdviceNames.length + 1];
239 System.arraycopy(tmp, 0, m_afterThrowingAdviceNames, 0, tmp.length);
240
241
242 m_afterThrowingAdviceIndexes = new AdviceInfo[m_afterThrowingAdviceNames.length];
243 for (int i = 0, j = m_afterThrowingAdviceNames.length; i < j; i++) {
244 m_afterThrowingAdviceIndexes[i] = m_aspectManager.getAdviceIndexFor(m_afterThrowingAdviceNames[i]);
245 }
246 }
247 }
248 }
249
250 /***
251 * Removes an advice from the pointcut.
252 *
253 * @TODO not used - remove?
254 *
255 * @param advice the name of the advice to remove
256 */
257 public void removeAroundAdvice(final String advice) {
258 if ((advice == null) || (advice.trim().length() == 0)) {
259 throw new IllegalArgumentException("name of advice to remove can not be null or an empty string");
260 }
261 synchronized (m_aroundAdviceNames) {
262 synchronized (m_aroundAdviceIndexes) {
263 int index = -1;
264 for (int i = 0; i < m_aroundAdviceNames.length; i++) {
265 if (m_aroundAdviceNames[i].equals(advice)) {
266 index = i;
267 break;
268 }
269 }
270 if (index == -1) {
271 throw new RuntimeException("can not remove advice with the name " + advice + ": no such advice");
272 }
273 final String[] names = new String[m_aroundAdviceNames.length - 1];
274 int j;
275 int k;
276 for (j = 0, k = 0; j < index; j++, k++) {
277 names[j] = m_aroundAdviceNames[j];
278 }
279 j++;
280 for (; j < m_aroundAdviceNames.length; j++, k++) {
281 names[k] = m_aroundAdviceNames[j];
282 }
283 m_aroundAdviceNames = new String[names.length];
284 System.arraycopy(names, 0, m_aroundAdviceNames, 0, names.length);
285 final AdviceInfo[] indexes = new AdviceInfo[m_aroundAdviceIndexes.length - 1];
286 for (j = 0, k = 0; j < index; j++, k++) {
287 indexes[j] = m_aroundAdviceIndexes[j];
288 }
289 j++;
290 for (; j < m_aroundAdviceIndexes.length; j++, k++) {
291 indexes[k] = m_aroundAdviceIndexes[j];
292 }
293 m_aroundAdviceIndexes = new AdviceInfo[indexes.length];
294 System.arraycopy(indexes, 0, m_aroundAdviceIndexes, 0, indexes.length);
295 }
296 }
297 }
298
299 /***
300 * Removes an advice from the pointcut.
301 *
302 * @TODO not used - remove?
303 *
304 * @param advice the name of the advice to remove
305 */
306 public void removeBeforeAdvice(final String advice) {
307 if ((advice == null) || (advice.trim().length() == 0)) {
308 throw new IllegalArgumentException("name of advice to remove can not be null or an empty string");
309 }
310 synchronized (m_beforeAdviceNames) {
311 synchronized (m_beforeAdviceIndexes) {
312 int index = -1;
313 for (int i = 0; i < m_beforeAdviceNames.length; i++) {
314 if (m_beforeAdviceNames[i].equals(advice)) {
315 index = i;
316 break;
317 }
318 }
319 if (index == -1) {
320 throw new RuntimeException("can not remove advice with the name " + advice + ": no such advice");
321 }
322 final String[] names = new String[m_beforeAdviceNames.length - 1];
323 int j;
324 int k;
325 for (j = 0, k = 0; j < index; j++, k++) {
326 names[j] = m_beforeAdviceNames[j];
327 }
328 j++;
329 for (; j < m_beforeAdviceNames.length; j++, k++) {
330 names[k] = m_beforeAdviceNames[j];
331 }
332 m_beforeAdviceNames = new String[names.length];
333 System.arraycopy(names, 0, m_beforeAdviceNames, 0, names.length);
334 final AdviceInfo[] indexes = new AdviceInfo[m_beforeAdviceIndexes.length - 1];
335 for (j = 0, k = 0; j < index; j++, k++) {
336 indexes[j] = m_beforeAdviceIndexes[j];
337 }
338 j++;
339 for (; j < m_beforeAdviceIndexes.length; j++, k++) {
340 indexes[k] = m_beforeAdviceIndexes[j];
341 }
342 m_beforeAdviceIndexes = new AdviceInfo[indexes.length];
343 System.arraycopy(indexes, 0, m_beforeAdviceIndexes, 0, indexes.length);
344 }
345 }
346 }
347
348 /***
349 * Removes an advice from the pointcut.
350 *
351 * @TODO not used - remove?
352 *
353 * @param advice the name of the advice to remove
354 */
355 public void removeAfterAdvice(final String advice) {
356 if ((advice == null) || (advice.trim().length() == 0)) {
357 throw new IllegalArgumentException("name of advice to remove can not be null or an empty string");
358 }
359 synchronized (m_afterFinallyAdviceNames) {
360 synchronized (m_afterFinallyAdviceIndexes) {
361 int index = -1;
362 for (int i = 0; i < m_afterFinallyAdviceNames.length; i++) {
363 if (m_afterFinallyAdviceNames[i].equals(advice)) {
364 index = i;
365 break;
366 }
367 }
368 if (index == -1) {
369 throw new RuntimeException("can not remove advice with the name " + advice + ": no such advice");
370 }
371 final String[] names = new String[m_afterFinallyAdviceNames.length - 1];
372 int j;
373 int k;
374 for (j = 0, k = 0; j < index; j++, k++) {
375 names[j] = m_afterFinallyAdviceNames[j];
376 }
377 j++;
378 for (; j < m_afterFinallyAdviceNames.length; j++, k++) {
379 names[k] = m_afterFinallyAdviceNames[j];
380 }
381 m_afterFinallyAdviceNames = new String[names.length];
382 System.arraycopy(names, 0, m_afterFinallyAdviceNames, 0, names.length);
383 final AdviceInfo[] indexes = new AdviceInfo[m_afterFinallyAdviceIndexes.length - 1];
384 for (j = 0, k = 0; j < index; j++, k++) {
385 indexes[j] = m_afterFinallyAdviceIndexes[j];
386 }
387 j++;
388 for (; j < m_afterFinallyAdviceIndexes.length; j++, k++) {
389 indexes[k] = m_afterFinallyAdviceIndexes[j];
390 }
391 m_afterFinallyAdviceIndexes = new AdviceInfo[indexes.length];
392 System.arraycopy(indexes, 0, m_afterFinallyAdviceIndexes, 0, indexes.length);
393 }
394 }
395 }
396
397 /***
398 * Checks if the pointcuts has a certain advice.
399 *
400 * @TODO not used - remove?
401 *
402 * @param advice the advice to check for existence
403 * @return boolean
404 */
405 public boolean hasAroundAdvice(final String advice) {
406 for (int i = 0; i < m_aroundAdviceNames.length; i++) {
407 if (m_aroundAdviceNames[i].equals(advice)) {
408 return true;
409 }
410 }
411 return false;
412 }
413
414 /***
415 * Checks if the pointcuts has a certain advice.
416 * @TODO not used - remove?
417 *
418 * @param advice the advice to check for existence
419 * @return boolean
420 */
421 public boolean hasBeforeAdvice(final String advice) {
422 for (int i = 0; i < m_beforeAdviceNames.length; i++) {
423 if (m_beforeAdviceNames[i].equals(advice)) {
424 return true;
425 }
426 }
427 return false;
428 }
429
430 /***
431 * Checks if the pointcuts has a certain advice.
432 *
433 * @TODO not used - remove?
434 *
435 * @param advice the advice to check for existence
436 * @return boolean
437 */
438 public boolean hasAfterAdvice(final String advice) {
439 for (int i = 0; i < m_afterFinallyAdviceNames.length; i++) {
440 if (m_afterFinallyAdviceNames[i].equals(advice)) {
441 return true;
442 }
443 }
444 return false;
445 }
446
447 /***
448 * Returns the advices in the form of an array with advice/index tuples. To be used when a reordering of the advices
449 * is necessary. <br/>For addition of an advice see <code>addAdviceTestMethod(..)</code>. <br/>For removal of an
450 * advice see <code>removeAdviceTestMethod(..)</code>.
451 *
452 * @TODO not used - remove?
453 *
454 * @return the current advice/index tuples as a list
455 */
456 public List getAroundAdviceIndexTuples() {
457 synchronized (m_aroundAdviceIndexes) {
458 synchronized (m_aroundAdviceNames) {
459 final List advices = new ArrayList(m_aroundAdviceNames.length);
460 for (int i = 0; i < m_aroundAdviceNames.length; i++) {
461 advices.add(new NameIndexTuple(m_aroundAdviceNames[i], m_aroundAdviceIndexes[i]));
462 }
463 return advices;
464 }
465 }
466 }
467
468 /***
469 * Returns the advices in the form of an array with advice/index tuples. To be used when a reordering of the advices
470 * is necessary. <br/>For addition of an advice see <code>addAdviceTestMethod(..)</code>. <br/>For removal of an
471 * advice see <code>removeAdviceTestMethod(..)</code>.
472 *
473 * @TODO not used - remove?
474 *
475 * @return the current advice/index tuples as a list
476 */
477 public List getBeforeAdviceIndexTuples() {
478 synchronized (m_beforeAdviceIndexes) {
479 synchronized (m_beforeAdviceNames) {
480 final List advices = new ArrayList(m_beforeAdviceNames.length);
481 for (int i = 0; i < m_beforeAdviceNames.length; i++) {
482 advices.add(new NameIndexTuple(m_beforeAdviceNames[i], m_beforeAdviceIndexes[i]));
483 }
484 return advices;
485 }
486 }
487 }
488
489 /***
490 * Returns the advices in the form of an array with advice/index tuples. To be used when a reordering of the advices
491 * is necessary. <br/>For addition of an advice see <code>addAdviceTestMethod(..)</code>. <br/>For removal of an
492 * advice see <code>removeAdviceTestMethod(..)</code>.
493 *
494 * @TODO not used - remove?
495 *
496 * @return the current advice/index tuples as a list
497 */
498 public List getAfterAdviceIndexTuples() {
499 synchronized (m_afterFinallyAdviceIndexes) {
500 synchronized (m_afterFinallyAdviceNames) {
501 final List advices = new ArrayList(m_afterFinallyAdviceNames.length);
502 for (int i = 0; i < m_afterFinallyAdviceNames.length; i++) {
503 advices.add(new NameIndexTuple(m_afterFinallyAdviceNames[i], m_afterFinallyAdviceIndexes[i]));
504 }
505 return advices;
506 }
507 }
508 }
509
510 /***
511 * Sets the advices. To be used when a reordering of the advices is necessary. <br/>For addition of an advice see
512 * <code>addAdviceTestMethod(..)</code>. <br/>For removal of an advice see
513 * <code>removeAdviceTestMethod(..)</code>.
514 *
515 * @TODO not used - remove?
516 *
517 * @param advices the new advice/index tuple array
518 */
519 public void setAroundAdviceIndexTuples(final List advices) {
520 synchronized (m_aroundAdviceIndexes) {
521 synchronized (m_aroundAdviceNames) {
522 m_aroundAdviceNames = new String[advices.size()];
523 m_aroundAdviceIndexes = new AdviceInfo[advices.size()];
524 int i = 0;
525 for (Iterator it = advices.iterator(); it.hasNext(); i++) {
526 try {
527 NameIndexTuple tuple = (NameIndexTuple) it.next();
528 m_aroundAdviceNames[i] = tuple.getName();
529 m_aroundAdviceIndexes[i] = tuple.getIndex();
530 } catch (ClassCastException e) {
531 throw new RuntimeException("advice list must only contain AdviceIndexTuples");
532 }
533 }
534 }
535 }
536 }
537
538 /***
539 * Sets the advices. To be used when a reordering of the advices is necessary. <br/>For addition of an advice see
540 * <code>addAdviceTestMethod(..)</code>. <br/>For removal of an advice see
541 * <code>removeAdviceTestMethod(..)</code>.
542 *
543 * @TODO not used - remove?
544 *
545 * @param advices the new advice/index tuple array
546 */
547 public void setBeforeAdviceIndexTuples(final List advices) {
548 synchronized (m_beforeAdviceIndexes) {
549 synchronized (m_beforeAdviceNames) {
550 m_beforeAdviceNames = new String[advices.size()];
551 m_beforeAdviceIndexes = new AdviceInfo[advices.size()];
552 int i = 0;
553 for (Iterator it = advices.iterator(); it.hasNext(); i++) {
554 try {
555 NameIndexTuple tuple = (NameIndexTuple) it.next();
556 m_beforeAdviceNames[i] = tuple.getName();
557 m_beforeAdviceIndexes[i] = tuple.getIndex();
558 } catch (ClassCastException e) {
559 throw new RuntimeException("advice list must only contain AdviceIndexTuples");
560 }
561 }
562 }
563 }
564 }
565
566 /***
567 * Sets the advices. To be used when a reordering of the advices is necessary. <br/>For addition of an advice see
568 * <code>addAdviceTestMethod(..)</code>. <br/>For removal of an advice see
569 * <code>removeAdviceTestMethod(..)</code>.
570 *
571 * @TODO not used - remove?
572 *
573 * @param advices the new advice/index tuple array
574 */
575 public void setAfterAdviceIndexTuples(final List advices) {
576 synchronized (m_afterFinallyAdviceIndexes) {
577 synchronized (m_afterFinallyAdviceNames) {
578 m_afterFinallyAdviceNames = new String[advices.size()];
579 m_afterFinallyAdviceIndexes = new AdviceInfo[advices.size()];
580 int i = 0;
581 for (Iterator it = advices.iterator(); it.hasNext(); i++) {
582 try {
583 NameIndexTuple tuple = (NameIndexTuple) it.next();
584 m_afterFinallyAdviceNames[i] = tuple.getName();
585 m_afterFinallyAdviceIndexes[i] = tuple.getIndex();
586 } catch (ClassCastException e) {
587 throw new RuntimeException("advice list must only contain AdviceIndexTuples");
588 }
589 }
590 }
591 }
592 }
593
594 /***
595 * Returns the around advice name at the given index.
596 *
597 * @return the advice name
598 */
599 public String getAroundAdviceName(int index) {
600 return m_aroundAdviceNames[index];
601 }
602
603 /***
604 * Returns a specific advice index.
605 *
606 * @TODO not used - remove?
607 *
608 * @return the advice index
609 */
610 public AdviceInfo getAroundAdviceIndex(final int index) {
611 return m_aroundAdviceIndexes[index];
612 }
613
614 /***
615 * Returns a specific advice index.
616 *
617 * @TODO not used - remove?
618 *
619 * @return the advice index
620 */
621 public AdviceInfo getBeforeAdviceIndex(final int index) {
622 return m_beforeAdviceIndexes[index];
623 }
624
625 /***
626 * Returns a specific advice index.
627 *
628 * @TODO not used - remove?
629 *
630 * @return the advice index
631 */
632 public AdviceInfo getAfterAdviceIndex(final int index) {
633 return m_afterFinallyAdviceIndexes[index];
634 }
635
636 /***
637 * Returns a list with the indexes for the around advices for the pointcut.
638 *
639 * @return the advices
640 */
641 public AdviceInfo[] getAroundAdviceIndexes() {
642 return m_aroundAdviceIndexes;
643 }
644
645 /***
646 * Returns a list with the indexes for the before advices for the pointcut.
647 *
648 * @return the advices
649 */
650 public AdviceInfo[] getBeforeAdviceIndexes() {
651 return m_beforeAdviceIndexes;
652 }
653
654 /***
655 * Returns the before advice name at the given index
656 *
657 * @return the advice name
658 */
659 public String getBeforeAdviceName(int index) {
660 return m_beforeAdviceNames[index];
661 }
662
663 /***
664 * Returns a list with the indexes for the after advices for the pointcut.
665 *
666 * @return the advices
667 */
668 public AdviceInfo[] getAfterFinallyAdviceIndexes() {
669 return m_afterFinallyAdviceIndexes;
670 }
671
672 /***
673 * Returns a list with the indexes for the after advices for the pointcut.
674 *
675 * @return the advices
676 */
677 public AdviceInfo[] getAfterReturningAdviceIndexes() {
678 return m_afterReturningAdviceIndexes;
679 }
680
681 /***
682 * Returns a list with the indexes for the after advices for the pointcut.
683 *
684 * @return the advices
685 */
686 public AdviceInfo[] getAfterThrowingAdviceIndexes() {
687 return m_afterThrowingAdviceIndexes;
688 }
689
690 /***
691 * Returns the after advice name at the given index
692 *
693 * @return the advice name
694 */
695 public String getAfterFinallyAdviceName(int index) {
696 return m_afterFinallyAdviceNames[index];
697 }
698
699 /***
700 * Returns the after advice name at the given index
701 *
702 * @return the advice name
703 */
704 public String getAfterReturningAdviceName(int index) {
705 return m_afterReturningAdviceNames[index];
706 }
707
708 /***
709 * Returns the after advice name at the given index
710 *
711 * @return the advice name
712 */
713 public String getAfterThrowingAdviceName(int index) {
714 return m_afterThrowingAdviceNames[index];
715 }
716
717 /***
718 * Returns the expression for the pointcut.
719 *
720 * @return the expression
721 */
722 public ExpressionInfo getExpressionInfo() {
723 return m_expressionInfo;
724 }
725
726 /***
727 * Returns the aspect manager.
728 *
729 * @return the aspect manager
730 */
731 public AspectManager getAspectManager() {
732 return m_aspectManager;
733 }
734
735 /***
736 * Provides custom deserialization.
737 *
738 * @param stream the object input stream containing the serialized object
739 * @throws java.lang.Exception in case of failure
740 * @TODO needs aspectManager recovery
741 */
742 private void readObject(final ObjectInputStream stream) throws Exception {
743 ObjectInputStream.GetField fields = stream.readFields();
744 m_expressionInfo = (ExpressionInfo) fields.get("m_annotation", null);
745 m_aroundAdviceNames = (String[]) fields.get("m_aroundAdviceNames", null);
746 m_aroundAdviceIndexes = (AdviceInfo[]) fields.get("m_aroundAdviceIndexes", null);
747 m_beforeAdviceNames = (String[]) fields.get("m_beforeAdviceNames", null);
748 m_beforeAdviceIndexes = (AdviceInfo[]) fields.get("m_beforeAdviceIndexes", null);
749 m_afterFinallyAdviceNames = (String[]) fields.get("m_afterFinallyAdviceNames", null);
750 m_afterFinallyAdviceIndexes = (AdviceInfo[]) fields.get("m_afterFinallyAdviceIndexes", null);
751 }
752 }