KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tctest > spring > bean > SingletonAdvice


1 /*
2  * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
3  */

4 package com.tctest.spring.bean;
5
6 import org.aopalliance.intercept.MethodInterceptor;
7 import org.aopalliance.intercept.MethodInvocation;
8
9 public class SingletonAdvice implements MethodInterceptor, ISingletonAdvice {
10   private int counter = 0;
11   
12   public Object JavaDoc invoke(MethodInvocation invocation) throws Throwable JavaDoc {
13     synchronized(this) {
14       this.counter++;
15     }
16     return invocation.proceed();
17   }
18   
19   synchronized public int getCounter() {
20     return counter;
21   }
22
23 }
24
Popular Tags