1 26 27 package org.objectweb.openccm.ir3; 28 29 import org.omg.CORBA.*; 31 32 40 41 abstract public class Contained_impl 42 extends IRObject_impl 43 implements ContainedOperations 44 { 45 51 52 protected Container_impl container_; 53 54 55 protected String id_; 56 57 58 protected String name_; 59 60 61 protected String version_; 62 63 69 70 public 71 Contained_impl(IFR ifr, 72 Container_impl container) 73 { 74 super(ifr); 76 77 container_ = container; 79 80 id_ = ""; 82 name_ = ""; 83 version_ = ""; 84 } 85 86 92 97 public String 98 getIdentity() 99 { 100 return id_; 101 } 102 103 109 112 protected boolean 113 isUnderDestruction() 114 { 115 if(super.isUnderDestruction()) return true; 117 118 if(container_ == null) return false; 120 121 return container_.isUnderDestruction(); 123 } 124 125 131 134 public Contained 135 asContained() 136 { 137 return ContainedHelper.narrow(asObject()); 138 } 139 140 143 public String 144 getContainerID() 145 { 146 if (container_ == null) return ""; 147 return container_.id(); 148 } 149 150 153 public String 154 getBaseContainerID() 155 { 156 if (container_ == null) return "IDL:"; 157 return computeBaseID(container_.id()); 158 } 159 160 163 public String 164 getBaseID() 165 { 166 return computeBaseID(id()); 167 } 168 169 172 public String 173 computeBaseID(String id) 174 { 175 return computeIDWithoutVersion(id) + '/'; 176 } 177 178 181 public String 182 computeIDWithoutVersion(String id) 183 { 184 int idx = id.lastIndexOf(':'); 185 if(idx == -1) return id; 186 return id.substring(0, idx); 187 } 188 189 194 public void 195 setDescriptionValue(Any any) 196 { 197 TypeDescription description = new TypeDescription(); 199 description.name = name(); 200 description.id = id(); 201 description.defined_in = getContainerID(); 202 description.version = version(); 203 description.type = type(); 204 205 TypeDescriptionHelper.insert(any, description); 207 } 208 209 215 218 protected void 219 cutDependencies() 220 { 221 if(id_.length() != 0) 223 getIFR().getRepository().removeRID(id_); 224 225 if (container_ != null) 227 container_.removeContained(this); 228 229 super.cutDependencies(); 231 } 232 233 239 245 248 public String 249 id() 250 { 251 return id_; 252 } 253 254 257 public void 258 id(String val) 259 { 260 if (val.equals(id_)) return; 262 263 Contained contained = getIFR().getRepository().lookup_id(val); 265 if (contained != null) 267 throw exceptionRidAlreadyDefined(val); 268 269 if(id_.length() != 0) 271 getIFR().getRepository().removeRID(id_); 272 273 id_ = val; 275 276 if(id_.length() != 0) 278 getIFR().getRepository().addRID(id_, this); 279 } 280 281 284 public String 285 name() 286 { 287 return name_; 288 } 289 290 293 public void 294 name(String val) 295 { 296 if (val.equals(name_)) return; 298 299 if (val.equalsIgnoreCase(container_.name())) 301 throw exceptionNameAlreadyUsedByImmediateScope(val); 302 303 container_.checkName(val, true, false); 306 307 name_ = val; 308 } 309 310 313 public String 314 version() 315 { 316 return version_; 317 } 318 319 322 public void 323 version(String val) 324 { 325 version_ = val; 326 } 327 328 331 public Container 332 defined_in() 333 { 334 return container_.asContainer(); 335 } 336 337 340 public String 341 absolute_name() 342 { 343 if (container_ == null) return ""; 345 346 return container_.absolute_name() + "::" + name_; 347 } 348 349 352 public Repository 353 containing_repository() 354 { 355 return getIFR().getRepository().asRepository(); 356 } 357 358 361 public org.omg.CORBA.ContainedPackage.Description 362 describe() 363 { 364 Any any = org.objectweb.openccm.corba.TheORB.create_any(); 366 setDescriptionValue(any); 367 368 return new org.omg.CORBA.ContainedPackage.Description(def_kind(), any); 370 } 371 372 375 public void 376 move(Container new_container, 377 String new_name, 378 String new_version) 379 { 380 if (new_container == null) 382 throw exceptionBadParam("IDL:omg.org/CORBA/Contained/move:1.0"); 383 384 Container_impl newContainer = castToLocal(new_container); 386 387 String oldName = name_; 389 String oldVersion = version_; 390 Container_impl oldContainer = container_; 391 392 oldContainer.removeContained(this); 396 try 397 { 398 newContainer.addContained(this); 399 container_ = newContainer; 400 } 401 catch(SystemException ex) 402 { 403 oldContainer.addContained(this); 407 container_ = oldContainer; 408 throw ex; 409 } 410 411 try 412 { 413 name(new_name); 417 version(new_version); 418 } 419 catch(SystemException ex) 420 { 421 oldContainer.addContained(this); 425 newContainer.removeContained(this); 426 container_ = oldContainer; 427 name(oldName); 428 version(oldVersion); 429 throw ex; 430 } 431 } 432 } 433 | Popular Tags |