Java Code Examples for org.omg.CosNaming.Binding

The following are top voted examples for showing how to use org.omg.CosNaming.Binding. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: OpenJSharp   File: TransientNamingContext.java   Source Code and License 6 votes vote down vote up
/**
 * 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 2
Project: OpenJSharp   File: PersistentBindingIterator.java   Source Code and 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 3
Project: openjdk-jdk10   File: TransientNamingContext.java   Source Code and License 6 votes vote down vote up
/**
 * 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 4
Project: openjdk-jdk10   File: PersistentBindingIterator.java   Source Code and 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 5
Project: openjdk9   File: TransientNamingContext.java   Source Code and License 6 votes vote down vote up
/**
 * 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 6
Project: openjdk9   File: PersistentBindingIterator.java   Source Code and 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 7
Project: lookaside_java-1.8.0-openjdk   File: TransientNamingContext.java   Source Code and License 6 votes vote down vote up
/**
 * 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 8
Project: lookaside_java-1.8.0-openjdk   File: PersistentBindingIterator.java   Source Code and 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 9
Project: jdk8u_corba   File: TransientNamingContext.java   Source Code and License 6 votes vote down vote up
/**
 * 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 10
Project: jdk8u_corba   File: PersistentBindingIterator.java   Source Code and 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 11
Project: javify   File: ListBindingsEnumeration.java   Source Code and License 6 votes vote down vote up
/**
 * Convert from the CORBA binding into the javax.naming binding. As the CORBA
 * naming service binding does not contain the object itself, this method
 * makes the additional calls to the naming service.
 *
 * @param binding
 *          the binding to convert
 * @return the value, that must be returned by the {@link #next()}.
 */
public Object convert(Binding binding)
{
  CPStringBuilder name = new CPStringBuilder();

  for (int i = 0; i < binding.binding_name.length; i++)
    {
      name.append(binding.binding_name[i]);
      if (i < binding.binding_name.length - 1)
        name.append('/');
    }

  try
    {
      Object object = service.resolve(binding.binding_name);
      return new javax.naming.Binding(name.toString(), object);
    }
  catch (Exception e)
    {
      // Probably was removed by the concurent thread.
      return null;
    }
}
 
Example 12
Project: javify   File: Binding_iterator_impl.java   Source Code and License 6 votes vote down vote up
/**
 * Return the desired amount of bindings.
 *
 * @param amount the maximal number of bindings to return.
 * @param a_list a holder to store the returned bindings.
 *
 * @return false if there are no more bindings available,
 * true otherwise.
 */
public boolean next_n(int amount, BindingListHolder a_list)
{
  if (p < bindings.length)
    {
      int n = bindings.length - p;
      if (n > amount)
        n = amount;

      a_list.value = new Binding[ n ];
      for (int i = 0; i < n; i++)
        a_list.value [ i ] = bindings [ p++ ];

      return true;
    }
  else
    {
      a_list.value = new Binding[ 0 ];
      return false;
    }
}
 
Example 13
Project: jvm-stm   File: ListBindingsEnumeration.java   Source Code and License 6 votes vote down vote up
/**
 * Convert from the CORBA binding into the javax.naming binding. As the CORBA
 * naming service binding does not contain the object itself, this method
 * makes the additional calls to the naming service.
 * 
 * @param binding
 *          the binding to convert
 * @return the value, that must be returned by the {@link #next()}.
 */
public Object convert(Binding binding)
{
  CPStringBuilder name = new CPStringBuilder();

  for (int i = 0; i < binding.binding_name.length; i++)
    {
      name.append(binding.binding_name[i]);
      if (i < binding.binding_name.length - 1)
        name.append('/');
    }
  
  try
    {
      Object object = service.resolve(binding.binding_name);
      return new javax.naming.Binding(name.toString(), object);
    }
  catch (Exception e)
    {
      // Probably was removed by the concurent thread.
      return null;
    }
}
 
Example 14
Project: jvm-stm   File: Binding_iterator_impl.java   Source Code and License 6 votes vote down vote up
/**
 * Return the desired amount of bindings.
 *
 * @param amount the maximal number of bindings to return.
 * @param a_list a holder to store the returned bindings.
 *
 * @return false if there are no more bindings available,
 * true otherwise.
 */
