KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > iiop > rmi > ir > ExceptionDefImpl


1 /*
2 * JBoss, Home of Professional Open Source
3 * Copyright 2005, JBoss Inc., and individual contributors as indicated
4 * by the @authors tag. See the copyright.txt in the distribution for a
5 * full listing of individual contributors.
6 *
7 * This is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU Lesser General Public License as
9 * published by the Free Software Foundation; either version 2.1 of
10 * the License, or (at your option) any later version.
11 *
12 * This software 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 software; if not, write to the Free
19 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21 */

22 package org.jboss.iiop.rmi.ir;
23
24 import org.omg.CORBA.ExceptionDefOperations JavaDoc;
25 import org.omg.CORBA.ExceptionDefPOATie;
26 import org.omg.CORBA.Any JavaDoc;
27 import org.omg.CORBA.TypeCode JavaDoc;
28 import org.omg.CORBA.IRObject JavaDoc;
29 import org.omg.CORBA.Contained JavaDoc;
30 import org.omg.CORBA.ContainedOperations JavaDoc;
31 import org.omg.CORBA.ContainedPackage.Description;
32 import org.omg.CORBA.IDLType JavaDoc;
33 import org.omg.CORBA.IDLTypeHelper JavaDoc;
34 import org.omg.CORBA.DefinitionKind JavaDoc;
35 import org.omg.CORBA.StructMember JavaDoc;
36 import org.omg.CORBA.UnionMember JavaDoc;
37 import org.omg.CORBA.InterfaceDef JavaDoc;
38 import org.omg.CORBA.ConstantDef JavaDoc;
39 import org.omg.CORBA.EnumDef JavaDoc;
40 import org.omg.CORBA.ValueDef JavaDoc;
41 import org.omg.CORBA.ValueBoxDef JavaDoc;
42 import org.omg.CORBA.Initializer JavaDoc;
43 import org.omg.CORBA.StructDef JavaDoc;
44 import org.omg.CORBA.UnionDef JavaDoc;
45 import org.omg.CORBA.ExceptionDef JavaDoc;
46 import org.omg.CORBA.AliasDef JavaDoc;
47 import org.omg.CORBA.NativeDef JavaDoc;
48 import org.omg.CORBA.ModuleDef JavaDoc;
49 import org.omg.CORBA.ExceptionDescription JavaDoc;
50 import org.omg.CORBA.ExceptionDescriptionHelper;
51 import org.omg.CORBA.BAD_INV_ORDER JavaDoc;
52
53 /**
54  * Abstract base class for all contained IR entities.
55  *
56  * @author <a HREF="mailto:osh@sparre.dk">Ole Husgaard</a>
57  * @version $Revision: 37459 $
58  */

