KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > sapia > ubik > rmi > examples > replication > ServerSideInterceptor


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

18 public class ServerSideInterceptor implements Interceptor {
19   private Foo _target;
20   private Set JavaDoc _siblings;
21
22   /**
23    *
24    */

25   public ServerSideInterceptor(Set JavaDoc siblings, Foo targetInstance) {
26     _siblings = siblings;
27     _target = targetInstance;
28   }
29
30   public void onReplicationEvent(ReplicationEvent evt) {
31     if (evt.getReplicatedCommand() instanceof ReplicatedCommandEx) {
32       System.out.println("Replicated command intercepted...");
33
34       ReplicatedInvokerImpl inv = (ReplicatedInvokerImpl) evt.getReplicatedCommand()
35                                                              .getReplicatedInvoker();
36       inv.setTargetInstance(_target);
37       inv.setSiblings(_siblings);
38     }
39   }
40 }
41
Popular Tags