Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CAMEL-20148: Discover resources on classpath
Browse files Browse the repository at this point in the history
Croway committed Nov 30, 2023
1 parent 751e02c commit c2413d2
Showing 2 changed files with 34 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -18,11 +18,17 @@

import org.apache.camel.impl.engine.DefaultPackageScanResourceResolver;
import org.apache.camel.util.IOHelper;
import org.apache.camel.util.StringHelper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.net.URLDecoder;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
import java.util.jar.JarEntry;
@@ -82,6 +88,33 @@ protected List<String> doLoadImplementationsInJar(String packageName, InputStrea
return entries;
}

protected String parseUrlPath(URL url) {
String urlPath = url.getFile();
urlPath = URLDecoder.decode(urlPath, StandardCharsets.UTF_8);
if (LOG.isTraceEnabled()) {
LOG.trace("Decoded urlPath: {} with protocol: {}", urlPath, url.getProtocol());
}

String nested = "nested:";

if (urlPath.startsWith(nested)) {
try {
urlPath = (new URI(url.getFile())).getPath();

return StringHelper.before(urlPath, "!", urlPath);
} catch (URISyntaxException var4) {
}

if (urlPath.startsWith(nested)) {
urlPath = urlPath.substring(nested.length());

return StringHelper.before(urlPath, "!", urlPath);
}
}

return super.parseUrlPath(url);
}

private boolean isSpringBootNestedJar(String name) {
// Supporting both versions of the packaging model
return name.endsWith(".jar") && (name.startsWith(SPRING_BOOT_CLASSIC_LIB_ROOT) || name.startsWith(SPRING_BOOT_BOOT_INF_LIB_ROOT) || name.startsWith(SPRING_BOOT_WEB_INF_LIB_ROOT));
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Manifest-Version: 1.0
Main-Class: org.springframework.boot.loader.JarLauncher
Main-Class: org.springframework.boot.loader.launch.JarLauncher
Start-Class: org.apache.camel.itest.springboot.ITestApplication

0 comments on commit c2413d2

Please sign in to comment.