KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > ccm > logservice > LogCallControllerImpl


1 // ====================================================================
2
//
3
// ECM: The Extensible Container Model
4
// Copyright (C) 2004 THALES
5
// Contact: openccm-ecm@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
// Initial Funding: IST COACH European project (IST-2001-34445)
24
// http://www.ist-coach.org
25
//
26
// ====================================================================
27

28
29
30 package org.objectweb.ccm.logservice;
31
32 import org.objectweb.corba.runtime.*;
33 import org.objectweb.corba.logservice.*;
34
35 /**
36  ** <p>Implementation of the <tt>ECA::ClientCallController</tt> and the
37  ** <tt>ECA::ServerCallController</tt> OMG IDL interfaces.</p>
38  **/

39 public class LogCallControllerImpl
40 extends org.omg.CORBA.LocalObject JavaDoc
41 implements org.coach.ECA.ClientCallController,
42            org.coach.ECA.ServerCallController
43 {
44     //
45
private LogCurrent _current;
46
47     public
48     LogCallControllerImpl(LogCurrent current,
49                           String JavaDoc scheme)
50     {
51         _current = current;
52         // NOTE: scheme is not used currently
53
}
54
55     //
56
// internal operations
57
//
58

59     private LogCurrent
60     getLogCurrent()
61     {
62         return _current;
63     }
64
65     //
66
// IDL:coach.org/ECA/CallController:1.0
67
//
68

69     final public void
70     destroy()
71     {
72     }
73
74     //
75
// IDL:coach.org/ECA/ClientCallController:1.0
76
//
77

78     final public void
79     send_request(org.coach.ECA.ClientCallContext ctx)
80     {
81         // obtain log callback
82
LogCallback callback = null;
83         String JavaDoc cid = "";
84         try {
85             callback = (LogCallback)ctx.get_service_callback(LOG_SERVICE_ID.value, LOG_SERVICE_CALLBACK_ID.value);
86             // obtain client id
87
cid = callback.get_identity();
88         } catch(org.coach.ECM.UnknownService ex) {
89         } catch(org.coach.ECM.UnknownServiceCallback ex) {
90         }
91
92         // set client id in current
93
org.omg.CORBA.Any JavaDoc acid = ctx.create_any();
94         acid.insert_string(cid);
95         getLogCurrent().current_id(acid);
96
97         // build message
98
MessageContent content = new MessageContent();
99         java.util.Calendar JavaDoc cal = java.util.Calendar.getInstance();
100         content.timestamp = java.lang.Long.toString(cal.getTimeInMillis());
101         content.interception_point = "SEND_REQUEST";
102         content.operation_name = ctx.call_information().operation_name;
103         content.sender_id = cid;
104         content.receiver_id = "";
105         content.data = "";
106
107         // obtain log internal
108
LogInternal internal = null;
109         internal = (LogInternal)ctx.get_service_internal(LOG_SERVICE_ID.value, LOG_SERVICE_INTERNAL_ID.value);
110
111         // send message
112
LogEvent evt = new LogEvent();
113         evt.level = INFO_LEVEL.value;
114         evt.message = content;
115         internal.log_event(evt);
116     }
117
118     final public void
119     receive_reply(org.coach.ECA.ClientCallContext ctx)
120     {
121     }
122
123     final public void
124     receive_system_exception(org.coach.ECA.ClientCallContext ctx)
125     {
126     }
127
128     final public void
129     receive_user_exception(org.coach.ECA.ClientCallContext ctx)
130     {
131     }
132
133     //
134
// IDL:coach.org/ECA/ServerCallController:1.0
135
//
136

137     final public void
138     receive_request(org.coach.ECA.ServerCallContext ctx)
139     {
140         // get client id in current
141
org.omg.CORBA.Any JavaDoc acid = getLogCurrent().current_id();
142         String JavaDoc cid = "";
143         if ((acid!=null) && (acid.type().kind()!=org.omg.CORBA.TCKind.tk_null)) {
144             cid = acid.extract_string();
145         }
146
147         // obtain log callback
148
LogCallback callback = null;
149         String JavaDoc sid = "";
150         try {
151             callback = (LogCallback)ctx.get_service_callback(LOG_SERVICE_ID.value, LOG_SERVICE_CALLBACK_ID.value);
152             // obtain client id
153
sid = callback.get_identity();
154         } catch(org.coach.ECM.UnknownService ex) {
155         } catch(org.coach.ECM.UnknownServiceCallback ex) {
156         }
157
158         // build message
159
MessageContent content = new MessageContent();
160         java.util.Calendar JavaDoc cal = java.util.Calendar.getInstance();
161         content.timestamp = java.lang.Long.toString(cal.getTimeInMillis());
162         content.interception_point = "RECEIVE_REQUEST";
163         content.operation_name = ctx.call_information().operation_name;
164         content.sender_id = cid;
165         content.receiver_id = sid;
166         content.data = "";
167
168         // obtain log internal
169
LogInternal internal = null;
170         internal = (LogInternal)ctx.get_service_internal(LOG_SERVICE_ID.value, LOG_SERVICE_INTERNAL_ID.value);
171
172         // send message
173
LogEvent evt = new LogEvent();
174         evt.level = INFO_LEVEL.value;
175         evt.message = content;
176         internal.log_event(evt);
177     }
178
179     final public void
180     send_reply(org.coach.ECA.ServerCallContext ctx)
181     {
182     }
183
184     final public void
185     send_system_exception(org.coach.ECA.ServerCallContext ctx)
186     {
187     }
188
189     final public void
190     send_user_exception(org.coach.ECA.ServerCallContext ctx)
191     {
192     }
193 }
194
Popular Tags