public boolean next_n(int amount, BindingListHolder a_list)
{
  if (p < bindings.length)
    {
      int n = bindings.length - p;
      if (n > amount)
        n = amount;

      a_list.value = new Binding[ n ];
      for (int i = 0; i < n; i++)
        a_list.value [ i ] = bindings [ p++ ];

      return true;
    }
  else
    {
      a_list.value = new Binding[ 0 ];
      return false;
    }
}
 
Example 15
Project: infobip-open-jdk-8   File: TransientNamingContext.java   Source Code and License 6 votes vote down vote up
/**
 * 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 16
Project: infobip-open-jdk-8   File: PersistentBindingIterator.java   Source Code and 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
Project: openjdk-source-code-learn   File: TransientNamingContext.java   Source Code and License 6 votes vote down vote up
/**
 * 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 18
Project: openjdk-source-code-learn   File: PersistentBindingIterator.java   Source Code and 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 19
Project: OLD-OpenJDK8   File: TransientNamingContext.java   Source Code and License 6 votes vote down vote up
/**
 * 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 20
Project: OLD-OpenJDK8   File: PersistentBindingIterator.java   Source Code and 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 21
Project: JamVM-PH   File: ListBindingsEnumeration.java   Source Code and License 6 votes vote down vote up
/**
 * Convert from the CORBA binding into the javax.naming binding. As the CORBA
 * naming service binding does not contain the object itself, this method
 * makes the additional calls to the naming service.
 * 
 * @param binding
 *          the binding to convert
 * @return the value, that must be returned by the {@link #next()}.
 */
public Object convert(Binding binding)
{
  CPStringBuilder name = new CPStringBuilder();

  for (int i = 0; i < binding.binding_name.length; i++)
    {
      name.append(binding.binding_name[i]);
      if (i < binding.binding_name.length - 1)
        name.append('/');
    }
  
  try
    {
      Object object = service.resolve(binding.binding_name);
      return new javax.naming.Binding(name.toString(), object);
    }
  catch (Exception e)
    {
      // Probably was removed by the concurent thread.
      return null;
    }
}
 
Example 22
Project: JamVM-PH   File: Binding_iterator_impl.java   Source Code and License 6 votes vote down vote up
/**
 * Return the desired amount of bindings.
 *
 * @param amount the maximal number of bindings to return.
 * @param a_list a holder to store the returned bindings.
 *
 * @return false if there are no more bindings available,
 * true otherwise.
 */
public boolean next_n(int amount, BindingListHolder a_list)
{
  if (p < bindings.length)
    {
      int n = bindings.length - p;
      if (n > amount)
        n = amount;

      a_list.value = new Binding[ n ];
      for (int i = 0; i < n; i++)
        a_list.value [ i ] = bindings [ p++ ];

      return true;
    }
  else
    {
      a_list.value = new Binding[ 0 ];
      return false;
    }
}
 
Example 23
Project: openjdk-orb   File: TransientNamingContext.java   Source Code and License 6 votes vote down vote up
/**
 * 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 24
Project: openjdk-orb   File: PersistentBindingIterator.java   Source Code and 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 25
Project: classpath   File: ListBindingsEnumeration.java   Source Code and License 6 votes vote down vote up
/**
 * Convert from the CORBA binding into the javax.naming binding. As the CORBA
 * naming service binding does not contain the object itself, this method
 * makes the additional calls to the naming service.
 *
 * @param binding
 *          the binding to convert
 * @return the value, that must be returned by the {@link #next()}.
 */
public Object convert(Binding binding)
{
  CPStringBuilder name = new CPStringBuilder();

  for (int i = 0; i < binding.binding_name.length; i++)
    {
      name.append(binding.binding_name[i]);
      if (i < binding.binding_name.length - 1)
        name.append('/');
    }

  try
    {
      Object object = service.resolve(binding.binding_name);
      return new javax.naming.Binding(name.toString(), object);
    }
  catch (Exception e)
    {
      // Probably was removed by the concurent thread.
      return null;
    }
}
 
Example 26
Project: classpath   File: Binding_iterator_impl.java   Source Code and License 6 votes vote down vote up
/**
 * Return the desired amount of bindings.
 *
 * @param amount the maximal number of bindings to return.
 * @param a_list a holder to store the returned bindings.
 *
 * @return false if there are no more bindings available,
 * true otherwise.
 */
public boolean next_n(int amount, BindingListHolder a_list)
{
  if (p < bindings.length)
    {
      int n = bindings.length - p;
      if (n > amount)
        n = amount;

      a_list.value = new Binding[ n ];
      for (int i = 0; i < n; i++)
        a_list.value [ i ] = bindings [ p++ ];

      return true;
    }
  else
    {
      a_list.value = new Binding[ 0 ];
      return false;
    }
}
 
