KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > sapia > ubik > rmi > examples > interceptor > HitCountInterceptor


1 package org.sapia.ubik.rmi.examples.interceptor;
2
3 import org.sapia.ubik.rmi.interceptor.Interceptor;
4 import org.sapia.ubik.rmi.server.Hub;
5 import org.sapia.ubik.rmi.server.invocation.ServerPreInvokeEvent;
6
7
8 /**
9  * @author Yanick Duchesne
10  * <dl>
11  * <dt><b>Copyright:</b><dd>Copyright &#169; 2002-2003 <a HREF="http://www.sapia-oss.org">Sapia Open Source Software</a>. All Rights Reserved.</dd></dt>
12  * <dt><b>License:</b><dd>Read the license.txt file of the jar or visit the
13  * <a HREF="http://www.sapia-oss.org/license.html">license page</a> at the Sapia OSS web site</dd></dt>
14  * </dl>
15  */

16 public class HitCountInterceptor implements Interceptor {
17   private int _count;
18
19   public synchronized void onServerPreInvokeEvent(ServerPreInvokeEvent evt) {
20     _count++;
21   }
22
23   public synchronized int getCount() {
24     return _count;
25   }
26
27   public static void main(String JavaDoc[] args) {
28     Hub.serverRuntime.dispatcher.addInterceptor(ServerPreInvokeEvent.class,
29       new HitCountInterceptor());
30   }
31 }
32
Popular Tags