1 package org.jacorb.ir; 2 3 22 23 import java.util.*; 24 25 import org.omg.CORBA.INTF_REPOS ; 26 import org.omg.PortableServer.POA ; 27 import org.apache.avalon.framework.logger.Logger; 28 29 public class ModuleDef 30 extends Contained 31 implements org.omg.CORBA.ModuleDefOperations , ContainerType 32 { 33 private static char fileSeparator = 34 System.getProperty("file.separator").charAt(0); 35 36 private Container delegate; 37 private String path = null; 38 private Logger logger; 39 40 public ModuleDef( String path, 41 String full_name, 42 org.omg.CORBA.Container def_in, 43 org.omg.CORBA.Repository ir, 44 ClassLoader loader, 45 POA poa, 46 Logger logger ) 47 throws INTF_REPOS 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 ("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 ) 75 { 76 absolute_name = 77 ((org.omg.CORBA.Contained )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 e ) 117 { 118 this.logger.error("Caught Exception", e); 119 throw new INTF_REPOS ( ErrorMsg.IR_Not_Implemented, 120 org.omg.CORBA.CompletionStatus.COMPLETED_NO); 121 } 122 } 123 124 125 public String 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 lookup( String 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 [] contents( 162 org.omg.CORBA.DefinitionKind limit_type, 163 boolean exclude_inherited) 164 { 165 return delegate.contents(limit_type, exclude_inherited); 166 } 167 168 public org.omg.CORBA.Contained [] lookup_name(String search_name, 169 int levels_to_search, 170 org.omg.CORBA.DefinitionKind 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 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 create_module(String id, String name, String version) 188 { 189 return delegate.create_module( id, name, version); 190 } 191 192 public org.omg.CORBA.ConstantDef create_constant( String id, 193 String name, 194 String version, 195 org.omg.CORBA.IDLType type, 196 org.omg.CORBA.Any value) 197 { 198 return delegate.create_constant( id, name, version, type, value ); 199 } 200 201 public org.omg.CORBA.StructDef create_struct( String id, 202 String name, 203 String version, 204 org.omg.CORBA.StructMember [] members) 205 { 206 return delegate.create_struct( id, name, version, members); 207 } 208 209 public org.omg.CORBA.UnionDef create_union( String id, 210 String name, 211 String version, 212 org.omg.CORBA.IDLType discriminator_type, 213 org.omg.CORBA.UnionMember [] members) 214 { 215 return delegate.create_union( id, name, version, discriminator_type, members); 216 } 217 218 public org.omg.CORBA.EnumDef create_enum( String id, 219 String name, 220 String version, 221 String [] members) 222 { 223 return delegate.create_enum( id, name, version, members); 224 } 225 226 public org.omg.CORBA.AliasDef create_alias( String id, 227 String name, 228 String version, 229 org.omg.CORBA.IDLType original_type) 230 { 231 return delegate.create_alias( id, name, version, original_type); 232 } 233 234 public org.omg.CORBA.ExceptionDef create_exception( String id, 235 String name, 236 String version, 237 org.omg.CORBA.StructMember [] member ) 238 { 239 return delegate.create_exception(id, name, version, member); 240 } 241 242 245 246 public org.omg.CORBA.InterfaceDef create_interface( String id, 247 String name, 248 String version, 249 org.omg.CORBA.InterfaceDef [] base_interfaces, 250 boolean is_abstract ) 251 { 252 return delegate.create_interface( id, name, version, 253 base_interfaces, is_abstract ); 254 } 255 256 259 260 public org.omg.CORBA.ValueBoxDef create_value_box(String id, String name, String version, 261 org.omg.CORBA.IDLType type) 262 { 263 return delegate.create_value_box(id, name, version, type); 264 } 265 266 269 270 public org.omg.CORBA.ValueDef create_value( 271 String id, 272 String name, 273 String version, 274 boolean is_custom, 275 boolean is_abstract, 276 org.omg.CORBA.ValueDef base_value, 277 boolean is_truncatable, 278 org.omg.CORBA.ValueDef [] abstract_base_values, 279 org.omg.CORBA.InterfaceDef [] supported_interfaces, 280 org.omg.CORBA.Initializer [] 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 298 299 public org.omg.CORBA.NativeDef create_native(java.lang.String id, 300 java.lang.String name, 301 java.lang.String version) 302 { 303 return delegate.create_native( id, name, version); 304 } 305 306 307 309 public org.omg.CORBA.ContainedPackage.Description describe() 310 { 311 org.omg.CORBA.Any a = orb.create_any(); 312 String defined_in_id = null; 313 314 if( defined_in instanceof org.omg.CORBA.Contained ) 315 defined_in_id = ((org.omg.CORBA.Contained )defined_in).id(); 316 else 317 defined_in_id = "IR"; 318 319 org.omg.CORBA.ModuleDescription m = 320 new org.omg.CORBA.ModuleDescription ( 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 |