Example 27
Project: openjdk-icedtea7   File: TransientNamingContext.java   Source Code and License 6 votes vote down vote up
/**
 * 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 28
Project: openjdk-icedtea7   File: PersistentBindingIterator.java   Source Code and 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 29
Project: OpenJSharp   File: BindingIteratorImpl.java   Source Code and License 5 votes vote down vote up
/**
 * lists next n bindings. It returns true or false, indicating
 * whether there were more bindings. This method has the package private
 * scope, It will be called from NamingContext.list() operation or
 * this.next_n().
 * @param how_many The number of requested bindings in the BindingList.
 * @param bl The BindingList as an out parameter.
 * @return true if there were more bindings.
 */
public boolean list( int how_many, org.omg.CosNaming.BindingListHolder blh)
{
    // Take the smallest of what's left and what's being asked for
    int numberToGet = Math.min(RemainingElements(),how_many);

    // Create a resulting BindingList
    Binding[] bl = new Binding[numberToGet];
    BindingHolder bh = new BindingHolder();
    int i = 0;
    // Keep iterating as long as there are entries
    while (i < numberToGet && this.NextOne(bh) == true) {
        bl[i] = bh.value;
        i++;
    }
    // Found any at all?
    if (i == 0) {
        // No
        blh.value = new Binding[0];
        return false;
    }

    // Set into holder
    blh.value = bl;

    return true;
}
 
Example 30
Project: OpenJSharp   File: TransientBindingIterator.java   Source Code and 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 31
Project: openjdk-jdk10   File: BindingIteratorImpl.java   Source Code and License 5 votes vote down vote up
/**
 * lists next n bindings. It returns true or false, indicating
 * whether there were more bindings. This method has the package private
 * scope, It will be called from NamingContext.list() operation or
 * this.next_n().
 * @param how_many The number of requested bindings in the BindingList.
 * @param blh The BindingList as an out parameter.
 * @return true if there were more bindings.
 */
public boolean list( int how_many, org.omg.CosNaming.BindingListHolder blh)
{
    // Take the smallest of what's left and what's being asked for
    int numberToGet = Math.min(RemainingElements(),how_many);

    // Create a resulting BindingList
    Binding[] bl = new Binding[numberToGet];
    BindingHolder bh = new BindingHolder();
    int i = 0;
    // Keep iterating as long as there are entries
    while (i < numberToGet && this.NextOne(bh) == true) {
        bl[i] = bh.value;
        i++;
    }
    // Found any at all?
    if (i == 0) {
        // No
        blh.value = new Binding[0];
        return false;
    }

    // Set into holder
    blh.value = bl;

    return true;
}
 
Example 32
Project: openjdk-jdk10   File: TransientBindingIterator.java   Source Code and 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 33
Project: openjdk9   File: BindingIteratorImpl.java   Source Code and License 5 votes vote down vote up
/**
 * lists next n bindings. It returns true or false, indicating
 * whether there were more bindings. This method has the package private
 * scope, It will be called from NamingContext.list() operation or
 * this.next_n().
 * @param how_many The number of requested bindings in the BindingList.
 * @param blh The BindingList as an out parameter.
 * @return true if there were more bindings.
 */
public boolean list( int how_many, org.omg.CosNaming.BindingListHolder blh)
{
    // Take the smallest of what's left and what's being asked for
    int numberToGet = Math.min(RemainingElements(),how_many);

    // Create a resulting BindingList
    Binding[] bl = new Binding[numberToGet];
    BindingHolder bh = new BindingHolder();
    int i = 0;
    // Keep iterating as long as there are entries
    while (i < numberToGet && this.NextOne(bh) == true) {
        bl[i] = bh.value;
        i++;
    }
    // Found any at all?
    if (i == 0) {
        // No
        blh.value = new Binding[0];
        return false;
    }

    // Set into holder
    blh.value = bl;

    return true;
}
 
Example 34
Project: openjdk9   File: TransientBindingIterator.java   Source Code and 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 35
Project: lookaside_java-1.8.0-openjdk   File: BindingIteratorImpl.java   Source Code and License 5 votes vote down vote up
/**
 * lists next n bindings. It returns true or false, indicating
 * whether there were more bindings. This method has the package private
 * scope, It will be called from NamingContext.list() operation or
 * this.next_n().
 * @param how_many The number of requested bindings in the BindingList.
 * @param bl The BindingList as an out parameter.
 * @return true if there were more bindings.
 */
public boolean list( int how_many, org.omg.CosNaming.BindingListHolder blh)
{
    // Take the smallest of what's left and what's being asked for
    int numberToGet = Math.min(RemainingElements(),how_many);

    // Create a resulting BindingList
    Binding[] bl = new Binding[numberToGet];
    BindingHolder bh = new BindingHolder();
    int i = 0;
    // Keep iterating as long as there are entries
    while (i < numberToGet && this.NextOne(bh) == true) {
        bl[i] = bh.value;
        i++;
    }
    // Found any at all?
    if (i == 0) {
        // No
        blh.value = new Binding[0];
        return false;
    }

    // Set into holder
    blh.value = bl;

    return true;
}
 
Example 36
Project: lookaside_java-1.8.0-openjdk   File: TransientBindingIterator.java   Source Code and 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 37
Project: jdk8u_corba   File: BindingIteratorImpl.java   Source Code and License 5 votes vote down vote up
/**
 * lists next n bindings. It returns true or false, indicating
 * whether there were more bindings. This method has the package private
 * scope, It will be called from NamingContext.list() operation or
 * this.next_n().
 * @param how_many The number of requested bindings in the BindingList.
 * @param bl The BindingList as an out parameter.
 * @return true if there were more bindings.
 */
public boolean list( int how_many, org.omg.CosNaming.BindingListHolder blh)
{
    // Take the smallest of what's left and what's being asked for
    int numberToGet = Math.min(RemainingElements(),how_many);

    // Create a resulting BindingList
    Binding[] bl = new Binding[numberToGet];
    BindingHolder bh = new BindingHolder();
    int i = 0;
    // Keep iterating as long as there are entries
    while (i < numberToGet && this.NextOne(bh) == true) {
        bl[i] = bh.value;
        i++;
    }
    // Found any at all?
    if (i == 0) {
        // No
        blh.value = new Binding[0];
        return false;
    }

    // Set into holder
    blh.value = bl;

    return true;
}
 
Example 38
Project: jdk8u_corba   File: TransientBindingIterator.java   Source Code and 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 39
Project: javify   File: ListEnumeration.java   Source Code and License 5 votes vote down vote up
/**
 * Convert from the CORBA binding into the {@link NameClassPair} that this
 * enumeration should return. This method converts into NameClassPair,
 * connecting the name components with slashes and setting the class name
 * to either NamingContext or GIOP Object.
 *
 * @param binding
 *          the binding to convert
 * @return the value, that must be returned by the {@link #next()}.
 */
public Object convert(Binding binding)
{
  CPStringBuilder name = new CPStringBuilder();

  for (int i = 0; i < binding.binding_name.length; i++)
    {
      name.append(binding.binding_name[i]);
      if (i < binding.binding_name.length - 1)
        name.append('/');
    }

  String className;

  switch (binding.binding_type.value())
    {
    case BindingType._ncontext:
      className = NamingContext.class.getName();
      break;
    case BindingType._nobject:
      className = org.omg.CORBA.Object.class.getName();
      break;
    default:
      className = Object.class.getName();
      break;
    }

  NameClassPair pair = new NameClassPair(name.toString(), className);
  return pair;
}
 
Example 40
Project: javify   File: TransientContext.java   Source Code and License 5 votes vote down vote up
/**
 * Iterate over all bindings, defined in this namind context.
 *
 * @param amount the maximal number of context to return in the
 * holder a_list. The remaining bindings are accessible via iterator
 * an_iter. If the parameter amount is zero, all bindings are accessed only
 * via this iterator.
 *
 * This implementation list contexts first, then objects.
 *
 * @param a_list the holder, where the returned bindigs are stored.
 * @param an_iter the iterator that can be used to access the remaining
 * bindings.
 */
public void list(int amount, BindingListHolder a_list,
                 BindingIteratorHolder an_iter
                )
{
  int nb = named_contexts.size() + named_objects.size();
  int nl = nb;
  if (nl > amount)
    nl = amount;

  a_list.value = new Binding[ nl ];

  Iterator contexts = named_contexts.entries().iterator();
  Iterator objects = named_objects.entries().iterator();

  // Create a binding list.
  for (int i = 0; i < nl; i++)
    {
      if (contexts.hasNext())
        a_list.value [ i ] = mkBinding(contexts.next(), BindingType.ncontext);
      else if (objects.hasNext())
        a_list.value [ i ] = mkBinding(objects.next(), BindingType.nobject);
      else
        throw new InternalError();
    }

  // Create an iterator.
  Binding[] remainder = new Binding[ nb - nl ];
  int p = 0;

  while (contexts.hasNext())
    remainder [ p++ ] = mkBinding(contexts.next(), BindingType.ncontext);

  while (objects.hasNext())
    remainder [ p++ ] = mkBinding(objects.next(), BindingType.nobject);

  Binding_iterator_impl bit = new Binding_iterator_impl(remainder);
  _orb().connect(bit);
  an_iter.value = bit;
}
 
