⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 namingcontextimpl.java

📁 java1.6众多例子参考
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
   * Unbind using compound Names.   * @param n a sequence of NameComponents which is the name to be resolved.   * @return the object reference bound under the supplied name.   * @exception org.omg.CosNaming.NamingContextPackage.NotFound Neither a NamingContext   * or a Corba Object reference not found under this Name   * @exception org.omg.CosNaming.NamingContextPackage.CannotProceed Could not proceed   * in resolving the the supplied name.   * @exception org.omg.CosNaming.NamingContextPackage.InvalidName The supplied name   * is invalid (i.e., has length less than 1).   * @exception org.omg.CORBA.SystemException One of a fixed set of CORBA system exceptions.   * @see Bind   */    public Object Unbind(NameComponent n) throws SystemException    {	try {	    InternalBindingKey key = new InternalBindingKey(n);	    InternalBindingValue value = null;	    try {		value = (InternalBindingValue) this.theHashtable.remove(key);	    } catch( Exception e ) {		// Ignore the exception in Hashtable.remove	    }	    theServantManagerImplHandle.updateContext( objKey, this );	    if( value == null ) {		return null;	    }	    if( value.strObjectRef.startsWith( "NC" ) ) {		theServantManagerImplHandle.readInContext( value.strObjectRef );		Object theObjectFromStringfiedReference = 		theNameServiceHandle.getObjectReferenceFromKey( value.strObjectRef );		return theObjectFromStringfiedReference;	    } else {		Object theObjectFromStringifiedReference = value.getObjectRef( );		if( theObjectFromStringifiedReference == null ) { 		    theObjectFromStringifiedReference =		    orb.string_to_object( value.strObjectRef );  			}		return theObjectFromStringifiedReference;	    }	} catch( Exception e ) {	    throw updateWrapper.unbindFailure( CompletionStatus.COMPLETED_MAYBE, e );	}     }   /**   * List the contents of this NamingContext. It creates a new   * PersistentBindingIterator object and passes it a clone of the   * hash table and an orb object. It then uses the   * newly created object to return the required number of bindings.   * @param how_many The number of requested bindings in the BindingList.   * @param bl The BindingList as an out parameter.   * @param bi The BindingIterator as an out parameter.   * @exception org.omg.CORBA.SystemException One of a fixed set of CORBA system exceptions.   */    public void List(int how_many, BindingListHolder bl, 		     BindingIteratorHolder bi) throws SystemException    {        if( biPOA == null ) {            createbiPOA( );        }        try {            PersistentBindingIterator bindingIterator =                new PersistentBindingIterator(this.orb,                (Hashtable)this.theHashtable.clone(), biPOA);            // Have it set the binding list            bindingIterator.list(how_many,bl);            byte[] objectId = biPOA.activate_object( bindingIterator );            org.omg.CORBA.Object obj = biPOA.id_to_reference( objectId );            // Get the object reference for the binding iterator servant            org.omg.CosNaming.BindingIterator bindingRef =                org.omg.CosNaming.BindingIteratorHelper.narrow( obj );            bi.value = bindingRef;        } catch (org.omg.CORBA.SystemException e) {            throw e;        } catch( Exception e ) {	    throw readWrapper.transNcListGotExc( e ) ;        }    }    private synchronized void createbiPOA( ) {        if( biPOA != null ) {            return;        }        try {            POA rootPOA = (POA) orb.resolve_initial_references(		ORBConstants.ROOT_POA_NAME );            rootPOA.the_POAManager().activate( );            int i = 0;            Policy[] poaPolicy = new Policy[3];            poaPolicy[i++] = rootPOA.create_lifespan_policy(                LifespanPolicyValue.TRANSIENT);            poaPolicy[i++] = rootPOA.create_id_assignment_policy(                IdAssignmentPolicyValue.SYSTEM_ID);            poaPolicy[i++] = rootPOA.create_servant_retention_policy(                ServantRetentionPolicyValue.RETAIN);            biPOA = rootPOA.create_POA("BindingIteratorPOA", null, poaPolicy );            biPOA.the_POAManager().activate( );        } catch( Exception e ) {	    throw readWrapper.namingCtxBindingIteratorCreate( e ) ;        }    }   /**   * Create a NamingContext object and return its object reference.   * @return an object reference for a new NamingContext object implemented   * by this Name Server.   * @exception org.omg.CORBA.SystemException One of a fixed set of CORBA system exceptions.   */    public NamingContext NewContext() throws SystemException    {	try {	    return  theNameServiceHandle.NewContext( );	} catch( org.omg.CORBA.SystemException e ) {	    throw e;	} catch( Exception e ) {	    throw updateWrapper.transNcNewctxGotExc( e ) ;	}     }   /**   * Destroys the NamingContext.   */    public void Destroy() throws SystemException    {	// XXX note that orb.disconnect is illegal here, since the	// POA is used.  However, there may be some associated state	// that needs to be cleaned up in ServerManagerImpl which we will	// look into further at another time.	/*	// XXX This needs to be replaced by cleaning up the	// file that backs up the naming context.  No explicit	// action is necessary at the POA level, since this is	// created with the non-retain policy.	/*	try { orb.disconnect(	    theNameServiceHandle.getObjectReferenceFromKey( this.objKey ) );	} catch( org.omg.CORBA.SystemException e ) {	    throw e;	} catch( Exception e ) {	    throw updateWrapper.transNcDestroyGotEx( e ) ;	}	*/    }    /**    * This operation creates a stringified name from the array of Name    * components.    * @param n Name of the object <p>    * @exception org.omg.CosNaming.NamingContextExtPackage.InvalidName    * Indicates the name does not identify a binding.<p>    *    */    public String to_string(org.omg.CosNaming.NameComponent[] n)         throws org.omg.CosNaming.NamingContextPackage.InvalidName    {        // Name valid?        if ( (n == null ) || (n.length == 0) )        {                throw new org.omg.CosNaming.NamingContextPackage.InvalidName();        }        String theStringifiedName = getINSImpl().convertToString( n );        if( theStringifiedName == null )        {                throw new org.omg.CosNaming.NamingContextPackage.InvalidName();        }        return theStringifiedName;    }    /**    * This operation  converts a Stringified Name into an  equivalent array    * of Name Components.    * @param sn Stringified Name of the object <p>    * @exception org.omg.CosNaming.NamingContextExtPackage.InvalidName    * Indicates the name does not identify a binding.<p>    *    */    public org.omg.CosNaming.NameComponent[] to_name(String sn)         throws org.omg.CosNaming.NamingContextPackage.InvalidName    {        // Name valid?        if  ( (sn == null ) || (sn.length() == 0) )        {                throw new org.omg.CosNaming.NamingContextPackage.InvalidName();        }        org.omg.CosNaming.NameComponent[] theNameComponents =                getINSImpl().convertToNameComponent( sn );        if( ( theNameComponents == null ) || (theNameComponents.length == 0 ) )        {                throw new org.omg.CosNaming.NamingContextPackage.InvalidName();        }        for( int i = 0; i < theNameComponents.length; i++ ) {            // If there is a name component whose id and kind null or            // zero length string, then an invalid name exception needs to be            // raised.            if ( ( ( theNameComponents[i].id  == null )                 ||( theNameComponents[i].id.length() == 0 ) )               &&( ( theNameComponents[i].kind == null )                 ||( theNameComponents[i].kind.length() == 0 ) ) ) {                throw new InvalidName();            }             }        return theNameComponents;    }    /**    * This operation creates a URL based "iiopname://" format name    * from the Stringified Name of the object.    * @param addr internet based address of the host machine where    * Name Service is running <p>    * @param sn Stringified Name of the object <p>    * @exception org.omg.CosNaming.NamingContextExtPackage.InvalidName    * Indicates the name does not identify a binding.<p>    * @exception org.omg.CosNaming.NamingContextPackage.InvalidAddress    * Indicates the internet based address of the host machine is    * incorrect <p>    *    */    public String to_url(String addr, String sn)        throws org.omg.CosNaming.NamingContextExtPackage.InvalidAddress,               org.omg.CosNaming.NamingContextPackage.InvalidName    {        // Name valid?        if  ( (sn == null ) || (sn.length() == 0) )        {                throw new org.omg.CosNaming.NamingContextPackage.InvalidName();        }        if( addr == null )        {                throw new org.omg.CosNaming.NamingContextExtPackage.InvalidAddress();        }        String urlBasedAddress = null;         try {            urlBasedAddress = getINSImpl().createURLBasedAddress( addr, sn );        } catch (Exception e ) {             urlBasedAddress = null;        }        // Extra check to see that corba name url created is valid as per        // INS spec grammer.        try {            INSURLHandler.getINSURLHandler().parseURL( urlBasedAddress );        } catch( BAD_PARAM e ) {            throw new                org.omg.CosNaming.NamingContextExtPackage.InvalidAddress();        }        return urlBasedAddress;    }    /**     * This operation resolves the Stringified name into the object     * reference.     * @param sn Stringified Name of the object <p>     * @exception org.omg.CosNaming.NamingContextPackage.NotFound     * Indicates there is no object reference for the given name. <p>     * @exception org.omg.CosNaming.NamingContextPackage.CannotProceed     * Indicates that the given compound name is incorrect <p>     * @exception org.omg.CosNaming.NamingContextExtPackage.InvalidName     * Indicates the name does not identify a binding.<p>     *     */    public org.omg.CORBA.Object resolve_str(String sn)        throws org.omg.CosNaming.NamingContextPackage.NotFound,               org.omg.CosNaming.NamingContextPackage.CannotProceed,               org.omg.CosNaming.NamingContextPackage.InvalidName    {        org.omg.CORBA.Object theObject = null;        // Name valid?        if  ( (sn == null ) || (sn.length() == 0) )        {                throw new org.omg.CosNaming.NamingContextPackage.InvalidName();        }        org.omg.CosNaming.NameComponent[] theNameComponents =                getINSImpl().convertToNameComponent( sn );        if( ( theNameComponents == null ) || (theNameComponents.length == 0 ) )        {                throw new org.omg.CosNaming.NamingContextPackage.InvalidName();        }        theObject = resolve( theNameComponents );        return theObject;    }     /**   * This is a Debugging Method   */    public boolean IsEmpty()    {	return this.theHashtable.isEmpty();    }   /**   * This is a Debugging Method   */    public void printSize( )    {	System.out.println( "Hashtable Size = " + theHashtable.size( ) );	java.util.Enumeration e = theHashtable.keys( );	for( ; e.hasMoreElements(); )	{	      InternalBindingValue thevalue = 			(InternalBindingValue) this.theHashtable.get(e.nextElement());		if( thevalue != null )		{			System.out.println( "value = " + thevalue.strObjectRef);		}	}    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -