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

📄 namingcontextimpl.java

📁 java1.6众多例子参考
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
						 NameComponent[] n)	throws org.omg.CosNaming.NamingContextPackage.NotFound,	       org.omg.CosNaming.NamingContextPackage.CannotProceed,	       org.omg.CosNaming.NamingContextPackage.InvalidName    {	org.omg.CORBA.Object obj = null;	BindingTypeHolder bth = new BindingTypeHolder();                	// Length must be greater than 0	if (n.length < 1)	    throw new InvalidName();	// The identifier must be set	if (n.length == 1) {	    synchronized (impl) {		// Resolve first level in this context		obj = impl.Resolve(n[0],bth);	    }	    if (obj == null) {		// Object was not found		throw new NotFound(NotFoundReason.missing_node,n);	    }	    return obj;	} else {	    // n.length > 1	    if ( (n[1].id.length() == 0) && (n[1].kind.length() == 0) ) {		throw new InvalidName();            }	    NamingContext context = resolveFirstAsContext(impl,n);      	    // Compute restOfName = name[1..length]	    NameComponent[] tail = new NameComponent[n.length -1];	    System.arraycopy(n,1,tail,0,n.length-1);            // Resolve rest of name in context            try {                // First try to resolve using the local call, this should work                // most of the time unless there are federated naming contexts.                Servant servant = impl.getNSPOA().reference_to_servant(                     context );                return doResolve(((NamingContextDataStore)servant), tail) ;            } catch( Exception e ) {                return context.resolve(tail);            }        }    }    /**   * Implements unbinding bound names in this NamingContext. If the   * name contains only one component, the name is unbound in this   * NamingContext using Unbind(). Otherwise, the first component   * of the name is resolved in this NamingContext and    * unbind passed to the resulting NamingContext.   * This method is static for maximal reuse - even for extended naming   * context implementations where the recursive semantics still apply.   * @param impl an implementation of NamingContextDataStore   * @param n a sequence of NameComponents which is the name to be unbound.   * @exception org.omg.CosNaming.NamingContextPackage.NotFound A name with multiple   * components was supplied, but the first component could not be   * resolved.   * @exception org.omg.CosNaming.NamingContextPackage.CannotProceed Could not proceed   * in resolving the n-1 components of 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 resolve   */    public static void doUnbind(NamingContextDataStore impl,				NameComponent[] n)	throws org.omg.CosNaming.NamingContextPackage.NotFound,	       org.omg.CosNaming.NamingContextPackage.CannotProceed,	       org.omg.CosNaming.NamingContextPackage.InvalidName    {	// Name valid?	if (n.length < 1)	    throw new InvalidName();    // Unbind here?	if (n.length == 1) {	    // The identifier must be set	    if ( (n[0].id.length() == 0) && (n[0].kind.length() == 0 ) ) {		throw new InvalidName();            }	    org.omg.CORBA.Object objRef = null;	    synchronized (impl) {		// Yes: unbind in this context		objRef = impl.Unbind(n[0]);	    }      	    if (objRef == null)		// It was not bound		throw new NotFound(NotFoundReason.missing_node,n);	    // Done	    return;	} else {	    // No: unbind in a different context            // Resolve first  - must be resolveable	    NamingContext context = resolveFirstAsContext(impl,n);      	    // Compute tail	    NameComponent[] tail = new NameComponent[n.length - 1];	    System.arraycopy(n,1,tail,0,n.length-1);      // Propagate unbind to this context	    context.unbind(tail);	}    }    /**   * Implements resolving a NameComponent in this context and   * narrowing it to CosNaming::NamingContext. It will throw appropriate   * exceptions if not found or not narrowable.   * @param impl an implementation of NamingContextDataStore   * @param n a NameComponents which is the name to be found.   * @exception org.omg.CosNaming.NamingContextPackage.NotFound The   * first component could not be resolved.   * @exception org.omg.CosNaming.NamingContextPackage.CannotProceed Could not proceed   * in resolving the first component of the supplied name.   * @exception org.omg.CORBA.SystemException One of a fixed set of CORBA system exceptions.   * @see resolve   */    protected static NamingContext resolveFirstAsContext(NamingContextDataStore impl,							 NameComponent[] n)	throws org.omg.CosNaming.NamingContextPackage.NotFound {	org.omg.CORBA.Object topRef = null;	BindingTypeHolder bth = new BindingTypeHolder();	NamingContext context = null;    	synchronized (impl) {	    // Resolve first  - must be resolveable	    topRef = impl.Resolve(n[0],bth);	    if (topRef == null) {		// It was not bound		throw new NotFound(NotFoundReason.missing_node,n);	    }	}      	// Was it bound as a context?	if (bth.value != BindingType.ncontext) {	    // It was not a context	    throw new NotFound(NotFoundReason.not_context,n);	}      	// Narrow to a naming context	try {	    context = NamingContextHelper.narrow(topRef);	} catch (org.omg.CORBA.BAD_PARAM ex) {	    // It was not a context	    throw new NotFound(NotFoundReason.not_context,n);	}	// Hmm. must be ok	return context;    }   /**    * 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 InvalidName();	}	NamingContextDataStore impl = (NamingContextDataStore)this;        String theStringifiedName = insImpl.convertToString( n );	if( theStringifiedName == null )	{		throw new 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 InvalidName();	}	NamingContextDataStore impl = (NamingContextDataStore)this;	org.omg.CosNaming.NameComponent[] theNameComponents =		insImpl.convertToNameComponent( sn );	if( ( theNameComponents == null ) || (theNameComponents.length == 0 ) )	{		throw new 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 InvalidName();	}	if( addr == null )	{	    throw new                 org.omg.CosNaming.NamingContextExtPackage.InvalidAddress();	}	NamingContextDataStore impl = (NamingContextDataStore)this;	String urlBasedAddress = null;	urlBasedAddress = insImpl.createURLBasedAddress( addr, sn );         // 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>     * @exception org.omg.CosNaming.NamingContextPackage.AlreadyBound     * Indicates the name is already bound.<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 InvalidName();	}	NamingContextDataStore impl = (NamingContextDataStore)this;	org.omg.CosNaming.NameComponent[] theNameComponents =		insImpl.convertToNameComponent( sn );	if( ( theNameComponents == null ) || (theNameComponents.length == 0 ) )	{		throw new InvalidName();	}	theObject = resolve( theNameComponents );	return theObject;    }    transient protected ORB orb;      public static String nameToString(NameComponent[] name)    {	StringBuffer s = new StringBuffer("{");	if (name != null || name.length > 0) {	    for (int i=0;i<name.length;i++) {		if (i>0)		    s.append(",");		s.append("[").		    append(name[i].id).		    append(",").		    append(name[i].kind).		    append("]");	    }	}	s.append("}");	return s.toString();    }      // Debugging aids.    public static final boolean debug = false;    private static void dprint(String msg) {	NamingUtils.dprint("NamingContextImpl("  +			   Thread.currentThread().getName() + " at " +			   System.currentTimeMillis() +			   " ems): " + msg);    }}

⌨️ 快捷键说明

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