KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > test > interceptor > ctx_passing > ServerInterceptor


1 package test.interceptor.ctx_passing;
2
3 import org.omg.PortableInterceptor.*;
4 import org.omg.IOP.Codec JavaDoc;
5 import org.omg.IOP.ServiceContext JavaDoc;
6
7 /**
8  * ServerInterceptor.java
9  *
10  *
11  * Created: Fri Oct 26 11:17:02 2001
12  *
13  * @author Nicolas Noffke
14  * @version $Id: ServerInterceptor.java,v 1.3 2001/11/22 15:59:42 prism Exp $
15  */

16
17 public class ServerInterceptor
18     extends org.omg.CORBA.LocalObject JavaDoc
19     implements ServerRequestInterceptor
20 {
21     private int slot_id = -1;
22     private Codec JavaDoc codec = null;
23
24     public ServerInterceptor(int slot_id, Codec JavaDoc codec)
25     {
26         this.slot_id = slot_id;
27         this.codec = codec;
28     }
29
30     // implementation of org.omg.PortableInterceptor.InterceptorOperations interface
31
public String JavaDoc name()
32     {
33         return "ServerInterceptor";
34     }
35
36     public void destroy()
37     {
38     }
39
40     public void receive_request_service_contexts(ServerRequestInfo ri)
41         throws ForwardRequest
42     {
43         System.out.println("ServerInterceptor: receive_request_service_contexts()");
44         
45         try
46         {
47             ServiceContext JavaDoc ctx =
48                 ri.get_request_service_context( 4711 );
49
50             ri.set_slot( slot_id, codec.decode( ctx.context_data ));
51         }
52         catch (Exception JavaDoc e)
53         {
54             e.printStackTrace();
55         }
56     }
57
58     public void receive_request(ServerRequestInfo ri)
59         throws ForwardRequest{
60     }
61
62     public void send_reply(ServerRequestInfo ri){
63     }
64
65     public void send_exception(ServerRequestInfo ri)
66         throws ForwardRequest{
67     }
68
69     public void send_other(ServerRequestInfo ri)
70         throws ForwardRequest{
71     }
72
73 }// ServerInterceptor
74

75
76
Popular Tags