Example 41
Project: javify   File: TransientContext.java   Source Code and License 5 votes vote down vote up
/**
 * Create a binding.
 *
 * @param an_entry the entry, defining the bound object.
 * @param type the binding type.
 * @return the created binding.
 */
private Binding mkBinding(java.lang.Object an_entry, BindingType type)
{
  Map.Entry entry = (Map.Entry) an_entry;
  Binding b = new Binding();

  // The name component has always only one node (the current context)
  b.binding_name = new NameComponent[] { (NameComponent) entry.getKey() };
  b.binding_type = type;
  return b;
}
 
Example 42
Project: javify   File: Binding_iterator_impl.java   Source Code and License 5 votes vote down vote up
/**
 * Return the next binding.
 *
 * @param a_binding a holder, where the next binding will be stored.
 *
 * @return false if there are no more bindings available, true
 * otherwise.
 */
public boolean next_one(BindingHolder a_binding)
{
  if (p < bindings.length)
    {
      a_binding.value = (Binding) bindings [ p++ ];
      return true;
    }
  else
    {
      a_binding.value = no_more_bindings;
      return false;
    }
}
 
Example 43
Project: jvm-stm   File: ListEnumeration.java   Source Code and License 5 votes vote down vote up
/**
 * Convert from the CORBA binding into the {@link NameClassPair} that this
 * enumeration should return. This method converts into NameClassPair,
 * connecting the name components with slashes and setting the class name
 * to either NamingContext or GIOP Object.
 * 
 * @param binding
 *          the binding to convert
 * @return the value, that must be returned by the {@link #next()}.
 */
public Object convert(Binding binding)
{
  CPStringBuilder name = new CPStringBuilder();

  for (int i = 0; i < binding.binding_name.length; i++)
    {
      name.append(binding.binding_name[i]);
      if (i < binding.binding_name.length - 1)
        name.append('/');
    }

  String className;

  switch (binding.binding_type.value())
    {
    case BindingType._ncontext:
      className = NamingContext.class.getName();
      break;
    case BindingType._nobject:
      className = org.omg.CORBA.Object.class.getName();
      break;
    default:
      className = Object.class.getName();
      break;
    }

  NameClassPair pair = new NameClassPair(name.toString(), className);
  return pair;
}
 
Example 44
Project: jvm-stm   File: TransientContext.java   Source Code and License 5 votes vote down vote up
/**
 * Iterate over all bindings, defined in this namind context.
 *
 * @param amount the maximal number of context to return in the
 * holder a_list. The remaining bindings are accessible via iterator
 * an_iter. If the parameter amount is zero, all bindings are accessed only
 * via this iterator.
 *
 * This implementation list contexts first, then objects.
 *
 * @param a_list the holder, where the returned bindigs are stored.
 * @param an_iter the iterator that can be used to access the remaining
 * bindings.
 */
public void list(int amount, BindingListHolder a_list,
                 BindingIteratorHolder an_iter
                )
{
  int nb = named_contexts.size() + named_objects.size();
  int nl = nb;
  if (nl > amount)
    nl = amount;

  a_list.value = new Binding[ nl ];

  Iterator contexts = named_contexts.entries().iterator();
  Iterator objects = named_objects.entries().iterator();

  // Create a binding list.
  for (int i = 0; i < nl; i++)
    {
      if (contexts.hasNext())
        a_list.value [ i ] = mkBinding(contexts.next(), BindingType.ncontext);
      else if (objects.hasNext())
        a_list.value [ i ] = mkBinding(objects.next(), BindingType.nobject);
      else
        throw new InternalError();
    }

  // Create an iterator.
  Binding[] remainder = new Binding[ nb - nl ];
  int p = 0;

  while (contexts.hasNext())
    remainder [ p++ ] = mkBinding(contexts.next(), BindingType.ncontext);

  while (objects.hasNext())
    remainder [ p++ ] = mkBinding(objects.next(), BindingType.nobject);

  Binding_iterator_impl bit = new Binding_iterator_impl(remainder);
  _orb().connect(bit);
  an_iter.value = bit;
}
 
