use of com.sun.enterprise.module.HK2Module 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();
}
use of com.sun.enterprise.module.HK2Module 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);
}
use of com.sun.enterprise.module.HK2Module in project glassfish-hk2 by eclipse-ee4j.
the class Utils method identifyCyclicDependency.
public static void identifyCyclicDependency(ModuleImpl m, Logger logger) {
StringBuffer tree = new StringBuffer();
tree.append(m.getName());
Vector<HK2Module> traversed = new Vector<HK2Module>();
boolean success = traverseAndFind(m, m, traversed);
if (success) {
traversed.remove(0);
for (HK2Module mod : traversed) {
tree.append("-->" + mod.getName());
}
tree.append("-->" + m.getName());
logger.log(Level.SEVERE, "Cyclic dependency : " + tree.toString());
}
}
use of com.sun.enterprise.module.HK2Module in project glassfish-hk2 by eclipse-ee4j.
the class Utils method traverseAndFind.
private static boolean traverseAndFind(HK2Module toTraverse, ModuleImpl toFind, Vector<HK2Module> traversed) {
traversed.add(toTraverse);
for (ModuleDependency md : toTraverse.getModuleDefinition().getDependencies()) {
ModulesRegistry registry = toTraverse.getRegistry();
for (HK2Module mod : registry.getModules()) {
if (mod.getName().equals(md.getName())) {
if (mod != null) {
if (mod.getName().equals(toFind.getName())) {
return true;
}
if (traverseAndFind(mod, toFind, traversed)) {
return true;
}
}
}
}
}
traversed.remove(toTraverse);
return false;
}
use of com.sun.enterprise.module.HK2Module in project Payara by payara.
the class ASClassLoaderUtil method getModulesClasspath.
private static synchronized String getModulesClasspath(ServiceLocator habitat) {
synchronized (ASClassLoaderUtil.class) {
if (modulesClassPath == null) {
final StringBuilder tmpString = new StringBuilder();
ModulesRegistry mr = habitat.getService(ModulesRegistry.class);
if (mr != null) {
for (HK2Module module : mr.getModules()) {
for (URI uri : module.getModuleDefinition().getLocations()) {
if (uri.toString().startsWith("reference:")) {
try {
// OSGi modules can have "reference:" prepended to them if they're exploded, except
// there doesn't appear to be an actual FileSystemProvider for this type
tmpString.append(new URI(uri.toString().substring("reference:".length())));
tmpString.append(File.pathSeparator);
} catch (URISyntaxException use) {
deplLogger.log(Level.WARNING, "Error truncating URI with prefix of \"reference:\"", use);
}
} else if (uri.toString().startsWith("jardir:")) {
// OSGi fileinstall created modules can have a "jardir:" schema for directory
// structures, but there is no FileSystemProvider for this type.
// Since the path is the file system path, just substitute the "file:" schema
tmpString.append("file:").append(uri.toString().substring("jardir:".length()));
tmpString.append(File.pathSeparator);
} else {
tmpString.append(Paths.get(uri).toString());
tmpString.append(File.pathSeparator);
}
}
}
}
// set shared classpath for module so that it doesn't need to be
// recomputed for every other invocation
modulesClassPath = tmpString.toString();
}
}
return modulesClassPath;
}
Aggregations