< prev index next >

src/java.corba/share/classes/com/sun/corba/se/impl/naming/pcosnaming/NamingContextImpl.java

Print this page




1123         // look into further at another time.
1124         /*
1125         // XXX This needs to be replaced by cleaning up the
1126         // file that backs up the naming context.  No explicit
1127         // action is necessary at the POA level, since this is
1128         // created with the non-retain policy.
1129         /*
1130         try { orb.disconnect(
1131             theNameServiceHandle.getObjectReferenceFromKey( this.objKey ) );
1132         } catch( org.omg.CORBA.SystemException e ) {
1133             throw e;
1134         } catch( Exception e ) {
1135             throw updateWrapper.transNcDestroyGotEx( e ) ;
1136         }
1137         */
1138     }
1139 
1140     /**
1141     * This operation creates a stringified name from the array of Name
1142     * components.
1143     * @param n Name of the object <p>
1144     * @exception org.omg.CosNaming.NamingContextExtPackage.InvalidName
1145     * Indicates the name does not identify a binding.<p>
1146     *
1147     */
1148     public String to_string(org.omg.CosNaming.NameComponent[] n)
1149          throws org.omg.CosNaming.NamingContextPackage.InvalidName
1150     {
1151         // Name valid?
1152         if ( (n == null ) || (n.length == 0) )
1153         {
1154                 throw new org.omg.CosNaming.NamingContextPackage.InvalidName();
1155         }
1156 
1157         String theStringifiedName = getINSImpl().convertToString( n );
1158 
1159         if( theStringifiedName == null )
1160         {
1161                 throw new org.omg.CosNaming.NamingContextPackage.InvalidName();
1162         }
1163 
1164         return theStringifiedName;
1165     }
1166 
1167     /**
1168     * This operation  converts a Stringified Name into an  equivalent array
1169     * of Name Components.
1170     * @param sn Stringified Name of the object <p>
1171     * @exception org.omg.CosNaming.NamingContextExtPackage.InvalidName
1172     * Indicates the name does not identify a binding.<p>
1173     *
1174     */
1175     public org.omg.CosNaming.NameComponent[] to_name(String sn)
1176          throws org.omg.CosNaming.NamingContextPackage.InvalidName
1177     {
1178         // Name valid?
1179         if  ( (sn == null ) || (sn.length() == 0) )
1180         {
1181                 throw new org.omg.CosNaming.NamingContextPackage.InvalidName();
1182         }
1183         org.omg.CosNaming.NameComponent[] theNameComponents =
1184                 getINSImpl().convertToNameComponent( sn );
1185         if( ( theNameComponents == null ) || (theNameComponents.length == 0 ) )
1186         {
1187                 throw new org.omg.CosNaming.NamingContextPackage.InvalidName();
1188         }
1189         for( int i = 0; i < theNameComponents.length; i++ ) {
1190             // If there is a name component whose id and kind null or
1191             // zero length string, then an invalid name exception needs to be
1192             // raised.
1193             if ( ( ( theNameComponents[i].id  == null )
1194                  ||( theNameComponents[i].id.length() == 0 ) )
1195                &&( ( theNameComponents[i].kind == null )
1196                  ||( theNameComponents[i].kind.length() == 0 ) ) ) {
1197                 throw new InvalidName();
1198             }
1199         }
1200         return theNameComponents;
1201     }
1202 
1203     /**
1204     * This operation creates a URL based "iiopname://" format name
1205     * from the Stringified Name of the object.
1206     * @param addr internet based address of the host machine where
1207     * Name Service is running <p>
1208     * @param sn Stringified Name of the object <p>
1209     * @exception org.omg.CosNaming.NamingContextExtPackage.InvalidName
1210     * Indicates the name does not identify a binding.<p>
1211     * @exception org.omg.CosNaming.NamingContextPackage.InvalidAddress
1212     * Indicates the internet based address of the host machine is
1213     * incorrect <p>
1214     *
1215     */
1216 
1217     public String to_url(String addr, String sn)
1218         throws org.omg.CosNaming.NamingContextExtPackage.InvalidAddress,
1219                org.omg.CosNaming.NamingContextPackage.InvalidName
1220     {
1221         // Name valid?
1222         if  ( (sn == null ) || (sn.length() == 0) )
1223         {
1224                 throw new org.omg.CosNaming.NamingContextPackage.InvalidName();
1225         }
1226         if( addr == null )
1227         {
1228                 throw new org.omg.CosNaming.NamingContextExtPackage.InvalidAddress();
1229         }
1230         String urlBasedAddress = null;
1231         try {
1232             urlBasedAddress = getINSImpl().createURLBasedAddress( addr, sn );
1233         } catch (Exception e ) {
1234             urlBasedAddress = null;
1235         }
1236         // Extra check to see that corba name url created is valid as per
1237         // INS spec grammer.
1238         try {
1239             INSURLHandler.getINSURLHandler().parseURL( urlBasedAddress );
1240         } catch( BAD_PARAM e ) {
1241             throw new
1242                 org.omg.CosNaming.NamingContextExtPackage.InvalidAddress();
1243         }
1244         return urlBasedAddress;
1245     }
1246 
1247     /**
1248      * This operation resolves the Stringified name into the object
1249      * reference.
1250      * @param sn Stringified Name of the object <p>
1251      * @exception org.omg.CosNaming.NamingContextPackage.NotFound
1252      * Indicates there is no object reference for the given name. <p>
1253      * @exception org.omg.CosNaming.NamingContextPackage.CannotProceed
1254      * Indicates that the given compound name is incorrect <p>
1255      * @exception org.omg.CosNaming.NamingContextExtPackage.InvalidName
1256      * Indicates the name does not identify a binding.<p>
1257      *
1258      */
1259     public org.omg.CORBA.Object resolve_str(String sn)
1260         throws org.omg.CosNaming.NamingContextPackage.NotFound,
1261                org.omg.CosNaming.NamingContextPackage.CannotProceed,
1262                org.omg.CosNaming.NamingContextPackage.InvalidName
1263     {
1264         org.omg.CORBA.Object theObject = null;
1265         // Name valid?
1266         if  ( (sn == null ) || (sn.length() == 0) )
1267         {
1268                 throw new org.omg.CosNaming.NamingContextPackage.InvalidName();
1269         }
1270         org.omg.CosNaming.NameComponent[] theNameComponents =
1271                 getINSImpl().convertToNameComponent( sn );
1272         if( ( theNameComponents == null ) || (theNameComponents.length == 0 ) )
1273         {
1274                 throw new org.omg.CosNaming.NamingContextPackage.InvalidName();
1275         }
1276         theObject = resolve( theNameComponents );
1277         return theObject;




1123         // look into further at another time.
1124         /*
1125         // XXX This needs to be replaced by cleaning up the
1126         // file that backs up the naming context.  No explicit
1127         // action is necessary at the POA level, since this is
1128         // created with the non-retain policy.
1129         /*
1130         try { orb.disconnect(
1131             theNameServiceHandle.getObjectReferenceFromKey( this.objKey ) );
1132         } catch( org.omg.CORBA.SystemException e ) {
1133             throw e;
1134         } catch( Exception e ) {
1135             throw updateWrapper.transNcDestroyGotEx( e ) ;
1136         }
1137         */
1138     }
1139 
1140     /**
1141     * This operation creates a stringified name from the array of Name
1142     * components.
1143     * @param n Name of the object
1144     * @exception org.omg.CosNaming.NamingContextExtPackage.InvalidName
1145     * Indicates the name does not identify a binding.

1146     */
1147     public String to_string(org.omg.CosNaming.NameComponent[] n)
1148          throws org.omg.CosNaming.NamingContextPackage.InvalidName
1149     {
1150         // Name valid?
1151         if ( (n == null ) || (n.length == 0) )
1152         {
1153                 throw new org.omg.CosNaming.NamingContextPackage.InvalidName();
1154         }
1155 
1156         String theStringifiedName = getINSImpl().convertToString( n );
1157 
1158         if( theStringifiedName == null )
1159         {
1160                 throw new org.omg.CosNaming.NamingContextPackage.InvalidName();
1161         }
1162 
1163         return theStringifiedName;
1164     }
1165 
1166     /**
1167     * This operation  converts a Stringified Name into an  equivalent array
1168     * of Name Components.
1169     * @param sn Stringified Name of the object
1170     * @exception org.omg.CosNaming.NamingContextExtPackage.InvalidName
1171     * Indicates the name does not identify a binding.

1172     */
1173     public org.omg.CosNaming.NameComponent[] to_name(String sn)
1174          throws org.omg.CosNaming.NamingContextPackage.InvalidName
1175     {
1176         // Name valid?
1177         if  ( (sn == null ) || (sn.length() == 0) )
1178         {
1179                 throw new org.omg.CosNaming.NamingContextPackage.InvalidName();
1180         }
1181         org.omg.CosNaming.NameComponent[] theNameComponents =
1182                 getINSImpl().convertToNameComponent( sn );
1183         if( ( theNameComponents == null ) || (theNameComponents.length == 0 ) )
1184         {
1185                 throw new org.omg.CosNaming.NamingContextPackage.InvalidName();
1186         }
1187         for( int i = 0; i < theNameComponents.length; i++ ) {
1188             // If there is a name component whose id and kind null or
1189             // zero length string, then an invalid name exception needs to be
1190             // raised.
1191             if ( ( ( theNameComponents[i].id  == null )
1192                  ||( theNameComponents[i].id.length() == 0 ) )
1193                &&( ( theNameComponents[i].kind == null )
1194                  ||( theNameComponents[i].kind.length() == 0 ) ) ) {
1195                 throw new InvalidName();
1196             }
1197         }
1198         return theNameComponents;
1199     }
1200 
1201     /**
1202     * This operation creates a URL based "iiopname://" format name
1203     * from the Stringified Name of the object.
1204     * @param addr internet based address of the host machine where
1205     *        Name Service is running
1206     * @param sn Stringified Name of the object
1207     * @exception org.omg.CosNaming.NamingContextExtPackage.InvalidName
1208     * Indicates the name does not identify a binding.
1209     * @exception org.omg.CosNaming.NamingContextPackage.InvalidAddress
1210     * Indicates the internet based address of the host machine is
1211     * incorrect

1212     */
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         // Name valid?
1219         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         // Extra check to see that corba name url created is valid as per
1234         // INS spec grammer.
1235         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     /**
1245      * This operation resolves the Stringified name into the object
1246      * reference.
1247      * @param sn Stringified Name of the object
1248      * @exception org.omg.CosNaming.NamingContextPackage.NotFound
1249      * Indicates there is no object reference for the given name.
1250      * @exception org.omg.CosNaming.NamingContextPackage.CannotProceed
1251      * Indicates that the given compound name is incorrect
1252      * @exception org.omg.CosNaming.NamingContextExtPackage.InvalidName
1253      * Indicates the name does not identify a binding.

1254      */
1255     public org.omg.CORBA.Object resolve_str(String sn)
1256         throws org.omg.CosNaming.NamingContextPackage.NotFound,
1257                org.omg.CosNaming.NamingContextPackage.CannotProceed,
1258                org.omg.CosNaming.NamingContextPackage.InvalidName
1259     {
1260         org.omg.CORBA.Object theObject = null;
1261         // Name valid?
1262         if  ( (sn == null ) || (sn.length() == 0) )
1263         {
1264                 throw new org.omg.CosNaming.NamingContextPackage.InvalidName();
1265         }
1266         org.omg.CosNaming.NameComponent[] theNameComponents =
1267                 getINSImpl().convertToNameComponent( sn );
1268         if( ( theNameComponents == null ) || (theNameComponents.length == 0 ) )
1269         {
1270                 throw new org.omg.CosNaming.NamingContextPackage.InvalidName();
1271         }
1272         theObject = resolve( theNameComponents );
1273         return theObject;


< prev index next >