Java Code Examples for org.omg.CosNaming.NameComponent

The following examples show how to use org.omg.CosNaming.NameComponent. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: JDKSourceCode1.8   Source File: InterOperableNamingImpl.java    License: MIT License 6 votes vote down vote up
/**
  * Method which converts the Stringified name into Array of Name Components.
  *
  * @param string which is the stringified name.
  * @return  Array of Name Components (Simple or Compound Names)
  */
public org.omg.CosNaming.NameComponent[] convertToNameComponent(
    String theStringifiedName )
    throws org.omg.CosNaming.NamingContextPackage.InvalidName
{
     String[] theStringifiedNameComponents =
              breakStringToNameComponents( theStringifiedName );
     if( ( theStringifiedNameComponents == null )
      || (theStringifiedNameComponents.length == 0 ) )
     {
         return null;
     }
     NameComponent[] theNameComponents =
         new NameComponent[theStringifiedNameComponents.length];
     for( int i = 0; i < theStringifiedNameComponents.length; i++ ) {
         theNameComponents[i] = createNameComponentFromString(
             theStringifiedNameComponents[i] );
     }
     return theNameComponents;
}
 
Example 2
Source Project: jdk1.8-source-analysis   Source File: NamingContextImpl.java    License: Apache License 2.0 6 votes vote down vote up
/**
* 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;
}
 
Example 3
Source Project: jdk1.8-source-analysis   Source File: NamingContextImpl.java    License: Apache License 2.0 6 votes vote down vote up
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();
}
 
Example 4
Source Project: jdk8u60   Source File: NamingContextImpl.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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;
}
 
Example 5
/**
 * Method which stringifies the Name Components given as the input
 * parameter.
 *
 * @param n Array of Name Components (Simple or Compound Names)
 * @return string which is the stringified reference.
 */
public String convertToString( org.omg.CosNaming.NameComponent[]
                               theNameComponents )
{
    String theConvertedString =
        convertNameComponentToString( theNameComponents[0] );
    String temp;
    for( int i = 1; i < theNameComponents.length; i++ ) {
        temp = convertNameComponentToString( theNameComponents[i] );
        if( temp != null ) {
             theConvertedString =
             theConvertedString + "/" +  convertNameComponentToString(
                 theNameComponents[i] );
        }
    }
    return theConvertedString;
}
 
Example 6
/**
* 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;
}
 
Example 7
/**
* Returns the next binding in the NamingContext. Uses the enumeration
* object to determine if there are more bindings and if so, returns
* the next binding from the InternalBindingValue.
* @param b The Binding as an out parameter.
* @return true if there were more bindings.
*/
 final public boolean NextOne(org.omg.CosNaming.BindingHolder b)
 {
     // If there are more elements get the next element
     boolean hasMore = theEnumeration.hasMoreElements();
     if (hasMore) {
         InternalBindingKey theBindingKey =
              ((InternalBindingKey)theEnumeration.nextElement());
         InternalBindingValue theElement =
             (InternalBindingValue)theHashtable.get( theBindingKey );
         NameComponent n = new NameComponent( theBindingKey.id, theBindingKey.kind );
         NameComponent[] nlist = new NameComponent[1];
         nlist[0] = n;
         BindingType theType = theElement.theBindingType;

         b.value =
             new Binding( nlist, theType );
     } else {
         // Return empty but marshalable binding
         b.value = new Binding(new NameComponent[0],BindingType.nobject);
     }
     return hasMore;
 }
 
Example 8
Source Project: JDKSourceCode1.8   Source File: TransientNamingContext.java    License: MIT License 6 votes vote down vote up
/**
 * Deletes the binding with the supplied name. It creates a
 * InternalBindingKey and uses it to remove the value associated
 * with the key. If nothing is found an exception is thrown, otherwise
 * the element is removed from the hash table.
 * @param n a NameComponent which is the name to unbind
 * @return the object reference bound to the name, or null if not found.
 * @exception org.omg.CORBA.SystemException One of a fixed set of CORBA
 * system exceptions.
 */
