Ejemplo n.º 1
0
  /**
   * Constructs a JNDI Binding object from the COS Naming binding object.
   *
   * @exception NameNotFound No objects under the name.
   * @exception CannotProceed Unable to obtain a continuation context
   * @exception InvalidName Name not understood.
   * @exception NamingException One of the above.
   */
  private javax.naming.Binding mapBinding(org.omg.CosNaming.Binding bndg) throws NamingException {
    java.lang.Object obj = _ctx.callResolve(bndg.binding_name);

    Name cname = CNNameParser.cosNameToName(bndg.binding_name);

    try {
      obj = NamingManager.getObjectInstance(obj, cname, _ctx, _env);
    } catch (NamingException e) {
      throw e;
    } catch (Exception e) {
      NamingException ne = new NamingException("problem generating object using object factory");
      ne.setRootCause(e);
      throw ne;
    }

    // Use cname.toString() instead of bindingName because the name
    // in the binding should be a composite name
    String cnameStr = cname.toString();
    javax.naming.Binding jbndg = new javax.naming.Binding(cnameStr, obj);

    NameComponent[] comps = _ctx.makeFullName(bndg.binding_name);
    String fullName = CNNameParser.cosNameToInsString(comps);
    jbndg.setNameInNamespace(fullName);
    return jbndg;
  }
Ejemplo n.º 2
0
  /**
   * Creates a CNBindingEnumeration object.
   *
   * @param ctx Context to enumerate
   */
  CNBindingEnumeration(CNCtx ctx, boolean isLookedUpCtx, Hashtable env) {
    // Get batch size to use
    String batch = (env != null ? (String) env.get(javax.naming.Context.BATCHSIZE) : null);
    if (batch != null) {
      try {
        batchsize = Integer.parseInt(batch);
      } catch (NumberFormatException e) {
        throw new IllegalArgumentException("Batch size not numeric: " + batch);
      }
    }
    _ctx = ctx;
    _ctx.incEnumCount();
    this.isLookedUpCtx = isLookedUpCtx;
    _env = env;
    _bindingList = new BindingListHolder();
    BindingIteratorHolder _bindingIterH = new BindingIteratorHolder();

    // Perform listing and request that bindings be returned in _bindingIter
    // Upon return,_bindingList returns a zero length list
    _ctx._nc.list(0, _bindingList, _bindingIterH);

    _bindingIter = _bindingIterH.value;

    // Get first batch using _bindingIter
    if (_bindingIter != null) {
      more = _bindingIter.next_n(batchsize, _bindingList);
    } else {
      more = false;
    }
    counter = 0;
  }
Ejemplo n.º 3
0
  public void close() throws NamingException {
    more = false;
    if (_bindingIter != null) {
      _bindingIter.destroy();
      _bindingIter = null;
    }
    if (_ctx != null) {
      _ctx.decEnumCount();

      /**
       * context was obtained by CNCtx, the user doesn't have a handle to it, close it as we are
       * done enumerating through the context
       */
      if (isLookedUpCtx) {
        _ctx.close();
      }
      _ctx = null;
    }
  }