KickJava   Java API By Example, From Geeks To Geeks.

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


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

17
18 public class ClientInterceptor
19     extends org.omg.CORBA.LocalObject JavaDoc
20     implements ClientRequestInterceptor
21 {
22     private int slot_id = -1;
23     private Codec JavaDoc codec = null;
24
25     public ClientInterceptor(int slot_id, Codec JavaDoc codec)
26     {
27         this.slot_id = slot_id;
28         this.codec = codec;
29     }
30
31     public String JavaDoc name()
32     {
33         return "ClientInterceptor";
34     }
35
36     public void destroy()
37     {
38     }
39
40     public void send_request( ClientRequestInfo ri )
41         throws ForwardRequest
42     {
43         System.out.println("ClientInterceptor: send_request()");
44         
45         try
46         {
47             org.omg.CORBA.Any JavaDoc any = ri.get_slot( slot_id );
48       
49             if( any.type().kind().value() != org.omg.CORBA.TCKind._tk_null )
50             {
51                 ServiceContext JavaDoc ctx =
52                     new ServiceContext JavaDoc(4711, codec.encode( any ));
53
54                 ri.add_request_service_context( ctx, false );
55             }
56         }
57         catch (Exception JavaDoc e)
58         {
59             e.printStackTrace();
60         }
61     }
62
63     public void send_poll(ClientRequestInfo ri)
64     {
65     }
66
67     public void receive_reply(ClientRequestInfo ri)
68     {
69     }
70
71     public void receive_exception(ClientRequestInfo ri)
72         throws ForwardRequest
73     {
74     }
75
76     public void receive_other(ClientRequestInfo ri)
77         throws ForwardRequest
78     {
79     }
80 }// ClientInterceptor
81
Popular Tags