KickJava   Java API By Example, From Geeks To Geeks.

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


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 /**
31  * @author Jerome Offroy
32  *
33  *class used to read CORBA::ServerRequestInfo
34  *
35  */

36 //TODO change logLevel to a more configurable way to get CORBA information about current call
37
public class ServerRequestInfoReader extends RequestInfoReader {
38
39     /**
40      * constant defining the more verbose server Loglevel
41      */

42     final static private short logLevelServerStart = 2;
43
44     /**
45      * Constructor
46      * @param logLevel
47      **/

48     public ServerRequestInfoReader(short logLevel) {
49         super(logLevel);
50     }
51
52     /************************************************************************
53      * Public Method
54      ***********************************************************************/

55     /**
56      * Method displayServerRequestInfoMONOLOG.
57      * @param info
58      * @return String
59      **/

60     public String JavaDoc displayServerRequestInfoMonolog(org.omg.PortableInterceptor.ServerRequestInfo JavaDoc info) {
61             return displayServerRequestInfoMonolog(info,true);
62     }
63         
64     /**
65      * Method displayServerRequestInfoMONOLOG.
66      * @param info
67      * @param withException
68      * @return String
69      */

70     public String JavaDoc displayServerRequestInfoMonolog(org.omg.PortableInterceptor.ServerRequestInfo JavaDoc info, boolean withException) {
71         String JavaDoc res = "";
72         res = res + displayRequestInfo(info, logLevel) ;
73         if (withException) res = res + displayException(info);
74         if (logLevel > logLevelServerStart) {
75             res = res + displayObjectID(info) + displayAdapterID(info);
76         }
77         res = res + displayMostDerivedInterface(info);
78
79         return res;
80     }
81
82     /************************************************************************
83      * Protected Method
84      ***********************************************************************/

85
86     /**
87      * Display PortableInterceptor::ServerRequestInfo ObjectID
88      * @param info
89      * @return String
90      **/

91     protected String JavaDoc displayObjectID(org.omg.PortableInterceptor.ServerRequestInfo JavaDoc info) {
92         String JavaDoc res = "";
93         try {
94             byte[] octets = info.object_id();
95             res = res + "object id = ";
96             for (int i = 0; i < octets.length; i++)
97                 res = res + getOctet(octets[i]);
98         } catch (org.omg.CORBA.BAD_INV_ORDER JavaDoc ex) {
99             // res = res + "Operation not supported in this context";
100
}
101         return res;
102     }
103
104     /**
105      * Display PortableInterceptor::ServerRequestInfo AdapterID
106      * @param info
107      * @return String
108      **/

109     protected String JavaDoc displayAdapterID(org.omg.PortableInterceptor.ServerRequestInfo JavaDoc info) {
110         String JavaDoc res = "";
111         try {
112             byte[] octets = info.adapter_id();
113             res = res + "adapter id = ";
114             for (int i = 0; i < octets.length; i++)
115                 res = res + getOctet(octets[i]);
116         } catch (org.omg.CORBA.BAD_INV_ORDER JavaDoc ex) {
117             //res = res + "Operation not supported in this context";
118
}
119         return res;
120     }
121
122     /**
123      * Display PortableInterceptor::ServerRequestInfo MostDerivedInterface
124      * @param info
125      * @return String
126      **/

127     protected String JavaDoc displayMostDerivedInterface(org.omg.PortableInterceptor.ServerRequestInfo JavaDoc info) {
128         String JavaDoc res = "";
129         try {
130             String JavaDoc tmdi = info.target_most_derived_interface();
131             res = res + "\ttarget most derived interface = " + tmdi;
132         } catch (org.omg.CORBA.BAD_INV_ORDER JavaDoc ex) {
133             // Operation not supported in this context
134
}
135         return res;
136     }
137
138     /************************************************************************
139      * Abstract implementation Method
140      ***********************************************************************/

141
142     protected String JavaDoc displayMore(org.omg.PortableInterceptor.RequestInfo JavaDoc info) {
143         return displayServerRequestInfoMonolog((org.omg.PortableInterceptor.ServerRequestInfo JavaDoc) info);
144     }
145
146     protected String JavaDoc getLabelException() {
147         return "sending exception = ";
148     }
149
150     protected org.omg.CORBA.Any JavaDoc requestOpException(org.omg.PortableInterceptor.RequestInfo JavaDoc info) {
151         return ((org.omg.PortableInterceptor.ServerRequestInfo JavaDoc) info).sending_exception();
152     }
153 }
Popular Tags