public final org.omg.CORBA.Object Unbind(NameComponent n)
    throws org.omg.CORBA.SystemException
{
    // Create a key and remove it from the hashtable
    InternalBindingKey key = new InternalBindingKey(n);
    InternalBindingValue value =
        (InternalBindingValue)this.theHashtable.remove(key);

    // Return what was found
    if (value == null) {
        if( updateLogger.isLoggable( Level.FINE ) ) {
            updateLogger.fine( LogKeywords.NAMING_UNBIND_FAILURE +
                " There was no binding with the name " + getName( n ) +
                " to Unbind " );
        }
        return null;
    } else {
        if( updateLogger.isLoggable( Level.FINE ) ) {
            updateLogger.fine( LogKeywords.NAMING_UNBIND_SUCCESS +
                " NameComponent:  " + getName( n ) );
        }
        return value.theObjectRef;
   }
}
 
Example 9
Source Project: JDKSourceCode1.8   Source File: NamingContextImpl.java    License: MIT License 6 votes vote down vote up
/**
* 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;
}
 
Example 10
/**
 * 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;
}
 
Example 11
/**
 * Binds the object to the name component as the specified binding type.
 * It creates a InternalBindingKey object and a InternalBindingValue
 * object and inserts them in the hash table.
 * @param n A single org.omg.CosNaming::NameComponent under which the
 * object will be bound.
 * @param obj An object reference to be bound under the supplied name.
 * @param bt The type of the binding (i.e., as object or as context).
 * @exception org.omg.CORBA.SystemException One of a fixed set of CORBA
 * system exceptions.
 */
public final void Bind(NameComponent n, org.omg.CORBA.Object obj,
                       BindingType bt)
    throws org.omg.CORBA.SystemException
{
    // Create a key and a value
    InternalBindingKey key = new InternalBindingKey(n);
    NameComponent[] name = new NameComponent[1];
    name[0] = n;
    Binding b = new Binding(name,bt);
    InternalBindingValue value = new InternalBindingValue(b,null);
    value.theObjectRef = obj;
    // insert it
    InternalBindingValue oldValue =
        (InternalBindingValue)this.theHashtable.put(key,value);

    if (oldValue != null) {
        updateLogger.warning( LogKeywords.NAMING_BIND + "Name " +
            getName( n ) + " Was Already Bound" );
        throw wrapper.transNcBindAlreadyBound() ;
    }
    if( updateLogger.isLoggable( Level.FINE ) ) {
        updateLogger.fine( LogKeywords.NAMING_BIND_SUCCESS +
            "Name Component: " + n.id + "." + n.kind );
    }
}
 
Example 12
/**
 * Deletes the binding with the supplied name. It creates a
 * InternalBindingKey and uses it to remove the value associated
 * with the key. If nothing is found an exception is thrown, otherwise
 * the element is removed from the hash table.
 * @param n a NameComponent which is the name to unbind
 * @return the object reference bound to the name, or null if not found.
 * @exception org.omg.CORBA.SystemException One of a fixed set of CORBA
 * system exceptions.
 */
public final org.omg.CORBA.Object Unbind(NameComponent n)
    throws org.omg.CORBA.SystemException
{
    // Create a key and remove it from the hashtable
    InternalBindingKey key = new InternalBindingKey(n);
    InternalBindingValue value =
        (InternalBindingValue)this.theHashtable.remove(key);

    // Return what was found
    if (value == null) {
        if( updateLogger.isLoggable( Level.FINE ) ) {
            updateLogger.fine( LogKeywords.NAMING_UNBIND_FAILURE +
                " There was no binding with the name " + getName( n ) +
                " to Unbind " );
        }
        return null;
    } else {
        if( updateLogger.isLoggable( Level.FINE ) ) {
            updateLogger.fine( LogKeywords.NAMING_UNBIND_SUCCESS +
                " NameComponent:  " + getName( n ) );
        }
        return value.theObjectRef;
   }
}
 
Example 13
Source Project: JDKSourceCode1.8   Source File: NamingContextImpl.java    License: MIT License 6 votes vote down vote up
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();
}
 
