1 26 27 package org.objectweb.openccm.ir3; 28 29 import org.omg.CORBA.*; 31 import org.omg.CORBA.ComponentIR.*; 32 33 41 42 abstract public class IRObject_impl 43 extends IFRObject 44 implements IRObjectOperations, 45 IDLTypeOperations 46 { 47 53 54 private boolean is_under_destruction_; 55 56 62 65 public 66 IRObject_impl(IFR ifr) 67 { 68 super(ifr); 70 71 is_under_destruction_ = false; 73 } 74 75 81 86 protected boolean 87 isUnderDestruction() 88 { 89 return is_under_destruction_; 90 } 91 92 98 102 protected TypeCode 103 recursiveType(java.util.List idSeq) 104 { 105 throw exceptionMustBeImplemented("IDL:omg.org/CORBA/IDLType/type:1.0"); 107 } 108 109 112 protected IRObject_impl 113 castToLocal(IDLType type) 114 { 115 IRObject_impl tmp = (IRObject_impl)getIFR().toImpl(type); 116 117 if (tmp == null) 118 throw exceptionNotLocalObject(); 119 120 return tmp; 121 } 122 123 126 protected Container_impl 127 castToLocal(org.omg.CORBA.Container container) 128 { 129 Container_impl tmp = (Container_impl)getIFR().toImpl(container); 130 131 if (tmp == null) 132 throw exceptionInvalidContainer(); 133 134 return tmp; 135 } 136 137 140 protected ExceptionDef_impl 141 castToLocal(ExceptionDef exc) 142 { 143 ExceptionDef_impl impl = (ExceptionDef_impl)(getIFR().toImpl(exc)); 144 145 if (impl == null) 146 throw exceptionNotLocalObject(); 147 148 return impl; 149 } 150 151 154 protected InterfaceDef_impl 155 castToLocal(InterfaceDef itf) 156 { 157 InterfaceDef_impl tmp = (InterfaceDef_impl)getIFR().toImpl(itf); 158 159 if (tmp == null) 160 throw exceptionNotLocalObject(); 161 162 return tmp; 163 } 164 165 168 protected ValueDef_impl 169 castToLocal(ValueDef value) 170 { 171 ValueDef_impl impl = (ValueDef_impl)(getIFR().toImpl(value)); 172 173 if (impl == null) 174 throw exceptionNotLocalObject(); 175 176 return impl; 177 } 178 179 182 protected ComponentDef_impl 183 castToLocal(ComponentDef comp) 184 { 185 ComponentDef_impl impl = (ComponentDef_impl)(getIFR().toImpl(comp)); 186 187 if (impl == null) 188 throw exceptionNotLocalObject(); 189 190 return impl; 191 } 192 193 196 protected HomeDef_impl 197 castToLocal(HomeDef home) 198 { 199 HomeDef_impl impl = (HomeDef_impl)(getIFR().toImpl(home)); 200 201 if (impl == null) 202 throw exceptionNotLocalObject(); 203 204 return impl; 205 } 206 207 213 216 protected void 217 logError(String message) 218 { 219 getIFR().log(1, this.getIdentity() + ": " + message + "!"); 220 } 221 222 225 protected void 226 nextLogError(String message) 227 { 228 getIFR().log(1, this.getIdentity() + ": " + message); 229 } 230 231 234 protected SystemException 235 exceptionMustBeImplemented(String method) 236 { 237 logError(method + " not implemented"); 238 return new NO_IMPLEMENT(SystemExceptionMinorValues.LIFLVMCID, 239 CompletionStatus.COMPLETED_NO); 240 } 241 242 245 protected SystemException 246 exceptionBadParam(String method) 247 { 248 logError(method + " BAD PARAM"); 249 return new BAD_PARAM(SystemExceptionMinorValues.LIFLVMCID, 250 CompletionStatus.COMPLETED_NO); 251 } 252 253 256 protected SystemException 257 exceptionRidAlreadyDefined(String rid) 258 { 259 logError(rid + " already defined in the IFR"); 260 return new BAD_PARAM(SystemExceptionMinorValues.RidAlreadyDefined, 261 CompletionStatus.COMPLETED_NO); 262 } 263 264 267 protected SystemException 268 exceptionNameAlreadyUsedByImmediateScope(String name) 269 { 270 logError(name + " already used by immediate scope"); 271 return new BAD_PARAM(SystemExceptionMinorValues. 272 NameAlreadyUsedByImmediateScope, 273 CompletionStatus.COMPLETED_NO); 274 } 275 276 279 protected SystemException 280 exceptionNameAlreadyUsed(String name) 281 { 282 logError(name + " already used in the context"); 283 return new BAD_PARAM(SystemExceptionMinorValues.NameAlreadyUsed, 284 CompletionStatus.COMPLETED_NO); 285 } 286 287 290 protected SystemException 291 exceptionNotLocalObject() 292 { 293 logError("not a local servant"); 294 return new BAD_PARAM(SystemExceptionMinorValues.NotLocalObject, 295 CompletionStatus.COMPLETED_NO); 296 } 297 298 301 protected SystemException 302 exceptionInvalidContainer() 303 { 304 logError("Target is not a valid container"); 305 return new BAD_PARAM(SystemExceptionMinorValues.InvalidContainer, 306 CompletionStatus.COMPLETED_NO); 307 } 308 309 312 protected SystemException 313 exceptionNameClashInInheritedContext(String name) 314 { 315 logError(name + " name clash in inherited context"); 316 return new BAD_PARAM(SystemExceptionMinorValues. 317 NameClashInInheritedContext, 318 CompletionStatus.COMPLETED_NO); 319 } 320 321 325 protected SystemException 326 exceptionInvalidAbstractInterfaceInheritance(String absolute_name) 327 { 328 logError(absolute_name + " is not an abstract interface"); 329 return new BAD_PARAM(SystemExceptionMinorValues. 330 InvalidAbstractInterfaceInheritance, 331 CompletionStatus.COMPLETED_NO); 332 } 333 334 338 protected SystemException 339 exceptionInvalidLocalInterfaceInheritance(String absolute_name) 340 { 341 logError(absolute_name + " is not a local interface"); 342 return new BAD_PARAM(SystemExceptionMinorValues. 343 InvalidLocalInterfaceInheritance, 344 CompletionStatus.COMPLETED_NO); 345 } 346 347 350 protected SystemException 351 exceptionDuplicateDeclarator(String name, int pos) 352 { 353 logError(name + " is a duplicate declarator"); 354 return new BAD_PARAM(SystemExceptionMinorValues. 355 DuplicateDeclarator + pos, 356 CompletionStatus.COMPLETED_NO); 357 } 358 359 362 protected SystemException 363 exceptionNeedOnlyInParams() 364 { 365 logError("only in params are needed"); 366 return new BAD_PARAM(SystemExceptionMinorValues.NeedOnlyInParams, 367 CompletionStatus.COMPLETED_NO); 368 } 369 370 373 protected SystemException 374 exceptionNoExceptionsForOnewayOperation() 375 { 376 logError("oneway operation has no exceptions"); 377 return new BAD_PARAM(SystemExceptionMinorValues. 378 NoExceptionsForOnewayOperation, 379 CompletionStatus.COMPLETED_NO); 380 } 381 382 385 protected SystemException 386 exceptionInvalidValueBoxType() 387 { 388 logError("invalid type for value box"); 389 return new BAD_PARAM(SystemExceptionMinorValues.InvalidValueBoxType, 390 CompletionStatus.COMPLETED_NO); 391 } 392 393 396 protected SystemException 397 exceptionBadInvOrder(String method) 398 { 399 logError(method + " BAD INV ORDER"); 400 return new BAD_INV_ORDER(SystemExceptionMinorValues.LIFLVMCID, 401 CompletionStatus.COMPLETED_NO); 402 } 403 404 408 protected SystemException 409 exceptionDependency() 410 { 411 logError("dependency exits in IFR preventing destruction of this object"); 412 413 org.objectweb.util.ref.api.Referencable[] referenced_by = getReferencedBy(); 414 415 if(referenced_by.length == 1) 416 nextLogError(" 1 dependency:"); 417 else 418 nextLogError(" " + referenced_by.length + " dependencies:"); 419 420 for(int i=0; i<referenced_by.length; i++) { 421 nextLogError(" [" + (i+1) + "] used by " + referenced_by[i].getIdentity()); 422 } 423 424 return new BAD_INV_ORDER(SystemExceptionMinorValues.Dependency, 425 CompletionStatus.COMPLETED_NO); 426 } 427 428 431 protected SystemException 432 exceptionCanNotBeDestroyed() 433 { 434 logError("indestructible object"); 435 return new BAD_INV_ORDER(SystemExceptionMinorValues.CanNotBeDestroyed, 436 CompletionStatus.COMPLETED_NO); 437 } 438 439 442 protected SystemException 443 exceptionAmbiguousLookup(String id1, String id2) 444 { 445 logError("ambiguous lookup between " + id1 + " and " + id2); 446 return new INTF_REPOS(SystemExceptionMinorValues.AmbiguousLookup, 447 CompletionStatus.COMPLETED_NO); 448 } 449 450 453 protected SystemException 454 exceptionIllegalRecursion(String id1, String id2) 455 { 456 logError("illegal recursion : "+id2+" in type : "+id1); 457 return new INTF_REPOS(SystemExceptionMinorValues.IllegalRecursion, 458 CompletionStatus.COMPLETED_NO); 459 } 460 461 467 470 protected void 471 checkDependencies() 472 { 473 if (getReferencedByCounter() != 0) 475 { 476 org.objectweb.util.ref.api.Referencable[] referenced_by = getReferencedBy(); 478 for(int i=0; i<referenced_by.length; i++) { 479 if(!((IRObject_impl)(referenced_by[i])).isUnderDestruction()) 482 throw exceptionDependency(); 483 } 484 } 485 } 486 487 490 protected void 491 cutDependencies() 492 { 493 setServant(null); 495 } 496 497 503 508 public String 509 getIdentity() 510 { 511 return this.toString(); 512 } 513 514 520 523 public IRObject 524 asIRObject() 525 { 526 return IRObjectHelper.narrow(asObject()); 527 } 528 529 532 public IDLType 533 asIDLType() 534 { 535 return IDLTypeHelper.narrow(asObject()); 536 } 537 538 544 548 abstract public DefinitionKind def_kind(); 549 550 553 public void 554 destroy() 555 { 556 558 try 559 { 560 is_under_destruction_ = true; 562 563 checkDependencies(); 565 566 cutDependencies(); 568 } 569 catch (org.omg.CORBA.SystemException exc) 570 { 571 logError("Exception " + exc+toString() + " during destroy"); 572 throw exc; 574 } 575 finally 576 { 577 is_under_destruction_ = false; 579 } 580 581 } 583 584 590 593 public TypeCode 594 type() 595 { 596 throw exceptionMustBeImplemented("IDL:omg.org/CORBA/IDLType/type:1.0"); 598 } 599 } 600 | Popular Tags |