org.openide.util.Lookup.getDefault()方法的使用及代码示例

x33g5p2x  于2022-01-23 转载在 其他  
字(8.7k)|赞(0)|评价(0)|浏览(189)

本文整理了Java中org.openide.util.Lookup.getDefault()方法的一些代码示例,展示了Lookup.getDefault()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Lookup.getDefault()方法的具体详情如下:
包路径:org.openide.util.Lookup
类名称:Lookup
方法名:getDefault

Lookup.getDefault介绍

[英]Static method to obtain the global lookup in the whole system. The actual returned implementation can be different in different systems, but the default one is based on org.openide.util.lookup.Lookups#metaInfServiceswith the context classloader of the first caller. Each system is adviced to honor this and include some form of metaInfServices implementation in the returned lookup as usage of META-INF/services is a JDK standard.
[中]在整个系统中获取全局查找的静态方法。在不同的系统中,实际返回的实现可能不同,但默认的实现是基于组织的。openide。util。查找。使用第一个调用者的上下文类加载器查找#MetaInfservices。建议每个系统遵守这一点,并在返回的查找中包含某种形式的metaInfServices实现,因为META-INF/services的使用是JDK标准。

代码示例

代码示例来源:origin: org.netbeans.api/org-openide-util

/** Lazy create default NB classloader for use during deserialization. */
private static ClassLoader getNBClassLoader() {
  ClassLoader c = Lookup.getDefault().lookup(ClassLoader.class);
  return (c != null) ? c : ClassLoader.getSystemClassLoader();
}

代码示例来源:origin: org.netbeans.api/org-openide-util

/**
 * Displays the help page in a supported viewer, if any.
 * @return true if this help was displayed successfully
 * @since 8.21
 * @see org.openide.util.HelpCtx.Displayer#display
 */
public boolean display() {
  for (Displayer d : Lookup.getDefault().lookupAll(Displayer.class)) {
    if (d.display(this)) {
      return true;
    }
  }
  return false;
}

代码示例来源:origin: org.netbeans.api/org-openide-util

/** @return default class loader which is used, when we don't have
* any other class loader. (in function getBundle(String), getLocalizedFile(String),
* and so on...
*/
private static ClassLoader getLoader() {
  ClassLoader c = Lookup.getDefault().lookup(ClassLoader.class);
  return (c != null) ? c : ClassLoader.getSystemClassLoader();
}

代码示例来源:origin: org.netbeans.api/org-openide-filesystems

