KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > openccm > Containers > Plugins > TraceController


1 /*====================================================================
2
3 OpenCCM: The Open CORBA Component Model Platform
4 Copyright (C) 2001-2002 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): Mathieu Vadet.
23 Contributor(s): ______________________________________.
24
25 ====================================================================*/

26
27 package org.objectweb.openccm.Containers.Plugins;
28
29 /**
30  * This interface ??????.
31  *
32  * @author <a HREF="mailto:Mathieu.Vadet@lifl.fr">Mathieu Vadet</a>
33  *
34  * @version 0.3
35  */

36
37 public class TraceController
38        extends org.omg.CORBA.LocalObject JavaDoc
39        implements org.objectweb.openccm.Containers.CallController
40 {
41     // ==================================================================
42
//
43
// Internal state.
44
//
45
// ==================================================================
46

47     /**
48      **
49      **/

50     private java.io.PrintStream JavaDoc trace_;
51
52     // ==================================================================
53
//
54
// Constructor.
55
//
56
// ==================================================================
57

58     /**
59      ** The constructor.
60      **
61      **/

62     public
63     TraceController()
64     {
65     }
66
67     // ==================================================================
68
//
69
// Internal methods.
70
//
71
// ==================================================================
72

73     /**
74      **
75      **/

76     protected static java.lang.String JavaDoc
77     monthToString(int month)
78     {
79         switch(month)
80         {
81             case java.util.Calendar.JANUARY :
82                 return "January";
83             case java.util.Calendar.FEBRUARY :
84                 return "February";
85             case java.util.Calendar.MARCH :
86                 return "March";
87             case java.util.Calendar.APRIL :
88                 return "April";
89             case java.util.Calendar.MAY :
90                 return "May";
91             case java.util.Calendar.JUNE :
92                 return "June";
93             case java.util.Calendar.JULY :
94                 return "July";
95             case java.util.Calendar.AUGUST :
96                 return "August";
97             case java.util.Calendar.SEPTEMBER :
98                 return "September";
99             case java.util.Calendar.OCTOBER :
100                 return "October";
101             case java.util.Calendar.NOVEMBER :
102                 return "November";
103             case java.util.Calendar.DECEMBER :
104                 return "December";
105             default :
106                 return "";
107         }
108     }
109
110     /**
111      **
112      **/

113     protected java.lang.String JavaDoc
114     getTime()
115     {
116         java.util.GregorianCalendar JavaDoc cal = new java.util.GregorianCalendar JavaDoc();
117         java.lang.String JavaDoc res = "";
118         res = res + java.lang.Integer.toString(cal.get(java.util.GregorianCalendar.HOUR_OF_DAY)) + ":";
119         res = res + java.lang.Integer.toString(cal.get(java.util.GregorianCalendar.MINUTE)) + " on ";
120         int month = cal.get(java.util.GregorianCalendar.MONTH);
121         res = res + monthToString(month) + " ";
122         res = res + java.lang.Integer.toString(cal.get(java.util.GregorianCalendar.DAY_OF_MONTH)) + ", ";
123         res = res + java.lang.Integer.toString(cal.get(java.util.GregorianCalendar.YEAR));
124         return res;
125     }
126
127     // ==================================================================
128
//
129
// Public methods for the CallController interface.
130
//
131
// ==================================================================
132

133     // ==================================================================
134
//
135
// Public methods for the CallProtocol interface.
136
//
137
// ==================================================================
138

139     //
140
// IDL:goal.lifl.fr/OpenCCM/Containers/CallProtocol/preinvoke:1.0
141
//
142
/**
143      **
144      **/

145     public void
146     preinvoke(org.objectweb.openccm.Containers.CallContext ctx)
147     {
148         java.lang.String JavaDoc msg =
149             "### preinvoke was called at "+getTime()+"\n"+
150             " on interface : \""+ctx.uid()+"\"\n"+
151             " on operation : \""+ctx.operation_name()+"\"\n";
152
153         trace_.print(msg);
154     }
155
156     //
157
// IDL:goal.lifl.fr/OpenCCM/Containers/CallProtocol/postinvoke:1.0
158
//
159
/**
160      **
161      **/

162     public void
163     postinvoke(org.objectweb.openccm.Containers.CallContext ctx)
164     {
165         java.lang.String JavaDoc msg =
166             "### postinvoke was called at "+getTime()+"\n"+
167             " on interface : \""+ctx.uid()+"\"\n"+
168             " on operation : \""+ctx.operation_name()+"\"\n";
169
170         trace_.print(msg);
171     }
172
173     // ==================================================================
174
//
175
// Public methods for the SystemComponent interface.
176
//
177
// ==================================================================
178

179     // ==================================================================
180
//
181
// Public methods for the Configuration interface.
182
//
183
// ==================================================================
184

185     //
186
// IDL:goal.lifl.fr/OpenCCM/Containers/Configuration/configure:1.0
187
//
188
/**
189      **
190      **/

191     public void
192     configure(org.objectweb.openccm.Containers.PropertySet config)
193     throws org.objectweb.openccm.Containers.ConfigurationFailed
194     {
195         try
196         {
197             java.lang.String JavaDoc filename = config.get_as_string("filename").value();
198             trace_ = new java.io.PrintStream JavaDoc(new java.io.FileOutputStream JavaDoc(filename));
199         }
200         catch(org.objectweb.openccm.Containers.UnknownProperty ex)
201         {
202             java.lang.String JavaDoc msg =
203                 "exception in class org.objectweb.openccm.Containers.Plugins.TraceController\n"+
204                 " operation : configure\n"+
205                 " message : "+ex.getMessage();
206             throw new org.objectweb.openccm.Containers.ConfigurationFailed(msg);
207         }
208         catch(org.objectweb.openccm.Containers.BadPropertyKind ex)
209         {
210             java.lang.String JavaDoc msg =
211                 "exception in class org.objectweb.openccm.Containers.Plugins.TraceController\n"+
212                 " operation : configure\n"+
213                 " message : "+ex.getMessage();
214             throw new org.objectweb.openccm.Containers.ConfigurationFailed(msg);
215         }
216         catch(java.io.FileNotFoundException JavaDoc ex)
217         {
218             java.lang.String JavaDoc msg =
219                 "exception in class org.objectweb.openccm.Containers.Plugins.TraceController\n"+
220                 " operation : configure\n"+
221                 " message : "+ex.getMessage();
222             throw new org.objectweb.openccm.Containers.ConfigurationFailed(msg);
223         }
224     }
225 }
226
Popular Tags