KickJava   Java API By Example, From Geeks To Geeks.

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


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 java.util.*;
24
25 import org.omg.CORBA.INTF_REPOS JavaDoc;
26 import org.omg.PortableServer.POA JavaDoc;
27 import org.apache.avalon.framework.logger.Logger;
28
29 public class ModuleDef
30     extends Contained
31     implements org.omg.CORBA.ModuleDefOperations JavaDoc, ContainerType
32 {
33     private static char fileSeparator =
34         System.getProperty("file.separator").charAt(0);
35
36     private Container delegate;
37     private String JavaDoc path = null;
38     private Logger logger;
39
40     public ModuleDef( String JavaDoc path,
41                       String JavaDoc full_name,
42                       org.omg.CORBA.Container JavaDoc def_in,
43                       org.omg.CORBA.Repository JavaDoc ir,
44                       ClassLoader JavaDoc loader,
45                       POA JavaDoc poa,
46                       Logger logger )
47         throws INTF_REPOS JavaDoc
48     {
49         this.logger = logger;
50         this.path = path;
51         this.full_name = full_name.replace(fileSeparator,'/');
52
53         if (this.logger.isDebugEnabled())
54         {
55             this.logger.debug("New ModuleDef " + full_name + " path: " + path);
56         }
57
58         def_kind = org.omg.CORBA.DefinitionKind.dk_Module;
59         if (ir == null)
60         {
61            throw new INTF_REPOS JavaDoc ("No repository!");
62         }
63
64         containing_repository = ir;
65         defined_in = def_in;
66
67         try
68         {
69             id( RepositoryID.toRepositoryID( full_name, false, loader ));
70             if( full_name.indexOf( fileSeparator ) > 0 )
71             {
72                 name( full_name.substring( full_name.lastIndexOf( fileSeparator ) + 1 ));
73
74                 if( defined_in instanceof org.omg.CORBA.Contained JavaDoc)
75                 {
76                     absolute_name =
77                         ((org.omg.CORBA.Contained JavaDoc)defined_in).absolute_name() +
78                         "::" + name();
79
80                     if (this.logger.isDebugEnabled())
81                     {
82                         this.logger.debug("New ModuleDef 1a) name " +
83                                           name() + " absolute: " +
84                                           absolute_name);
85                     }
86                 }
87                 else
88                 {
89                     absolute_name = "::" + name();
90
91                     if (this.logger.isDebugEnabled())
92                     {
93                         this.logger.debug("New ModuleDef 1b) name " +
94                                           name() + " absolute: " +
95                                           absolute_name + " defined_in : " +
96                                           defined_in.getClass().getName());
97                     }
98                 }
99             }
100             else
101             {
102                 defined_in = containing_repository;
103                 name( full_name );
104                 absolute_name = "::" + name();
105
106                 if (this.logger.isDebugEnabled())
107                 {
108                     this.logger.debug("New ModuleDef 2) name " +
109                                       name() +
110                                       " absolute:" + absolute_name);
111                 }
112             }
113             delegate = new Container( this, path, full_name, loader, poa, this.logger );
114
115         }
116         catch ( Exception JavaDoc e )
117         {
118             this.logger.error("Caught Exception", e);
119             throw new INTF_REPOS JavaDoc( ErrorMsg.IR_Not_Implemented,
120                                   org.omg.CORBA.CompletionStatus.COMPLETED_NO);
121         }
122     }
123
124
125     public String JavaDoc path()
126     {
127         return path;
128     }
129
130
131     public void loadContents()
132     {
133         if (this.logger.isDebugEnabled())
134         {
135             this.logger.debug("Module " + name() + " loading...");
136         }
137
138         delegate.loadContents();
139
140         if (this.logger.isDebugEnabled())
141         {
142             this.logger.debug("Module " + name() + " loaded");
143         }
144     }
145
146     void define()
147     {
148         delegate.define();
149     }
150
151     public org.omg.CORBA.Contained JavaDoc lookup(/*ScopedName*/ String JavaDoc name)
152     {
153         if (this.logger.isDebugEnabled())
154         {
155             this.logger.debug("Module " + this.name + " lookup " + name);
156         }
157
158         return delegate.lookup(name);
159     }
160
161     public org.omg.CORBA.Contained JavaDoc[] contents(
162         org.omg.CORBA.DefinitionKind JavaDoc limit_type,
163         boolean exclude_inherited)
164     {
165         return delegate.contents(limit_type, exclude_inherited);
166     }
167
168     public org.omg.CORBA.Contained JavaDoc[] lookup_name(String JavaDoc search_name,
169                                                  int levels_to_search,
170                                                  org.omg.CORBA.DefinitionKind JavaDoc limit_type,
171                                                  boolean exclude_inherited)
172     {
173         return delegate.lookup_name( search_name, levels_to_search,
174                                      limit_type, exclude_inherited );
175     }
176
177     public org.omg.CORBA.ContainerPackage.Description[] describe_contents(
178                                              org.omg.CORBA.DefinitionKind JavaDoc limit_type,
179                                              boolean exclude_inherited,
180                                              int max_returned_objs)
181     {
182         return delegate.describe_contents( limit_type,
183                                            exclude_inherited,
184                                            max_returned_objs );
185     }
186
187     public org.omg.CORBA.ModuleDef JavaDoc create_module(String JavaDoc id, String JavaDoc name, String JavaDoc version)
188     {
189         return delegate.create_module( id, name, version);
190     }
191
192     public org.omg.CORBA.ConstantDef JavaDoc create_constant( String JavaDoc id,
193                                                       String JavaDoc name,
194                                                       String JavaDoc version,
195                                                       org.omg.CORBA.IDLType JavaDoc type,
196                                                       org.omg.CORBA.Any JavaDoc value)
197     {
198         return delegate.create_constant( id, name, version, type, value );
199     }
200
201     public org.omg.CORBA.StructDef JavaDoc create_struct( String JavaDoc id,
202                                                   String JavaDoc name,
203                                                   String JavaDoc version,
204                                                   org.omg.CORBA.StructMember JavaDoc[] members)
205     {
206         return delegate.create_struct( id, name, version, members);
207     }
208
209     public org.omg.CORBA.UnionDef JavaDoc create_union( String JavaDoc id,
210                                                 String JavaDoc name,
211                                                 String JavaDoc version,
212                                                 org.omg.CORBA.IDLType JavaDoc discriminator_type,
213                                                 org.omg.CORBA.UnionMember JavaDoc[] members)
214     {
215         return delegate.create_union( id, name, version, discriminator_type, members);
216     }
217
218     public org.omg.CORBA.EnumDef JavaDoc create_enum( String JavaDoc id,
219                                               String JavaDoc name,
220                                               String JavaDoc version,
221                                               String JavaDoc[] members)
222     {
223         return delegate.create_enum( id, name, version, members);
224     }
225
226     public org.omg.CORBA.AliasDef JavaDoc create_alias( String JavaDoc id,
227                                                 String JavaDoc name,
228                                                 String JavaDoc version,
229                                                 org.omg.CORBA.IDLType JavaDoc original_type)
230     {
231         return delegate.create_alias( id, name, version, original_type);
232     }
233
234     public org.omg.CORBA.ExceptionDef JavaDoc create_exception( String JavaDoc id,
235                                                         String JavaDoc name,
236                                                         String JavaDoc version,
237                                                         org.omg.CORBA.StructMember JavaDoc[] member )
238     {
239         return delegate.create_exception(id, name, version, member);
240     }
241
242     /**
243      * not supported
244      */

245
246     public org.omg.CORBA.InterfaceDef JavaDoc create_interface( String JavaDoc id,
247                                                         String JavaDoc name,
248                                                         String JavaDoc version,
249                                                         org.omg.CORBA.InterfaceDef JavaDoc[] base_interfaces,
250                                                         boolean is_abstract )
251     {
252         return delegate.create_interface( id, name, version,
253                     base_interfaces, is_abstract );
254     }
255
256     /**
257      * not supported
258      */

259
260     public org.omg.CORBA.ValueBoxDef JavaDoc create_value_box(String JavaDoc id, String JavaDoc name, String JavaDoc version,
261                                                       org.omg.CORBA.IDLType JavaDoc type)
262     {
263         return delegate.create_value_box(id, name, version, type);
264     }
265
266     /**
267      * not supported
268      */

269
270     public org.omg.CORBA.ValueDef JavaDoc create_value(
271                                      String JavaDoc id,
272                                      String JavaDoc name,
273                                      String JavaDoc version,
274                                      boolean is_custom,
275                                      boolean is_abstract,
276                                      org.omg.CORBA.ValueDef JavaDoc base_value,
277                                      boolean is_truncatable,
278                                      org.omg.CORBA.ValueDef JavaDoc[] abstract_base_values,
279                                      org.omg.CORBA.InterfaceDef JavaDoc[] supported_interfaces,
280                                      org.omg.CORBA.Initializer JavaDoc[] initializers)
281     {
282         return delegate.create_value( id,
283                                       name,
284                                       version,
285                                       is_custom,
286                                       is_abstract,
287                                       base_value,
288                                       is_truncatable,
289                                       abstract_base_values,
290                                       supported_interfaces,
291                                       initializers);
292     }
293
294
295     /**
296      * not supported
297      */

298
299     public org.omg.CORBA.NativeDef JavaDoc create_native(java.lang.String JavaDoc id,
300                                                  java.lang.String JavaDoc name,
301                                                  java.lang.String JavaDoc version)
302     {
303         return delegate.create_native( id, name, version);
304     }
305
306
307     // from Contained
308

309     public org.omg.CORBA.ContainedPackage.Description describe()
310     {
311         org.omg.CORBA.Any JavaDoc a = orb.create_any();
312         String JavaDoc defined_in_id = null;
313
314         if( defined_in instanceof org.omg.CORBA.Contained JavaDoc )
315             defined_in_id = ((org.omg.CORBA.Contained JavaDoc)defined_in).id();
316         else
317             defined_in_id = "IR";
318
319         org.omg.CORBA.ModuleDescription JavaDoc m =
320             new org.omg.CORBA.ModuleDescription JavaDoc(
321                 name, id, defined_in_id, version);
322
323         org.omg.CORBA.ModuleDescriptionHelper.insert( a, m );
324         return new org.omg.CORBA.ContainedPackage.Description(
325             org.omg.CORBA.DefinitionKind.dk_Module, a);
326     }
327
328     public void destroy()
329     {
330         delegate.destroy();
331     }
332
333
334 }
335
Popular Tags