private Collection<JID> getGroupMembers(String groupName) {
    Cache<String, Collection<JID>> groupMembershipCache =
        CacheFactory.createLocalCache(GROUP_MEMBERSHIP_CACHE_NAME);
    Collection<JID> members = groupMembershipCache.get(groupName);
    if (members != null) {
      return members;
    }

    try {
      List<String> users = manager.getGroupMembers(groupName);
      Collection<JID> results = new ArrayList<JID>();

      for (String username : users) {
        results.add(server.createJID(username, null));
      }

      groupMembershipCache.put(groupName, results);
      return results;

    } catch (RemoteException re) {
      LOG.error("Failure to get the members of crowd group:" + String.valueOf(groupName), re);
    }

    groupMembershipCache.put(groupName, new ArrayList<JID>());
    return Collections.emptyList();
  }
  public CrowdGroupProvider() {
    String propertyValue = JiveGlobals.getProperty(JIVE_CROWD_GROUPS_CACHE_TTL_SECS);
    int ttl =
        (propertyValue == null || propertyValue.trim().length() == 0)
            ? CACHE_TTL
            : Integer.parseInt(propertyValue);

    Cache<String, Collection<JID>> groupMembershipCache =
        CacheFactory.createLocalCache(GROUP_MEMBERSHIP_CACHE_NAME);
    groupMembershipCache.setMaxCacheSize(-1);
    groupMembershipCache.setMaxLifetime(ttl * 1000); // msecs instead of sec - see Cache API

    Cache<JID, Collection<String>> userMembershipCache =
        CacheFactory.createLocalCache(USER_MEMBERSHIP_CACHE_NAME);
    userMembershipCache.setMaxCacheSize(-1);
    userMembershipCache.setMaxLifetime(ttl * 1000); // msecs instead of sec - see Cache API

    Cache<String, org.jivesoftware.openfire.crowd.jaxb.Group> groupCache =
        CacheFactory.createLocalCache(GROUP_CACHE_NAME);
    groupCache.setMaxCacheSize(-1);
    groupCache.setMaxLifetime(ttl * 1000); // msecs instead of sec - see Cache API
  }
  public Group getGroup(String name) throws GroupNotFoundException {
    try {
      Cache<String, org.jivesoftware.openfire.crowd.jaxb.Group> groupCache =
          CacheFactory.createLocalCache(GROUP_CACHE_NAME);
      org.jivesoftware.openfire.crowd.jaxb.Group group = groupCache.get(name);
      if (group == null) {
        group = manager.getGroup(name);
        groupCache.put(name, group);
      }
      Collection<JID> members = getGroupMembers(name);
      Collection<JID> admins = Collections.emptyList();
      return new Group(name, group.description, members, admins);

    } catch (RemoteException re) {
      LOG.error("Failure to load group:" + String.valueOf(name), re);
      throw new GroupNotFoundException(re);
    }
  }