KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > nanocontainer > aop > LoggingInterceptor


1 /*****************************************************************************
2  * Copyright (c) PicoContainer Organization. All rights reserved. *
3  * ------------------------------------------------------------------------- *
4  * The software in this package is published under the terms of the BSD *
5  * style license a copy of which has been included with this distribution in *
6  * the LICENSE.txt file. *
7  * *
8  * Idea by Rachel Davies, Original code by various *
9  *****************************************************************************/

10 package org.nanocontainer.aop;
11
12 import org.aopalliance.intercept.MethodInterceptor;
13 import org.aopalliance.intercept.MethodInvocation;
14
15 /**
16  * @author Stephen Molitor
17  */

18 public class LoggingInterceptor implements MethodInterceptor {
19
20     private final StringBuffer JavaDoc log;
21
22     public LoggingInterceptor(StringBuffer JavaDoc log) {
23         this.log = log;
24     }
25
26     public Object JavaDoc invoke(MethodInvocation invocation) throws Throwable JavaDoc {
27         log.append("start");
28         Object JavaDoc result = invocation.proceed();
29         log.append("end");
30         return result;
31     }
32
33 }
Popular Tags