1 26 27 package org.objectweb.ccm.visitorIDL3.java; 28 29 import org.objectweb.ccm.visitorIDL3.common.*; 30 31 38 39 public class JavaSkeletonPrinter 40 extends JavaPrinterBase 41 { 42 48 54 57 public 58 JavaSkeletonPrinter(Generator gen, 59 java.lang.String indent) 60 throws fr.lifl.cim.jidlscript.lang.JISError 61 { 62 super(gen, '$', '#', indent); 63 64 super.setAlias("self", this); 66 67 super.loadFile("java_skeleton_component.template"); 70 super.loadFile("java_skeleton_home.template"); 71 super.loadFile("java_skeleton_event.template"); 72 super.loadFile("java_skeleton_common.template"); 73 } 74 75 81 87 90 public java.lang.String 91 modifyCurrentLine(java.lang.String str) 92 { 93 if (str.length()==0) 94 return "\\n"; 97 98 if (str.charAt(0)=='{') 99 return "{\\n$self.inc()$"; 100 101 if (str.charAt(0)=='}') 102 return "$self.dec()$}\\n"; 103 104 if ((str.charAt(0)!=getCallChar()) || (str.charAt(str.length()-1)!=getCallChar())) 105 return str+"\\n"; 106 107 return str; 108 } 109 110 116 119 public java.lang.String 120 which() 121 { 122 return "ir3_java"; 123 } 124 125 128 public java.lang.String 129 visitModule(org.objectweb.ccm.IDL3.ModuleDecl module) 130 { 131 org.objectweb.ccm.util.Vector ports = new org.objectweb.ccm.util.Vector(); 132 133 org.objectweb.ccm.IDL3.Declaration[] components = null; 134 components = module.getContents(true, org.objectweb.ccm.IDL3.DeclarationKind._dk_component); 135 for (int i=0;i<components.length;i++) 136 { 137 org.objectweb.ccm.IDL3.ComponentDecl comp = null; 138 org.objectweb.ccm.IDL3.Declaration[] comp_ports = null; 139 140 comp = (org.objectweb.ccm.IDL3.ComponentDecl)components[i]; 141 visitContained(comp, "_SKELETON"); 142 visitContained(comp.getClientMapping(), "_SKELETON_INTERCEPTOR"); 143 visitContained(comp.getClientMapping(), "_STUB_INTERCEPTOR"); 144 visitContained(comp, "_MONOLITHIC_WRAPPER"); 145 comp_ports = comp.getContents(false, org.objectweb.ccm.IDL3.DeclarationKind._dk_provides + 146 org.objectweb.ccm.IDL3.DeclarationKind._dk_uses + 147 org.objectweb.ccm.IDL3.DeclarationKind._dk_consumes + 148 org.objectweb.ccm.IDL3.DeclarationKind._dk_publishes + 149 org.objectweb.ccm.IDL3.DeclarationKind._dk_emits); 150 151 for (int j=0;j<comp_ports.length;j++) 152 { 153 org.objectweb.ccm.IDL3.TypeRef port_type = getType(comp_ports[j]); 154 if (!ports.contains(port_type)) 155 ports.add(port_type); 156 } 157 } 158 159 org.objectweb.ccm.IDL3.Declaration[] ports_arr = null; 160 ports_arr = (org.objectweb.ccm.IDL3.Declaration[])ports.toArray(new org.objectweb.ccm.IDL3.Declaration[0]); 161 for (int i=0;i<ports_arr.length;i++) 162 { 163 if (ports_arr[i].getDeclKind()==org.objectweb.ccm.IDL3.DeclarationKind._dk_interface) 164 { 165 visitContained(ports_arr[i], "_SKELETON_INTERCEPTOR"); 166 visitContained(ports_arr[i], "_STUB_INTERCEPTOR"); 167 } 168 else if (ports_arr[i].getDeclKind()==org.objectweb.ccm.IDL3.DeclarationKind._dk_event) 169 { 170 org.objectweb.ccm.IDL3.EventDecl event = null; 171 event = (org.objectweb.ccm.IDL3.EventDecl)ports_arr[i]; 172 visitContained(event.getClientMapping(),"_SKELETON_INTERCEPTOR"); 173 visitContained(event.getClientMapping(),"_STUB_INTERCEPTOR"); 174 } 175 } 176 177 org.objectweb.ccm.IDL3.Declaration[] homes = null; 178 homes = module.getContents(true, org.objectweb.ccm.IDL3.DeclarationKind._dk_home); 179 for (int i=0;i<homes.length;i++) 180 { 181 visitContained(homes[i], "_SKELETON"); 182 visitContained(((org.objectweb.ccm.IDL3.HomeDecl)homes[i]).getClientMapping(), 183 "_SKELETON_INTERCEPTOR"); 184 visitContained(((org.objectweb.ccm.IDL3.HomeDecl)homes[i]).getClientMapping(), 185 "_STUB_INTERCEPTOR"); 186 } 187 188 org.objectweb.ccm.IDL3.Declaration[] events = null; 189 events = module.getContents(true, org.objectweb.ccm.IDL3.DeclarationKind._dk_event); 190 for (int i=0;i<events.length;i++) 191 { 192 visitContained(events[i], ""); 193 visitContained(events[i], "_CONSUMER_WRAPPER"); 194 } 195 196 org.objectweb.ccm.IDL3.Declaration[] values = null; 197 values = module.getContents(true, org.objectweb.ccm.IDL3.DeclarationKind._dk_value); 198 for (int i=0;i<values.length;i++) 199 { 200 org.objectweb.ccm.IDL3.ValueDecl val = (org.objectweb.ccm.IDL3.ValueDecl)values[i]; 204 if (val.isPrimaryKey()) 205 visitContained(values[i], "_PK"); 206 else 207 visitContained(values[i], ""); 208 } 209 210 org.objectweb.ccm.IDL3.Declaration[] modules = null; 211 modules = module.getContents(true, org.objectweb.ccm.IDL3.DeclarationKind._dk_module); 212 for (int i=0;i<modules.length;i++) 213 visitContained(modules[i], ""); 214 215 return ""; 216 } 217 218 221 public java.lang.String 222 extractSuperName(org.objectweb.ccm.IDL3.Declaration obj, 223 org.objectweb.ccm.IDL3.Declaration mapobj) 224 { 225 java.lang.String res = mapobj.getName(); 226 int idx = res.lastIndexOf(obj.getName()); 227 if (idx==0) 228 return res; 229 230 return res.substring(0, idx-1); 231 } 232 233 236 public java.lang.String 237 packageName(org.objectweb.ccm.IDL3.Declaration decl) 238 { 239 java.lang.String pack_name = getTranslator().getPackage(decl); 240 if (!pack_name.equals("")) 241 return pack_name; 242 243 delete(8); 244 skip(3); 245 return ""; 246 } 247 248 254 public java.lang.String 257 javaPackage(org.objectweb.ccm.IDL3.Declaration type) 258 { 259 java.lang.String packageName = getTranslator().getPackage(type); 260 261 if (packageName.length() != 0) 262 packageName = packageName + '.'; 263 264 return packageName; 265 } 266 267 public java.lang.String 270 javaType(org.objectweb.ccm.IDL3.Declaration type, 271 java.lang.String prefix, 272 java.lang.String postfix) 273 { 274 return javaPackage(type) + prefix + type.getName() + postfix; 275 } 276 277 public java.lang.String 280 javaCCMConsumer(org.objectweb.ccm.IDL3.Declaration type) 281 { 282 return javaType(type, "CCM_", "Consumer"); 283 } 284 285 public java.lang.String 287 executorWrapperAttributes(org.objectweb.ccm.IDL3.Scope scope) 288 { 289 org.objectweb.ccm.IDL3.Declaration[] objs = 290 scope.getContents(false, 291 org.objectweb.ccm.IDL3.DeclarationKind._dk_consumes); 292 293 java.lang.String res = ""; 294 for (int i=0; i<objs.length; i++) 295 { 296 java.lang.String name = objs[i].getName(); 297 298 res = res + 299 "/** Wrapper for port " + name + ". */\n " + 300 "protected " + name + "_ConsumerWrapper " + 301 name + "_wrapper_ =\n new " + 302 name + "_ConsumerWrapper();\n\n"; 303 } 304 305 return res; 306 } 307 308 311 public java.lang.String 312 obtainExecutorWrapper(org.objectweb.ccm.IDL3.Scope scope) 313 { 314 org.objectweb.ccm.IDL3.Declaration[] objs = null; 315 objs = scope.getContents(false, org.objectweb.ccm.IDL3.DeclarationKind._dk_provides + 316 org.objectweb.ccm.IDL3.DeclarationKind._dk_consumes); 317 318 java.lang.String [] aliases = { "name" , "impl" }; 319 for (int i=0;i<objs.length;i++) 320 { 321 java.lang.String impl = ""; 322 if (objs[i].getDeclKind()==org.objectweb.ccm.IDL3.DeclarationKind._dk_provides) 323 impl = "_monolithic_executor.get_"+objs[i].getName()+"()"; 324 else 325 impl = objs[i].getName()+"_wrapper_"; 326 327 java.lang.Object [] objs2 = { objs[i].getName(), impl }; 328 super.map("COMPONENT_MONOLITHIC_EXECUTOR_WRAPPER", aliases, objs2); 329 } 330 331 return ""; 332 } 333 334 337 public java.lang.String 338 monolithicEventWrapperClasses(org.objectweb.ccm.IDL3.Scope scope) 339 { 340 org.objectweb.ccm.IDL3.Declaration[] objs = 341 scope.getContents(false, 342 org.objectweb.ccm.IDL3.DeclarationKind._dk_consumes); 343 344 java.lang.String res = ""; 345 for (int i=0; i<objs.length; i++) 346 { 347 org.objectweb.ccm.IDL3.InterfaceDecl itf = 348 ((org.objectweb.ccm.IDL3.EventDecl)getType(objs[i])). 349 getLocalConsumerMapping(); 350 351 org.objectweb.ccm.IDL3.Declaration[] ops = 352 itf.getContents(false, 353 org.objectweb.ccm.IDL3.DeclarationKind._dk_operation); 354 355 for (int j=0; j<ops.length; j++) 356 visitContainedWithMapping(objs[i], ops[j], 357 "_EVENT_CONSUMER_MONOLITHIC_WRAPPER"); 358 } 359 360 return ""; 361 } 362 363 366 public java.lang.String 367 portDeclarations(org.objectweb.ccm.IDL3.Scope scope) 368 { 369 org.objectweb.ccm.IDL3.Declaration[] objs = null; 370 java.lang.String res = ""; 371 objs = scope.getContents(false, org.objectweb.ccm.IDL3.DeclarationKind._dk_provides + 372 org.objectweb.ccm.IDL3.DeclarationKind._dk_uses + 373 org.objectweb.ccm.IDL3.DeclarationKind._dk_consumes + 374 org.objectweb.ccm.IDL3.DeclarationKind._dk_publishes + 375 org.objectweb.ccm.IDL3.DeclarationKind._dk_emits); 376 377 378 for (int i=0;i<objs.length;i++) 379 { 380 java.lang.String port_info = ""; 381 org.objectweb.ccm.IDL3.Declaration type = null; 382 type = (org.objectweb.ccm.IDL3.Declaration)getType(objs[i]); 383 384 if (objs[i].getDeclKind()==org.objectweb.ccm.IDL3.DeclarationKind._dk_provides) 385 port_info = "ProvidesInfo(\""+objs[i].getId()+"\", \""+objs[i].getName()+"\", \""+type.getId()+"\")"; 386 else if (objs[i].getDeclKind()==org.objectweb.ccm.IDL3.DeclarationKind._dk_consumes) 387 { 388 org.objectweb.ccm.IDL3.EventDecl event = (org.objectweb.ccm.IDL3.EventDecl)type; 389 org.objectweb.ccm.IDL3.InterfaceDecl itf = event.getClientMapping(); 390 port_info = "ConsumesInfo(\""+objs[i].getId()+"\", \""+objs[i].getName()+"\", \""+itf.getId()+"\")"; 391 } 392 else if (objs[i].getDeclKind()==org.objectweb.ccm.IDL3.DeclarationKind._dk_emits) 393 { 394 org.objectweb.ccm.IDL3.EventDecl event = (org.objectweb.ccm.IDL3.EventDecl)type; 395 org.objectweb.ccm.IDL3.InterfaceDecl itf = event.getClientMapping(); 396 port_info = "EmitsInfo(\""+objs[i].getId()+"\", \""+objs[i].getName()+"\", \""+itf.getId()+"\")"; 397 } 398 else if (objs[i].getDeclKind()==org.objectweb.ccm.IDL3.DeclarationKind._dk_publishes) 399 { 400 org.objectweb.ccm.IDL3.EventDecl event = (org.objectweb.ccm.IDL3.EventDecl)type; 401 org.objectweb.ccm.IDL3.InterfaceDecl itf = event.getClientMapping(); 402 port_info = "PublishesInfo(\""+objs[i].getId()+"\", \""+objs[i].getName()+"\", \""+itf.getId()+"\")"; 403 } 404 else 405 { 406 org.objectweb.ccm.IDL3.UsesDecl uses = (org.objectweb.ccm.IDL3.UsesDecl)objs[i]; 407 if (uses.isMultiple()) 408 port_info = "UsesInfo(\""+objs[i].getId()+"\", \""+objs[i].getName()+"\", \""+type.getId()+"\", "+ 409 java.lang.Integer.toString(java.lang.Integer.MAX_VALUE)+")"; 410 else 411 port_info = "UsesInfo(\""+objs[i].getId()+"\", \""+objs[i].getName()+"\", \""+type.getId()+"\")"; 412 } 413 414 res = res+"_declare_port(new org.objectweb.openccm.Components."+port_info+");\\n"; 415 } 416 417 return res; 418 } 419 420 423 public java.lang.String 424 computeComponentOpName(org.objectweb.ccm.IDL3.Declaration obj, 425 org.objectweb.ccm.IDL3.Declaration mapobj) 426 { 427 java.lang.String str = ""; 428 429 if (obj.getDeclKind()==org.objectweb.ccm.IDL3.DeclarationKind._dk_provides) 430 str = "provide_facet"; 431 else if (obj.getDeclKind()==org.objectweb.ccm.IDL3.DeclarationKind._dk_uses) 432 { 433 str = "_"+extractSuperName(obj, mapobj); 434 org.objectweb.ccm.IDL3.UsesDecl uses = (org.objectweb.ccm.IDL3.UsesDecl)obj; 435 if (!uses.isMultiple()) 436 str = str+"_simple_receptacle"; 437 } 438 else if (obj.getDeclKind()==org.objectweb.ccm.IDL3.DeclarationKind._dk_consumes) 439 str = "_get_consumer"; 440 else if (obj.getDeclKind()==org.objectweb.ccm.IDL3.DeclarationKind._dk_emits) 441 str = "_"+extractSuperName(obj, mapobj)+"_emitter"; 442 else if (obj.getDeclKind()==org.objectweb.ccm.IDL3.DeclarationKind._dk_publishes) 443 str = "_"+extractSuperName(obj, mapobj); 444 445 return str; 446 } 447 448 453 public java.lang.String 454 contextOperations(org.objectweb.ccm.IDL3.Scope scope) 455 { 456 org.objectweb.ccm.IDL3.Declaration[] objs = null; 457 objs = scope.getContents(false, 458 org.objectweb.ccm.IDL3.DeclarationKind._dk_publishes + 459 org.objectweb.ccm.IDL3.DeclarationKind._dk_emits); 460 461 java.lang.String [] aliases = { "obj", "event_abs_name", "port_name", "event" }; 462 for (int i=0;i<objs.length;i++) 463 { 464 org.objectweb.ccm.IDL3.OperationDecl[] ops = null; 465 java.lang.String id = ""; 466 467 if (objs[i].getDeclKind()==org.objectweb.ccm.IDL3.DeclarationKind._dk_publishes) 468 { 469 ops = ((org.objectweb.ccm.IDL3.PublishesDecl)objs[i]).getLocalContextMapping(); 470 id = "COMPONENT_CONTEXT_PUBLISHES"; 471 } 472 else 473 { 474 ops = ((org.objectweb.ccm.IDL3.EmitsDecl)objs[i]).getLocalContextMapping(); 475 id = "COMPONENT_CONTEXT_EMITS"; 476 } 477 478 for (int j=0;j<ops.length;j++) 479 { 480 java.lang.Object [] objs2 = { ops[j], 481 getTranslator().getAbsoluteName( 482 (org.objectweb.ccm.IDL3.Declaration)getType(objs[i])), 483 objs[i].getName(), 484 getType(objs[i]) }; 485 super.map(id, aliases, objs2); 486 } 487 } 488 489 return ""; 490 } 491 492 495 public java.lang.String 496 connectionOperations(org.objectweb.ccm.IDL3.Scope scope) 497 { 498 org.objectweb.ccm.IDL3.Declaration[] objs = null; 499 objs = scope.getContents(false, 500 org.objectweb.ccm.IDL3.DeclarationKind._dk_provides + 501 org.objectweb.ccm.IDL3.DeclarationKind._dk_uses + 502 org.objectweb.ccm.IDL3.DeclarationKind._dk_consumes + 503 org.objectweb.ccm.IDL3.DeclarationKind._dk_publishes + 504 org.objectweb.ccm.IDL3.DeclarationKind._dk_emits); 505 506 for (int i=0;i<objs.length;i++) 507 { 508 org.objectweb.ccm.IDL3.OperationDecl[] ops = null; 509 java.lang.String id = ""; 510 511 if (objs[i].getDeclKind()==org.objectweb.ccm.IDL3.DeclarationKind._dk_provides) 512 ops = ((org.objectweb.ccm.IDL3.ProvidesDecl)objs[i]).getClientMapping(); 513 else if (objs[i].getDeclKind()==org.objectweb.ccm.IDL3.DeclarationKind._dk_uses) 514 ops = ((org.objectweb.ccm.IDL3.UsesDecl)objs[i]).getClientMapping(); 515 else if (objs[i].getDeclKind()==org.objectweb.ccm.IDL3.DeclarationKind._dk_consumes) 516 ops = ((org.objectweb.ccm.IDL3.ConsumesDecl)objs[i]).getClientMapping(); 517 else if (objs[i].getDeclKind()==org.objectweb.ccm.IDL3.DeclarationKind._dk_publishes) 518 ops = ((org.objectweb.ccm.IDL3.PublishesDecl)objs[i]).getClientMapping(); 519 else 520 ops = ((org.objectweb.ccm.IDL3.EmitsDecl)objs[i]).getClientMapping(); 521 522 java.lang.String [] aliases = { "obj", "narrow", "super_op_name", 523 "port_name", "param_names", 524 "port_abs_name", "struct_abs_name" }; 525 for (int j=0;j<ops.length;j++) 526 { 527 id = "COMPONENT_CONNECTION"; 528 java.lang.String narrow = ""; 529 java.lang.String param_names = paramNames(ops[j]); 530 java.lang.String port_abs_name = getTranslator().getAbsoluteName(objs[i]); 531 java.lang.String struct_abs_name = ""; 532 if (!param_names.equals("")) 533 param_names = ", "+param_names; 534 if (ops[j].getType().getTypeKind()!=org.objectweb.ccm.IDL3.TypeKind._tk_void) 535 { 536 if (ops[j].getType().getTypeKind()!=org.objectweb.ccm.IDL3.TypeKind._tk_value) 539 { 540 id = id+"_DEFAULT"; 541 narrow = type(ops[j].getType())+"Helper.narrow"; 542 } 543 else 544 id = id+"_NO_NARROW"; 545 } 546 else 547 id = id+"_VOID"; 548 549 if ((objs[i].getDeclKind()==org.objectweb.ccm.IDL3.DeclarationKind._dk_uses) && 551 (ops[j].getName().startsWith("get_connections_"))) 552 { 553 id = "COMPONENT_CONNECTION_USES_MULTIPLE"; 554 org.objectweb.ccm.IDL3.AliasDecl alias = null; 555 org.objectweb.ccm.IDL3.TypeRefImpl sequence = null; 556 org.objectweb.ccm.IDL3.StructDecl struct = null; 557 alias = (org.objectweb.ccm.IDL3.AliasDecl)ops[j].getType(); 558 sequence = (org.objectweb.ccm.IDL3.TypeRefImpl)alias.getType(); 559 struct = (org.objectweb.ccm.IDL3.StructDecl)sequence.getContentType(); 560 struct_abs_name = getTranslator().getAbsoluteName(struct); 561 narrow = type(getType(objs[i]))+"Helper.narrow"; 562 } 563 564 java.lang.Object [] objs2 = { ops[j], narrow, 565 computeComponentOpName(objs[i], ops[j]), 566 objs[i].getName(), 567 param_names, 568 port_abs_name, 569 struct_abs_name }; 570 super.map(id, aliases, objs2); 571 } 572 } 573 574 return ""; 575 } 576 577 578 584 587 public java.lang.String 588 homeHelper(org.objectweb.ccm.IDL3.TypeRef type) 589 { 590 java.lang.String res = getTranslator().toJava(type); 591 if (type.getTypeKind()!=org.objectweb.ccm.IDL3.TypeKind._tk_interface) 593 res = res + "Factory"; 594 595 return res; 596 } 597 598 601 public java.lang.String 602 hasPK(org.objectweb.ccm.IDL3.HomeDecl home) 603 { 604 if (home.getPrimaryKey()==null) 605 return "false"; 606 607 return "true"; 608 } 609 610 613 public java.lang.String 614 baseHome(org.objectweb.ccm.IDL3.HomeDecl home) 615 { 616 if (home.getPrimaryKey()==null) 617 return "CCMHomeImpl"; 618 619 return "CCMHomeWithPKImpl"; 620 } 621 622 625 public java.lang.String 626 implementedHomeExecutor(org.objectweb.ccm.IDL3.HomeDecl home) 627 { 628 if (home.getPrimaryKey()==null) 629 return "HomeExecutor"; 630 631 return "HomeExecutorWithPK"; 632 } 633 634 637 public java.lang.String 638 homeExecutorOps(org.objectweb.ccm.IDL3.HomeDecl home) 639 { 640 java.lang.String id = "HOME_EXECUTOR_OPS"; 641 java.lang.String key_abs_name = ""; 642 if (home.getPrimaryKey()!=null) 643 { 644 id = id + "_WITH_PK"; 645 key_abs_name = getTranslator().getAbsoluteName(home.getPrimaryKey()); 646 } 647 648 java.lang.String [] aliases = { "key_abs_name" }; 649 java.lang.Object [] objs = { key_abs_name }; 650 super.map(id, aliases, objs); 651 652 653 return ""; 654 } 655 656 659 public java.lang.String 660 primaryKeyOperations(org.objectweb.ccm.IDL3.HomeDecl home) 661 { 662 org.objectweb.ccm.IDL3.InterfaceDecl itf = null; 663 org.objectweb.ccm.IDL3.Declaration[] ops = null; 664 665 itf = home.getClientImplicitMapping(); 666 ops = itf.getContents(true, org.objectweb.ccm.IDL3.DeclarationKind._dk_operation); 667 668 java.lang.String id = ""; 669 java.lang.String [] aliases = { "obj" }; 670 for (int i=0;i<ops.length;i++) 671 { 672 id = "HOME_OPERATION_SUPER"; 673 if (getType(ops[i]).getTypeKind()==org.objectweb.ccm.IDL3.TypeKind._tk_void) 674 id = id + "_VOID"; 675 676 java.lang.Object [] objs = { ops[i] }; 677 super.map(id, aliases, objs); 678 } 679 680 return ""; 681 } 682 683 686 public java.lang.String 687 factoryFinderOperations(org.objectweb.ccm.IDL3.HomeDecl home) 688 { 689 org.objectweb.ccm.IDL3.Declaration[] objs = null; 690 691 objs = home.getContents(false, org.objectweb.ccm.IDL3.DeclarationKind._dk_factory + 692 org.objectweb.ccm.IDL3.DeclarationKind._dk_finder); 693 694 java.lang.String id = ""; 695 org.objectweb.ccm.IDL3.Declaration[] ops = null; 696 org.objectweb.ccm.IDL3.FactoryDecl factory = null; 697 org.objectweb.ccm.IDL3.FinderDecl finder = null; 698 java.lang.String [] aliases = { "obj" }; 699 for (int i=0;i<objs.length;i++) 700 { 701 id = "HOME"; 702 if (objs[i].getDeclKind()==org.objectweb.ccm.IDL3.DeclarationKind._dk_factory) 703 { 704 factory = (org.objectweb.ccm.IDL3.FactoryDecl)objs[i]; 705 ops = factory.getClientMapping(); 706 id = id + "_FACTORY_SUPER"; 707 } 708 else 709 { 710 finder = (org.objectweb.ccm.IDL3.FinderDecl)objs[i]; 711 ops = finder.getClientMapping(); 712 id = id + "_FINDER_SUPER"; 713 } 714 715 for (int j=0;j<ops.length;j++) 716 { 717 java.lang.Object [] objs2 = { ops[j] }; 718 super.map(id, aliases, objs2); 719 } 720 } 721 722 return ""; 723 } 724 725 728 public java.lang.String 729 portInterceptors(org.objectweb.ccm.IDL3.Scope scope) 730 { 731 org.objectweb.ccm.IDL3.Declaration[] objs = null; 732 objs = scope.getContents(false, org.objectweb.ccm.IDL3.DeclarationKind._dk_provides + 733 org.objectweb.ccm.IDL3.DeclarationKind._dk_consumes + 734 org.objectweb.ccm.IDL3.DeclarationKind._dk_emits + 735 org.objectweb.ccm.IDL3.DeclarationKind._dk_publishes + 736 org.objectweb.ccm.IDL3.DeclarationKind._dk_uses); 737 738 java.lang.String res = ""; 739 org.objectweb.ccm.IDL3.Declaration type = null; 740 java.lang.String ext = ""; 741 for (int i=0;i<objs.length;i++) 742 { 743 if ((objs[i].getDeclKind()==org.objectweb.ccm.IDL3.DeclarationKind._dk_emits) || 744 (objs[i].getDeclKind()==org.objectweb.ccm.IDL3.DeclarationKind._dk_publishes)) 745 ext = "ConsumerStub"; 746 else if (objs[i].getDeclKind()==org.objectweb.ccm.IDL3.DeclarationKind._dk_consumes) 747 ext = "ConsumerSkeleton"; 748 else if (objs[i].getDeclKind()==org.objectweb.ccm.IDL3.DeclarationKind._dk_uses) 749 ext = "Stub"; 750 else 751 ext = "Skeleton"; 752 753 type = (org.objectweb.ccm.IDL3.Declaration)getType(objs[i]); 754 res = "if (uid.equals(\""+objs[i].getId()+ 755 "\"))\\n"+ 756 getIndentation()+"return new "+getTranslator().getAbsoluteName(type)+ext+"Interceptor();\\n"; 757 758 super.printImmediately(res); 759 } 760 761 return ""; 762 } 763 764 767 public java.lang.String 768 portUids(org.objectweb.ccm.IDL3.Scope scope) 769 { 770 org.objectweb.ccm.IDL3.Declaration[] objs = null; 771 java.lang.String res = ""; 772 objs = scope.getContents(false, org.objectweb.ccm.IDL3.DeclarationKind._dk_provides + 773 org.objectweb.ccm.IDL3.DeclarationKind._dk_consumes + 774 org.objectweb.ccm.IDL3.DeclarationKind._dk_emits + 775 org.objectweb.ccm.IDL3.DeclarationKind._dk_publishes + 776 org.objectweb.ccm.IDL3.DeclarationKind._dk_uses); 777 778 for (int i=0;i<objs.length;i++) 779 res = res+"\""+objs[i].getId()+"\", "; 780 781 if (!res.equals("")) 782 res = res.substring(0, res.length()-2); 783 784 return res; 785 } 786 787 790 public java.lang.String 791 portTypeUid(org.objectweb.ccm.IDL3.Scope scope) 792 { 793 org.objectweb.ccm.IDL3.Declaration[] objs = null; 794 objs = scope.getContents(false, org.objectweb.ccm.IDL3.DeclarationKind._dk_provides + 795 org.objectweb.ccm.IDL3.DeclarationKind._dk_consumes + 796 org.objectweb.ccm.IDL3.DeclarationKind._dk_emits + 797 org.objectweb.ccm.IDL3.DeclarationKind._dk_publishes + 798 org.objectweb.ccm.IDL3.DeclarationKind._dk_uses); 799 800 java.lang.String res = ""; 801 org.objectweb.ccm.IDL3.Declaration type = null; 802 for (int i=0;i<objs.length;i++) 803 { 804 type = (org.objectweb.ccm.IDL3.Declaration)getType(objs[i]); 805 806 res = "if (port_uid.equals(\""+objs[i].getId()+ 807 "\"))\\n"+ 808 getIndentation()+"return \""; 809 810 java.lang.String type_id = type.getId(); 811 if ((objs[i].getDeclKind()!=org.objectweb.ccm.IDL3.DeclarationKind._dk_provides) && 812 (objs[i].getDeclKind()!=org.objectweb.ccm.IDL3.DeclarationKind._dk_uses)) 813 { 814 org.objectweb.ccm.IDL3.EventDecl event = (org.objectweb.ccm.IDL3.EventDecl)type; 815 org.objectweb.ccm.IDL3.InterfaceDecl itf = event.getClientMapping(); 816 type_id = itf.getId(); 817 } 818 819 res = res+type_id+"\";\\n"; 820 821 super.printImmediately(res); 822 } 823 824 return ""; 825 } 826 827 830 public java.lang.String 831 executorWrappers(org.objectweb.ccm.IDL3.ComponentDecl comp) 832 { 833 org.objectweb.ccm.IDL3.Declaration[] objs = null; 834 objs = comp.getContents(false, org.objectweb.ccm.IDL3.DeclarationKind._dk_consumes); 835 836 java.lang.String [] aliases = { "obj", "pack_name", "port_id" }; 837 for (int i=0;i<objs.length;i++) 838 { 839 org.objectweb.ccm.IDL3.ConsumesDecl cons = (org.objectweb.ccm.IDL3.ConsumesDecl)objs[i]; 840 org.objectweb.ccm.IDL3.EventDecl event = (org.objectweb.ccm.IDL3.EventDecl)cons.getType(); 841 842 java.lang.Object [] objs2 = { event, javaPackage(event), 843 cons.getId() }; 844 super.map("COMPONENT_EVENT_WRAPPER", aliases, objs2); 845 } 846 847 return ""; 848 } 849 850 856 859 public java.lang.String 860 eventConsumerOpWrapper(org.objectweb.ccm.IDL3.EventDecl event) 861 { 862 org.objectweb.ccm.IDL3.InterfaceDecl itf = null; 863 org.objectweb.ccm.IDL3.Declaration[] ops = null; 864 itf = event.getClientMapping(); 865 ops = itf.getContents(false, org.objectweb.ccm.IDL3.DeclarationKind._dk_operation); 866 867 for (int i=0;i<ops.length;i++) 868 { 869 if (!ops[i].getName().equals("push_event")) 870 visitContainedWithMapping(event, ops[i], "_EVENT_CONSUMER_WRAPPER"); 871 } 872 873 return ""; 874 } 875 876 882 885 public java.lang.String 886 delegateOperations(org.objectweb.ccm.IDL3.Scope scope) 887 { 888 org.objectweb.ccm.IDL3.Declaration[] objs = null; 889 objs = scope.getContents(false, org.objectweb.ccm.IDL3.DeclarationKind._dk_operation + 890 org.objectweb.ccm.IDL3.DeclarationKind._dk_attribute); 891 892 for (int i=0;i<objs.length;i++) 893 { 894 if (objs[i].getDeclKind()==org.objectweb.ccm.IDL3.DeclarationKind._dk_attribute) 895 { 896 org.objectweb.ccm.IDL3.AttributeDecl attr = (org.objectweb.ccm.IDL3.AttributeDecl)objs[i]; 897 if (attr.isReadonly()) 898 visitContained(attr, "_READONLY_DELEGATE"); 899 else 900 visitContained(attr, "_DELEGATE"); 901 } 902 else 903 visitContained(objs[i], "_DELEGATE"); 904 } 905 906 return ""; 907 } 908 909 912 public java.lang.String 913 interceptorDelegateWrapper(org.objectweb.ccm.IDL3.Declaration obj, 914 java.lang.String name) 915 { 916 if (obj.getDeclKind()!=org.objectweb.ccm.IDL3.DeclarationKind._dk_consumes) 917 return name; 918 919 return "new "+name(obj)+"EventWrapper("+name+")"; 920 } 921 922 925 public java.lang.String 926 interceptorIState(org.objectweb.ccm.IDL3.Scope scope) 927 { 928 org.objectweb.ccm.IDL3.Declaration[] objs = null; 929 java.lang.String str = ""; 930 objs = scope.getContents(false, org.objectweb.ccm.IDL3.DeclarationKind._dk_operation + 931 org.objectweb.ccm.IDL3.DeclarationKind._dk_attribute); 932 933 for (int i=0;i<objs.length;i++) 934 { 935 if (objs[i].getDeclKind()==org.objectweb.ccm.IDL3.DeclarationKind._dk_attribute) 936 { 937 str = "private org.objectweb.openccm.Containers.CallCoordinator _cc_get_"+ 938 objs[i].getName()+" = null;\\n\\n"; 939 940 super.printImmediately(str); 941 942 org.objectweb.ccm.IDL3.AttributeDecl attr = (org.objectweb.ccm.IDL3.AttributeDecl)objs[i]; 943 if (!attr.isReadonly()) 944 { 945 str = "private org.objectweb.openccm.Containers.CallCoordinator _cc_set_"+ 946 objs[i].getName()+" = null;\\n\\n"; 947 super.printImmediately(str); 948 } 949 } 950 else 951 { 952 str = "private org.objectweb.openccm.Containers.CallCoordinator _cc_"+ 953 objs[i].getName()+" = null;\\n\\n"; 954 super.printImmediately(str); 955 } 956 957 } 958 959 return ""; 960 } 961 962 965 public java.lang.String 966 interceptorOperations(org.objectweb.ccm.IDL3.Scope scope) 967 { 968 org.objectweb.ccm.IDL3.Declaration[] objs = null; 969 objs = scope.getContents(false, org.objectweb.ccm.IDL3.DeclarationKind._dk_operation + 970 org.objectweb.ccm.IDL3.DeclarationKind._dk_attribute); 971 for (int i=0;i<objs.length;i++) 972 { 973 if (objs[i].getDeclKind()==org.objectweb.ccm.IDL3.DeclarationKind._dk_attribute) 974 { 975 org.objectweb.ccm.IDL3.AttributeDecl attr = (org.objectweb.ccm.IDL3.AttributeDecl)objs[i]; 976 if (attr.isReadonly()) 977 visitContained(attr, "_READONLY_INTERCEPTOR"); 978 else 979 visitContained(attr, "_INTERCEPTOR"); 980 } 981 else 982 visitContained(objs[i], "_INTERCEPTOR"); 983 } 984 985 return ""; 986 } 987 } 988 | Popular Tags |