KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > openccm > ir3 > ExtValueDef_impl


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.
23 Contributor(s): Mathieu Vadet, Christophe Demarey.
24
25 ====================================================================*/

26
27 package org.objectweb.openccm.ir3;
28
29 // Package dependencies
30
import org.omg.CORBA.*;
31 import org.omg.CORBA.ExtValueDefPackage.ExtFullValueDescription;
32
33 /**
34  * Implementation of the CORBA::ExtValueDef interface.
35  *
36  * @author <a=href="Philippe.Merle@lifl.fr">Philippe Merle</a>
37  * <a=href="Mathieu.Vadet@lifl.fr">Mathieu Vadet</a>
38  *
39  * @version 0.3
40  */

41
42 public class ExtValueDef_impl
43        extends ValueDef_impl
44        implements ExtValueDefOperations
45 {
46     // ==================================================================
47
//
48
// Internal state.
49
//
50
// ==================================================================
51

52     /**
53      * TODO
54      */

55     protected ExtInitializer_impl[] ext_initializers_;
56
57     // ==================================================================
58
//
59
// Constructor.
60
//
61
// ==================================================================
62

63     /**
64      * TODO
65      */

66     public
67     ExtValueDef_impl(IFR ifr,
68                      Container_impl container)
69     {
70         // call the Container_impl contructor.
71
super(ifr, container);
72
73         ext_initializers_ = new ExtInitializer_impl[0];
74
75         // set the tie servant object.
76
setServant(new ExtValueDefPOATie(this));
77     }
78
79     // ==================================================================
80
//
81
// Public methods.
82
//
83
// ==================================================================
84

85     /**
86      * Obtain its CORBA::ExtValueDef object reference.
87      */

88     public ExtValueDef
89     asExtValueDef()
90     {
91         return ExtValueDefHelper.narrow(asObject());
92     }
93
94     // ==================================================================
95
//
96
// For CORBA::ExtValueDef interface.
97
//
98
// ==================================================================
99

100     /**
101      * IDL:omg.org/CORBA/ValueDef/create_attribute:1.0
102      */

103     public AttributeDef
104     create_attribute(String JavaDoc id,
105                      String JavaDoc name,
106                      String JavaDoc version,
107                      IDLType type,
108                      AttributeMode mode)
109     {
110         ExtAttributeDef_impl attr = new ExtAttributeDef_impl(getIFR(), this);
111
112         try
113         {
114             addContained(attr, id, name, version);
115             attr.type_def(type);
116             attr.mode(mode);
117             attr.get_exceptions(new ExceptionDef[0]);
118             attr.set_exceptions(new ExceptionDef[0]);
119         }
120         catch(SystemException exc)
121         {
122             attr.destroy();
123             throw exc;
124         }
125
126         return attr.asAttributeDef();
127     }
128
129     /**
130      * IDL:omg.org/CORBA/ValueDef/initializers:1.0
131      */

132     public Initializer[]
133     initializers()
134     {
135         Initializer[] result = new Initializer[initializers_.length];
136
137         for(int i=0; i<result.length; i++)
138             result[i] = ext_initializers_[i].getInitializer();
139
140         return result;
141     }
142
143     public void
144     initializers(Initializer[] val)
145     {
146         ExtInitializer_impl[] tmp = new ExtInitializer_impl[val.length];
147         for(int i=0; i<tmp.length; i++)
148     {
149             tmp[i] = new ExtInitializer_impl(this);
150             tmp[i].setInitializer(val[i]);
151         }
152         ext_initializers_ = tmp;
153     }
154
155     // ==================================================================
156
//
157
// For CORBA::ExtValueDef interface.
158
//
159
// ==================================================================
160

161     /**
162      * IDL:omg.org/CORBA/ExtValueDef/create_ext_attribute:1.0
163      */

164     public ExtAttributeDef
165     create_ext_attribute(String JavaDoc id,
166                          String JavaDoc name,
167                          String JavaDoc version,
168                          IDLType type,
169                          AttributeMode mode,
170                          ExceptionDef[] get_exceptions,
171                          ExceptionDef[] set_exceptions)
172     {
173         ExtAttributeDef_impl attr = new ExtAttributeDef_impl(getIFR(), this);
174
175         try
176         {
177             addContained(attr, id, name, version);
178             attr.type_def(type);
179             attr.mode(mode);
180             attr.get_exceptions(get_exceptions);
181             attr.set_exceptions(set_exceptions);
182         }
183         catch(SystemException exc)
184         {
185             attr.destroy();
186             throw exc;
187         }
188
189         return attr.asExtAttributeDef();
190     }
191
192     /**
193      * IDL:omg.org/CORBA/ExtValueDef/ext_initializers:1.0
194      */

195     public ExtInitializer[]
196     ext_initializers()
197     {
198         ExtInitializer[] result = new ExtInitializer[ext_initializers_.length];
199
200         for(int i=0; i<result.length; i++)
201             result[i] = ext_initializers_[i].getExtInitializer();
202
203         return result;
204     }
205
206     /**
207      * IDL:omg.org/CORBA/ExtValueDef/ext_initializers:1.0
208      */

209     public void
210     ext_initializers(ExtInitializer[] val)
211     {
212         ExtInitializer_impl[] tmp = new ExtInitializer_impl[val.length];
213         for(int i=0; i<tmp.length; i++)
214     {
215             tmp[i] = new ExtInitializer_impl(this);
216             tmp[i].setExtInitializer(val[i]);
217         }
218         ext_initializers_ = tmp;
219     }
220
221     /**
222      * IDL:omg.org/CORBA/ExtValueDef/describe_ext_value:1.0
223      */

224     public ExtFullValueDescription
225     describe_ext_value()
226     {
227         ExtFullValueDescription description = new ExtFullValueDescription();
228         description.name = name();
229         description.id = id();
230         description.is_abstract = is_abstract();
231         description.is_custom = is_custom();
232         description.defined_in = getContainerID();
233         description.version = version();
234         description.operations = getOpDescriptionSeq();
235         description.attributes = getExtAttrDescriptionSeq();
236         description.members = getValueMemberSeq();
237         description.initializers = ext_initializers();
238         description.supported_interfaces = InterfaceDef_ref.
239                          computeRepositoryIdSeq(supported_interfaces_);
240         description.abstract_base_values = ValueDef_ref.
241                          computeRepositoryIdSeq(abstract_base_values_);
242         description.is_truncatable = is_truncatable();
243         description.base_value = base_value_.getId();
244         description.type = type();
245         return description;
246     }
247
248     // ==================================================================
249
//
250
// For IDL2 mapping.
251
//
252
// ==================================================================
253

254     /**
255      * TODO : change code
256      */

257     protected void
258     whenCreated()
259     {
260         if (abstract_base_values_.length==0)
261             return ;
262
263         for (int i=0;i<abstract_base_values_.length;i++)
264         {
265             if (abstract_base_values_[i].getImpl().absolute_name().equals("::Components::EventBase"))
266             {
267                 //
268
// create the <event_type>Consumer interface
269
//
270
String JavaDoc cont_base_id = getBaseContainerID();
271                 String JavaDoc name = name() + "Consumer";
272                 String JavaDoc version = version();
273                 String JavaDoc id = cont_base_id + name + ":" + version;
274                 org.omg.CORBA.InterfaceDef JavaDoc[] bases = new org.omg.CORBA.InterfaceDef JavaDoc[1];
275                 bases[0] = org.omg.CORBA.InterfaceDefHelper.narrow(
276                     getIFR().getRepository().lookup("::Components::EventConsumerBase"));
277                 org.omg.CORBA.InterfaceDef JavaDoc consumer = container_.create_interface(id, name, version, bases);
278
279                 //
280
// add the push operation
281
//
282
id = cont_base_id + name + "/push:" + version;
283                 name = "push";
284                 org.omg.CORBA.ParameterDescription JavaDoc[] params = new org.omg.CORBA.ParameterDescription JavaDoc[1];
285                 params[0] = new org.omg.CORBA.ParameterDescription JavaDoc();
286                 params[0].name = "event";
287                 params[0].type_def = asValueDef();
288                 params[0].type = params[0].type_def.type();
289                 params[0].mode = org.omg.CORBA.ParameterMode.PARAM_IN;
290                 consumer.create_operation(id, name, version,
291                                           getIFR().getRepository().get_primitive(
292                                               org.omg.CORBA.PrimitiveKind.pk_void),
293                                           org.omg.CORBA.OperationMode.OP_NORMAL,
294                                           params,
295                                           new org.omg.CORBA.ExceptionDef JavaDoc[0],
296                                           new java.lang.String JavaDoc[0]);
297                 break ;
298             }
299         }
300     }
301 }
302
Popular Tags