001: /*
002: * JBoss, Home of Professional Open Source.
003: * Copyright 2006, Red Hat Middleware LLC, and individual contributors
004: * as indicated by the @author tags. See the copyright.txt file in the
005: * distribution for a full listing of individual contributors.
006: *
007: * This is free software; you can redistribute it and/or modify it
008: * under the terms of the GNU Lesser General Public License as
009: * published by the Free Software Foundation; either version 2.1 of
010: * the License, or (at your option) any later version.
011: *
012: * This software is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015: * Lesser General Public License for more details.
016: *
017: * You should have received a copy of the GNU Lesser General Public
018: * License along with this software; if not, write to the Free
019: * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020: * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
021: */
022: package org.jboss.iiop.rmi.ir;
023:
024: import org.omg.CORBA.ExceptionDefOperations;
025: import org.omg.CORBA.ExceptionDefPOATie;
026: import org.omg.CORBA.ExceptionDefHelper;
027: import org.omg.CORBA.Any;
028: import org.omg.CORBA.TypeCode;
029: import org.omg.CORBA.IRObject;
030: import org.omg.CORBA.Contained;
031: import org.omg.CORBA.ContainedOperations;
032: import org.omg.CORBA.ContainedPackage.Description;
033: import org.omg.CORBA.Container;
034: import org.omg.CORBA.IDLType;
035: import org.omg.CORBA.IDLTypeHelper;
036: import org.omg.CORBA.DefinitionKind;
037: import org.omg.CORBA.StructMember;
038: import org.omg.CORBA.UnionMember;
039: import org.omg.CORBA.InterfaceDef;
040: import org.omg.CORBA.ConstantDef;
041: import org.omg.CORBA.EnumDef;
042: import org.omg.CORBA.ValueDef;
043: import org.omg.CORBA.ValueBoxDef;
044: import org.omg.CORBA.Initializer;
045: import org.omg.CORBA.StructDef;
046: import org.omg.CORBA.UnionDef;
047: import org.omg.CORBA.ExceptionDef;
048: import org.omg.CORBA.AliasDef;
049: import org.omg.CORBA.NativeDef;
050: import org.omg.CORBA.ModuleDef;
051: import org.omg.CORBA.ExceptionDef;
052: import org.omg.CORBA.ExceptionDescription;
053: import org.omg.CORBA.ExceptionDescriptionHelper;
054: import org.omg.CORBA.BAD_INV_ORDER;
055: import org.omg.PortableServer.POA;
056:
057: /**
058: * Abstract base class for all contained IR entities.
059: *
060: * @author <a href="mailto:osh@sparre.dk">Ole Husgaard</a>
061: * @version $Revision: 57194 $
062: */
063: class ExceptionDefImpl extends ContainedImpl implements
064: ExceptionDefOperations, LocalContainer {
065: // Constants -----------------------------------------------------
066:
067: // Attributes ----------------------------------------------------
068:
069: // Static --------------------------------------------------------
070:
071: // Constructors --------------------------------------------------
072:
073: ExceptionDefImpl(String id, String name, String version,
074: TypeCode typeCode, ValueDefImpl vDef,
075: LocalContainer defined_in, RepositoryImpl repository) {
076: super (id, name, version, defined_in,
077: DefinitionKind.dk_Exception, repository);
078:
079: this .delegate = new ContainerImplDelegate(this );
080: this .typeCode = typeCode;
081: this .vDef = vDef;
082: }
083:
084: // Public --------------------------------------------------------
085:
086: // LocalContainer implementation ---------------------------------
087:
088: public LocalContained _lookup(String search_name) {
089: return delegate._lookup(search_name);
090: }
091:
092: public LocalContained[] _contents(DefinitionKind limit_type,
093: boolean exclude_inherited) {
094: return delegate._contents(limit_type, exclude_inherited);
095: }
096:
097: public LocalContained[] _lookup_name(String search_name,
098: int levels_to_search, DefinitionKind limit_type,
099: boolean exclude_inherited) {
100: return delegate._lookup_name(search_name, levels_to_search,
101: limit_type, exclude_inherited);
102: }
103:
104: public void add(String name, LocalContained contained)
105: throws IRConstructionException {
106: throw new RuntimeException("Should never reach this point.");
107: //delegate.add(name, contained);
108: }
109:
110: // ContainerOperations implementation ----------------------------
111:
112: public Contained lookup(String search_name) {
113: return delegate.lookup(search_name);
114: }
115:
116: public Contained[] contents(DefinitionKind limit_type,
117: boolean exclude_inherited) {
118: return delegate.contents(limit_type, exclude_inherited);
119: }
120:
121: public Contained[] lookup_name(String search_name,
122: int levels_to_search, DefinitionKind limit_type,
123: boolean exclude_inherited) {
124: return delegate.lookup_name(search_name, levels_to_search,
125: limit_type, exclude_inherited);
126: }
127:
128: public org.omg.CORBA.ContainerPackage.Description[] describe_contents(
129: DefinitionKind limit_type, boolean exclude_inherited,
130: int max_returned_objs) {
131: return delegate.describe_contents(limit_type,
132: exclude_inherited, max_returned_objs);
133: }
134:
135: public ModuleDef create_module(String id, String name,
136: String version) {
137: return delegate.create_module(id, name, version);
138: }
139:
140: public ConstantDef create_constant(String id, String name,
141: String version, IDLType type, Any value) {
142: return delegate.create_constant(id, name, version, type, value);
143: }
144:
145: public StructDef create_struct(String id, String name,
146: String version, StructMember[] members) {
147: return delegate.create_struct(id, name, version, members);
148: }
149:
150: public UnionDef create_union(String id, String name,
151: String version, IDLType discriminator_type,
152: UnionMember[] members) {
153: return delegate.create_union(id, name, version,
154: discriminator_type, members);
155: }
156:
157: public EnumDef create_enum(String id, String name, String version,
158: String[] members) {
159: return delegate.create_enum(id, name, version, members);
160: }
161:
162: public AliasDef create_alias(String id, String name,
163: String version, IDLType original_type) {
164: return delegate.create_alias(id, name, version, original_type);
165: }
166:
167: public InterfaceDef create_interface(String id, String name,
168: String version, InterfaceDef[] base_interfaces,
169: boolean is_abstract) {
170: return delegate.create_interface(id, name, version,
171: base_interfaces, is_abstract);
172: }
173:
174: public ValueDef create_value(String id, String name,
175: String version, boolean is_custom, boolean is_abstract,
176: ValueDef base_value, boolean is_truncatable,
177: ValueDef[] abstract_base_values,
178: InterfaceDef[] supported_interfaces,
179: Initializer[] initializers) {
180: return delegate.create_value(id, name, version, is_custom,
181: is_abstract, base_value, is_truncatable,
182: abstract_base_values, supported_interfaces,
183: initializers);
184: }
185:
186: public ValueBoxDef create_value_box(String id, String name,
187: String version, IDLType original_type_def) {
188: return delegate.create_value_box(id, name, version,
189: original_type_def);
190: }
191:
192: public ExceptionDef create_exception(String id, String name,
193: String version, StructMember[] members) {
194: return delegate.create_exception(id, name, version, members);
195: }
196:
197: public NativeDef create_native(String id, String name,
198: String version) {
199: return delegate.create_native(id, name, version);
200: }
201:
202: // LocalIRObject implementation ----------------------------------
203:
204: public IRObject getReference() {
205: if (ref == null) {
206: ref = org.omg.CORBA.ExceptionDefHelper
207: .narrow(servantToReference(new ExceptionDefPOATie(
208: this )));
209: }
210: return ref;
211: }
212:
213: public void allDone() throws IRConstructionException {
214: getReference();
215: delegate.allDone();
216: }
217:
218: // ContainedImpl implementation ----------------------------------
219:
220: public Description describe() {
221: String defined_in_id = "IR";
222:
223: if (defined_in instanceof ContainedOperations)
224: defined_in_id = ((ContainedOperations) defined_in).id();
225:
226: ExceptionDescription ed = new ExceptionDescription(name, id,
227: defined_in_id, version, type());
228:
229: Any any = getORB().create_any();
230:
231: ExceptionDescriptionHelper.insert(any, ed);
232:
233: return new Description(DefinitionKind.dk_Exception, any);
234: }
235:
236: // ExceptionDefOperations implementation -------------------------
237:
238: public TypeCode type() {
239: return typeCode;
240: }
241:
242: public StructMember[] members() {
243: if (members == null) {
244: TypeCode type = vDef.type();
245: LocalIDLType localTypeDef = IDLTypeImpl.getIDLType(type,
246: repository);
247: IDLType type_def = IDLTypeHelper.narrow(localTypeDef
248: .getReference());
249:
250: members = new StructMember[1];
251: members[0] = new StructMember("value", type, type_def);
252: }
253: return members;
254: }
255:
256: public void members(StructMember[] arg) {
257: throw new BAD_INV_ORDER("Cannot change RMI/IIOP mapping.");
258: }
259:
260: // Package protected ---------------------------------------------
261:
262: // Protected -----------------------------------------------------
263:
264: // Private -------------------------------------------------------
265:
266: /**
267: * My delegate for Container functionality.
268: */
269: private ContainerImplDelegate delegate;
270:
271: /**
272: * My CORBA reference.
273: */
274: private ExceptionDef ref = null;
275:
276: /**
277: * My TypeCode.
278: */
279: private TypeCode typeCode;
280:
281: /**
282: * The value I contain as my only member.
283: */
284: ValueDefImpl vDef;
285:
286: /**
287: * My members.
288: */
289: private StructMember[] members;
290:
291: // Inner classes -------------------------------------------------
292: }
|