KickJava   Java API By Example, From Geeks To Geeks.

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


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 /**
30  * @author offroy@lifl.fr
31  *
32  * used to read CORBA::ClientRequestInfo
33  *
34  */

35 //TODO change logLevel to a more configurable way to get CORBA information about current call
36
public class ClientRequestInfoReader extends RequestInfoReader {
37     /**
38      * CORBA Client Portable Interceptor Trace level
39      */

40     final static private short logLevelClientStart = 2;
41
42     /**
43      * Constructor
44      * @param logLevel
45      **/

46     public ClientRequestInfoReader(short logLevel) {
47         super(logLevel);
48     }
49
50     /************************************************************************
51      * Public Method
52      ***********************************************************************/

53     /**
54      * Method displayServerRequestInfoMONOLOG.
55      * @param info
56      * @return String
57      **/

58     public String JavaDoc displayClientRequestInfoMonolog(org.omg.PortableInterceptor.ClientRequestInfo JavaDoc info) {
59             return displayClientRequestInfoMonolog(info,true);
60     }
61     
62     /**
63     * Display PortableInterceptor::ClientRequestInfo MONOLOG
64     * @param info
65     * @return String
66     **/

67     public String JavaDoc displayClientRequestInfoMonolog(
68         org.omg.PortableInterceptor.ClientRequestInfo JavaDoc info,boolean withException) {
69         String JavaDoc res = "";
70         res = res + displayRequestInfo(info, logLevel);
71         if (withException) res = res + displayException(info); // cause NO_RESSOURCE with OpenORB1.3.0
72
if (logLevel > logLevelClientStart) {
73             res = res + displayEffectiveProfile(info);
74         }
75         res = res + displayReceivedExceptionID(info);
76
77         return res;
78     }
79
80     /************************************************************************
81      * Protected Method
82      ***********************************************************************/

83
84     /**
85      * Display PortableInterceptor::ClientRequestInfo EffectiveProfile
86      * @param info
87      * @return String
88      **/

89     protected String JavaDoc displayEffectiveProfile(
90         org.omg.PortableInterceptor.ClientRequestInfo JavaDoc info) {
91         org.omg.IOP.TaggedProfile JavaDoc profile = info.effective_profile();
92         String JavaDoc res = "effective profile = ";
93         if (profile.tag == org.omg.IOP.TAG_INTERNET_IOP.value)
94             res = res + "TAG_INTERNET_IOP";
95         else if (profile.tag == org.omg.IOP.TAG_MULTIPLE_COMPONENTS.value)
96             res = res + "TAG_MULTIPLE_COMPONENTS";
97         else
98             res = res + "UNKNOWN_TAG";
99         res = res + ": \n\t";
100         for (int i = 0; i < profile.profile_data.length; i++)
101             res = res + getOctet(profile.profile_data[i]);
102         return res;
103     }
104
105     /**
106      * Display PortableInterceptor::ClientRequestInfo ReceivedExceptionID
107      * @param info
108      * @return String
109      **/

110     protected String JavaDoc displayReceivedExceptionID(
111         org.omg.PortableInterceptor.ClientRequestInfo JavaDoc info) {
112         String JavaDoc res = "";
113         try {
114             res =
115                 res
116                     + "\t"
117                     + "received exception id = "
118                     + info.received_exception_id();
119         } catch (org.omg.CORBA.BAD_INV_ORDER JavaDoc ex) {
120             //res = res + "Operation not supported in this context";
121
}
122         //res = res + "\n";
123
return res;
124     }
125
126     /************************************************************************
127      * Abstract implementation Method
128      ***********************************************************************/

129
130     protected String JavaDoc getLabelException() {
131         return "received exception = ";
132     }
133
134     protected String JavaDoc displayMore(
135         org.omg.PortableInterceptor.RequestInfo JavaDoc info) {
136         return displayClientRequestInfoMonolog(
137             (org.omg.PortableInterceptor.ClientRequestInfo JavaDoc) info);
138     }
139
140     protected org.omg.CORBA.Any JavaDoc requestOpException(
141         org.omg.PortableInterceptor.RequestInfo JavaDoc info) {
142                 org.omg.CORBA.Any JavaDoc res = null;
143                 // ignoring Exception when NO_RESSOURCES raised
144
try{
145                     res = ((org.omg.PortableInterceptor.ClientRequestInfo JavaDoc) info)
146                         .received_exception();
147                 }catch (org.omg.CORBA.NO_RESOURCES JavaDoc ex){}
148         return res;
149     }
150 }
151
Popular Tags