|
|
@ -25,11 +25,10 @@ import java.io.IOException; |
|
|
|
import java.io.Reader; |
|
|
|
import java.io.Reader; |
|
|
|
import java.net.URISyntaxException; |
|
|
|
import java.net.URISyntaxException; |
|
|
|
import java.net.URL; |
|
|
|
import java.net.URL; |
|
|
|
import java.util.HashSet; |
|
|
|
import java.nio.charset.StandardCharsets; |
|
|
|
import java.util.LinkedHashMap; |
|
|
|
import java.nio.file.*; |
|
|
|
import java.util.List; |
|
|
|
import java.nio.file.attribute.BasicFileAttributes; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.*; |
|
|
|
import java.util.Set; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* The ServiceLoader base implementation for ExtensionFinder. |
|
|
|
* The ServiceLoader base implementation for ExtensionFinder. |
|
|
@ -50,18 +49,26 @@ public class ServiceProviderExtensionFinder extends AbstractExtensionFinder { |
|
|
|
log.debug("Reading extensions storages from classpath"); |
|
|
|
log.debug("Reading extensions storages from classpath"); |
|
|
|
Map<String, Set<String>> result = new LinkedHashMap<>(); |
|
|
|
Map<String, Set<String>> result = new LinkedHashMap<>(); |
|
|
|
|
|
|
|
|
|
|
|
Set<String> bucket = new HashSet<>(); |
|
|
|
final Set<String> bucket = new HashSet<>(); |
|
|
|
try { |
|
|
|
try { |
|
|
|
URL url = getClass().getClassLoader().getResource(getExtensionsResource()); |
|
|
|
URL url = getClass().getClassLoader().getResource(getExtensionsResource()); |
|
|
|
if (url != null) { |
|
|
|
if (url != null) { |
|
|
|
File[] files = new File(url.toURI()).listFiles(); |
|
|
|
Path extensionPath; |
|
|
|
if (files != null) { |
|
|
|
if (url.toURI().getScheme().equals("jar")) { |
|
|
|
for (File file : files) { |
|
|
|
FileSystem fileSystem = FileSystems.newFileSystem(url.toURI(), Collections.<String, Object>emptyMap()); |
|
|
|
|
|
|
|
extensionPath = fileSystem.getPath(getExtensionsResource()); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
extensionPath = Paths.get(url.toURI()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
Files.walkFileTree(extensionPath, Collections.<FileVisitOption>emptySet(), 1, new SimpleFileVisitor<Path>() { |
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { |
|
|
|
log.debug("Read '{}'", file); |
|
|
|
log.debug("Read '{}'", file); |
|
|
|
Reader reader = new FileReader(file); |
|
|
|
Reader reader = Files.newBufferedReader(file, StandardCharsets.UTF_8); |
|
|
|
ServiceProviderExtensionStorage.read(reader, bucket); |
|
|
|
ServiceProviderExtensionStorage.read(reader, bucket); |
|
|
|
|
|
|
|
return FileVisitResult.CONTINUE; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (bucket.isEmpty()) { |
|
|
|
if (bucket.isEmpty()) { |
|
|
|