01: /**************************************************************************************
02: * Copyright (c) Jonas BonŽr, Alexandre Vasseur. All rights reserved. *
03: * http://aspectwerkz.codehaus.org *
04: * ---------------------------------------------------------------------------------- *
05: * The software in this package is published under the terms of the LGPL license *
06: * a copy of which has been included with this distribution in the license.txt file. *
07: **************************************************************************************/package test.proceedinnewthread;
08:
09: import org.codehaus.aspectwerkz.joinpoint.JoinPoint;
10:
11: /**
12: * @author <a href="mailto:jboner@codehaus.org">Jonas BonŽr </a>
13: */
14: public class TestAspect {
15:
16: public Object advice1(final JoinPoint jp) throws Throwable {
17: Thread t = new Thread(new Runnable() {
18: public void run() {
19: try {
20: ProceedTest.LOG += "advice1Pre ";
21: jp.proceed();
22: ProceedTest.LOG += "advice1Post ";
23: } catch (Throwable e) {
24: throw new RuntimeException(e.toString());
25: }
26: }
27: });
28: // Note: in 2.0, it happens that the context switch does not occurs and the test case reach the assertion
29: // before the new thread updates the test data LOG. We force priority just in case
30: // but it may still corrupt the test case.
31: t.setPriority(Thread.MAX_PRIORITY);
32: t.start();
33: return null;
34: }
35:
36: public Object advice2(final JoinPoint jp) throws Throwable {
37: ProceedTest.LOG += "advice2Pre ";
38: jp.proceed();
39: ProceedTest.LOG += "advice2Post ";
40: return null;
41: }
42:
43: public Object advice3(final JoinPoint jp) throws Throwable {
44: ProceedTest.LOG += "advice3Pre ";
45: jp.proceed();
46: ProceedTest.LOG += "advice3Post ";
47: return null;
48: }
49: }
|