KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jacorb > ir > AliasDef


1 package org.jacorb.ir;
2
3 /*
4  * JacORB - a free Java ORB
5  *
6  * Copyright (C) 1997-2004 Gerald Brose.
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Library General Public
10  * License as published by the Free Software Foundation; either
11  * version 2 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Library General Public License for more details.
17  *
18  * You should have received a copy of the GNU Library General Public
19  * License along with this library; if not, write to the Free
20  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21  */

22
23 import org.omg.CORBA.INTF_REPOS JavaDoc;
24 import org.omg.PortableServer.POA JavaDoc;
25 import org.apache.avalon.framework.logger.Logger;
26
27 public class AliasDef
28     extends TypedefDef
29     implements org.omg.CORBA.AliasDefOperations JavaDoc
30 {
31     private org.omg.CORBA.IDLType JavaDoc original_type_def;
32     private Logger logger;
33     private POA JavaDoc poa;
34
35     public AliasDef( org.omg.CORBA.TypeCode JavaDoc type,
36                      org.omg.CORBA.Container JavaDoc defined_in,
37                      org.omg.CORBA.Repository JavaDoc containing_repository,
38                      Logger logger,
39                      POA JavaDoc poa)
40     {
41         this.logger = logger;
42         this.poa = poa;
43         def_kind = org.omg.CORBA.DefinitionKind.dk_Alias;
44         this.type = type;
45         this.containing_repository = containing_repository;
46         this.defined_in = defined_in;
47         try
48         {
49             name( type.name() );
50             id( type.id() );
51             version = ("1.0");
52             absolute_name = org.omg.CORBA.ContainedHelper.narrow( defined_in ).absolute_name() +
53                 "::" + name();
54         }
55         catch( Exception JavaDoc e )
56         {
57             this.logger.error("Caught Exception", e); // should not happen
58
}
59         
60         if (this.logger.isDebugEnabled())
61         {
62             this.logger.debug("New AliasDef name: " + name());
63         }
64     }
65
66     public org.omg.CORBA.IDLType JavaDoc original_type_def()
67     {
68         if (original_type_def == null)
69         {
70            throw new INTF_REPOS JavaDoc ("Alias " + name () + " has null original_type_def" );
71         }
72         return original_type_def;
73     }
74
75     public void original_type_def(org.omg.CORBA.IDLType JavaDoc arg)
76     {
77         original_type_def = arg;
78     }
79
80     public void define()
81     {
82         try
83         {
84             original_type_def( IDLType.create( type().content_type(),
85                                                containing_repository,
86                                                true,
87                                                this.logger,
88                                                this.poa)
89                                );
90         }
91         catch( Exception JavaDoc e )
92         {
93             this.logger.error("Caught Exception", e); // should not happen
94
}
95     }
96
97     public org.omg.CORBA.ContainedPackage.Description describe()
98     {
99         org.omg.CORBA.Any JavaDoc a = orb.create_any();
100         String JavaDoc containerId;
101         if( defined_in._is_a("IDL:omg.org/CORBA/Contained:1.0"))
102             containerId = org.omg.CORBA.ContainedHelper.narrow(defined_in).id();
103         else
104             containerId = "IDL::1.0"; // top level, IR
105

106         org.omg.CORBA.TypeDescription JavaDoc td =
107             new org.omg.CORBA.TypeDescription JavaDoc( name,
108                                                id(),
109                                                containerId,
110                                                version(),
111                                                type() );
112
113         org.omg.CORBA.TypeDescriptionHelper.insert( a , td );
114
115         org.omg.CORBA.ContainedPackage.Description result =
116             new org.omg.CORBA.ContainedPackage.Description(
117                   org.omg.CORBA.DefinitionKind.dk_Alias, a );
118         return result;
119     }
120
121     public void destroy()
122     {}
123
124 }
125
Popular Tags