public void removeRepositoryDelegate(XRepository delegate) { synchronized (delegates) { if (delegate != this) { LOGGER.debugf("Remove repository: %s", delegate); delegates.remove(delegate); } } }
public void addRepositoryDelegate(XRepository delegate) { synchronized (delegates) { if (delegate != this) { LOGGER.debugf("Add repository: %s", delegate); delegates.add(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; }
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(); }