/** * Constructs a new empty database. * @param adaptor the module container adaptor */ public ModuleDatabase(ModuleContainerAdaptor adaptor) { this.adaptor = adaptor; this.modulesByLocations = new HashMap<String, Module>(); this.modulesById = new HashMap<Long, Module>(); this.wirings = new HashMap<ModuleRevision, ModuleWiring>(); // Start at id 1 because 0 is reserved for the system bundle this.nextId = new AtomicLong(1); // seed with current time to avoid duplicate timestamps after using -clean this.constructionTime = System.currentTimeMillis(); this.revisionsTimeStamp = new AtomicLong(constructionTime); this.allTimeStamp = new AtomicLong(constructionTime); this.moduleSettings = new HashMap<Long, EnumSet<Settings>>(); this.capabilities = new Capabilities(); }
private List<ModuleCapability> match(Filter f, Set<ModuleCapability> candidates, boolean synthetic) { List<ModuleCapability> result = new ArrayList<ModuleCapability>(1); for (ModuleCapability candidate : candidates) { if (matches(f, candidate, !synthetic && matchMandatory)) { result.add(candidate); } } return result; } }
/** * Removes the {@link ModuleRevision#getModuleCapabilities(String) capabilities} * provided by the specified revision from this database. These capabilities * must no longer be available for lookup with the * {@link ModuleDatabase#findCapabilities(Requirement)} method. * <p> * This method must be called while holding the {@link #writeLock() write} lock. * @param revision */ protected void removeCapabilities(ModuleRevision revision) { checkWrite(); capabilities.removeCapabilities(revision); }
/** * Adds the {@link ModuleRevision#getModuleCapabilities(String) capabilities} * provided by the specified revision to this database. These capabilities must * become available for lookup with the {@link ModuleDatabase#findCapabilities(Requirement)} * method. * <p> * This method must be called while holding the {@link #writeLock() write} lock. * @param revision the revision which has capabilities to add */ final void addCapabilities(ModuleRevision revision) { checkWrite(); Collection<String> packageNames = capabilities.addCapabilities(revision); // Clear the dynamic miss caches for all the package names added for (ModuleWiring wiring : wirings.values()) { wiring.removeDynamicPackageMisses(packageNames); } }
/** * Returns a mutable snapshot of capabilities that are candidates for * satisfying the specified requirement. * <p> * A read operation protected by the {@link #readLock() read} lock. * Implementers of this method should acquire the read lock while * finding capabilities. * @param requirement the requirement * @return the candidates for the requirement */ final List<ModuleCapability> findCapabilities(Requirement requirement) { readLock(); try { return capabilities.findCapabilities(requirement); } finally { readUnlock(); } }
/** * Adds the {@link ModuleRevision#getModuleCapabilities(String) capabilities} * provided by the specified revision to this database. These capabilities must * become available for lookup with the {@link ModuleDatabase#findCapabilities(Requirement)} * method. * <p> * This method must be called while holding the {@link #writeLock() write} lock. * @param revision the revision which has capabilities to add */ final void addCapabilities(ModuleRevision revision) { checkWrite(); Collection<String> packageNames = capabilities.addCapabilities(revision); // Clear the dynamic miss caches for all the package names added for (ModuleWiring wiring : wirings.values()) { wiring.removeDynamicPackageMisses(packageNames); } }
/** * Returns a mutable snapshot of capabilities that are candidates for * satisfying the specified requirement. * <p> * A read operation protected by the {@link #readLock() read} lock. * Implementers of this method should acquire the read lock while * finding capabilities. * @param requirement the requirement * @return the candidates for the requirement */ final List<ModuleCapability> findCapabilities(Requirement requirement) { readLock(); try { return capabilities.findCapabilities(requirement); } finally { readUnlock(); } }
private List<ModuleCapability> match(Filter f, Set<ModuleCapability> candidates, boolean synthetic) { List<ModuleCapability> result = new ArrayList<ModuleCapability>(1); for (ModuleCapability candidate : candidates) { if (matches(f, candidate, !synthetic && matchMandatory)) { result.add(candidate); } } return result; } }
/** * Removes the {@link ModuleRevision#getModuleCapabilities(String) capabilities} * provided by the specified revision from this database. These capabilities * must no longer be available for lookup with the * {@link ModuleDatabase#findCapabilities(Requirement)} method. * <p> * This method must be called while holding the {@link #writeLock() write} lock. * @param revision */ protected void removeCapabilities(ModuleRevision revision) { checkWrite(); capabilities.removeCapabilities(revision); }
/** * Adds the {@link ModuleRevision#getModuleCapabilities(String) capabilities} * provided by the specified revision to this database. These capabilities must * become available for lookup with the {@link ModuleDatabase#findCapabilities(Requirement)} * method. * <p> * This method must be called while holding the {@link #writeLock() write} lock. * @param revision the revision which has capabilities to add */ final void addCapabilities(ModuleRevision revision) { checkWrite(); Collection<String> packageNames = capabilities.addCapabilities(revision); // Clear the dynamic miss caches for all the package names added for (ModuleWiring wiring : wirings.values()) { wiring.removeDynamicPackageMisses(packageNames); } }
/** * Returns a mutable snapshot of capabilities that are candidates for * satisfying the specified requirement. * <p> * A read operation protected by the {@link #readLock() read} lock. * Implementers of this method should acquire the read lock while * finding capabilities. * @param requirement the requirement * @return the candidates for the requirement */ final List<ModuleCapability> findCapabilities(Requirement requirement) { readLock(); try { return capabilities.findCapabilities(requirement); } finally { readUnlock(); } }
/** * Constructs a new empty database. * @param adaptor the module container adaptor */ public ModuleDatabase(ModuleContainerAdaptor adaptor) { this.adaptor = adaptor; this.modulesByLocations = new HashMap<String, Module>(); this.modulesById = new HashMap<Long, Module>(); this.wirings = new HashMap<ModuleRevision, ModuleWiring>(); // Start at id 1 because 0 is reserved for the system bundle this.nextId = new AtomicLong(1); // seed with current time to avoid duplicate timestamps after using -clean this.constructionTime = System.currentTimeMillis(); this.revisionsTimeStamp = new AtomicLong(constructionTime); this.allTimeStamp = new AtomicLong(constructionTime); this.moduleSettings = new HashMap<Long, EnumSet<Settings>>(); this.capabilities = new Capabilities(); }
private List<ModuleCapability> match(Filter f, Set<ModuleCapability> candidates, boolean synthetic) { List<ModuleCapability> result = new ArrayList<>(1); for (ModuleCapability candidate : candidates) { if (matches(f, candidate, !synthetic && matchMandatory)) { result.add(candidate); } } return result; } }
/** * Removes the {@link ModuleRevision#getModuleCapabilities(String) capabilities} * provided by the specified revision from this database. These capabilities * must no longer be available for lookup with the * {@link ModuleDatabase#findCapabilities(Requirement)} method. * <p> * This method must be called while holding the {@link #writeLock() write} lock. * @param revision */ protected void removeCapabilities(ModuleRevision revision) { checkWrite(); capabilities.removeCapabilities(revision); }
/** * Adds the {@link ModuleRevision#getModuleCapabilities(String) capabilities} * provided by the specified revision to this database. These capabilities must * become available for lookup with the {@link ModuleDatabase#findCapabilities(Requirement)} * method. * <p> * This method must be called while holding the {@link #writeLock() write} lock. * @param revision the revision which has capabilities to add */ final void addCapabilities(ModuleRevision revision) { checkWrite(); Collection<String> packageNames = capabilities.addCapabilities(revision); // Clear the dynamic miss caches for all the package names added for (ModuleWiring wiring : wirings.values()) { wiring.removeDynamicPackageMisses(packageNames); } }
/** * Returns a mutable snapshot of capabilities that are candidates for * satisfying the specified requirement. * <p> * A read operation protected by the {@link #readLock() read} lock. * Implementers of this method should acquire the read lock while * finding capabilities. * @param requirement the requirement * @return the candidates for the requirement */ final List<ModuleCapability> findCapabilities(Requirement requirement) { readLock(); try { return capabilities.findCapabilities(requirement); } finally { readUnlock(); } }
/** * Constructs a new empty database. * @param adaptor the module container adaptor */ public ModuleDatabase(ModuleContainerAdaptor adaptor) { this.adaptor = adaptor; this.modulesByLocations = new HashMap<>(); this.modulesById = new HashMap<>(); this.wirings = new HashMap<>(); // Start at id 1 because 0 is reserved for the system bundle this.nextId = new AtomicLong(1); // seed with current time to avoid duplicate timestamps after using -clean this.constructionTime = System.currentTimeMillis(); this.revisionsTimeStamp = new AtomicLong(constructionTime); this.allTimeStamp = new AtomicLong(constructionTime); this.moduleSettings = new HashMap<>(); this.capabilities = new Capabilities(); }
private List<ModuleCapability> match(Filter f, Set<ModuleCapability> candidates, boolean synthetic) { List<ModuleCapability> result = new ArrayList<ModuleCapability>(1); for (ModuleCapability candidate : candidates) { if (matches(f, candidate, !synthetic && matchMandatory)) { result.add(candidate); } } return result; } }
/** * Removes the {@link ModuleRevision#getModuleCapabilities(String) capabilities} * provided by the specified revision from this database. These capabilities * must no longer be available for lookup with the * {@link ModuleDatabase#findCapabilities(Requirement)} method. * <p> * This method must be called while holding the {@link #writeLock() write} lock. * @param revision */ protected void removeCapabilities(ModuleRevision revision) { checkWrite(); capabilities.removeCapabilities(revision); }
/** * Adds the {@link ModuleRevision#getModuleCapabilities(String) capabilities} * provided by the specified revision to this database. These capabilities must * become available for lookup with the {@link ModuleDatabase#findCapabilities(Requirement)} * method. * <p> * This method must be called while holding the {@link #writeLock() write} lock. * @param revision the revision which has capabilities to add */ final void addCapabilities(ModuleRevision revision) { checkWrite(); Collection<String> packageNames = capabilities.addCapabilities(revision); // Clear the dynamic miss caches for all the package names added for (ModuleWiring wiring : wirings.values()) { wiring.removeDynamicPackageMisses(packageNames); } }