Example 14
/**
 * Binds the object to the name component as the specified binding type.
 * It creates a InternalBindingKey object and a InternalBindingValue
 * object and inserts them in the hash table.
 * @param n A single org.omg.CosNaming::NameComponent under which the
 * object will be bound.
 * @param obj An object reference to be bound under the supplied name.
 * @param bt The type of the binding (i.e., as object or as context).
 * @exception org.omg.CORBA.SystemException One of a fixed set of CORBA
 * system exceptions.
 */
public final void Bind(NameComponent n, org.omg.CORBA.Object obj,
                       BindingType bt)
    throws org.omg.CORBA.SystemException
{
    // Create a key and a value
    InternalBindingKey key = new InternalBindingKey(n);
    NameComponent[] name = new NameComponent[1];
    name[0] = n;
    Binding b = new Binding(name,bt);
    InternalBindingValue value = new InternalBindingValue(b,null);
    value.theObjectRef = obj;
    // insert it
    InternalBindingValue oldValue =
        (InternalBindingValue)this.theHashtable.put(key,value);

    if (oldValue != null) {
        updateLogger.warning( LogKeywords.NAMING_BIND + "Name " +
            getName( n ) + " Was Already Bound" );
        throw wrapper.transNcBindAlreadyBound() ;
    }
    if( updateLogger.isLoggable( Level.FINE ) ) {
        updateLogger.fine( LogKeywords.NAMING_BIND_SUCCESS +
            "Name Component: " + n.id + "." + n.kind );
    }
}
 
Example 15
/**
* Returns the next binding in the NamingContext. Uses the enumeration
* object to determine if there are more bindings and if so, returns
* the next binding from the InternalBindingValue.
* @param b The Binding as an out parameter.
* @return true if there were more bindings.
*/
 final public boolean NextOne(org.omg.CosNaming.BindingHolder b)
 {
     // If there are more elements get the next element
     boolean hasMore = theEnumeration.hasMoreElements();
     if (hasMore) {
         InternalBindingKey theBindingKey =
              ((InternalBindingKey)theEnumeration.nextElement());
         InternalBindingValue theElement =
             (InternalBindingValue)theHashtable.get( theBindingKey );
         NameComponent n = new NameComponent( theBindingKey.id, theBindingKey.kind );
         NameComponent[] nlist = new NameComponent[1];
         nlist[0] = n;
         BindingType theType = theElement.theBindingType;

         b.value =
             new Binding( nlist, theType );
     } else {
         // Return empty but marshalable binding
         b.value = new Binding(new NameComponent[0],BindingType.nobject);
     }
     return hasMore;
 }
 
Example 16
Source Project: JDKSourceCode1.8   Source File: PersistentBindingIterator.java    License: MIT License 6 votes vote down vote up
/**
* Returns the next binding in the NamingContext. Uses the enumeration
* object to determine if there are more bindings and if so, returns
* the next binding from the InternalBindingValue.
* @param b The Binding as an out parameter.
* @return true if there were more bindings.
*/
 final public boolean NextOne(org.omg.CosNaming.BindingHolder b)
 {
     // If there are more elements get the next element
     boolean hasMore = theEnumeration.hasMoreElements();
     if (hasMore) {
         InternalBindingKey theBindingKey =
              ((InternalBindingKey)theEnumeration.nextElement());
         InternalBindingValue theElement =
             (InternalBindingValue)theHashtable.get( theBindingKey );
         NameComponent n = new NameComponent( theBindingKey.id, theBindingKey.kind );
         NameComponent[] nlist = new NameComponent[1];
         nlist[0] = n;
         BindingType theType = theElement.theBindingType;

         b.value =
             new Binding( nlist, theType );
     } else {
         // Return empty but marshalable binding
         b.value = new Binding(new NameComponent[0],BindingType.nobject);
     }
     return hasMore;
 }
 
Example 17
/**
 * Deletes the binding with the supplied name. It creates a
 * InternalBindingKey and uses it to remove the value associated
 * with the key. If nothing is found an exception is thrown, otherwise
 * the element is removed from the hash table.
 * @param n a NameComponent which is the name to unbind
 * @return the object reference bound to the name, or null if not found.
 * @exception org.omg.CORBA.SystemException One of a fixed set of CORBA
 * system exceptions.
 */
