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 BSD-style license *
06: * a copy of which has been included with this distribution in the license.txt file. *
07: **************************************************************************************/package examples.asynch;
08:
09: import EDU.oswego.cs.dl.util.concurrent.PooledExecutor;
10: import org.codehaus.aspectwerkz.joinpoint.JoinPoint;
11: import org.codehaus.aspectwerkz.exception.WrappedRuntimeException;
12:
13: /**
14: * @author <a href="mailto:jboner@codehaus.org">Jonas BonŽr </a>
15: */
16: public class AsynchAspect {
17:
18: private PooledExecutor m_threadPool = new PooledExecutor();
19:
20: public Object execute(final JoinPoint joinPoint) throws Throwable {
21: m_threadPool.execute(new Runnable() {
22: public void run() {
23: try {
24: // proceed in a new thread
25: joinPoint.proceed();
26: } catch (Throwable e) {
27: throw new WrappedRuntimeException(e);
28: }
29: }
30: });
31: return null;
32: }
33: }
|