1 7 22 23 package com.sun.corba.se.impl.naming.pcosnaming; 24 25 26 import org.omg.CORBA.Object ; 27 import org.omg.CORBA.SystemException ; 28 import org.omg.CORBA.BAD_PARAM ; 29 import org.omg.CORBA.CompletionStatus ; 30 import org.omg.CORBA.Policy ; 31 import org.omg.PortableServer.POA ; 32 import org.omg.PortableServer.LifespanPolicyValue ; 33 import org.omg.PortableServer.RequestProcessingPolicyValue ; 34 import org.omg.PortableServer.IdAssignmentPolicyValue ; 35 import org.omg.PortableServer.ServantRetentionPolicyValue ; 36 37 import org.omg.CosNaming.*; 38 import org.omg.CosNaming.NamingContextPackage.*; 39 import org.omg.CosNaming.NamingContextExtPackage.*; 40 41 import com.sun.corba.se.impl.naming.cosnaming.NamingContextDataStore; 42 import com.sun.corba.se.impl.naming.cosnaming.NamingUtils; 43 44 import com.sun.corba.se.impl.naming.namingutil.INSURLHandler; 45 46 import com.sun.corba.se.spi.orb.ORB; 47 import com.sun.corba.se.spi.logging.CORBALogDomains; 48 49 import com.sun.corba.se.impl.orbutil.ORBConstants; 50 import com.sun.corba.se.impl.logging.NamingSystemException; 51 52 import java.io.Serializable ; 53 import java.util.Hashtable ; 54 55 70 71 72 public class NamingContextImpl 73 extends NamingContextExtPOA 74 implements NamingContextDataStore, Serializable 75 { 76 77 private transient ORB orb; 80 81 private final String objKey; 84 85 private final Hashtable theHashtable = new Hashtable ( ); 91 92 private transient NameService theNameServiceHandle; 96 97 private transient ServantManagerImpl theServantManagerImplHandle; 100 101 private transient com.sun.corba.se.impl.naming.cosnaming.InterOperableNamingImpl insImpl; 104 105 private transient NamingSystemException readWrapper ; 106 107 private transient NamingSystemException updateWrapper ; 108 109 private static POA biPOA = null; 110 111 120 121 public NamingContextImpl(ORB orb, String objKey, 122 NameService theNameService, ServantManagerImpl theServantManagerImpl ) 123 throws Exception 124 { 125 super(); 126 127 this.orb = orb; 128 readWrapper = NamingSystemException.get( orb, 129 CORBALogDomains.NAMING_READ ) ; 130 updateWrapper = NamingSystemException.get( orb, 131 CORBALogDomains.NAMING_UPDATE ) ; 132 133 debug = true ; this.objKey = objKey; 135 theNameServiceHandle = theNameService; 136 theServantManagerImplHandle = theServantManagerImpl; 137 insImpl = 138 new com.sun.corba.se.impl.naming.cosnaming.InterOperableNamingImpl(); 139 } 140 141 com.sun.corba.se.impl.naming.cosnaming.InterOperableNamingImpl getINSImpl( ) 142 { 143 if( insImpl == null ) 144 { 145 insImpl = 148 new com.sun.corba.se.impl.naming.cosnaming.InterOperableNamingImpl(); 149 } 150 return insImpl; 151 } 152 153 154 public void setRootNameService( NameService theNameService ) { 155 theNameServiceHandle = theNameService; 156 } 157 158 public void setORB( ORB theOrb ) { 159 orb = theOrb; 160 } 161 162 public void setServantManagerImpl( 163 ServantManagerImpl theServantManagerImpl ) 164 { 165 theServantManagerImplHandle = theServantManagerImpl; 166 } 167 168 public POA getNSPOA( ) { 169 return theNameServiceHandle.getNSPOA( ); 170 } 171 172 173 174 175 198 public void bind(NameComponent[] n, org.omg.CORBA.Object obj) 199 throws org.omg.CosNaming.NamingContextPackage.NotFound , 200 org.omg.CosNaming.NamingContextPackage.CannotProceed , 201 org.omg.CosNaming.NamingContextPackage.InvalidName , 202 org.omg.CosNaming.NamingContextPackage.AlreadyBound 203 { 204 if( obj == null ) { 205 throw updateWrapper.objectIsNull() ; 206 } 207 208 if (debug) 209 dprint("bind " + nameToString(n) + " to " + obj); 210 NamingContextDataStore impl = (NamingContextDataStore)this; 212 doBind(impl,n,obj,false,BindingType.nobject); 213 } 214 215 236 public void bind_context(NameComponent[] n, NamingContext nc) 237 throws org.omg.CosNaming.NamingContextPackage.NotFound , 238 org.omg.CosNaming.NamingContextPackage.CannotProceed , 239 org.omg.CosNaming.NamingContextPackage.InvalidName , 240 org.omg.CosNaming.NamingContextPackage.AlreadyBound 241 { 242 if( nc == null ) { 243 throw updateWrapper.objectIsNull() ; 244 } 245 NamingContextDataStore impl = (NamingContextDataStore)this; 247 doBind(impl,n,nc,false,BindingType.ncontext); 248 } 249 250 271 public void rebind(NameComponent[] n, org.omg.CORBA.Object obj) 272 throws org.omg.CosNaming.NamingContextPackage.NotFound , 273 org.omg.CosNaming.NamingContextPackage.CannotProceed , 274 org.omg.CosNaming.NamingContextPackage.InvalidName 275 { 276 if( obj == null ) 277 { 278 throw updateWrapper.objectIsNull() ; 279 } 280 try { 281 if (debug) 282 dprint("rebind " + nameToString(n) + " to " + obj); 283 NamingContextDataStore impl = (NamingContextDataStore)this; 285 doBind(impl,n,obj,true,BindingType.nobject); 286 } catch (org.omg.CosNaming.NamingContextPackage.AlreadyBound ex) { 287 throw updateWrapper.namingCtxRebindAlreadyBound( ex ) ; 289 } 290 } 291 292 312 public void rebind_context(NameComponent[] n, NamingContext nc) 313 throws org.omg.CosNaming.NamingContextPackage.NotFound , 314 org.omg.CosNaming.NamingContextPackage.CannotProceed , 315 org.omg.CosNaming.NamingContextPackage.InvalidName 316 { 317 try { 318 if (debug) 319 dprint("rebind_context " + nameToString(n) + " to " + nc); 320 NamingContextDataStore impl = (NamingContextDataStore)this; 322 doBind(impl,n,nc,true,BindingType.ncontext); 323 } catch (org.omg.CosNaming.NamingContextPackage.AlreadyBound ex) { 324 throw updateWrapper.namingCtxRebindAlreadyBound( ex ) ; 326 } 327 } 328 329 348 public org.omg.CORBA.Object resolve(NameComponent[] n) 349 throws org.omg.CosNaming.NamingContextPackage.NotFound , 350 org.omg.CosNaming.NamingContextPackage.CannotProceed , 351 org.omg.CosNaming.NamingContextPackage.InvalidName 352 { 353 if (debug) 354 dprint("resolve " + nameToString(n)); 355 NamingContextDataStore impl = (NamingContextDataStore)this; 357 return doResolve(impl,n); 358 } 359 360 376 public void unbind(NameComponent[] n) 377 throws org.omg.CosNaming.NamingContextPackage.NotFound , 378 org.omg.CosNaming.NamingContextPackage.CannotProceed , 379 org.omg.CosNaming.NamingContextPackage.InvalidName 380 { 381 if (debug) 382 dprint("unbind " + nameToString(n)); 383 NamingContextDataStore impl = (NamingContextDataStore)this; 385 doUnbind(impl,n); 386 } 387 388 400 public void list(int how_many, BindingListHolder bl, BindingIteratorHolder bi) 401 { 402 if (debug) 403 dprint("list(" + how_many + ")"); 404 NamingContextDataStore impl = (NamingContextDataStore)this; 406 synchronized (impl) { 407 impl.List(how_many,bl,bi); 408 } 409 if (debug && bl.value != null) 410 dprint("list(" + how_many + ") -> bindings[" + bl.value.length + 411 "] + iterator: " + bi.value); 412 } 413 414 415 421 public synchronized NamingContext new_context() 422 { 423 if (debug) 425 dprint("new_context()"); 426 NamingContextDataStore impl = (NamingContextDataStore)this; 427 synchronized (impl) { 428 return impl.NewContext(); 429 } 430 } 431 432 433 454 public NamingContext bind_new_context(NameComponent[] n) 455 throws org.omg.CosNaming.NamingContextPackage.NotFound , 456 org.omg.CosNaming.NamingContextPackage.AlreadyBound , 457 org.omg.CosNaming.NamingContextPackage.CannotProceed , 458 org.omg.CosNaming.NamingContextPackage.InvalidName 459 { 460 NamingContext nc = null; 461 NamingContext rnc = null; 462 try { 463 if (debug) 464 dprint("bind_new_context " + nameToString(n)); 465 nc = this.new_context(); 467 this.bind_context(n,nc); 468 rnc = nc; 469 nc = null; 470 } finally { 471 try { 472 if(nc != null) 473 nc.destroy(); 474 } catch (org.omg.CosNaming.NamingContextPackage.NotEmpty e) { 475 } 476 } 477 return rnc; 478 } 479 480 487 public void destroy() 488 throws org.omg.CosNaming.NamingContextPackage.NotEmpty 489 { 490 if (debug) 491 dprint("destroy "); 492 NamingContextDataStore impl = (NamingContextDataStore)this; 493 synchronized (impl) { 494 if (impl.IsEmpty() == true) 495 impl.Destroy(); 497 else 498 throw new org.omg.CosNaming.NamingContextPackage.NotEmpty (); 500 } 501 } 502 503 536 private void doBind(NamingContextDataStore impl, 537 NameComponent[] n, 538 org.omg.CORBA.Object obj, 539 boolean rebind, 540 org.omg.CosNaming.BindingType bt) 541 throws org.omg.CosNaming.NamingContextPackage.NotFound , 542 org.omg.CosNaming.NamingContextPackage.CannotProceed , 543 org.omg.CosNaming.NamingContextPackage.InvalidName , 544 org.omg.CosNaming.NamingContextPackage.AlreadyBound 545 { 546 if (n.length < 1) 548 throw new org.omg.CosNaming.NamingContextPackage.InvalidName (); 549 550 if (n.length == 1) { 552 if( (n[0].id.length() == 0) && (n[0].kind.length() == 0) ) 554 throw new org.omg.CosNaming.NamingContextPackage.InvalidName (); 555 556 synchronized (impl) { 558 BindingTypeHolder bth = new BindingTypeHolder(); 560 if (rebind) { 561 org.omg.CORBA.Object objRef = impl.Resolve( n[0], bth ); 562 if( objRef != null ) { 563 if ( bth.value.value() == BindingType.nobject.value() ) { 570 if ( bt.value() == BindingType.ncontext.value() ) { 571 throw new NotFound(NotFoundReason.not_context, n); 572 } 573 } else { 574 if ( bt.value() == BindingType.nobject.value() ) { 577 throw new NotFound(NotFoundReason.not_object, n); 578 } 579 } 580 impl.Unbind(n[0]); 581 } 582 } else { 583 if (impl.Resolve(n[0],bth) != null) 584 throw new org.omg.CosNaming.NamingContextPackage.AlreadyBound (); 585 } 586 587 impl.Bind(n[0],obj,bt); 589 } 590 } else { 591 NamingContext context = resolveFirstAsContext(impl,n); 593 594 NameComponent[] tail = new NameComponent[n.length - 1]; 596 System.arraycopy(n,1,tail,0,n.length-1); 597 598 switch (bt.value()) { 600 case BindingType._nobject: 601 { 602 if (rebind) 604 context.rebind(tail,obj); 605 else 606 context.bind(tail,obj); 607 } 608 break; 609 case BindingType._ncontext: 610 { 611 NamingContext objContext = (NamingContext)obj; 613 if (rebind) 615 context.rebind_context(tail,objContext); 616 else 617 context.bind_context(tail,objContext); 618 } 619 break; 620 default: 621 throw updateWrapper.namingCtxBadBindingtype() ; 623 } 624 } 625 } 626 627 628 651 public static org.omg.CORBA.Object doResolve(NamingContextDataStore impl, 652 NameComponent[] n) 653 throws org.omg.CosNaming.NamingContextPackage.NotFound , 654 org.omg.CosNaming.NamingContextPackage.CannotProceed , 655 org.omg.CosNaming.NamingContextPackage.InvalidName 656 { 657 org.omg.CORBA.Object obj = null; 658 BindingTypeHolder bth = new BindingTypeHolder(); 659 660 if (n.length < 1) 662 throw new org.omg.CosNaming.NamingContextPackage.InvalidName (); 663 664 if (n.length == 1) { 666 synchronized (impl) { 667 obj = impl.Resolve(n[0],bth); 669 } 670 if (obj == null) { 671 throw new org.omg.CosNaming.NamingContextPackage.NotFound (NotFoundReason.missing_node,n); 673 } 674 return obj; 675 } else { 676 if ( (n[1].id.length() == 0) && (n[1].kind.length() == 0 ) ) 678 throw new org.omg.CosNaming.NamingContextPackage.InvalidName (); 679 680 NamingContext context = resolveFirstAsContext(impl,n); 681 682 NameComponent[] tail = new NameComponent[n.length -1]; 684 System.arraycopy(n,1,tail,0,n.length-1); 685 686 return context.resolve(tail); 688 } 689 } 690 691 711 public static void doUnbind(NamingContextDataStore impl, 712 NameComponent[] n) 713 throws org.omg.CosNaming.NamingContextPackage.NotFound , 714 org.omg.CosNaming.NamingContextPackage.CannotProceed , 715 org.omg.CosNaming.NamingContextPackage.InvalidName 716 { 717 if (n.length < 1) 719 throw new org.omg.CosNaming.NamingContextPackage.InvalidName (); 720 721 if (n.length == 1) { 723 if ( (n[0].id.length() == 0) && (n[0].kind.length() == 0 ) ) 725 throw new org.omg.CosNaming.NamingContextPackage.InvalidName (); 726 727 org.omg.CORBA.Object objRef = null; 728 synchronized (impl) { 729 objRef = impl.Unbind(n[0]); 731 } 732 733 if (objRef == null) 734 throw new org.omg.CosNaming.NamingContextPackage.NotFound (NotFoundReason.missing_node,n); 736 return; 738 } else { 739 741 NamingContext context = resolveFirstAsContext(impl,n); 743 744 NameComponent[] tail = new NameComponent[n.length - 1]; 746 System.arraycopy(n,1,tail,0,n.length-1); 747 748 context.unbind(tail); 750 } 751 } 752 753 766 protected static NamingContext resolveFirstAsContext(NamingContextDataStore impl, 767 NameComponent[] n) 768 throws org.omg.CosNaming.NamingContextPackage.NotFound { 769 org.omg.CORBA.Object topRef = null; 770 BindingTypeHolder bth = new BindingTypeHolder(); 771 NamingContext context = null; 772 773 synchronized (impl) { 774 topRef = impl.Resolve(n[0],bth); 776 if (topRef == null) { 777 throw new org.omg.CosNaming.NamingContextPackage.NotFound (NotFoundReason.missing_node,n); 779 } 780 } 781 782 if (bth.value != BindingType.ncontext) { 784 throw new org.omg.CosNaming.NamingContextPackage.NotFound (NotFoundReason.not_context,n); 786 } 787 788 try { 790 context = NamingContextHelper.narrow(topRef); 791 } catch (org.omg.CORBA.BAD_PARAM ex) { 792 throw new org.omg.CosNaming.NamingContextPackage.NotFound (NotFoundReason.not_context,n); 794 } 795 796 return context; 798 } 799 800 public static String nameToString(NameComponent[] name) 801 { 802 StringBuffer s = new StringBuffer ("{"); 803 if (name != null || name.length > 0) { 804 for (int i=0;i<name.length;i++) { 805 if (i>0) 806 s.append(","); 807 s.append("["). 808 append(name[i].id). 809 append(","). 810 append(name[i].kind). 811 append("]"); 812 } 813 } 814 s.append("}"); 815 return s.toString(); 816 } 817 818 private static boolean debug ; 820 821 private static void dprint(String msg) { 822 NamingUtils.dprint("NamingContextImpl(" + 823 Thread.currentThread().getName() + " at " + 824 System.currentTimeMillis() + 825 " ems): " + msg); 826 } 827 828 829 852 public void Bind(NameComponent n, org.omg.CORBA.Object obj, BindingType bt) 853 { 854 if( obj == null ) { 855 return; 857 } 858 859 InternalBindingKey key = new InternalBindingKey(n); 860 InternalBindingValue value; 861 862 try { 863 if( bt.value() == BindingType._nobject ) { 864 value = new InternalBindingValue(bt, orb.object_to_string(obj) ); 868 value.setObjectRef( obj ); 869 } else { 870 String theNCKey = theNameServiceHandle.getObjectKey( obj ); 873 value = new InternalBindingValue( bt, theNCKey ); 874 value.setObjectRef( obj ); 875 } 876 877 InternalBindingValue oldValue = 878 (InternalBindingValue)this.theHashtable.put(key,value); 879 880 if( oldValue != null) { 881 throw updateWrapper.namingCtxRebindAlreadyBound() ; 884 } else { 885 try { 886 theServantManagerImplHandle.updateContext( objKey, this ); 889 } catch( Exception e ) { 890 throw updateWrapper.bindUpdateContextFailed( e ) ; 893 } 894 } 895 } catch( Exception e ) { 896 throw updateWrapper.bindFailure( e ) ; 899 } 900 } 901 902 918 public Object Resolve(NameComponent n, BindingTypeHolder bth) 919 throws SystemException 920 { 921 if( ( n.id.length() == 0 ) &&( n.kind.length() == 0 ) ) { 922 bth.value = BindingType.ncontext; 925 return theNameServiceHandle.getObjectReferenceFromKey( 926 this.objKey ); 927 } 928 929 InternalBindingKey key = new InternalBindingKey(n); 930 InternalBindingValue value = 931 (InternalBindingValue) this.theHashtable.get(key); 932 933 if( value == null ) { 934 return null; 938 } 939 940 Object theObjectFromStringifiedReference = null; 941 bth.value = value.theBindingType; 942 943 try { 944 if( value.strObjectRef.startsWith( "NC" ) ) { 949 bth.value = BindingType.ncontext; 950 return theNameServiceHandle.getObjectReferenceFromKey( value.strObjectRef ); 951 } else { 952 theObjectFromStringifiedReference = value.getObjectRef( ); 956 957 if (theObjectFromStringifiedReference == null ) { 958 try { 959 theObjectFromStringifiedReference = 960 orb.string_to_object( value.strObjectRef ); 961 value.setObjectRef( theObjectFromStringifiedReference ); 962 } catch( Exception e ) { 963 throw readWrapper.resolveConversionFailure( 964 CompletionStatus.COMPLETED_MAYBE, e ); 965 } 966 } 967 } 968 } catch ( Exception e ) { 969 throw readWrapper.resolveFailure( 970 CompletionStatus.COMPLETED_MAYBE, e ); 971 } 972 973 return theObjectFromStringifiedReference; 974 } 975 976 991 992 public Object Unbind(NameComponent n) throws SystemException 993 { 994 try { 995 InternalBindingKey key = new InternalBindingKey(n); 996 InternalBindingValue value = null; 997 998 try { 999 value = (InternalBindingValue) this.theHashtable.remove(key); 1000 } catch( Exception e ) { 1001 } 1003 1004 theServantManagerImplHandle.updateContext( objKey, this ); 1005 1006 if( value == null ) { 1007 return null; 1008 } 1009 1010 if( value.strObjectRef.startsWith( "NC" ) ) { 1011 theServantManagerImplHandle.readInContext( value.strObjectRef ); 1012 Object theObjectFromStringfiedReference = 1013 theNameServiceHandle.getObjectReferenceFromKey( value.strObjectRef ); 1014 return theObjectFromStringfiedReference; 1015 } else { 1016 Object theObjectFromStringifiedReference = value.getObjectRef( ); 1017 1018 if( theObjectFromStringifiedReference == null ) { 1019 theObjectFromStringifiedReference = 1020 orb.string_to_object( value.strObjectRef ); 1021 } 1022 1023 return theObjectFromStringifiedReference; 1024 } 1025 } catch( Exception e ) { 1026 throw updateWrapper.unbindFailure( CompletionStatus.COMPLETED_MAYBE, e ); 1027 } 1028 } 1029 1030 1040 1041 public void List(int how_many, BindingListHolder bl, 1042 BindingIteratorHolder bi) throws SystemException 1043 { 1044 if( biPOA == null ) { 1045 createbiPOA( ); 1046 } 1047 try { 1048 PersistentBindingIterator bindingIterator = 1049 new PersistentBindingIterator(this.orb, 1050 (Hashtable )this.theHashtable.clone(), biPOA); 1051 bindingIterator.list(how_many,bl); 1053 1054 byte[] objectId = biPOA.activate_object( bindingIterator ); 1055 org.omg.CORBA.Object obj = biPOA.id_to_reference( objectId ); 1056 1057 org.omg.CosNaming.BindingIterator bindingRef = 1059 org.omg.CosNaming.BindingIteratorHelper.narrow( obj ); 1060 1061 bi.value = bindingRef; 1062 } catch (org.omg.CORBA.SystemException e) { 1063 throw e; 1064 } catch( Exception e ) { 1065 throw readWrapper.transNcListGotExc( e ) ; 1066 } 1067 } 1068 1069 private synchronized void createbiPOA( ) { 1070 if( biPOA != null ) { 1071 return; 1072 } 1073 try { 1074 POA rootPOA = (POA ) orb.resolve_initial_references( 1075 ORBConstants.ROOT_POA_NAME ); 1076 rootPOA.the_POAManager().activate( ); 1077 1078 int i = 0; 1079 Policy [] poaPolicy = new Policy [3]; 1080 poaPolicy[i++] = rootPOA.create_lifespan_policy( 1081 LifespanPolicyValue.TRANSIENT); 1082 poaPolicy[i++] = rootPOA.create_id_assignment_policy( 1083 IdAssignmentPolicyValue.SYSTEM_ID); 1084 poaPolicy[i++] = rootPOA.create_servant_retention_policy( 1085 ServantRetentionPolicyValue.RETAIN); 1086 biPOA = rootPOA.create_POA("BindingIteratorPOA", null, poaPolicy ); 1087 biPOA.the_POAManager().activate( ); 1088 } catch( Exception e ) { 1089 throw readWrapper.namingCtxBindingIteratorCreate( e ) ; 1090 } 1091 } 1092 1093 1094 1100 public NamingContext NewContext() throws SystemException 1101 { 1102 try { 1103 return theNameServiceHandle.NewContext( ); 1104 } catch( org.omg.CORBA.SystemException e ) { 1105 throw e; 1106 } catch( Exception e ) { 1107 throw updateWrapper.transNcNewctxGotExc( e ) ; 1108 } 1109 } 1110 1111 1112 1115 public void Destroy() throws SystemException 1116 { 1117 1135 } 1136 1137 1145 public String to_string(org.omg.CosNaming.NameComponent [] n) 1146 throws org.omg.CosNaming.NamingContextPackage.InvalidName 1147 { 1148 if ( (n == null ) || (n.length == 0) ) 1150 { 1151 throw new org.omg.CosNaming.NamingContextPackage.InvalidName (); 1152 } 1153 1154 String theStringifiedName = getINSImpl().convertToString( n ); 1155 1156 if( theStringifiedName == null ) 1157 { 1158 throw new org.omg.CosNaming.NamingContextPackage.InvalidName (); 1159 } 1160 1161 return theStringifiedName; 1162 } 1163 1164 1172 public org.omg.CosNaming.NameComponent [] to_name(String sn) 1173 throws org.omg.CosNaming.NamingContextPackage.InvalidName 1174 { 1175 if ( (sn == null ) || (sn.length() == 0) ) 1177 { 1178 throw new org.omg.CosNaming.NamingContextPackage.InvalidName (); 1179 } 1180 org.omg.CosNaming.NameComponent [] theNameComponents = 1181 getINSImpl().convertToNameComponent( sn ); 1182 if( ( theNameComponents == null ) || (theNameComponents.length == 0 ) ) 1183 { 1184 throw new org.omg.CosNaming.NamingContextPackage.InvalidName (); 1185 } 1186 for( int i = 0; i < theNameComponents.length; i++ ) { 1187 if ( ( ( theNameComponents[i].id == null ) 1191 ||( theNameComponents[i].id.length() == 0 ) ) 1192 &&( ( theNameComponents[i].kind == null ) 1193 ||( theNameComponents[i].kind.length() == 0 ) ) ) { 1194 throw new InvalidName(); 1195 } 1196 } 1197 return theNameComponents; 1198 } 1199 1200 1213 1214 public String to_url(String addr, String sn) 1215 throws org.omg.CosNaming.NamingContextExtPackage.InvalidAddress , 1216 org.omg.CosNaming.NamingContextPackage.InvalidName 1217 { 1218 if ( (sn == null ) || (sn.length() == 0) ) 1220 { 1221 throw new org.omg.CosNaming.NamingContextPackage.InvalidName (); 1222 } 1223 if( addr == null ) 1224 { 1225 throw new org.omg.CosNaming.NamingContextExtPackage.InvalidAddress (); 1226 } 1227 String urlBasedAddress = null; 1228 try { 1229 urlBasedAddress = getINSImpl().createURLBasedAddress( addr, sn ); 1230 } catch (Exception e ) { 1231 urlBasedAddress = null; 1232 } 1233 try { 1236 INSURLHandler.getINSURLHandler().parseURL( urlBasedAddress ); 1237 } catch( BAD_PARAM e ) { 1238 throw new 1239 org.omg.CosNaming.NamingContextExtPackage.InvalidAddress (); 1240 } 1241 return urlBasedAddress; 1242 } 1243 1244 1256 public org.omg.CORBA.Object resolve_str(String sn) 1257 throws org.omg.CosNaming.NamingContextPackage.NotFound , 1258 org.omg.CosNaming.NamingContextPackage.CannotProceed , 1259 org.omg.CosNaming.NamingContextPackage.InvalidName 1260 { 1261 org.omg.CORBA.Object theObject = null; 1262 if ( (sn == null ) || (sn.length() == 0) ) 1264 { 1265 throw new org.omg.CosNaming.NamingContextPackage.InvalidName (); 1266 } 1267 org.omg.CosNaming.NameComponent [] theNameComponents = 1268 getINSImpl().convertToNameComponent( sn ); 1269 if( ( theNameComponents == null ) || (theNameComponents.length == 0 ) ) 1270 { 1271 throw new org.omg.CosNaming.NamingContextPackage.InvalidName (); 1272 } 1273 theObject = resolve( theNameComponents ); 1274 return theObject; 1275 } 1276 1277 1280 public boolean IsEmpty() 1281 { 1282 return this.theHashtable.isEmpty(); 1283 } 1284 1285 1288 public void printSize( ) 1289 { 1290 System.out.println( "Hashtable Size = " + theHashtable.size( ) ); 1291 java.util.Enumeration e = theHashtable.keys( ); 1292 for( ; e.hasMoreElements(); ) 1293 { 1294 InternalBindingValue thevalue = 1295 (InternalBindingValue) this.theHashtable.get(e.nextElement()); 1296 if( thevalue != null ) 1297 { 1298 System.out.println( "value = " + thevalue.strObjectRef); 1299 } 1300 } 1301 } 1302 1303} 1304 | Popular Tags |