use of org.osgi.framework.wiring.BundleRequirement in project aries by apache.
the class HttpExtension method getAttributes.
private Map<String, Object> getAttributes() {
BundleWiring bundleWiring = _bundle.adapt(BundleWiring.class);
List<BundleWire> wires = bundleWiring.getRequiredWires(EXTENDER_NAMESPACE);
Map<String, Object> cdiAttributes = Collections.emptyMap();
for (BundleWire wire : wires) {
BundleCapability capability = wire.getCapability();
Map<String, Object> attributes = capability.getAttributes();
String extender = (String) attributes.get(EXTENDER_NAMESPACE);
if (extender.equals(CDI_CAPABILITY_NAME)) {
BundleRequirement requirement = wire.getRequirement();
cdiAttributes = requirement.getAttributes();
break;
}
}
return cdiAttributes;
}
use of org.osgi.framework.wiring.BundleRequirement in project karaf by apache.
the class BundleServiceImpl method getDiag.
@Override
public String getDiag(Bundle bundle) {
StringBuilder message = new StringBuilder();
for (BundleStateService bundleStateService : stateServices) {
String part = bundleStateService.getDiag(bundle);
if (part != null) {
message.append(bundleStateService.getName());
message.append("\n");
message.append(part);
}
}
if (bundle.getState() == Bundle.INSTALLED) {
System.out.println("Unsatisfied Requirements:");
List<BundleRequirement> reqs = getUnsatisfiedRequirements(bundle, null);
for (BundleRequirement req : reqs) {
System.out.println(req);
}
}
return message.toString();
}
use of org.osgi.framework.wiring.BundleRequirement in project karaf by apache.
the class Requirements method printMatchingRequirements.
private static boolean printMatchingRequirements(BundleWiring wiring, Pattern namespace) {
List<BundleWire> wires = wiring.getRequiredWires(null);
Map<BundleRequirement, List<BundleWire>> aggregateReqs = aggregateRequirements(namespace, wires);
List<BundleRequirement> allReqs = wiring.getRequirements(null);
boolean matches = false;
for (BundleRequirement req : allReqs) {
if (matchNamespace(namespace, req.getNamespace())) {
matches = true;
List<BundleWire> providers = aggregateReqs.get(req);
if (providers != null) {
System.out.println(req.getNamespace() + "; " + req.getDirectives().get(Constants.FILTER_DIRECTIVE) + " resolved by:");
for (BundleWire wire : providers) {
String msg;
Object keyAttr = wire.getCapability().getAttributes().get(wire.getCapability().getNamespace());
if (keyAttr != null) {
msg = wire.getCapability().getNamespace() + "; " + keyAttr + " " + getVersionFromCapability(wire.getCapability());
} else {
msg = wire.getCapability().toString();
}
msg = " " + msg + " from " + wire.getProviderWiring().getBundle();
System.out.println(msg);
}
} else {
System.out.println(req.getNamespace() + "; " + req.getDirectives().get(Constants.FILTER_DIRECTIVE) + " " + UNRESOLVED_MESSAGE);
}
}
}
return matches;
}
use of org.osgi.framework.wiring.BundleRequirement in project karaf by apache.
the class BundleWiresTest method packageWire.
private BundleWire packageWire(String packageFilter, BundleCapability bundleRef) {
BundleWire wire = c.createMock(BundleWire.class);
BundleRequirement req = packageRequirement(packageFilter);
expect(wire.getRequirement()).andReturn(req);
expect(wire.getCapability()).andReturn(bundleRef);
return wire;
}
use of org.osgi.framework.wiring.BundleRequirement in project felix by apache.
the class Inspect method printMatchingRequirements.
private static boolean printMatchingRequirements(BundleWiring wiring, List<String> namespace) {
List<BundleWire> wires = wiring.getRequiredWires(null);
Map<BundleRequirement, List<BundleWire>> aggregateReqs = aggregateRequirements(namespace, wires);
List<BundleRequirement> allReqs = wiring.getRequirements(null);
boolean matches = false;
for (BundleRequirement req : allReqs) {
if (matchNamespace(namespace, req.getNamespace())) {
matches = true;
List<BundleWire> providers = aggregateReqs.get(req);
if (providers != null) {
System.out.println(req.getNamespace() + "; " + req.getDirectives().get(Constants.FILTER_DIRECTIVE) + " resolved by:");
for (BundleWire wire : providers) {
String msg;
Object keyAttr = wire.getCapability().getAttributes().get(wire.getCapability().getNamespace());
if (keyAttr != null) {
msg = wire.getCapability().getNamespace() + "; " + keyAttr + " " + getVersionFromCapability(wire.getCapability());
} else {
msg = wire.getCapability().toString();
}
msg = " " + msg + " from " + wire.getProviderWiring().getBundle();
System.out.println(msg);
}
} else {
System.out.println(req.getNamespace() + "; " + req.getDirectives().get(Constants.FILTER_DIRECTIVE) + " " + UNRESOLVED_MESSAGE);
}
}
}
return matches;
}
Aggregations