Skip to content

Commit

Permalink
Merge and resolve conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
cdfive committed Apr 23, 2019
2 parents db460b5 + ee1b5ab commit 7980c5c
Showing 1 changed file with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,13 @@ public static <T> T loadHighestPriorityInstance(Class<T> clazz) {
}

/**
<<<<<<< HEAD
* Load the SPI instance list for provided SPI interface.
=======
* Load and sorted SPI instance list
*
* Note: each call return new instances.
>>>>>>> ee1b5ab11ebf3ca740105a794c97c5195554546a
*
* @param clazz class of the SPI
* @param <T> SPI type
Expand All @@ -101,13 +107,8 @@ public static <T> T loadHighestPriorityInstance(Class<T> clazz) {
*/
public static <T> List<T> loadInstanceList(Class<T> clazz) {
try {
String key = clazz.getName();
// Not thread-safe, as it's expected to be resolved in a thread-safe context.
ServiceLoader<T> serviceLoader = SERVICE_LOADER_MAP.get(key);
if (serviceLoader == null) {
serviceLoader = ServiceLoader.load(clazz);
SERVICE_LOADER_MAP.put(key, serviceLoader);
}
// Call ServiceLoader.load(clazz) to get new instance
ServiceLoader<T> serviceLoader = ServiceLoader.load(clazz);

List<T> list = new ArrayList<>();
for (T spi : serviceLoader) {
Expand Down

0 comments on commit 7980c5c

Please sign in to comment.