64 public String providerName() {
65 return providerName;
66 }
67
68 @Override
69 public int hashCode() {
70 return Objects.hash(module, providerName);
71 }
72
73 @Override
74 public boolean equals(Object ob) {
75 if (!(ob instanceof ServiceProvider))
76 return false;
77 ServiceProvider that = (ServiceProvider)ob;
78 return Objects.equals(this.module, that.module)
79 && Objects.equals(this.providerName, that.providerName);
80 }
81 }
82
83 // service name -> list of providers
84 private final Map<String, List<ServiceProvider>> map = new ConcurrentHashMap<>();
85
86 private ServicesCatalog() { }
87
88 /**
89 * Creates a ServicesCatalog that supports concurrent registration
90 * and lookup
91 */
92 public static ServicesCatalog create() {
93 return new ServicesCatalog();
94 }
95
96 /**
97 * Returns the list of service provides for the given service type
98 * name, creating it if needed.
99 */
100 private List<ServiceProvider> providers(String service) {
101 // avoid computeIfAbsent here
102 List<ServiceProvider> list = map.get(service);
103 if (list == null) {
104 list = new CopyOnWriteArrayList<>();
|
64 public String providerName() {
65 return providerName;
66 }
67
68 @Override
69 public int hashCode() {
70 return Objects.hash(module, providerName);
71 }
72
73 @Override
74 public boolean equals(Object ob) {
75 if (!(ob instanceof ServiceProvider))
76 return false;
77 ServiceProvider that = (ServiceProvider)ob;
78 return Objects.equals(this.module, that.module)
79 && Objects.equals(this.providerName, that.providerName);
80 }
81 }
82
83 // service name -> list of providers
84 private final Map<String, List<ServiceProvider>> map = new ConcurrentHashMap<>(32);
85
86 private ServicesCatalog() { }
87
88 /**
89 * Creates a ServicesCatalog that supports concurrent registration
90 * and lookup
91 */
92 public static ServicesCatalog create() {
93 return new ServicesCatalog();
94 }
95
96 /**
97 * Returns the list of service provides for the given service type
98 * name, creating it if needed.
99 */
100 private List<ServiceProvider> providers(String service) {
101 // avoid computeIfAbsent here
102 List<ServiceProvider> list = map.get(service);
103 if (list == null) {
104 list = new CopyOnWriteArrayList<>();
|