public void addGroups(String[] newGroups) throws IOException {
  testArrayForNullElement(newGroups);
  checkGroups(newGroups);
synchronized (registrars) {
    if (terminated)     throw new IllegalStateException("discovery terminated");
    if (groups == null)     throw new UnsupportedOperationException("can't add to \"any groups\"");
    Collection req=new ArrayList(newGroups.length);
    for (int i=0; i < newGroups.length; i++) {
      if (groups.add(newGroups[i]))       req.add(newGroups[i]);
    }
    if (!req.isEmpty())     requestGroups(req);
  }
}

public void addGroups ( String [ ] newGroups ) throws IOException { testArrayForNullElement ( newGroups ) ; checkGroups ( newGroups ) ; synchronized ( registrars ) { if ( terminated ) throw new IllegalStateException ( "discovery terminated" ) ; if ( groups == null ) throw new UnsupportedOperationException ( "can't add to \"any groups\"" ) ; Collection req = new ArrayList ( newGroups . length ) ; for ( int i = 0 ; i < newGroups . length ; i ++ ) { if ( groups . add ( newGroups [ i ] ) ) req . add ( newGroups [ i ] ) ; } if ( ! req . isEmpty ( ) ) requestGroups ( req ) ; } }
add a set of groups to the set to be discovered . the caller must have discoverypermission for each group .