Example 45
Project: jvm-stm   File: TransientContext.java   Source Code and License 5 votes vote down vote up
/**
 * Create a binding.
 *
 * @param an_entry the entry, defining the bound object.
 * @param type the binding type.
 * @return the created binding.
 */
private Binding mkBinding(java.lang.Object an_entry, BindingType type)
{
  Map.Entry entry = (Map.Entry) an_entry;
  Binding b = new Binding();

  // The name component has always only one node (the current context)
  b.binding_name = new NameComponent[] { (NameComponent) entry.getKey() };
  b.binding_type = type;
  return b;
}
 
Example 46
Project: jvm-stm   File: Binding_iterator_impl.java   Source Code and License 5 votes vote down vote up
/**
 * Return the next binding.
 *
 * @param a_binding a holder, where the next binding will be stored.
 *
 * @return false if there are no more bindings available, true
 * otherwise.
 */
public boolean next_one(BindingHolder a_binding)
{
  if (p < bindings.length)
    {
      a_binding.value = (Binding) bindings [ p++ ];
      return true;
    }
  else
    {
      a_binding.value = no_more_bindings;
      return false;
    }
}
 
Example 47
Project: infobip-open-jdk-8   File: BindingIteratorImpl.java   Source Code and License 5 votes vote down vote up
/**
 * lists next n bindings. It returns true or false, indicating
 * whether there were more bindings. This method has the package private
 * scope, It will be called from NamingContext.list() operation or
 * this.next_n().
 * @param how_many The number of requested bindings in the BindingList.
 * @param bl The BindingList as an out parameter.
 * @return true if there were more bindings.
 */
public boolean list( int how_many, org.omg.CosNaming.BindingListHolder blh)
{
    // Take the smallest of what's left and what's being asked for
    int numberToGet = Math.min(RemainingElements(),how_many);

    // Create a resulting BindingList
    Binding[] bl = new Binding[numberToGet];
    BindingHolder bh = new BindingHolder();
    int i = 0;
    // Keep iterating as long as there are entries
    while (i < numberToGet && this.NextOne(bh) == true) {
        bl[i] = bh.value;
        i++;
    }
    // Found any at all?
    if (i == 0) {
        // No
        blh.value = new Binding[0];
        return false;
    }

    // Set into holder
    blh.value = bl;

    return true;
}
 
Example 48
Project: infobip-open-jdk-8   File: TransientBindingIterator.java   Source Code and 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 49
Project: openjdk-source-code-learn   File: BindingIteratorImpl.java   Source Code and License 5 votes vote down vote up
/**
 * lists next n bindings. It returns true or false, indicating
 * whether there were more bindings. This method has the package private
 * scope, It will be called from NamingContext.list() operation or
 * this.next_n().
 * @param how_many The number of requested bindings in the BindingList.
 * @param bl The BindingList as an out parameter.
 * @return true if there were more bindings.
 */
public boolean list( int how_many, org.omg.CosNaming.BindingListHolder blh)
{
    // Take the smallest of what's left and what's being asked for
    int numberToGet = Math.min(RemainingElements(),how_many);

    // Create a resulting BindingList
    Binding[] bl = new Binding[numberToGet];
    BindingHolder bh = new BindingHolder();
    int i = 0;
    // Keep iterating as long as there are entries
    while (i < numberToGet && this.NextOne(bh) == true) {
        bl[i] = bh.value;
        i++;
    }
    // Found any at all?
    if (i == 0) {
        // No
        blh.value = new Binding[0];
        return false;
    }

    // Set into holder
    blh.value = bl;

    return true;
}
 
Example 50
Project: openjdk-source-code-learn   File: TransientBindingIterator.java   Source Code and 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 51
Project: OLD-OpenJDK8   File: BindingIteratorImpl.java   Source Code and License 5 votes vote down vote up
/**
 * lists next n bindings. It returns true or false, indicating
 * whether there were more bindings. This method has the package private
 * scope, It will be called from NamingContext.list() operation or
 * this.next_n().
 * @param how_many The number of requested bindings in the BindingList.
 * @param bl The BindingList as an out parameter.
 * @return true if there were more bindings.
 */
