KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jacorb > util > tracing > ServerTraceInterceptor


1 package org.jacorb.util.tracing;
2
3 /*
4  * JacORB - a free Java ORB
5  *
6  * Copyright (C) 1999-2004 Gerald Brose
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Library General Public
10  * License as published by the Free Software Foundation; either
11  * version 2 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Library General Public License for more details.
17  *
18  * You should have received a copy of the GNU Library General Public
19  * License along with this library; if not, write to the Free
20  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21  *
22  */

23
24 import java.io.PrintStream JavaDoc;
25 import org.omg.IOP.Codec JavaDoc;
26 import org.omg.PortableInterceptor.ServerRequestInfo JavaDoc;
27 import org.omg.PortableInterceptor.ServerRequestInterceptor JavaDoc;
28
29 public class ServerTraceInterceptor
30     extends org.omg.CORBA.LocalObject JavaDoc
31     implements ServerRequestInterceptor JavaDoc
32 {
33
34
35     private int slot_id;
36     private PrintStream JavaDoc logStream = null;
37     private Codec JavaDoc codec = null;
38
39     public ServerTraceInterceptor( int slot_id, Codec JavaDoc codec )
40     {
41         this(slot_id, codec, System.out);
42     }
43
44     public ServerTraceInterceptor( int slot_id, Codec JavaDoc codec,
45                                    PrintStream JavaDoc logStream )
46     {
47         this.slot_id = slot_id;
48         this.codec = codec;
49         this.logStream = logStream;
50     }
51
52     public String JavaDoc name()
53     {
54         return "ServerTraceInterceptor";
55     }
56
57     public void destroy()
58     {
59     }
60
61     public void receive_request_service_contexts( ServerRequestInfo JavaDoc ri )
62         throws org.omg.PortableInterceptor.ForwardRequest JavaDoc
63     {
64         System.out.println("SI in operation <" + ri.operation() + ">");
65         try
66         {
67             System.out.println("Request for op " + ri.operation());
68
69             org.omg.IOP.ServiceContext JavaDoc ctx =
70                 ri.get_request_service_context( TracingContextID.value );
71
72             ri.set_slot(slot_id, codec.decode(ctx.context_data));
73
74             ri.add_reply_service_context( ctx, true );
75         }
76         catch (org.omg.CORBA.BAD_PARAM JavaDoc bp)
77         {
78             //ignore, SC not present
79

80             System.out.println("ServerRequestInterceptor: " + bp);
81
82         }
83         catch( Exception JavaDoc e )
84         {
85             System.err.println("No service context in operation <" + ri.operation() + ">");
86             e.printStackTrace();
87         }
88     }
89
90     public void receive_request( ServerRequestInfo JavaDoc ri )
91         throws org.omg.PortableInterceptor.ForwardRequest JavaDoc
92     {
93     }
94
95     public void send_reply(org.omg.PortableInterceptor.ServerRequestInfo JavaDoc ri)
96     {
97
98     }
99
100     public void send_exception(org.omg.PortableInterceptor.ServerRequestInfo JavaDoc ri)
101         throws org.omg.PortableInterceptor.ForwardRequest JavaDoc
102     {
103
104     }
105
106     public void send_other(org.omg.PortableInterceptor.ServerRequestInfo JavaDoc ri)
107         throws org.omg.PortableInterceptor.ForwardRequest JavaDoc
108     {
109
110     }
111
112
113 }
114
Popular Tags