KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > examples > asynch > AsynchAspect


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 BSD-style license *
6  * a copy of which has been included with this distribution in the license.txt file. *
7  **************************************************************************************/

8 package examples.asynch;
9
10 import EDU.oswego.cs.dl.util.concurrent.PooledExecutor;
11 import org.codehaus.aspectwerkz.joinpoint.JoinPoint;
12 import org.codehaus.aspectwerkz.exception.WrappedRuntimeException;
13
14 /**
15  * @author <a HREF="mailto:jboner@codehaus.org">Jonas BonŽr </a>
16  */

17 public class AsynchAspect {
18
19     private PooledExecutor m_threadPool = new PooledExecutor();
20
21     public Object JavaDoc execute(final JoinPoint joinPoint) throws Throwable JavaDoc {
22         m_threadPool.execute(
23                 new Runnable JavaDoc() {
24                     public void run() {
25                         try {
26                             // proceed in a new thread
27
joinPoint.proceed();
28                         } catch (Throwable JavaDoc e) {
29                             throw new WrappedRuntimeException(e);
30                         }
31                     }
32                 }
33         );
34         return null;
35     }
36 }
Popular Tags