KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > openccm > ast > lib > EventDeclImpl


1 /*====================================================================
2
3 OpenCCM: The Open CORBA Component Model Platform
4 Copyright (C) 2000-2004 INRIA & USTL - LIFL - GOAL
5 Contact: openccm@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): Philippe Merle, Mathieu Vadet.
23 Contributor(s): Christophe Demarey.
24
25 ====================================================================*/

26
27 package org.objectweb.openccm.ast.lib;
28
29 /** Used to access AST TypeKind. */
30 import org.objectweb.openccm.ast.api.TypeKind;
31
32 /** Used to access AST DeclarationKind. */
33 import org.objectweb.openccm.ast.api.DeclarationKind;
34
35 /** Used to access AST InterfaceDecl. */
36 import org.objectweb.openccm.ast.api.InterfaceDecl;
37
38 /** To use CORBA::ComponentIR::EventDef. */
39 import org.omg.CORBA.ComponentIR.EventDef;
40 import org.omg.CORBA.ComponentIR.EventDefHelper;
41
42 /**
43  * EventDeclImpl is a wrapper class for IDL eventtype declarations.
44  *
45  *
46  * Inherits from:
47  *
48  * - ValueDeclImpl as eventtypes are also valuetypes,
49  *
50  * - ClientInterfaceMapping
51  * to obtain the equivalent client interface mapping.
52  *
53  *
54  * Provides:
55  *
56  * - The local consumer interface mapping,
57  * i.e. the getLocalConsumerMapping interface operation.
58  *
59  *
60  * @author <a HREF="mailto:Philippe.Merle@lifl.fr">Philippe Merle</a>
61  * <a HREF="mailto:Mathieu.Vadet@lifl.fr">Mathieu Vadet</a>
62  *
63  * @version 0.3
64  */

