@Override public void shutdown() { modules.clear(); for (Repository repo : repositories.values()) { try { repo.shutdown(); } catch(Exception e) { java.util.logging.Logger.getAnonymousLogger().log(Level.SEVERE, "Error while closing repository " + repo, e); // swallows } } // don't try to stop the system bundle, as we may be embedded inside // something like Eclipse. }
/** * 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); }
protected Module loadFromRepository(String name, String version) { Set<Integer> keys = repositories.keySet(); TreeSet<Integer> sortedKeys = new TreeSet<Integer>(); sortedKeys.addAll(keys); for (Integer key : sortedKeys) { Repository repo = repositories.get(key); ModuleDefinition moduleDef = repo.find(name, version); if (moduleDef!=null) { return newModule(moduleDef); } } return null; }
/** * Remove a repository from the list of attached repositories to * this instances. After this call, the <code>Repository</code> * name will not be used to procure missing modules any * longer * @param name name of the repository to remove */ public synchronized void removeRepository(String name) { for (Integer weight : repositories.keySet()) { Repository repo = repositories.get(weight); if (repo.getName().equals(name)) { repositories.remove(weight); return; } } }
for (Integer key : sortedKeys) { Repository repo = repos.get(key); for (ModuleDefinition moduleDef : repo.findAll()) { if (modules.get(AbstractFactory.getInstance().createModuleId(moduleDef)) == null) { Module newModule = newModule(moduleDef);
/** * <p> This method installs the admin console OSGi bundle respository so * our plugins can be found.</p> */ private void addRepository(String name, String path) { File pathFile = new File(path); Repository repo = new DirectoryBasedRepository( name, pathFile); modulesRegistry.addRepository(repo); try { repo.initialize(); } catch (IOException ex) { logger.log(Level.SEVERE, "Problem initializing additional repository!", ex); } }
/** * Get a repository from the list of attached repositories * * @param name name of the repository to return * @return the repository or null if not found */ public synchronized Repository getRepository(String name) { for (Integer weight : repositories.keySet()) { Repository repo = repositories.get(weight); if (repo.getName().equals(name)) { return repo; } } return null; }
for (Integer key : sortedKeys) { Repository repo = repos.get(key); for (ModuleDefinition moduleDef : repo.findAll()) { if (modules.get(AbstractFactory.getInstance().createModuleId(moduleDef)) == null) { Module newModule = newModule(moduleDef);
/** * Shuts down this module's registry, apply housekeeping tasks * */ public void shutdown() { detachAll(); for (Repository repo : repositories.values()) { try { repo.shutdown(); } catch(Exception e) { Logger.getAnonymousLogger().log(Level.SEVERE, "Error while closing repository " + repo, e); // swallows } } }
/** * 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); }
/** * Get a repository from the list of attached repositories * * @param name name of the repository to return * @return the repository or null if not found */ public synchronized Repository getRepository(String name) { for (Integer weight : repositories.keySet()) { Repository repo = repositories.get(weight); if (repo.getName().equals(name)) { return repo; } } return null; }
protected Module loadFromRepository(String name, String version) { Set<Integer> keys = repositories.keySet(); TreeSet<Integer> sortedKeys = new TreeSet<Integer>(); sortedKeys.addAll(keys); for (Integer key : sortedKeys) { Repository repo = repositories.get(key); ModuleDefinition moduleDef = repo.find(name, version); if (moduleDef!=null) { return newModule(moduleDef); } } return null; }
/** * Shuts down this module's registry, apply housekeeping tasks * */ public void shutdown() { detachAll(); for (Repository repo : repositories.values()) { try { repo.shutdown(); } catch(Exception e) { Logger.getAnonymousLogger().log(Level.SEVERE, "Error while closing repository " + repo, e); // swallows } } }
@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); }
/** * Remove a repository from the list of attached repositories to * this instances. After this call, the <code>Repository</code> * name will not be used to procure missing modules any * longer * @param name name of the repository to remove */ public synchronized void removeRepository(String name) { for (Integer weight : repositories.keySet()) { Repository repo = repositories.get(weight); if (repo.getName().equals(name)) { repositories.remove(weight); return; } } }
public synchronized void shutdown() { for (Module m : modules.values()) { // Only stop modules that were started after ModulesRegistry // came into existence. if (OSGiModuleImpl.class.cast(m).isTransientlyActive()) { m.stop(); } } // Save the cache before clearing modules try { if (cacheInvalidated) { saveCache(); } } catch (IOException e) { Logger.logger.log(Level.WARNING, "Cannot save metadata to cache", e); } modules.clear(); for (Repository repo : repositories.values()) { try { repo.shutdown(); } catch(Exception e) { java.util.logging.Logger.getAnonymousLogger().log(Level.SEVERE, "Error while closing repository " + repo, e); // swallows } } // don't try to stop the system bundle, as we may be embedded inside // something like Eclipse. }