public boolean list( int how_many, org.omg.CosNaming.BindingListHolder blh)
{
    // Take the smallest of what's left and what's being asked for
    int numberToGet = Math.min(RemainingElements(),how_many);

    // Create a resulting BindingList
    Binding[] bl = new Binding[numberToGet];
    BindingHolder bh = new BindingHolder();
    int i = 0;
    // Keep iterating as long as there are entries
    while (i < numberToGet && this.NextOne(bh) == true) {
        bl[i] = bh.value;
        i++;
    }
    // Found any at all?
    if (i == 0) {
        // No
        blh.value = new Binding[0];
        return false;
    }

    // Set into holder
    blh.value = bl;

    return true;
}
 
Example 52
Project: OLD-OpenJDK8   File: TransientBindingIterator.java   Source Code and 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 53
Project: JamVM-PH   File: ListEnumeration.java   Source Code and License 5 votes vote down vote up
/**
 * Convert from the CORBA binding into the {@link NameClassPair} that this
 * enumeration should return. This method converts into NameClassPair,
 * connecting the name components with slashes and setting the class name
 * to either NamingContext or GIOP Object.
 * 
 * @param binding
 *          the binding to convert
 * @return the value, that must be returned by the {@link #next()}.
 */
public Object convert(Binding binding)
{
  CPStringBuilder name = new CPStringBuilder();

  for (int i = 0; i < binding.binding_name.length; i++)
    {
      name.append(binding.binding_name[i]);
      if (i < binding.binding_name.length - 1)
        name.append('/');
    }

  String className;

  switch (binding.binding_type.value())
    {
    case BindingType._ncontext:
      className = NamingContext.class.getName();
      break;
    case BindingType._nobject:
      className = org.omg.CORBA.Object.class.getName();
      break;
    default:
      className = Object.class.getName();
      break;
    }

  NameClassPair pair = new NameClassPair(name.toString(), className);
  return pair;
}
 
Example 54
Project: JamVM-PH   File: TransientContext.java   Source Code and License 5 votes vote down vote up
/**
 * Iterate over all bindings, defined in this namind context.
 *
 * @param amount the maximal number of context to return in the
 * holder a_list. The remaining bindings are accessible via iterator
 * an_iter. If the parameter amount is zero, all bindings are accessed only
 * via this iterator.
 *
 * This implementation list contexts first, then objects.
 *
 * @param a_list the holder, where the returned bindigs are stored.
 * @param an_iter the iterator that can be used to access the remaining
 * bindings.
 */
public void list(int amount, BindingListHolder a_list,
                 BindingIteratorHolder an_iter
                )
{
  int nb = named_contexts.size() + named_objects.size();
  int nl = nb;
  if (nl > amount)
    nl = amount;

  a_list.value = new Binding[ nl ];

  Iterator contexts = named_contexts.entries().iterator();
  Iterator objects = named_objects.entries().iterator();

  // Create a binding list.
  for (int i = 0; i < nl; i++)
    {
      if (contexts.hasNext())
        a_list.value [ i ] = mkBinding(contexts.next(), BindingType.ncontext);
      else if (objects.hasNext())
        a_list.value [ i ] = mkBinding(objects.next(), BindingType.nobject);
      else
        throw new InternalError();
    }

  // Create an iterator.
  Binding[] remainder = new Binding[ nb - nl ];
  int p = 0;

  while (contexts.hasNext())
    remainder [ p++ ] = mkBinding(contexts.next(), BindingType.ncontext);

  while (objects.hasNext())
    remainder [ p++ ] = mkBinding(objects.next(), BindingType.nobject);

  Binding_iterator_impl bit = new Binding_iterator_impl(remainder);
  _orb().connect(bit);
  an_iter.value = bit;
}
 
Example 55
Project: JamVM-PH   File: TransientContext.java   Source Code and License 5 votes vote down vote up
/**
 * Create a binding.
 *
 * @param an_entry the entry, defining the bound object.
 * @param type the binding type.
 * @return the created binding.
 */
private Binding mkBinding(java.lang.Object an_entry, BindingType type)
{
  Map.Entry entry = (Map.Entry) an_entry;
  Binding b = new Binding();

  // The name component has always only one node (the current context)
  b.binding_name = new NameComponent[] { (NameComponent) entry.getKey() };
  b.binding_type = type;
  return b;
}
 
Example 56
Project: JamVM-PH   File: Binding_iterator_impl.java   Source Code and License 5 votes vote down vote up
/**
 * Return the next binding.
 *
 * @param a_binding a holder, where the next binding will be stored.
 *
 * @return false if there are no more bindings available, true
 * otherwise.
 */
