示例#1
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;
  }
示例#2
0
 /** Get the next batch using _bindingIter. Update the 'more' field. */
 private boolean getMore() throws NamingException {
   try {
     more = _bindingIter.next_n(batchsize, _bindingList);
     counter = 0; // reset
   } catch (Exception e) {
     more = false;
     NamingException ne = new NamingException("Problem getting binding list");
     ne.setRootCause(e);
     throw ne;
   }
   return more;
 }
示例#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;
    }
  }