Search in sources :

Example 1 with Repository

use of com.sun.enterprise.module.Repository in project glassfish-hk2 by eclipse-ee4j.

the class AbstractModulesRegistryImpl method getModules.

/**
 * Returns the list of shared Modules registered in this instance.
 *
 * <p>
 * The returned list will not include the modules defined in the ancestor
 * {@link AbstractModulesRegistryImpl}s.
 *
 * @return an umodifiable list of loaded modules
 */
public Collection<HK2Module> getModules() {
    // make a copy to avoid synchronizing since this API can be called while
    // modules are added or removed by other threads.
    Map<Integer, Repository> repos = new TreeMap<Integer, Repository>();
    repos.putAll(repositories);
    // force repository extraction
    Set<Integer> keys = repos.keySet();
    TreeSet<Integer> sortedKeys = new TreeSet<Integer>();
    sortedKeys.addAll(keys);
    for (Integer key : sortedKeys) {
        Repository repo = repos.get(key);
        for (ModuleDefinition moduleDef : repo.findAll()) {
            if (modules.get(AbstractFactory.getInstance().createModuleId(moduleDef)) == null) {
                HK2Module newModule = newModule(moduleDef);
                if (newModule != null) {
                    // When some module can't get installed,
                    // don't halt proceeding, instead continue
                    add(newModule);
                // don't resolve such modules, we just want to know about them
                }
            }
        }
    }
    return modules.values();
}
Also used : ModuleDefinition(com.sun.enterprise.module.ModuleDefinition) Repository(com.sun.enterprise.module.Repository) HK2Module(com.sun.enterprise.module.HK2Module) TreeSet(java.util.TreeSet) TreeMap(java.util.TreeMap)

Example 2 with Repository

use of com.sun.enterprise.module.Repository in project glassfish-hk2 by eclipse-ee4j.

the class AbstractModulesRegistryImpl method dumpState.

public void dumpState(PrintStream writer) {
    StringBuilder sb = new StringBuilder("Registry Info:: Total repositories: " + repositories.size() + ", Total modules = " + modules.size() + "\n");
    for (Repository repo : repositories.values()) {
        sb.append("Attached repository: [" + repo + "]\n");
    }
    for (HK2Module module : getModules()) {
        sb.append("Registered Module: [" + module + "]\n");
    }
    writer.println(sb);
}
Also used : Repository(com.sun.enterprise.module.Repository) HK2Module(com.sun.enterprise.module.HK2Module)

Example 3 with Repository

use of com.sun.enterprise.module.Repository in project glassfish-hk2 by eclipse-ee4j.

the class AbstractModulesRegistryImpl method loadFromRepository.

protected HK2Module 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;
}
Also used : ModuleDefinition(com.sun.enterprise.module.ModuleDefinition) Repository(com.sun.enterprise.module.Repository) TreeSet(java.util.TreeSet)

Aggregations

Repository (com.sun.enterprise.module.Repository)3 HK2Module (com.sun.enterprise.module.HK2Module)2 ModuleDefinition (com.sun.enterprise.module.ModuleDefinition)2 TreeSet (java.util.TreeSet)2 TreeMap (java.util.TreeMap)1