KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > ccm > IDL3 > EventDeclImpl


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

26
27 package org.objectweb.ccm.IDL3;
28
29 /**
30  * This class manages event type declarations.
31  *
32  * @author <a=href="Philippe.Merle@lifl.fr">Philippe Merle</a>
33  * <a=href="Mathieu.Vadet@lifl.fr">Mathieu Vadet</a>
34  *
35  * @version 0.3
36  */

37
38 public class EventDeclImpl
39        extends ValueDeclImpl
40        implements EventRef, EventDecl
41 {
42     // ==================================================================
43
//
44
// Internal state.
45
//
46
// ==================================================================
47

48     /**
49      ** Reference to the CORBA 3.0 ValueDef.
50      **/

51     private org.omg.CORBA.ComponentIR.EventDef event_def_;
52
53     /**
54      **
55      **/

56     private InterfaceDeclImpl client_mapping_;
57
58     /**
59      **
60      **/

61     private InterfaceDeclImpl local_consumer_mapping_;
62
63     // ==================================================================
64
//
65
// Constructor.
66
//
67
// ==================================================================
68

69     /**
70      ** The constructor with the parent scope.
71      **
72      ** @param parent The parent scope of the value declaration.
73      **/

74     public
75     EventDeclImpl(Repository rep, ScopeImpl parent)
76     {
77         // Call the EventDeclImpl constructor.
78
super(rep, parent);
79
80         // Init internal state.
81
event_def_ = null;
82         client_mapping_ = null;
83         local_consumer_mapping_ = null;
84         the_declaration_kind_ = DeclarationKind._dk_event;
85     }
86
87     // ==================================================================
88
//
89
// Internal methods.
90
//
91
// ==================================================================
92

93     /**
94      ** Loads infos of the CORBA 3.0 ValueDef.
95      **
96      ** @param valueDef The ValueDef to load.
97      **/

98     protected void
99     load(org.omg.CORBA.Contained JavaDoc contained)
100     {
101         event_def_ = org.omg.CORBA.ComponentIR.EventDefHelper.narrow(contained);
102
103         // load it's mapped declarations
104
getClientMapping();
105         getLocalConsumerMapping();
106
107         super.load(contained);
108     }
109
110     // ==================================================================
111
//
112
// Methods for the TypeRef interface.
113
//
114
// ==================================================================
115

116     /**
117      ** Obtain its IDLType reference.
118      **
119      ** @return The IDLType associated with the value declaration.
120      **/

121     public org.omg.CORBA.IDLType JavaDoc
122     getIDLType()
123     {
124         return event_def_;
125     }
126
127     /**
128      **
129      **/

130     public int
131     getTypeKind()
132     {
133         return TypeKind._tk_event;
134     }
135
136     // ==================================================================
137
//
138
// Methods for the EventRef interface.
139
//
140
// ==================================================================
141

142     /**
143      ** Obtain its EventDef reference.
144      **
145      ** @return The ValueDef associated with the value declaration.
146      **/

147     public org.omg.CORBA.ComponentIR.EventDef
148     getEventDef()
149     {
150         return event_def_;
151     }
152
153     // ==================================================================
154
//
155
// Methods for the ValueRef interface.
156
//
157
// ==================================================================
158

159     /**
160      ** Obtain its ValueDef reference.
161      **
162      ** @return The ValueDef associated with the value declaration.
163      **/

164     public org.omg.CORBA.ExtValueDef
165     getExtValueDef()
166     {
167         return event_def_;
168     }
169
170     /**
171      ** Obtain its ValueDef reference.
172      **
173      ** @return The ValueDef associated with the value declaration.
174      **/

175     public org.omg.CORBA.ValueDef JavaDoc
176     getValueDef()
177     {
178         return event_def_;
179     }
180
181     // ==================================================================
182
//
183
// Methods for the EventDecl interface.
184
//
185
// ==================================================================
186

187     /**
188      **
189      **/

190     public InterfaceDecl
191     getClientMapping()
192     {
193         if (client_mapping_!=null)
194             return client_mapping_;
195
196         // load the context mapping for this component.
197
String JavaDoc base_id = getId();
198         int idx = base_id.lastIndexOf(':');
199         base_id = base_id.substring(0, idx);
200         String JavaDoc id = base_id + "Consumer:"+getVersion();
201
202         client_mapping_ = (InterfaceDeclImpl)getRepository().loadMapping(getParent(), id);
203         return client_mapping_;
204     }
205
206     /**
207      **
208      **/

209     public InterfaceDecl
210     getLocalConsumerMapping()
211     {
212         if (local_consumer_mapping_!=null)
213             return local_consumer_mapping_;
214
215         // load the local consumer mapping for this event.
216
String JavaDoc parent_base_id = the_parent_.getId();
217         int idx = parent_base_id.lastIndexOf(':');
218         parent_base_id = parent_base_id.substring(0, idx);
219         String JavaDoc id = parent_base_id + "/CCM_"+getName()+"Consumer:"+getVersion();
220
221         local_consumer_mapping_ = (InterfaceDeclImpl)getRepository().loadMapping(getParent(), id);
222         return local_consumer_mapping_;
223     }
224
225     // ==================================================================
226
//
227
// Methods for the inherited DeclarationImpl class.
228
//
229
// ==================================================================
230

231     /**
232      ** Obtain its CORBA 3.0 Contained reference.
233      **
234      ** @return The Contained object associated with the value declaration.
235      **/

236     protected org.omg.CORBA.Contained JavaDoc
237     getContained()
238     {
239        return event_def_;
240     }
241
242     // ==================================================================
243
//
244
// Methods for the inherited ScopeImpl class.
245
//
246
// ==================================================================
247

248     /**
249      ** Obtain its CORBA 3.0 Container reference.
250      **
251      ** @return The Container object associated with the value declaration.
252      **/

253     protected org.omg.CORBA.Container JavaDoc
254     getContainer()
255     {
256         return event_def_;
257     }
258
259     // ==================================================================
260
//
261
// Methods for the inherited ForwardScopeImpl class.
262
//
263
// ==================================================================
264

265     /**
266      ** Create the container object.
267      **/

268     protected void
269     createContainer()
270     {
271         org.omg.CORBA.ValueDef JavaDoc[] abstract_base_values =
272         new org.omg.CORBA.ValueDef JavaDoc[abstract_base_values_.size()];
273         for(int i=0; i<abstract_base_values.length; i++)
274         {
275             abstract_base_values[i] =
276                 ((ValueRef)(abstract_base_values_.get(i))).getExtValueDef();
277         }
278
279         org.omg.CORBA.InterfaceDef JavaDoc[] supported_interfaces =
280         new org.omg.CORBA.InterfaceDef JavaDoc[supported_interfaces_.size()];
281         for(int i=0; i<supported_interfaces.length; i++)
282         {
283             supported_interfaces[i] =
284                 ((InterfaceRef)(supported_interfaces_.get(i))).getExtInterfaceDef();
285         }
286
287         // Create a EventDef into the IFR.
288
event_def_ = the_parent_.getComponentContainer().create_event(
289                                        getId(), getName(), getVersion(),
290                                        is_custom_, is_abstract_,
291                                        getBaseValueDef(),
292                                        is_truncatable_,
293                                        abstract_base_values,
294                                        supported_interfaces,
295                                        new org.omg.CORBA.ExtInitializer[0]);
296     }
297 }
298
Popular Tags