本文整理汇总了Java中org.openide.modules.Dependency.TYPE_MODULE属性的典型用法代码示例。如果您正苦于以下问题:Java Dependency.TYPE_MODULE属性的具体用法?Java Dependency.TYPE_MODULE怎么用?Java Dependency.TYPE_MODULE使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.openide.modules.Dependency
的用法示例。
在下文中一共展示了Dependency.TYPE_MODULE属性的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addToJaveleonDisableList
private void addToJaveleonDisableList(Set<Module> willDisable, Module m) {
if (willDisable.contains(m)) {
return;
}
willDisable.add(m);
for (Module other : modules) {
if (! other.isEnabled() || willDisable.contains(other)) {
continue;
}
Dependency[] depenencies = other.getDependenciesArray();
for (int i = 0; i < depenencies.length; i++) {
Dependency dep = depenencies[i];
if (dep.getType() == Dependency.TYPE_MODULE) {
if (Util.parseCodeName(dep.getName())[0].equals(m.getCodeNameBase())) {
addToJaveleonDisableList(willDisable, other);
break;
}
}
}
}
}
示例2: toString
@Override
public String toString () {
StringBuilder buf = new StringBuilder(100);
buf.append ("Key[");
if (type == Dependency.TYPE_MODULE) {
buf.append("module "); // NOI18N
} else if (type == Dependency.TYPE_PACKAGE) {
buf.append("package "); // NOI18N
} else if (type == Dependency.TYPE_REQUIRES) {
buf.append("requires "); // NOI18N
} else if (type == Dependency.TYPE_NEEDS) {
buf.append("needs "); // NOI18N
} else if (type == Dependency.TYPE_RECOMMENDS) {
buf.append("recommends "); // NOI18N
}
buf.append(name);
buf.append (']');
return buf.toString();
}
示例3: calculateParents
private final Set<Module> calculateParents(Module m) throws NumberFormatException, IOException {
// Calculate the parents to initialize the classloader with.
Dependency[] dependencies = m.getDependenciesArray();
Set<Module> res = new HashSet<Module>(dependencies.length * 4 / 3 + 1);
for (int i = 0; i < dependencies.length; i++) {
Dependency dep = dependencies[i];
if (dep.getType() != Dependency.TYPE_MODULE) {
// Token providers do *not* go into the parent classloader
// list. The providing module must have been turned on first.
// But you cannot automatically access classes from it.
continue;
}
String name = (String) Util.parseCodeName(dep.getName())[0];
Module parent = get(name);
// Should not happen:
if (parent == null) {
throw new IOException("Parent " + name + " not found!"); // NOI18N
}
res.add(parent);
}
// dependencies of fragment modules should be injected into the main module.
Collection<Module> fragments = getAttachedFragments(m);
if (!fragments.isEmpty()) {
for (Module frag : fragments) {
Set<Module> mods = calculateParents(frag);
mods.remove(m);
res.addAll(mods);
}
}
return res;
}
示例4: clearProblemCache
private void clearProblemCache(Map<Module,Set<Union2<Dependency,InvalidException>>> mP) {
Iterator<Map.Entry<Module,Set<Union2<Dependency,InvalidException>>>> it = mP.entrySet().iterator();
while (it.hasNext()) {
Map.Entry<Module,Set<Union2<Dependency,InvalidException>>> entry = it.next();
Module m = entry.getKey();
if (! m.isEnabled()) {
Set<Union2<Dependency,InvalidException>> s = entry.getValue();
if (s != null) {
boolean clear = false;
for (Union2<Dependency,InvalidException> problem : s) {
if (problem.hasSecond()) {
// Hard problem, skip this one.
continue;
}
Dependency dep = problem.first();
if (dep.getType() != Dependency.TYPE_MODULE &&
dep.getType() != Dependency.TYPE_REQUIRES &&
dep.getType() != Dependency.TYPE_NEEDS &&
dep.getType() != Dependency.TYPE_RECOMMENDS
) {
// Also a hard problem.
continue;
}
// Some soft problems found, i.e. module deps. Clear them all.
// #76917: Even clear any hard problems.
clear = true;
break;
}
if (clear || s.isEmpty()) { // leave alone only if all hard problems
it.remove();
firer.change(new ChangeFirer.Change(m, Module.PROP_PROBLEMS, null, null));
}
}
// if we never computed anything, make no change now
}
// enabled modules are definitely OK, no change there
}
}
示例5: setupClassLoaderForJaveleonModule
private void setupClassLoaderForJaveleonModule(ModuleManager mgr, JaveleonModule javeleonModule) throws InvalidException {
try {
// Calculate the parents to initialize the classloader with.
Dependency[] dependencies = javeleonModule.getDependenciesArray();
Set<Module> parents = new HashSet<Module>(dependencies.length * 4 / 3 + 1);
for (Dependency dep : dependencies) {
if (dep.getType() != Dependency.TYPE_MODULE) {
// Token providers do *not* go into the parent classloader
// list. The providing module must have been turned on first.
// But you cannot automatically access classes from it.
continue;
}
String name = (String) Util.parseCodeName(dep.getName())[0];
Module parent = mgr.get(name);
// Should not happen:
if (parent == null) {
throw new IOException("Parent " + name + " not found!"); // NOI18N
}
parents.add(parent);
}
javeleonModule.classLoaderUp(parents);
// classLoader.append(new ClassLoader[]{javeleonModule.getClassLoader()});
} catch (IOException ioe) {
InvalidException ie = new InvalidException(javeleonModule, ioe.toString());
ie.initCause(ioe);
throw ie;
}
}
示例6: ignoreBrokenDependency
public boolean ignoreBrokenDependency (Dependency dependency) {
if (Dependency.TYPE_REQUIRES == dependency.getType ()) {
return true;
} else if (Dependency.TYPE_MODULE == dependency.getType ()) {
return ! dependency.getName ().startsWith ("org.yourorghere");
}
return false;
}
示例7: classLoaderUp
/** Turn on the classloader. Passed a list of parent modules to use.
* The parents should already have had their classloaders initialized.
*/
protected void classLoaderUp(Set<Module> parents) throws IOException {
if (Util.err.isLoggable(Level.FINE)) {
Util.err.fine("classLoaderUp on " + this + " with parents " + parents);
}
// Find classloaders for dependent modules and parent to them.
List<ClassLoader> loaders = new ArrayList<ClassLoader>(parents.size() + 1);
// This should really be the base loader created by org.nb.Main for loading openide etc.:
loaders.add(Module.class.getClassLoader());
for (Module parent: parents) {
PackageExport[] exports = parent.getPublicPackages();
if (exports != null && exports.length == 0) {
// Check if there is an impl dep here.
boolean implDep = false;
for (Dependency dep : getDependenciesArray()) {
if (dep.getType() == Dependency.TYPE_MODULE &&
dep.getComparison() == Dependency.COMPARE_IMPL &&
dep.getName().equals(parent.getCodeName())) {
implDep = true;
break;
}
}
if (!implDep) {
// Nothing exported from here at all, no sense even adding it.
// Shortcut; would not harm anything to add it now, but we would
// never use it anyway.
// Cf. #27853.
continue;
}
}
ClassLoader l = getParentLoader(parent);
if (parent.isFixed() && loaders.contains(l)) {
Util.err.log(Level.FINE, "#24996: skipping duplicate classloader from {0}", parent);
continue;
}
loaders.add(l);
}
List<File> classp = new ArrayList<File>(3);
Set<File> ptchs = findPatches();
if (ptchs != null) classp.addAll(ptchs);
if (reloadable) {
ensurePhysicalJar();
// Using OPEN_DELETE does not work well with test modules under 1.4.
// Random code (URL handler?) still expects the JAR to be there and
// it is not.
classp.add(physicalJar);
} else {
classp.add(jar);
}
((StandardModuleData)data()).addCp(classp);
// possibly inject some patches
getManager().refineModulePath(this, classp);
// #27853
ClassLoader cld = getManager().refineClassLoader(this, loaders);
// the classloader may be shared, if this module is a fragment
if (cld != null) {
classloader = cld;
} else {
try {
classloader = createNewClassLoader(classp, loaders);
} catch (IllegalArgumentException iae) {
// Should not happen, but just in case.
throw (IOException) new IOException(iae.toString()).initCause(iae);
}
}
}
示例8: shouldDelegateResource
/** Use by OneModuleClassLoader to communicate with the ModuleInstaller re. masking. */
public boolean shouldDelegateResource(Module m, Module parent, String pkg) {
// Cf. #19621:
Module.PackageExport[] exports = (parent == null) ? null : parent.getPublicPackages();
if (exports != null) {
//Util.err.fine("exports=" + Arrays.asList(exports));
// Packages from parent are restricted: #19621.
boolean exported = false;
if (parent.isDeclaredAsFriend(m)) { // meaning public to all, or at least to me
for (int i = 0; i < exports.length; i++) {
if (exports[i].recursive ? pkg.startsWith(exports[i].pkg) : pkg.equals(exports[i].pkg)) {
//Util.err.fine("matches " + exports[i]);
exported = true;
break;
}
}
}
if (!exported) {
// This package is not public. m must have a direct impl-version
// dependency on parent or it has no right to use this package.
boolean impldep = false;
Dependency[] deps = m.getDependenciesArray();
for (int i = 0; i < deps.length; i++) {
if (deps[i].getType() == Dependency.TYPE_MODULE &&
deps[i].getComparison() == Dependency.COMPARE_IMPL &&
deps[i].getName().equals(parent.getCodeName())) {
impldep = true;
//Util.err.fine("impldep in " + deps[i]);
break;
}
}
if (!impldep) {
// This module cannot use the package, sorry! It's private.
//Util.err.fine("forbidden");
if (Util.err.isLoggable(Level.FINE)) {
// Note that this is usually harmless. Typical case: Introspector.getBeanInfo
// is called on some module-supplied class; this looks in the module's classloader
// for org.netbeans.beaninfo.ModuleClassBeanInfo, which of course would not be
// found anyway.
Util.err.fine("Refusing to load non-public package " + pkg + " for " + m + " from parent module " + parent + " without an impl dependency");
}
return false;
}
//Util.err.fine("impl dep");
}
//Util.err.fine("exported");
}
if (pkg.startsWith("META-INF/")) { // NOI18N
// Modules should not make direct reference to metainfo dirs of
// other modules. Don't bother logging it, however.
return false;
}
// The installer can perform additional checks:
return installer.shouldDelegateResource(m, parent, pkg);
}
示例9: addToDisableList
private void addToDisableList(Set<Module> willDisable, Module m) {
if (willDisable.contains(m)) {
// E.g. if original set had A then B, B depends on A.
return;
}
willDisable.add(m);
// Find any modules depending on this one which are currently enabled.
// (And not already here.)
// If there are any, add them.
for (Module other : modules) {
if (other.isFixed() || ! other.isEnabled() || willDisable.contains(other)) {
continue;
}
Dependency[] depenencies = other.getDependenciesArray();
for (int i = 0; i < depenencies.length; i++) {
Dependency dep = depenencies[i];
if (dep.getType() == Dependency.TYPE_MODULE) {
if (Util.parseCodeName(dep.getName())[0].equals(m.getCodeNameBase())) {
// Need to disable this one too.
addToDisableList(willDisable, other);
// No need to scan the rest of its dependencies.
break;
}
} else if (
dep.getType() == Dependency.TYPE_REQUIRES ||
dep.getType() == Dependency.TYPE_NEEDS
) {
if (m.provides(dep.getName())) {
// Careful. There may be some third module still enabled which
// provides this same token too.
boolean foundOne = false;
for (Module third: getEnabledModules()) {
if (third.isEnabled() &&
!willDisable.contains(third) &&
third.provides(dep.getName())) {
foundOne = true;
break;
}
}
if (!foundOne) {
// Nope, we were the only/last one to provide it.
addToDisableList(willDisable, other);
break;
}
}
}
// else some other kind of dependency, we do not care
}
}
}
示例10: searchForUnusedAutoloads
private boolean searchForUnusedAutoloads(Set<Module> willDisable, Set<Module> stillEnabled) {
// Check for any autoloads in stillEnabled which are not used by anything else
// in stillEnabled. For each such, remove it from stillEnabled and add
// to willDisable. If any were found, return true.
boolean found = false;
Iterator<Module> it = stillEnabled.iterator();
FIND_AUTOLOADS:
while (it.hasNext()) {
Module m = it.next();
if (m.isAutoload()) {
for (Module other: stillEnabled) {
Dependency[] dependencies = other.getDependenciesArray();
for (int i = 0; i < dependencies.length; i++) {
Dependency dep = dependencies[i];
if (dep.getType() == Dependency.TYPE_MODULE) {
if (Util.parseCodeName(dep.getName())[0].equals(m.getCodeNameBase())) {
// Still used, skip it.
continue FIND_AUTOLOADS;
}
} else if (
dep.getType() == Dependency.TYPE_REQUIRES ||
dep.getType() == Dependency.TYPE_NEEDS ||
dep.getType() == Dependency.TYPE_RECOMMENDS
) {
// Here we play it safe and leave autoloads on if they provide
// something used by some module - even if technically it would
// be possible to turn off the autoload because there is another
// enabled module providing the same thing. Leave it on anyway.
if (m.provides(dep.getName())) {
continue FIND_AUTOLOADS;
}
}
// else some other type
}
}
// Nobody uses it!
found = true;
it.remove();
willDisable.add(m);
}
}
return found;
}
示例11: type
public int type() {
return Dependency.TYPE_MODULE;
}
示例12: addModuleClasspathEntries
/** Recursively build a classpath based on the module dependency tree.
* @param m the current module whose JAR(s) might be added to the classpath
* @param orig the module whose classpath we are ultimately trying to compute
* @param considered modules we have already handled
* @param implDeps module code names on which the orig module has an impl dep
* @param cp the classpath to add to
* @param depth the recursion depth to go to: 0 = only m's JAR, 1 = m + its parents, ..., MAX_INT = full recursion
* @see "#22466"
*/
private void addModuleClasspathEntries(Module m, Module orig, Set<Module> considered, Set<String> implDeps, List<String> cp, int depth) {
// Head recursion so that baser modules are added to the front of the classpath:
if (!considered.add(m)) return;
for (Dependency dep : m.getDependencies()) {
if (dep.getType() == Dependency.TYPE_MODULE) {
String cnb = (String) Util.parseCodeName(dep.getName())[0];
Module next = mgr.get(cnb);
if (next == null) throw new IllegalStateException("No such module: " + cnb); // NOI18N
if (depth > 0) {
addModuleClasspathEntries(next, orig, considered, implDeps, cp, depth - 1);
}
}
}
// Now add entries from m, if applicable.
// We are friendly if we are considering the original module itself,
// or if the original module has a (direct) impl dep on this module.
boolean friend = (m == orig) || implDeps.contains(m.getCodeName());
// Friend modules export everything to the classpath.
// Otherwise, there may or may not be package restrictions.
Module.PackageExport[] exports = friend ? null : m.getPublicPackages();
String qualification = ""; // NOI18N
if (exports != null) {
if (exports.length == 0) {
// Everything is blocked.
return;
}
// Only certain packages are exported, so list them explicitly.
StringBuilder b = new StringBuilder(100);
b.append('['); // NOI18N
for (int i = 0; i < exports.length; i++) {
if (i > 0) {
b.append(','); // NOI18N
}
b.append(exports[i].pkg.replace('/', '.')); // NOI18N
b.append(exports[i].recursive ? "**" : "*"); // NOI18N
}
b.append(']'); // NOI18N
qualification = b.toString();
}
for (File jar : m.getAllJars()) {
cp.add(jar.getAbsolutePath() + qualification);
}
}
示例13: findBrokenDependencies
public static Set<Dependency> findBrokenDependencies (Set<Dependency> deps, Collection<ModuleInfo> modules) {
Set<Dependency> res = new HashSet<Dependency> ();
for (Dependency dep : deps) {
err.log(Level.FINE, "Dependency[" + dep.getType () + "]: " + dep);
switch (dep.getType ()) {
case (Dependency.TYPE_REQUIRES) :
case (Dependency.TYPE_NEEDS) :
if (findModuleMatchesDependencyRequires (dep, modules).isEmpty ()) {
// bad, report missing module
res.add (dep);
} else {
// ok
}
break;
case (Dependency.TYPE_RECOMMENDS) :
break;
case (Dependency.TYPE_MODULE) :
if (matchDependencyModule (dep, modules) != null) {
// ok
} else {
// bad, report missing module
res.add (dep);
}
break;
case (Dependency.TYPE_JAVA) :
if (! matchDependencyJava (dep)) {
err.log(Level.FINE, "The Java platform version " + dep +
" or higher was requested but only " + Dependency.JAVA_SPEC + " is running.");
res.add (dep);
}
break;
case (Dependency.TYPE_PACKAGE) :
if (! matchPackageDependency (dep)) {
err.log(Level.FINE, "The package " + dep +
" was requested but it is not in current ClassPath.");
res.add (dep);
}
break;
default:
//assert false : "Unknown type of Dependency, was " + dep.getType ();
err.log(Level.FINE, "Uncovered Dependency " + dep);
}
}
return res;
}