KickJava   Java API By Example, From Geeks To Geeks.

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


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 SecurityServiceImpl implements SecurityService, Interceptor {
17   /**
18    * @see org.sapia.ubik.rmi.examples.interceptor.SecurityService#call()
19    */

20   public void call() {
21     System.out.println("call performed...");
22   }
23
24   public void onServerPreInvokeEvent(ServerPreInvokeEvent evt) {
25     throw new RuntimeException JavaDoc("call forbidden");
26   }
27
28   public static void main(String JavaDoc[] args) {
29     try {
30       SecurityServiceImpl svc = new SecurityServiceImpl();
31       Hub.serverRuntime.addInterceptor(ServerPreInvokeEvent.class, svc);
32       Hub.exportObject(svc, 6767);
33
34       while (true) {
35         Thread.sleep(10000);
36       }
37     } catch (Exception JavaDoc e) {
38       e.printStackTrace();
39     }
40   }
41 }
42
Popular Tags