public final org.omg.CORBA.Object Unbind(NameComponent n)
    throws org.omg.CORBA.SystemException
{
    // Create a key and remove it from the hashtable
    InternalBindingKey key = new InternalBindingKey(n);
    InternalBindingValue value =
        (InternalBindingValue)this.theHashtable.remove(key);

    // Return what was found
    if (value == null) {
        if( updateLogger.isLoggable( Level.FINE ) ) {
            updateLogger.fine( LogKeywords.NAMING_UNBIND_FAILURE +
                " There was no binding with the name " + getName( n ) +
                " to Unbind " );
        }
        return null;
    } else {
        if( updateLogger.isLoggable( Level.FINE ) ) {
            updateLogger.fine( LogKeywords.NAMING_UNBIND_SUCCESS +
                " NameComponent:  " + getName( n ) );
        }
        return value.theObjectRef;
   }
}
 
Example 18
Source Project: jdk8u60   Source File: CNNameParser.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the INS stringified form of a NameComponent[].
 * Used by CNCtx.getNameInNamespace(), CNCompoundName.toString().
 */
static String cosNameToInsString(NameComponent[] cname) {
  StringBuffer str = new StringBuffer();
  for ( int i = 0; i < cname.length; i++) {
      if ( i > 0) {
          str.append(compSeparator);
      }
      str.append(stringifyComponent(cname[i]));
  }
  return str.toString();
}
 
Example 19
Source Project: JDKSourceCode1.8   Source File: TransientBindingIterator.java    License: MIT License 5 votes vote down vote up
/**
* Returns the next binding in the NamingContext. Uses the enumeration
* object to determine if there are more bindings and if so, returns
* the next binding from the InternalBindingValue.
* @param b The Binding as an out parameter.
* @return true if there were more bindings.
*/
 final public boolean NextOne(org.omg.CosNaming.BindingHolder b)
 {
     // If there are more elements get the next element
     boolean hasMore = theEnumeration.hasMoreElements();
     if (hasMore) {
         b.value =
             ((InternalBindingValue)theEnumeration.nextElement()).theBinding;
         currentSize--;
     } else {
         // Return empty but marshalable binding
         b.value = new Binding(new NameComponent[0],BindingType.nobject);
     }
     return hasMore;
 }
 
Example 20
/**
* Returns the next binding in the NamingContext. Uses the enumeration
* object to determine if there are more bindings and if so, returns
* the next binding from the InternalBindingValue.
* @param b The Binding as an out parameter.
* @return true if there were more bindings.
*/
 final public boolean NextOne(org.omg.CosNaming.BindingHolder b)
 {
     // If there are more elements get the next element
     boolean hasMore = theEnumeration.hasMoreElements();
     if (hasMore) {
         b.value =
             ((InternalBindingValue)theEnumeration.nextElement()).theBinding;
         currentSize--;
     } else {
         // Return empty but marshalable binding
         b.value = new Binding(new NameComponent[0],BindingType.nobject);
     }
     return hasMore;
 }
 
Example 21
Source Project: jdk1.8-source-analysis   Source File: NamingContextImpl.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Create a new NamingContext, bind it in this Naming Context and return
 * its object reference. This is equivalent to using new_context() followed
 * by bind_context() with the supplied name and the object reference for
 * the newly created NamingContext.
 * @param n a sequence of NameComponents which is the name to be unbound.
 * @return an object reference for a new NamingContext object implemented
 * by this Name Server, bound to the supplied name.
 * @exception org.omg.CosNaming.NamingContextPackage.AlreadyBound An object
 * is already 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 new_context
 * @see bind_context
 */
public  NamingContext bind_new_context(NameComponent[] n)
    throws org.omg.CosNaming.NamingContextPackage.NotFound,
           org.omg.CosNaming.NamingContextPackage.AlreadyBound,
           org.omg.CosNaming.NamingContextPackage.CannotProceed,
           org.omg.CosNaming.NamingContextPackage.InvalidName
{
    NamingContext nc = null;
    NamingContext rnc = null;
    try {
        if (debug)
            dprint("bind_new_context " + nameToString(n));
        // The obvious solution:
        nc = this.new_context();
        this.bind_context(n,nc);
        rnc = nc;
        nc = null;
    } finally {
        try {
            if(nc != null)
                nc.destroy();
        } catch (org.omg.CosNaming.NamingContextPackage.NotEmpty e) {
        }
    }
    if( updateLogger.isLoggable( Level.FINE ) ) {
        // isLoggable call to make sure that we save some precious
        // processor cycles, if there is no need to log.
        updateLogger.fine ( LogKeywords.NAMING_BIND +
            "New Context Bound To " +
            NamingUtils.getDirectoryStructuredName( n ) );
    }
    return rnc;
}
 