layerUrls.add(generatedLayer);
for (LayerProvider p : Lookup.getDefault().lookupAll(LayerProvider.class)) {
  List<URL> newURLs = new ArrayList<URL>();
  p.registerLayers(newURLs);

代码示例来源:origin: org.netbeans.api/org-openide-filesystems

private static ClassLoader loader() {
  ClassLoader l = Lookup.getDefault().lookup(ClassLoader.class);
  if (l == null) {
    l = FOItem.class.getClassLoader();
  }
  return l;
}

代码示例来源:origin: org.netbeans.api/org-openide-modules

public @Override ModuleInfo ownerOf(Class<?> clazz) {
  for (ModuleInfo module : Lookup.getDefault().lookupAll(ModuleInfo.class)) {
    if (module.owns(clazz)) {
      return module;
    }
  }
  return null;
}

代码示例来源:origin: org.netbeans.api/org-openide-util-lookup

private void readObject(ObjectInputStream ois)
throws IOException, ClassNotFoundException {
  ois.defaultReadObject();
  if (l == null) {
    l = Lookup.getDefault().lookup(ClassLoader.class);
  }
  clazz = Class.forName(clazzName, false, l);
}

代码示例来源:origin: org.netbeans.api/org-openide-util-ui

/**
 * Displays the help page in a supported viewer, if any.
 * @return true if this help was displayed successfully
 * @since 8.21
 * @see org.openide.util.HelpCtx.Displayer#display
 */
public boolean display() {
  for (Displayer d : Lookup.getDefault().lookupAll(Displayer.class)) {
    if (d.display(this)) {
      return true;
    }
  }
  return false;
}

代码示例来源:origin: org.netbeans.api/org-openide-filesystems

/** Loads a class of given name
 * @param name name of the class
 * @return the class
 * @exception ClassNotFoundException if class was not found
 */
public static Class findClass(String name) throws ClassNotFoundException {
  ClassLoader c = Lookup.getDefault().lookup(ClassLoader.class);
  if (c == null) {
    return Class.forName(name);
  } else {
    return Class.forName(name, true, c);
  }
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-cnd-utils

private static Collection<? extends CndFileExistSensitiveCache> getCaches() {
    if (listeners == null) {
       listeners = Lookup.getDefault().lookupAll(CndFileExistSensitiveCache.class);
    }
    return listeners;
  }
}

代码示例来源:origin: org.netbeans.api/org-openide-util

/** Returns the <code>hostname</code> part of network proxy address 
 * based on given URI to access the resource at.
 * Returns <code>null</code> for direct connection.
 * 
 * @param u The URI that a connection is required to
 * @return the hostname part of the Proxy address or <code>null</code>
 */
public static String getProxyHost(URI u) {
  ProxyCredentialsProvider provider = Lookup.getDefault().lookup(ProxyCredentialsProvider.class);
  if (provider == null) {
    LOGGER.warning("No ProxyCredentialsProvider found in lookup " + Lookup.getDefault() + " thus no proxy information will provide!");
  }
  return provider == null ? null : provider.getProxyHost(u);
}

代码示例来源:origin: org.netbeans.api/org-openide-text

/** Returns enumeration of all registered indentation engines.
 * @return enumeration of IndentEngine
 */
public static Enumeration<? extends IndentEngine> indentEngines() {
  return Collections.enumeration(Lookup.getDefault().lookupAll(IndentEngine.class));
}

代码示例来源:origin: org.netbeans.api/org-openide-util

/** Returns the <code>port</code> part of network proxy address 
 * based on given URI to access the resource at.
 * Returns <code>null</code> for direct connection.
 * 
 * @param u The URI that a connection is required to
 * @return the port part of the Proxy address or <code>null</code>
 */
public static String getProxyPort(URI u) {
  ProxyCredentialsProvider provider = Lookup.getDefault().lookup(ProxyCredentialsProvider.class);
  if (provider == null) {
    LOGGER.warning("No ProxyCredentialsProvider found in lookup " + Lookup.getDefault() + " thus no proxy information will provide!");
  }
  return provider == null ? null : provider.getProxyPort(u);
}

代码示例来源:origin: org.netbeans.api/org-netbeans-modules-vmd-io

public static ProjectTypeInfo getProjectTypeInfoFor (String projectType) {
  for (ProjectTypeInfo info : Lookup.getDefault ().lookupAll (ProjectTypeInfo.class))
    if (info.projectType.equals (projectType))
      return info;
  return null;
}

代码示例来源:origin: org.netbeans.api/org-openide-util-lookup

private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException {
  object = (Node) ois.readObject();
  interfaces = new WeakHashMap<Class,Object>();
  String clazz;
  ClassLoader l = Lookup.getDefault().lookup(ClassLoader.class);
  while ((clazz = (String) ois.readObject()) != null) {
    Object o = ois.readObject();
    if (!(o instanceof Collection) && !(o instanceof AbstractLookup.Pair)) {
      throw new ClassCastException(String.valueOf(o));
    }
    Class c = Class.forName(clazz, false, l);
    interfaces.put(c, o);
  }
}

代码示例来源:origin: it.tidalwave.geo/it-tidalwave-geo-geocoding

/*******************************************************************************************************************
 *
 * {@inheritDoc}
 *
 ******************************************************************************************************************/
@Override @Nonnull
public Set<GeoCoder> findAllGeoCoders()
 {
  return new HashSet<GeoCoder>(Lookup.getDefault().lookupAll(GeoCoder.class));
 }

代码示例来源:origin: org.netbeans.api/org-openide-util

/** Returns the <code>key</code> for reading password for Proxy Authentication.
 * Use <a href="@org-netbeans-modules-keyring@/org/netbeans/api/keyring/Keyring.html"><code>org.netbeans.api.keyring.Keyring</code></a> for reading the password from the ring.
 * Returns <code>null</code> if no authentication required.
 * 
 * @param u The URI that a connection is required to
 * @return the key for reading password for Proxy Authentication from the ring or <code>null</code>
 */
public static String getKeyForAuthenticationPassword(URI u) {
  ProxyCredentialsProvider provider = Lookup.getDefault().lookup(ProxyCredentialsProvider.class);
  if (provider == null) {
    LOGGER.warning("No ProxyCredentialsProvider found in lookup " + Lookup.getDefault() + " thus no proxy information will provide!");
  }
  if (provider != null && provider.isProxyAuthentication(u)) {
    return PROXY_AUTHENTICATION_PASSWORD;
  }
  return null;
}

代码示例来源:origin: org.netbeans.api/org-netbeans-modules-java-project-ui

private synchronized PackageRenameHandler getRenameHandler() {
  Collection<? extends PackageRenameHandler> handlers = Lookup.getDefault().lookupAll(PackageRenameHandler.class);
  if (handlers.size()==0)
    return null;
  if (handlers.size()>1)
    LOG.warning("Multiple instances of PackageRenameHandler found in Lookup; only using first one: " + handlers); //NOI18N
  return handlers.iterator().next(); 
}

代码示例来源:origin: org.netbeans.api/org-openide-util

/** Gets the default implementation from lookup.
 * @return the presenter
 */
public static ActionPresenterProvider getDefault () {
  ActionPresenterProvider ap = Lookup.getDefault().lookup(ActionPresenterProvider.class);
  return ap == null ? new Default () : ap;
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-cnd-source

private static synchronized RenameHandler getRenameHandler() {
  Collection<? extends RenameHandler> handlers = (Lookup.getDefault().lookupAll(RenameHandler.class));
  if (handlers.isEmpty()) {
    return null;
  }
  if (handlers.size() > 1) {
    LOG.log(Level.WARNING, "Multiple instances of RenameHandler found in Lookup; only using first one: {0}", handlers); //NOI18N
  }
  return handlers.iterator().next();
}
private static final Logger LOG = Logger.getLogger(SourceDataNode.class.getName());

相关文章