Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,19 @@ public static Object probeResource(final Bundle origin, final String resourceNam
}
// not in the bundle, lets check for a direct import of the containing package
BundleWiring wiring = (BundleWiring) origin.adapt(BundleWiring.class);
List<BundleWire> importWires = wiring.getRequiredWires(PACKAGE_NAMESPACE);
if (null != importWires) {
int lastSlash = resourceName.lastIndexOf('/');
if (lastSlash > 0) {
String pkg = resourceName.substring(0, lastSlash).replace('/', '.');
for (BundleWire wire : importWires) {
if (pkg.equals(wire.getCapability().getAttributes().get(PACKAGE_NAMESPACE))) {
// class resource comes from a transitive import - to avoid cost of finding it, and
// because classloader matching/probing just checks existence, we return a resource
// we know exists to stand-in for the real resource
return origin.getEntry("META-INF/MANIFEST.MF");
if (null != wiring) {
List<BundleWire> importWires = wiring.getRequiredWires(PACKAGE_NAMESPACE);
if (null != importWires) {
int lastSlash = resourceName.lastIndexOf('/');
if (lastSlash > 0) {
String pkg = resourceName.substring(0, lastSlash).replace('/', '.');
for (BundleWire wire : importWires) {
if (pkg.equals(wire.getCapability().getAttributes().get(PACKAGE_NAMESPACE))) {
// class resource comes from a transitive import - to avoid cost of finding it, and
// because classloader matching/probing just checks existence, we return a resource
// we know exists to stand-in for the real resource
return origin.getEntry("META-INF/MANIFEST.MF");
}
}
}
}
Expand Down Expand Up @@ -86,16 +88,18 @@ private static <T> T searchDirectWires(
final BundleWiring origin,
final Function<BundleWiring, T> filter,
final Set<BundleRevision> visited) {
// track which bundles we've visited to avoid dependency cycles
visited.add(origin.getRevision());
List<BundleWire> wires = origin.getRequiredWires(null);
if (null != wires) {
for (BundleWire wire : wires) {
BundleWiring wiring = wire.getProviderWiring();
if (null != wiring && visited.add(wiring.getRevision())) {
T result = filter.apply(wiring);
if (null != result) {
return result;
if (null != origin) {
// track which bundles we've visited to avoid dependency cycles
visited.add(origin.getRevision());
List<BundleWire> wires = origin.getRequiredWires(null);
if (null != wires) {
for (BundleWire wire : wires) {
BundleWiring wiring = wire.getProviderWiring();
if (null != wiring && visited.add(wiring.getRevision())) {
T result = filter.apply(wiring);
if (null != result) {
return result;
}
}
}
}
Expand Down