001: package org.jacorb.ir;
002:
003: /*
004: * JacORB - a free Java ORB
005: *
006: * Copyright (C) 1997-2004 Gerald Brose.
007: *
008: * This library is free software; you can redistribute it and/or
009: * modify it under the terms of the GNU Library General Public
010: * License as published by the Free Software Foundation; either
011: * version 2 of the License, or (at your option) any later version.
012: *
013: * This library is distributed in the hope that it will be useful,
014: * but WITHOUT ANY WARRANTY; without even the implied warranty of
015: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
016: * Library General Public License for more details.
017: *
018: * You should have received a copy of the GNU Library General Public
019: * License along with this library; if not, write to the Free
020: * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
021: */
022:
023: import org.omg.CORBA.INTF_REPOS;
024: import org.omg.PortableServer.POA;
025: import org.apache.avalon.framework.logger.Logger;
026:
027: public class AliasDef extends TypedefDef implements
028: org.omg.CORBA.AliasDefOperations {
029: private org.omg.CORBA.IDLType original_type_def;
030: private Logger logger;
031: private POA poa;
032:
033: public AliasDef(org.omg.CORBA.TypeCode type,
034: org.omg.CORBA.Container defined_in,
035: org.omg.CORBA.Repository containing_repository,
036: Logger logger, POA poa) {
037: this .logger = logger;
038: this .poa = poa;
039: def_kind = org.omg.CORBA.DefinitionKind.dk_Alias;
040: this .type = type;
041: this .containing_repository = containing_repository;
042: this .defined_in = defined_in;
043: try {
044: name(type.name());
045: id(type.id());
046: version = ("1.0");
047: absolute_name = org.omg.CORBA.ContainedHelper.narrow(
048: defined_in).absolute_name()
049: + "::" + name();
050: } catch (Exception e) {
051: this .logger.error("Caught Exception", e); // should not happen
052: }
053:
054: if (this .logger.isDebugEnabled()) {
055: this .logger.debug("New AliasDef name: " + name());
056: }
057: }
058:
059: public org.omg.CORBA.IDLType original_type_def() {
060: if (original_type_def == null) {
061: throw new INTF_REPOS("Alias " + name()
062: + " has null original_type_def");
063: }
064: return original_type_def;
065: }
066:
067: public void original_type_def(org.omg.CORBA.IDLType arg) {
068: original_type_def = arg;
069: }
070:
071: public void define() {
072: try {
073: original_type_def(IDLType.create(type().content_type(),
074: containing_repository, true, this .logger, this .poa));
075: } catch (Exception e) {
076: this .logger.error("Caught Exception", e); // should not happen
077: }
078: }
079:
080: public org.omg.CORBA.ContainedPackage.Description describe() {
081: org.omg.CORBA.Any a = orb.create_any();
082: String containerId;
083: if (defined_in._is_a("IDL:omg.org/CORBA/Contained:1.0"))
084: containerId = org.omg.CORBA.ContainedHelper.narrow(
085: defined_in).id();
086: else
087: containerId = "IDL::1.0"; // top level, IR
088:
089: org.omg.CORBA.TypeDescription td = new org.omg.CORBA.TypeDescription(
090: name, id(), containerId, version(), type());
091:
092: org.omg.CORBA.TypeDescriptionHelper.insert(a, td);
093:
094: org.omg.CORBA.ContainedPackage.Description result = new org.omg.CORBA.ContainedPackage.Description(
095: org.omg.CORBA.DefinitionKind.dk_Alias, a);
096: return result;
097: }
098:
099: public void destroy() {
100: }
101:
102: }
|