public boolean next_one(BindingHolder a_binding)
{
  if (p < bindings.length)
    {
      a_binding.value = (Binding) bindings [ p++ ];
      return true;
    }
  else
    {
      a_binding.value = no_more_bindings;
      return false;
    }
}
 
Example 57
Project: openjdk-orb   File: BindingIteratorImpl.java   Source Code and License 5 votes vote down vote up
/**
 * lists next n bindings. It returns true or false, indicating
 * whether there were more bindings. This method has the package private
 * scope, It will be called from NamingContext.list() operation or
 * this.next_n().
 * @param how_many The number of requested bindings in the BindingList.
 * @param bl The BindingList as an out parameter.
 * @return true if there were more bindings.
 */
public boolean list( int how_many, org.omg.CosNaming.BindingListHolder blh)
{
    // Take the smallest of what's left and what's being asked for
    int numberToGet = Math.min(RemainingElements(),how_many);

    // Create a resulting BindingList
    Binding[] bl = new Binding[numberToGet];
    BindingHolder bh = new BindingHolder();
    int i = 0;
    // Keep iterating as long as there are entries
    while (i < numberToGet && this.NextOne(bh) == true) {
        bl[i] = bh.value;
        i++;
    }
    // Found any at all?
    if (i == 0) {
        // No
        blh.value = new Binding[0];
        return false;
    }

    // Set into holder
    blh.value = bl;

    return true;
}
 
Example 58
Project: openjdk-orb   File: TransientBindingIterator.java   Source Code and 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 59
Project: classpath   File: ListEnumeration.java   Source Code and License 5 votes vote down vote up
/**
 * Convert from the CORBA binding into the {@link NameClassPair} that this
 * enumeration should return. This method converts into NameClassPair,
 * connecting the name components with slashes and setting the class name
 * to either NamingContext or GIOP Object.
 *
 * @param binding
 *          the binding to convert
 * @return the value, that must be returned by the {@link #next()}.
 */
public Object convert(Binding binding)
{
  CPStringBuilder name = new CPStringBuilder();

  for (int i = 0; i < binding.binding_name.length; i++)
    {
      name.append(binding.binding_name[i]);
      if (i < binding.binding_name.length - 1)
        name.append('/');
    }

  String className;

  switch (binding.binding_type.value())
    {
    case BindingType._ncontext:
      className = NamingContext.class.getName();
      break;
    case BindingType._nobject:
      className = org.omg.CORBA.Object.class.getName();
      break;
    default:
      className = Object.class.getName();
      break;
    }

  NameClassPair pair = new NameClassPair(name.toString(), className);
  return pair;
}
 
Example 60
Project: classpath   File: TransientContext.java   Source Code and License 5 votes vote down vote up
/**
 * Iterate over all bindings, defined in this namind context.
 *
 * @param amount the maximal number of context to return in the
 * holder a_list. The remaining bindings are accessible via iterator
 * an_iter. If the parameter amount is zero, all bindings are accessed only
 * via this iterator.
 *
 * This implementation list contexts first, then objects.
 *
 * @param a_list the holder, where the returned bindigs are stored.
 * @param an_iter the iterator that can be used to access the remaining
 * bindings.
 */
public void list(int amount, BindingListHolder a_list,
                 BindingIteratorHolder an_iter
                )
{
  int nb = named_contexts.size() + named_objects.size();
  int nl = nb;
  if (nl > amount)
    nl = amount;

  a_list.value = new Binding[ nl ];

  Iterator contexts = named_contexts.entries().iterator();
  Iterator objects = named_objects.entries().iterator();

  // Create a binding list.
  for (int i = 0; i < nl; i++)
    {
      if (contexts.hasNext())
        a_list.value [ i ] = mkBinding(contexts.next(), BindingType.ncontext);
      else if (objects.hasNext())
        a_list.value [ i ] = mkBinding(objects.next(), BindingType.nobject);
      else
        throw new InternalError();
    }

  // Create an iterator.
  Binding[] remainder = new Binding[ nb - nl ];
  int p = 0;

  while (contexts.hasNext())
    remainder [ p++ ] = mkBinding(contexts.next(), BindingType.ncontext);

  while (objects.hasNext())
    remainder [ p++ ] = mkBinding(objects.next(), BindingType.nobject);

  Binding_iterator_impl bit = new Binding_iterator_impl(remainder);
  _orb().connect(bit);
  an_iter.value = bit;
}