1 5 package ve.luz.ica.jackass.daemon.group; 6 7 import java.util.Enumeration ; 8 import java.util.Hashtable ; 9 import java.util.Iterator ; 10 import java.util.Map ; 11 import java.util.Properties ; 12 13 import org.apache.commons.logging.Log; 14 import org.apache.commons.logging.LogFactory; 15 16 import ve.luz.ica.jackass.util.ConfigurationManager; 17 18 22 public final class GroupManager 23 { 24 private static Log log = LogFactory.getLog(GroupManager.class); 25 26 private static GroupManager manager = null; 27 private Map groups; 28 29 33 public static GroupManager getManager() 34 { 35 if (manager == null) 36 { 37 manager = new GroupManager(); 38 } 39 return manager; 40 } 41 42 46 private GroupManager() 47 { 48 groups = new Hashtable (); 49 Properties cf = ConfigurationManager.getConfigFile(); 50 Enumeration e = cf.propertyNames(); 51 while (e.hasMoreElements()) 52 { 53 String name = (String ) e.nextElement(); 54 if (name.startsWith("group.")) 55 { 56 String groupName = cf.getProperty(name); 57 if (log.isDebugEnabled()) 58 { 59 log.debug("Creating group "+name); 60 } 61 GroupNode gm = new GroupNode(groupName); 62 groups.put(groupName, gm); 63 } 64 } 65 66 } 67 68 73 public GroupNode getGroupMember(String name) 74 { 75 return (GroupNode) groups.get(name); 76 } 77 78 82 public Iterator getGroupNames() 83 { 84 return groups.keySet().iterator(); 85 } 86 } 87 | Popular Tags |