65
66 public class EventDeclImpl
67        extends ValueDeclImpl
68        implements org.objectweb.openccm.ast.api.EventDecl
69 {
70     // ==================================================================
71
//
72
// Internal state.
73
//
74
// ==================================================================
75

76     /** Reference to the CORBA 3.0 ValueDef. */
77     private EventDef event_def_;
78
79     /** The client interface mapping. **/
80     private InterfaceDeclImpl client_mapping_;
81
82     /** The local consumer interface mapping. **/
83     private InterfaceDeclImpl local_consumer_mapping_;
84
85     // ==================================================================
86
//
87
// Constructor.
88
//
89
// ==================================================================
90

91     /**
92      * The constructor with the parent scope.
93      *
94      * @param parent The parent scope of the value declaration.
95      */

96     public
97     EventDeclImpl(Repository rep,
98                   ScopeImpl parent)
99     {
100         // Call the ValueDeclImpl constructor.
101
super(rep, parent);
102
103         // Init internal state.
104
event_def_ = null;
105         client_mapping_ = null;
106         local_consumer_mapping_ = null;
107     }
108
109     // ==================================================================
110
//
111
// Internal methods.
112
//
113
// ==================================================================
114

115     // ==================================================================
116
//
117
// Internal methods for DeclarationImpl.
118
//
119
// ==================================================================
120

121     /**
122      * Loads infos of the CORBA 3.0 ValueDef.
123      *
124      * @param contained The ValueDef to load.
125      */

126     protected void
127     load(org.omg.CORBA.Contained JavaDoc contained)
128     {
129         event_def_ = EventDefHelper.narrow(contained);
130
131         // load it's mapped declarations
132
getClientMapping();
133         getLocalConsumerMapping();
134
135         super.load(contained);
136     }
137
138     /**
139      * Obtain its CORBA 3.0 Contained reference.
140      *
141      * @return The Contained object associated with the value declaration.
142      */

143     protected org.omg.CORBA.Contained JavaDoc
144     getContained()
145     {
146        return event_def_;
147     }
148
149     // ==================================================================
150
//
151
// Internal methods for ScopeImpl.
152
//
153
// ==================================================================
154

155     /**
156      * Obtain its CORBA 3.0 Container reference.
157      *
158      * @return The Container object associated with the value declaration.
159      */

160     protected org.omg.CORBA.Container JavaDoc
161     getContainer()
162     {
163         return event_def_;
164     }
165
166     // ==================================================================
167
//
168
// Internal methods for ForwardScopeImpl.
169
//
170
// ==================================================================
171

172     /**
173      * Create the container object.
174      */

175     protected void
176     createContainer()
177     {
178         // Create an EventDef into the IFR.
179
event_def_ = the_parent_.getComponentContainer().
180                      create_event(getId(), getName(), getVersion(),
181                          is_custom_, is_abstract_,
182                          getBaseValueDef(),
183                          is_truncatable_,
184                          abstract_base_values_.getValueDefSeq(),
185                          supported_interfaces_.getInterfaceDefSeq(),
186                          new org.omg.CORBA.ExtInitializer[0]);
187     }
188
189     // ==================================================================
190
//
191
// Public methods.
192
//
193
// ==================================================================
194

195     /**
196      * Obtain its ValueDef reference.
197      *
198      * @return The ValueDef associated with the value declaration.
199      */

200     public org.omg.CORBA.ExtValueDef
201     getExtValueDef()
202     {
203         return event_def_;
204     }
205
206     /**
207      * Obtain its ValueDef reference.
208      *
209      * @return The ValueDef associated with the value declaration.
210      */

211     public org.omg.CORBA.ValueDef JavaDoc
212     getValueDef()
213     {
214         return event_def_;
215     }
216
217     /**
218      * Obtain its EventDef reference.
219      *
220      * @return The ValueDef associated with the value declaration.
221      */

222     public EventDef
223     getEventDef()
224     {
225         return event_def_;
226     }
227
228     // ==================================================================
229
//
230
// Methods for OMG IDL org.objectweb.openccm.ast.api.WithDependencies
231
//
232
// ==================================================================
233

234     // ==================================================================
235
//
236
// Methods for OMG IDL org.objectweb.openccm.ast.api.Declaration
237
//
238
// ==================================================================
239

240     /**
241      * Obtain its DeclarationKind.
242      *
243      * @return The DeclarationKind of the object.
244      */

245     public long
246     getDeclKind()
247     {
248         return DeclarationKind.dk_event;
249     }
250
251     // ==================================================================
252
//
253
// Methods for OMG IDL org.objectweb.openccm.ast.api.Scope
254
//
255
// ==================================================================
256

257     // ==================================================================
258
//
259
// Methods for OMG IDL org.objectweb.openccm.ast.api.ForwardScope
260
//
261
// ==================================================================
262

263     // ==================================================================
264
//
265
// Methods for OMG IDL org.objectweb.openccm.ast.api.TypeRef
266
//
267
// ==================================================================
268

269     /**
270      * Obtain its associated TypeKind.
271      *
272      * @return The associated TypeKind.
273      */

274     public TypeKind
275     getTypeKind()
276     {
277         return TypeKind.tk_event;
278     }
279
280     // ==================================================================
281
//
282
// Methods for OMG IDL org.objectweb.openccm.ast.api.ValueDecl
283
//
284
// ==================================================================
285

286     // ==================================================================
287
//
288
// Methods for interface IDLTypeWrapper
289
//
290
// ==================================================================
291

292     /**
293      * Obtain its IDLType reference.
294      *
295      * @return The IDLType associated with the value declaration.
296      */

297     public org.omg.CORBA.IDLType JavaDoc
298     getIDLType()
299     {
300         return event_def_;
301     }
302
303     // ==================================================================
304
//
305
// Methods for OMG IDL org.objectweb.openccm.ast.api.ClientInterfaceMapping
306
//
307
// ==================================================================
308

309     /**
310      * Obtain the client interface mapping.
311      *
312      * @return The client interface mapping.
313      */

314     public InterfaceDecl
315     getClientMapping()
316     {
317         if (client_mapping_==null)
318         {
319             // load the context mapping for this component.
320
String JavaDoc base_id = getId();
321             int idx = base_id.lastIndexOf(':');
322             base_id = base_id.substring(0, idx);
323             String JavaDoc id = base_id + "Consumer:" + getVersion();
324
325             client_mapping_ = (InterfaceDeclImpl)getRepository().
326                               loadMapping(getParent(), id);
327         }
328         return client_mapping_;
329     }
330
331     // ==================================================================
332
//
333
// Methods for OMG IDL org.objectweb.openccm.ast.api.EventDecl
334
//
335
// ==================================================================
336

337     /**
338      * Obtain the local consumer mapping.
339      *
340      * @return The local consumer mapping.
341      */

342     public InterfaceDecl
343     getLocalConsumerMapping()
344     {
345         if (local_consumer_mapping_==null)
346         {
347             // load the local consumer mapping for this event.
348
String JavaDoc parent_base_id = the_parent_.getId();
349             int idx = parent_base_id.lastIndexOf(':');
350             parent_base_id = parent_base_id.substring(0, idx);
351             String JavaDoc id = parent_base_id + "/CCM_" + getName() +
352                     "Consumer:" + getVersion();
353
354             local_consumer_mapping_ = (InterfaceDeclImpl)getRepository().
355                                       loadMapping(getParent(), id);
356         }
357         return local_consumer_mapping_;
358     }
359 }
360
Popular Tags