public void addRepositoryDelegate(XRepository delegate) { synchronized (delegates) { if (delegate != this) { LOGGER.debugf("Add repository: %s", delegate); delegates.add(delegate); } } }
@Override public synchronized Collection<Capability> findProviders(Requirement req) { Set<Capability> result = findCachedProviders(req); LOGGER.tracef("Find cached providers: %s => %s", req, result); return result; }
LOGGER.infoFindMavenProviders(mavenId); break; } catch (IOException e) { LOGGER.debugf("Cannot access input stream for: %s", url); builder.addIdentityCapability(mavenId); XResource resource = builder.getResource(); LOGGER.debugf("Found maven resource: %s", resource); result.add(resource.getIdentityCapability()); } catch (Exception ex) { LOGGER.errorCannotCreateResource(ex, mavenId.toExternalForm());
private XResource getTargetResource(XResource resource, Module module) throws Exception { // Add the module identity attribute and remove all requirements ModuleIdentifier moduleId = module.getIdentifier(); XResource auxres = super.getTargetResource(resource); XIdentityCapability icap = auxres.getIdentityCapability(); XResourceBuilder<XResource> builder = XResourceBuilderFactory.create(); for (Capability cap : auxres.getCapabilities(null)) { String namespace = cap.getNamespace(); Map<String, Object> atts = new LinkedHashMap<String, Object>(cap.getAttributes()); Map<String, String> dirs = new LinkedHashMap<String, String>(cap.getDirectives()); if (cap == icap) { atts.put(MODULE_IDENTITY_NAMESPACE, moduleId.toString()); } builder.addCapability(namespace, atts, dirs); } List<Requirement> reqs = auxres.getRequirements(null); if (LOGGER.isDebugEnabled()) { LOGGER.debugf("Ignoring %d requirements", reqs.size()); for (Requirement req : reqs) { LOGGER.debugf(" %s", req); } } return builder.getResource(); }
@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); }
if (LOGGER.isDebugEnabled()) { LOGGER.debugf("Resource added: %s", res); for (Capability cap : res.getCapabilities(null)) { LOGGER.debugf(" %s", cap); LOGGER.debugf(" %s", req);
public void removeRepositoryDelegate(XRepository delegate) { synchronized (delegates) { if (delegate != this) { LOGGER.debugf("Remove repository: %s", delegate); delegates.remove(delegate); } } }
protected Manifest getResourceManifest(XResource resource) throws IOException { Manifest manifest = null; if (resource instanceof RepositoryContent) { try (InputStream content = ((RepositoryContent) resource).getContent(); JarInputStream jis = new JarInputStream(content)) { manifest = jis.getManifest(); } catch (IOException ex) { LOGGER.debugf("Cannot access manifest from: %s", resource); } } return manifest; }
@Override public synchronized boolean removeResource(XResource res) throws RepositoryStorageException { if (res == null) throw MESSAGES.illegalArgumentNull("resource"); boolean found = false; synchronized (capabilityCache) { for (Capability cap : res.getCapabilities(null)) { XCapability xcap = (XCapability) cap; String namespace = cap.getNamespace(); String nsvalue = (String) xcap.getAttribute(namespace); Iterator<XCapability> capit = getCachedCapabilities(namespace, nsvalue).iterator(); while (capit.hasNext()) { Resource auxres = capit.next().getResource(); if (res == auxres) { capit.remove(); found = true; } } } LOGGER.debugf("Resource removed: %s", res); } return found; }