1 19 20 package org.netbeans.modules.websvc.wsitconf.spi; 21 22 import java.util.Collections ; 23 import java.util.Comparator ; 24 import java.util.HashMap ; 25 import java.util.Map ; 26 import java.util.Set ; 27 import java.util.TreeSet ; 28 29 33 public class SecurityProfileRegistry { 34 35 private static SecurityProfileRegistry instance; 36 37 private Map <String , SecurityProfile> profiles = 38 Collections.synchronizedMap(new HashMap <String , SecurityProfile>()); 39 40 43 private SecurityProfileRegistry() {} 44 45 48 public static SecurityProfileRegistry getDefault(){ 49 if (instance == null) { 50 instance = new SecurityProfileRegistry(); 51 } 52 return instance; 53 } 54 55 58 public SecurityProfile getProfile(String displayName) { 59 return profiles.get(displayName); 60 } 61 62 65 public void register(SecurityProfile profile){ 66 profiles.put(profile.getDisplayName(), profile); 67 } 68 69 72 public void unregister(SecurityProfile profile){ 73 profiles.remove(profile.getDisplayName()); 74 } 75 76 public void unregister(String profile){ 77 profiles.remove(profile); 78 } 79 80 public Set <SecurityProfile> getSecurityProfiles() { 81 82 TreeSet <SecurityProfile> set = new TreeSet (new Comparator () { 83 public int compare(Object obj1, Object obj2) { 84 SecurityProfile p1 = (SecurityProfile)obj1; 85 SecurityProfile p2 = (SecurityProfile)obj2; 86 Integer i1 = p1.getId(); 87 Integer i2 = p2.getId(); 88 return i1.compareTo(i2); 89 } 90 }); 91 set.addAll(profiles.values()); 92 return Collections.synchronizedSortedSet(set); 93 } 94 95 } 96 | Popular Tags |