@Override public Collection<Capability> findProviders(Requirement req) { String namespace = req.getNamespace(); if (!MODULE_IDENTITY_NAMESPACE.equals(namespace)) { return Collections.emptyList(); } String idspec = (String) req.getAttributes().get(MODULE_IDENTITY_NAMESPACE); if (idspec == null) throw MESSAGES.cannotObtainRequiredAttribute(MODULE_IDENTITY_NAMESPACE); // Load the module ModuleIdentifier moduleId = ModuleIdentifier.fromString(idspec); Module module = loadModule(moduleId); // Build the module resource XResourceBuilder<XResource> factory = XResourceBuilderFactory.create(); factory.addIdentityCapability(moduleId); XResource resource = factory.getResource(); // Convert the resource to the given target type List<Capability> result = new ArrayList<Capability>(); try { resource = getTargetResource(resource, module); result.add(resource.getIdentityCapability()); } catch (Exception ex) { LOGGER.errorCannotCreateResource(ex, idspec); } return Collections.unmodifiableList(result); }