KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > perseus > concurrency > distributed > globallock > UserInterceptor


1 package org.objectweb.perseus.concurrency.distributed.globallock;
2
3 import org.objectweb.perseus.distribution.api.DistResUser;
4 import java.io.Serializable JavaDoc;
5
6 public class UserInterceptor implements DistResUser {
7     DistResUser dru;
8     GlobalLockInterceptor.FailureListener failureListener;
9     Serializable JavaDoc nodeId;
10
11     public UserInterceptor(DistResUser dru, Serializable JavaDoc nodeId) {
12         this.dru = dru;
13         this.nodeId = nodeId;
14     }
15
16     public void receive(Serializable JavaDoc resId, Serializable JavaDoc message) {
17         dru.receive(resId, message);
18     }
19
20     public Serializable JavaDoc getState(Serializable JavaDoc resId) {
21         Serializable JavaDoc ret = dru.getState(resId);
22         if (failureListener != null)
23             failureListener.handle(resId, nodeId);
24         return ret;
25     }
26
27     public void setFailureListener(GlobalLockInterceptor.FailureListener failureListener) {
28         this.failureListener = failureListener;
29     }
30 }
31
Popular Tags