namingcontextimpl.java
来自「java jdk 1.4的源码」· Java 代码 · 共 932 行 · 第 1/3 页
JAVA
932 行
/* * @(#)NamingContextImpl.java 1.65 03/01/23 * * Copyright 2003 Sun Microsystems, Inc. All rights reserved. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. */package com.sun.corba.se.internal.CosNaming;// Import general CORBA classesimport org.omg.CORBA.ORB;import org.omg.CORBA.Object;import org.omg.CORBA.BAD_PARAM;import org.omg.CORBA.INTERNAL;import org.omg.CORBA.CompletionStatus;import org.omg.PortableServer.POA;import org.omg.PortableServer.Servant;// Import org.omg.CosNaming classesimport org.omg.CosNaming.BindingType;import org.omg.CosNaming.BindingTypeHolder;import org.omg.CosNaming.BindingListHolder;import org.omg.CosNaming.BindingIteratorHolder;import org.omg.CosNaming.NameComponent;import org.omg.CosNaming.NamingContextHelper;import org.omg.CosNaming.NamingContext;import org.omg.CosNaming.NamingContextPackage.*;import org.omg.CosNaming._NamingContextImplBase;import org.omg.CosNaming.NamingContextExtHelper;import org.omg.CosNaming.NamingContextExt;import org.omg.CosNaming.NamingContextExtPOA;import org.omg.CosNaming.NamingContextExtPackage.*;import com.sun.corba.se.internal.POA.POAORB;import org.omg.CosNaming.NamingContextPackage.NotFound;import com.sun.corba.se.internal.CosNaming.NamingContextDataStore;import com.sun.corba.se.internal.CosNaming.MinorCodes;import com.sun.corba.se.internal.corba.InitialNamingClient;import com.sun.corba.se.internal.corba.CorbaName;/** * Class NamingContextImpl implements the org.omg.CosNaming::NamingContext * interface, but does not implement the methods associated with * maintaining the "table" of current bindings in a NamingContext. * Instead, this implementation assumes that the derived implementation * implements the NamingContextDataStore interface, which has the necessary * methods. This allows multiple * NamingContext implementations that differ in storage of the bindings, * as well as implementations of interfaces derived from * CosNaming::NamingContext that still reuses the implementation. * <p> * The operations bind(), rebind(), bind_context() and rebind_context() * are all really implemented by doBind(). resolve() is really implemented * by doResolve(), unbind() by doUnbind(). list(), new_context() and * destroy() uses the NamingContextDataStore interface directly. All the * doX() methods are public static. * They synchronize on the NamingContextDataStore object. * <p> * An implementation a NamingContext must extend this class and implement * the NamingContextDataStore interface with the operations: * Bind(), Resolve(), * Unbind(), List(), NewContext() and Destroy(). Calls * to these methods are synchronized; these methods should * therefore not be synchronized. */public abstract class NamingContextImpl extends NamingContextExtPOA implements NamingContextDataStore{ protected POA nsPOA; // The grammer for Parsing and Building Interoperable Stringified Names // are implemented in this class private InterOperableNamingImpl insImpl; /** * Create a naming context servant. * Runs the super constructor. * @param orb an ORB object. * @exception java.lang.Exception a Java exception. */ public NamingContextImpl(POAORB orb, POA poa) throws java.lang.Exception { super(); this.orb = orb; insImpl = new InterOperableNamingImpl( ); this.nsPOA = poa; } public POA getNSPOA( ) { return nsPOA; } /** * Bind an object under a name in this NamingContext. If the name * contains multiple (n) components, n-1 will be resolved in this * NamingContext and the object bound in resulting NamingContext. * An exception is thrown if a binding with the supplied name already * exists. If the * object to be bound is a NamingContext it will not participate in * a recursive resolve. * @param n a sequence of NameComponents which is the name under which * the object will be bound. * @param obj the object reference to be bound. * @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.CosNaming.NamingContextPackage.AlreadyBound An object * is already bound under the supplied name. * @exception org.omg.CORBA.SystemException One of a fixed set of CORBA * system exceptions. * @see doBind */ public void bind(NameComponent[] n, org.omg.CORBA.Object obj) throws org.omg.CosNaming.NamingContextPackage.NotFound, org.omg.CosNaming.NamingContextPackage.CannotProceed, org.omg.CosNaming.NamingContextPackage.InvalidName, org.omg.CosNaming.NamingContextPackage.AlreadyBound { if( obj == null ) { throw new org.omg.CORBA.INTERNAL(MinorCodes.OBJECT_IS_NULL, CompletionStatus.COMPLETED_NO); } if (debug) dprint("bind " + nameToString(n) + " to " + obj); // doBind implements all four flavors of binding NamingContextDataStore impl = (NamingContextDataStore)this; doBind(impl,n,obj,false,BindingType.nobject); } /** * Bind a NamingContext under a name in this NamingContext. If the name * contains multiple (n) components, n-1 will be resolved in this * NamingContext and the object bound in resulting NamingContext. * An exception is thrown if a binding with the supplied name already * exists. The NamingContext will participate in recursive resolving. * @param n a sequence of NameComponents which is the name under which * the object will be bound. * @param obj the NamingContect object reference to be bound. * @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.CosNaming.NamingContextPackage.AlreadyBound An object * is already bound under the supplied name. * @exception org.omg.CORBA.SystemException One of a fixed set of CORBA * system exceptions. * @see doBind */ public void bind_context(NameComponent[] n, NamingContext nc) throws org.omg.CosNaming.NamingContextPackage.NotFound, org.omg.CosNaming.NamingContextPackage.CannotProceed, org.omg.CosNaming.NamingContextPackage.InvalidName, org.omg.CosNaming.NamingContextPackage.AlreadyBound { if( nc == null ) { throw new BAD_PARAM( "Naming Context should not be null " ); } // doBind implements all four flavors of binding NamingContextDataStore impl = (NamingContextDataStore)this; doBind(impl,n,nc,false,BindingType.ncontext); } /** * Bind an object under a name in this NamingContext. If the name * contains multiple (n) components, n-1 will be resolved in this * NamingContext and the object bound in resulting NamingContext. * If a binding under the supplied name already exists it will be * unbound first. If the * object to be bound is a NamingContext it will not participate in * a recursive resolve. * @param n a sequence of NameComponents which is the name under which * the object will be bound. * @param obj the object reference to be bound. * @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 doBind */ public void rebind(NameComponent[] n, org.omg.CORBA.Object obj) throws org.omg.CosNaming.NamingContextPackage.NotFound, org.omg.CosNaming.NamingContextPackage.CannotProceed, org.omg.CosNaming.NamingContextPackage.InvalidName { if( obj == null ) { throw new org.omg.CORBA.INTERNAL(MinorCodes.OBJECT_IS_NULL, CompletionStatus.COMPLETED_NO); } try { if (debug) dprint("rebind " + nameToString(n) + " to " + obj); // doBind implements all four flavors of binding NamingContextDataStore impl = (NamingContextDataStore)this; doBind(impl,n,obj,true,BindingType.nobject); } catch (org.omg.CosNaming.NamingContextPackage.AlreadyBound ex) { // This should not happen throw new org.omg.CORBA.INTERNAL( MinorCodes.NAMING_CTX_REBIND_ALREADY_BOUND, CompletionStatus.COMPLETED_NO); } } /** * Bind a NamingContext under a name in this NamingContext. If the name * contains multiple (n) components, the first n-1 components will be * resolved in this NamingContext and the object bound in resulting * NamingContext. If a binding under the supplied name already exists it * will be unbound first. The NamingContext will participate in recursive * resolving. * @param n a sequence of NameComponents which is the name under which * the object will be bound. * @param obj the object reference to be bound. * @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 doBind */ public void rebind_context(NameComponent[] n, NamingContext nc) throws org.omg.CosNaming.NamingContextPackage.NotFound, org.omg.CosNaming.NamingContextPackage.CannotProceed, org.omg.CosNaming.NamingContextPackage.InvalidName { try { if (debug) dprint("rebind_context " + nameToString(n) + " to " + nc); // doBind implements all four flavors of binding NamingContextDataStore impl = (NamingContextDataStore)this; doBind(impl,n,nc,true,BindingType.ncontext); } catch (org.omg.CosNaming.NamingContextPackage.AlreadyBound ex) { // This should not happen throw new org.omg.CORBA.INTERNAL( MinorCodes.NAMING_CTX_REBINDCTX_ALREADY_BOUND, CompletionStatus.COMPLETED_NO); } } /** * Resolve a name in this NamingContext and return the object reference * bound to the name. If the name contains multiple (n) components, * the first component will be resolved in this NamingContext and the * remaining components resolved in the resulting NamingContext, provided * that the NamingContext bound to the first component of the name was * bound with bind_context(). * @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 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 doResolve */ public org.omg.CORBA.Object resolve(NameComponent[] n) throws org.omg.CosNaming.NamingContextPackage.NotFound, org.omg.CosNaming.NamingContextPackage.CannotProceed, org.omg.CosNaming.NamingContextPackage.InvalidName { if (debug) dprint("resolve " + nameToString(n)); // doResolve actually resolves NamingContextDataStore impl = (NamingContextDataStore)this; return doResolve(impl,n); } /** * Remove a binding from this NamingContext. If the name contains * multiple (n) components, the first n-1 components will be resolved * from this NamingContext and the final component unbound in * the resulting NamingContext. * @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 doUnbind */ public void unbind(NameComponent[] n) throws org.omg.CosNaming.NamingContextPackage.NotFound, org.omg.CosNaming.NamingContextPackage.CannotProceed, org.omg.CosNaming.NamingContextPackage.InvalidName {
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?