Example 22
Source Project: jdk8u60   Source File: CNNameParser.java    License: GNU General Public License v2.0 5 votes vote down vote up
private static String stringifyComponent(NameComponent comp) {
    StringBuffer one = new StringBuffer(escape(comp.id));
    if (comp.kind != null && !comp.kind.equals("")) {
        one.append(kindSeparator + escape(comp.kind));
    }
    if (one.length() == 0) {
        return ""+kindSeparator;  // if neither id nor kind specified
    } else {
        return one.toString();
    }
}
 
Example 23
Source Project: jdk1.8-source-analysis   Source File: NamingContextImpl.java    License: Apache License 2.0 5 votes vote down vote up
/**
* 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;
 }
 
Example 24
Source Project: jdk1.8-source-analysis   Source File: NamingContextImpl.java    License: Apache License 2.0 5 votes vote down vote up
/**
* 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;
}
 
Example 25
Source Project: jdk1.8-source-analysis   Source File: NamingUtils.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * A utility method that takes Array of NameComponent and converts
 * into a directory structured name in the format of /id1.kind1/id2.kind2..
 * This is used mainly for Logging.
 */
static String getDirectoryStructuredName( NameComponent[] name ) {
    StringBuffer directoryStructuredName = new StringBuffer("/");
    for( int i = 0; i < name.length; i++ ) {
        directoryStructuredName.append( name[i].id + "." + name[i].kind );
    }
    return directoryStructuredName.toString( );
}
 
Example 26
/**
* 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;
 }
 
Example 27
Source Project: JDKSourceCode1.8   Source File: NamingContextImpl.java    License: MIT License 5 votes vote down vote up
/**
* 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;
}
 
Example 28
/**
 * 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
{
    if( nc == null )
    {
        updateLogger.warning( LogKeywords.NAMING_REBIND_FAILURE +
            " NULL Context cannot be Bound " );
        throw wrapper.objectIsNull() ;
    }
    try {
        // 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
        updateLogger.warning( LogKeywords.NAMING_REBIND_FAILURE +
            NamingUtils.getDirectoryStructuredName( n ) +
            " is already bound to a CORBA Object" );
        throw wrapper.namingCtxRebindctxAlreadyBound( ex ) ;
    }
    if( updateLogger.isLoggable( Level.FINE ) ) {
        // isLoggable call to make sure that we save some precious
        // processor cycles, if there is no need to log.
        updateLogger.fine( LogKeywords.NAMING_REBIND_SUCCESS + " Name = " +
            NamingUtils.getDirectoryStructuredName( n ) );
    }
}
 
Example 29
Source Project: dragonwell8_jdk   Source File: CNNameParser.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the INS stringified form of a NameComponent[].
 * Used by CNCtx.getNameInNamespace(), CNCompoundName.toString().
 */
static String cosNameToInsString(NameComponent[] cname) {
  StringBuffer str = new StringBuffer();
  for ( int i = 0; i < cname.length; i++) {
      if ( i > 0) {
          str.append(compSeparator);
      }
      str.append(stringifyComponent(cname[i]));
  }
  return str.toString();
}
 
Example 30
Source Project: JDKSourceCode1.8   Source File: NamingUtils.java    License: MIT License 5 votes vote down vote up
/**
 * A utility method that takes Array of NameComponent and converts
 * into a directory structured name in the format of /id1.kind1/id2.kind2..
 * This is used mainly for Logging.
 */
static String getDirectoryStructuredName( NameComponent[] name ) {
    StringBuffer directoryStructuredName = new StringBuffer("/");
    for( int i = 0; i < name.length; i++ ) {
        directoryStructuredName.append( name[i].id + "." + name[i].kind );
    }
    return directoryStructuredName.toString( );
}