Ejemplo n.º 1
0
 /**
  * Returns a Group by name.
  *
  * @param name The name of the group to retrieve
  * @return The group corresponding to that name
  * @throws GroupNotFoundException if the group does not exist.
  */
 public Group getGroup(String name) throws GroupNotFoundException {
   Group group = (Group) groupCache.get(name);
   // If ID wan't found in cache, load it up and put it there.
   if (group == null) {
     synchronized (name.intern()) {
       group = (Group) groupCache.get(name);
       // If ID wan't found in cache, load it up and put it there.
       if (group == null) {
         group = provider.getGroup(name);
         groupCache.put(name, group);
       }
     }
   }
   return group;
 }
Ejemplo n.º 2
0
 /**
  * Returns the roster for the given username.
  *
  * @param username the username to search for.
  * @return the roster associated with the ID.
  * @throws org.jivesoftware.messenger.user.UserNotFoundException if the ID does not correspond to
  *     a known entity on the server.
  */
 public Roster getRoster(String username) throws UserNotFoundException {
   if (rosterCache == null) {
     rosterCache = CacheManager.getCache("username2roster");
   }
   if (rosterCache == null) {
     throw new UserNotFoundException("Could not load caches");
   }
   Roster roster = (Roster) rosterCache.get(username);
   if (roster == null) {
     // Not in cache so load a new one:
     roster = new Roster(username);
     rosterCache.put(username, roster);
   }
   if (roster == null) {
     throw new UserNotFoundException(username);
   }
   return roster;
 }