KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > corba > trace > PI > TraceCI


1 /*====================================================================
2
3 OpenCCM: The Open CORBA Component Model Platform
4 Copyright (C) 2000-2003 USTL - LIFL - GOAL
5 Contact: openccm-team@objectweb.org
6
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or any later version.
11
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public
18 License along with this library; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20 USA
21
22 Initial developer(s): Jerome Offroy.
23 Contributor(s): ______________________________________.
24
25 ====================================================================*/

26
27 package org.objectweb.corba.trace.PI;
28
29 /* MONOLOG import */
30 import org.objectweb.util.monolog.api.BasicLevel;
31 import org.objectweb.util.monolog.api.Logger;
32
33 /**
34 * The Client side interceptor used to log CORBA Client activity
35  * @author <a HREF="mailto:offroy@lifl.fr">Jerome Offroy@lifl.fr</a>
36  */

37 public class TraceCI extends org.omg.CORBA.LocalObject JavaDoc implements org.omg.PortableInterceptor.ClientRequestInterceptor JavaDoc{
38
39     /**
40       * slot for trace
41       **/

42     private int trace_slot;
43
44     /**
45      * reference logger to use in this class
46      */

47     protected Logger logger_;
48
49     /**
50      * Level of logging for Client side Interceptor
51      */

52     private short logLevelClient;
53     /* TODO change static def of ClientLevelLog */
54     
55     /**
56      * used to get CORBA call information (client side)
57      */

58     protected ClientRequestInfoReader crir_;
59
60     /**
61      * Constructor
62      */

63     public TraceCI(int trace_slot, org.omg.PortableInterceptor.ORBInitInfo JavaDoc info) {
64         /* MONOLOG logger initialization */
65         logger_ = MonologLogger.loggerCI;
66         this.trace_slot = trace_slot;
67         logLevelClient = 1;
68         this.crir_ = new ClientRequestInfoReader(logLevelClient);
69
70         if (MonologLogger.enableTrace)
71             logger_.log(BasicLevel.DEBUG, "Init Trace Interceptor CORBA Client Side");
72     }
73
74     /**********************************************************************
75      * Public Method
76      **********************************************************************/

77     /**
78      * Called when the client send a request to the server
79      * @param ri the client request
80      */

81     public void send_request(org.omg.PortableInterceptor.ClientRequestInfo JavaDoc ri){
82         if (MonologLogger.enableTrace)
83             logger_.log(BasicLevel.INFO, crir_.displayClientRequestInfoMonolog(ri));
84     }
85
86     /**
87      * used to query information during a Time Independent Invocation polling get reply sequence ??
88      * @param ri the client request
89      */

90     public void send_poll(org.omg.PortableInterceptor.ClientRequestInfo JavaDoc ri) {
91          if (MonologLogger.enableTrace)
92             logger_.log(BasicLevel.INFO, crir_.displayClientRequestInfoMonolog(ri));
93     }
94
95     /**
96      * Called when the client receive a reply from the server
97      * @param ri the client request
98      */

99     public void receive_reply(org.omg.PortableInterceptor.ClientRequestInfo JavaDoc ri) {
100          if (MonologLogger.enableTrace)
101             logger_.log(BasicLevel.INFO, crir_.displayClientRequestInfoMonolog(ri));
102     }
103
104     /**
105      * Called when the client receive an exception from the server
106      * @param ri the client request
107      */

108     public void receive_exception(org.omg.PortableInterceptor.ClientRequestInfo JavaDoc ri) {
109          if (MonologLogger.enableTrace)
110             logger_.log(BasicLevel.ERROR, crir_.displayClientRequestInfoMonolog(ri,false));
111     }
112
113     /**
114      * Called when the client receive a message from the server
115      * which is not a reply and not an exception
116      * @param ri the client request
117      */

118     public void receive_other(org.omg.PortableInterceptor.ClientRequestInfo JavaDoc ri) {
119          if (MonologLogger.enableTrace)
120             logger_.log(BasicLevel.INFO, crir_.displayClientRequestInfoMonolog(ri));
121     }
122
123     /**
124      * return the name of the Logging Client Interceptor
125      */

126     public java.lang.String JavaDoc name() {
127         return "LoggingClientInterceptor";
128     }
129
130     /**
131      * Destroy the interceptor.
132      */

133     public void destroy() {
134     }
135 }
136
Popular Tags