/** * Add a new <code>Repository</code> to this registry. From now on * the repository will be used to procure requested module not yet registered * in this registry instance. Repository can be searched in a particular * order (to accomodate performance requirements like looking at local * repositories first), a search order (1 to 100) can be specified when * adding a repository to the registry (1 is highest priority). * @param repository new repository to attach to this registry * @param weight int value from 1 to 100 to specify the search order */ public synchronized void addRepository(Repository repository, int weight) { // check that we don't already have this repository for (Repository repo : repositories.values()) { if (repo.getLocation().equals(repository.getLocation())) { throw new RuntimeException("repository at " + repository.getLocation() + " already registered"); } } while (repositories.containsKey(weight)) { weight++; } repositories.put(weight, repository); }
/** * Add a new <code>Repository</code> to this registry. From now on * the repository will be used to procure requested module not yet registered * in this registry instance. Repository can be searched in a particular * order (to accomodate performance requirements like looking at local * repositories first), a search order (1 to 100) can be specified when * adding a repository to the registry (1 is highest priority). * @param repository new repository to attach to this registry * @param weight int value from 1 to 100 to specify the search order */ public synchronized void addRepository(Repository repository, int weight) { // check that we don't already have this repository for (Repository repo : repositories.values()) { if (repo.getLocation().equals(repository.getLocation())) { throw new RuntimeException("repository at " + repository.getLocation() + " already registered"); } } while (repositories.containsKey(weight)) { weight++; } repositories.put(weight, repository); }
@Override public void addRepository(Repository repository, int weight) { if (repository instanceof OSGiDirectoryBasedRepository) { try { obrHandler.addRepository(repository.getLocation()); } catch (Exception e) { throw new RuntimeException(e); } } super.addRepository(repository, weight); }