59 class ExceptionDefImpl
60    extends ContainedImpl
61    implements ExceptionDefOperations JavaDoc, LocalContainer
62 {
63    // Constants -----------------------------------------------------
64

65    // Attributes ----------------------------------------------------
66

67    // Static --------------------------------------------------------
68

69    // Constructors --------------------------------------------------
70

71    ExceptionDefImpl(String JavaDoc id, String JavaDoc name, String JavaDoc version,
72                     TypeCode JavaDoc typeCode, ValueDefImpl vDef,
73                     LocalContainer defined_in, RepositoryImpl repository)
74    {
75       super(id, name, version, defined_in,
76             DefinitionKind.dk_Exception, repository);
77
78       this.delegate = new ContainerImplDelegate(this);
79       this.typeCode = typeCode;
80       this.vDef = vDef;
81    }
82
83    // Public --------------------------------------------------------
84

85    // LocalContainer implementation ---------------------------------
86

87    public LocalContained _lookup(String JavaDoc search_name)
88    {
89       return delegate._lookup(search_name);
90    }
91  
92    public LocalContained[] _contents(DefinitionKind JavaDoc limit_type,
93                                     boolean exclude_inherited)
94    {
95       return delegate._contents(limit_type, exclude_inherited);
96    }
97  
98    public LocalContained[] _lookup_name(String JavaDoc search_name,
99                                         int levels_to_search,
100                                         DefinitionKind JavaDoc limit_type,
101                                         boolean exclude_inherited)
102    {
103       return delegate._lookup_name(search_name, levels_to_search, limit_type,
104                                    exclude_inherited);
105    }
106  
107    public void add(String JavaDoc name, LocalContained contained)
108       throws IRConstructionException
109    {
110       throw new RuntimeException JavaDoc("Should never reach this point.");
111       //delegate.add(name, contained);
112
}
113
114    // ContainerOperations implementation ----------------------------
115

116    public Contained JavaDoc lookup(String JavaDoc search_name)
117    {
118       return delegate.lookup(search_name);
119    }
120
121    public Contained JavaDoc[] contents(DefinitionKind JavaDoc limit_type,
122                                boolean exclude_inherited)
123    {
124       return delegate.contents(limit_type, exclude_inherited);
125    }
126
127    public Contained JavaDoc[] lookup_name(String JavaDoc search_name, int levels_to_search,
128                                   DefinitionKind JavaDoc limit_type,
129                                   boolean exclude_inherited)
130    {
131       return delegate.lookup_name(search_name, levels_to_search, limit_type,
132                                   exclude_inherited);
133    }
134
135    public org.omg.CORBA.ContainerPackage.Description[]
136                         describe_contents(DefinitionKind JavaDoc limit_type,
137                                           boolean exclude_inherited,
138                                           int max_returned_objs)
139    {
140       return delegate.describe_contents(limit_type, exclude_inherited,
141                                         max_returned_objs);
142    }
143
144    public ModuleDef JavaDoc create_module(String JavaDoc id, String JavaDoc name, String JavaDoc version)
145    {
146       return delegate.create_module(id, name, version);
147    }
148
149    public ConstantDef JavaDoc create_constant(String JavaDoc id, String JavaDoc name, String JavaDoc version,
150                                       IDLType JavaDoc type, Any JavaDoc value)
151    {
152       return delegate.create_constant(id, name, version, type, value);
153    }
154
155    public StructDef JavaDoc create_struct(String JavaDoc id, String JavaDoc name, String JavaDoc version,
156                                   StructMember JavaDoc[] members)
157    {
158       return delegate.create_struct(id, name, version, members);
159    }
160
161    public UnionDef JavaDoc create_union(String JavaDoc id, String JavaDoc name, String JavaDoc version,
162                                 IDLType JavaDoc discriminator_type,
163                                 UnionMember JavaDoc[] members)
164    {
165       return delegate.create_union(id, name, version, discriminator_type,
166                                    members);
167    }
168
169    public EnumDef JavaDoc create_enum(String JavaDoc id, String JavaDoc name, String JavaDoc version,
170                               String JavaDoc[] members)
171    {
172       return delegate.create_enum(id, name, version, members);
173    }
174
175    public AliasDef JavaDoc create_alias(String JavaDoc id, String JavaDoc name, String JavaDoc version,
176                                 IDLType JavaDoc original_type)
177    {
178       return delegate.create_alias(id, name, version, original_type);
179    }
180
181    public InterfaceDef JavaDoc create_interface(String JavaDoc id, String JavaDoc name, String JavaDoc version,
182                                         InterfaceDef JavaDoc[] base_interfaces,
183                                         boolean is_abstract)
184    {
185       return delegate.create_interface(id, name, version,
186                                        base_interfaces, is_abstract);
187    }
188
189    public ValueDef JavaDoc create_value(String JavaDoc id, String JavaDoc name, String JavaDoc version,
190                                 boolean is_custom, boolean is_abstract,
191                                 ValueDef JavaDoc base_value, boolean is_truncatable,
192                                 ValueDef JavaDoc[] abstract_base_values,
193                                 InterfaceDef JavaDoc[] supported_interfaces,
194                                 Initializer JavaDoc[] initializers)
195    {
196       return delegate.create_value(id, name, version, is_custom, is_abstract,
197                                    base_value, is_truncatable,
198                                    abstract_base_values, supported_interfaces,
199                                    initializers);
200    }
201
202    public ValueBoxDef JavaDoc create_value_box(String JavaDoc id, String JavaDoc name, String JavaDoc version,
203                                        IDLType JavaDoc original_type_def)
204    {
205       return delegate.create_value_box(id, name, version, original_type_def);
206    }
207
208    public ExceptionDef JavaDoc create_exception(String JavaDoc id, String JavaDoc name, String JavaDoc version,
209                                         StructMember JavaDoc[] members)
210    {
211       return delegate.create_exception(id, name, version, members);
212    }
213
214    public NativeDef JavaDoc create_native(String JavaDoc id, String JavaDoc name, String JavaDoc version)
215    {
216       return delegate.create_native(id, name, version);
217    }
218
219    // LocalIRObject implementation ----------------------------------
220

221    public IRObject JavaDoc getReference()
222    {
223       if (ref == null) {
224          ref = org.omg.CORBA.ExceptionDefHelper.narrow(
225                                servantToReference(new ExceptionDefPOATie(this)) );
226       }
227       return ref;
228    }
229
230    public void allDone()
231       throws IRConstructionException
232    {
233       getReference();
234       delegate.allDone();
235    }
236
237    // ContainedImpl implementation ----------------------------------
238

239    public Description describe()
240    {
241       String JavaDoc defined_in_id = "IR";
242  
243       if (defined_in instanceof ContainedOperations JavaDoc)
244          defined_in_id = ((ContainedOperations JavaDoc)defined_in).id();
245  
246       ExceptionDescription JavaDoc ed = new ExceptionDescription JavaDoc(name, id,
247                                                          defined_in_id,
248                                                          version, type());
249  
250       Any JavaDoc any = getORB().create_any();
251
252       ExceptionDescriptionHelper.insert(any, ed);
253
254       return new Description(DefinitionKind.dk_Exception, any);
255    }
256
257
258    // ExceptionDefOperations implementation -------------------------
259

260    public TypeCode JavaDoc type() {
261       return typeCode;
262    }
263
264    public StructMember JavaDoc[] members()
265    {
266       if (members == null) {
267          TypeCode JavaDoc type = vDef.type();
268          LocalIDLType localTypeDef = IDLTypeImpl.getIDLType(type, repository);
269          IDLType JavaDoc type_def = IDLTypeHelper.narrow(localTypeDef.getReference());
270
271          members = new StructMember JavaDoc[1];
272          members[0] = new StructMember JavaDoc("value", type, type_def);
273       }
274       return members;
275    }
276
277    public void members(StructMember JavaDoc[] arg)
278    {
279       throw new BAD_INV_ORDER JavaDoc("Cannot change RMI/IIOP mapping.");
280    }
281
282    // Package protected ---------------------------------------------
283

284    // Protected -----------------------------------------------------
285

286    // Private -------------------------------------------------------
287

288    /**
289     * My delegate for Container functionality.
290     */

291    private ContainerImplDelegate delegate;
292
293    /**
294     * My CORBA reference.
295     */

296    private ExceptionDef JavaDoc ref = null;
297
298    /**
299     * My TypeCode.
300     */

301    private TypeCode JavaDoc typeCode;
302
303    /**
304     * The value I contain as my only member.
305     */

306    ValueDefImpl vDef;
307
308    /**
309     * My members.
310     */

311    private StructMember JavaDoc[] members;
312
313    // Inner classes -------------------------------------------------
314
}
315
316
Popular Tags