use of org.hotswap.agent.util.spring.io.resource.UrlResource in project HotswapAgent by HotswapProjects.
the class PathMatchingResourcePatternResolver method resolveRootDirResource.
/**
* Resolve the specified resource for path matching.
* <p>
* The default implementation detects an Equinox OSGi "bundleresource:" /
* "bundleentry:" URL and resolves it into a standard jar file URL that can
* be traversed using Spring's standard jar file traversal algorithm.
*
* @param original
* the resource to resolve
* @return the resolved resource (may be identical to the passed-in
* resource)
* @throws IOException
* in case of resolution failure
*/
protected Resource resolveRootDirResource(Resource original) throws IOException {
URL url = original.getURL();
if (url != null && url.getProtocol().startsWith("bundle")) {
if (equinoxResolveMethod != null) {
return new UrlResource((URL) ReflectionUtils.invokeMethod(equinoxResolveMethod, null, url));
}
if (url.getProtocol().equals("bundle")) {
try {
// Try felix OSGi
Class<?> bundleWiringClass = ClassUtils.forName("org.apache.felix.framework.BundleWiringImpl", null);
URL convertedURL = (URL) ReflectionHelper.invoke(null, bundleWiringClass, "convertToLocalUrl", new Class[] { URL.class }, url);
return new UrlResource(convertedURL);
} catch (ClassNotFoundException e) {
logger.trace("org.apache.felix.framework.BundleWiringImpl class not found for {}", url);
} catch (Exception e) {
logger.error("Felix BundleWiring.convertToLocalUrl(URL) failed for URL {}", url, e);
}
}
}
return original;
}
Aggregations