• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java PluginClassLoader类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.intellij.ide.plugins.cl.PluginClassLoader的典型用法代码示例。如果您正苦于以下问题:Java PluginClassLoader类的具体用法?Java PluginClassLoader怎么用?Java PluginClassLoader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



PluginClassLoader类属于com.intellij.ide.plugins.cl包,在下文中一共展示了PluginClassLoader类的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getDefaultClassLoader

import com.intellij.ide.plugins.cl.PluginClassLoader; //导入依赖的package包/类
protected ClassLoader getDefaultClassLoader() {
  int maxIndex = -1;
  ClassLoader bestLoader = null;
  if (interfaces != null && interfaces.length > 0) {
    for (final Class anInterface : interfaces) {
      final ClassLoader loader = anInterface.getClassLoader();
      if (loader instanceof PluginClassLoader) {
        final int order = PluginManager.getPluginLoadingOrder(((PluginClassLoader)loader).getPluginId());
        if (maxIndex < order) {
          maxIndex = order;
          bestLoader = loader;
        }
      }
    }
  }
  ClassLoader superLoader = null;
  if (superclass != null) {
    superLoader = superclass.getClassLoader();
    if (superLoader instanceof PluginClassLoader &&
        maxIndex < PluginManager.getPluginLoadingOrder(((PluginClassLoader)superLoader).getPluginId())) {
      return superLoader;
    }
  }
  if (bestLoader != null) return bestLoader;
  return superLoader;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:27,代码来源:AdvancedEnhancer.java


示例2: createPluginClassLoader

import com.intellij.ide.plugins.cl.PluginClassLoader; //导入依赖的package包/类
@Nullable
static ClassLoader createPluginClassLoader(@Nonnull File[] classPath, @Nonnull ClassLoader[] parentLoaders, @Nonnull IdeaPluginDescriptor pluginDescriptor) {

  PluginId pluginId = pluginDescriptor.getPluginId();
  File pluginRoot = pluginDescriptor.getPath();

  //if (classPath.length == 0) return null;
  try {
    final List<URL> urls = new ArrayList<>(classPath.length);
    for (File aClassPath : classPath) {
      final File file = aClassPath.getCanonicalFile(); // it is critical not to have "." and ".." in classpath elements
      urls.add(file.toURI().toURL());
    }
    return new PluginClassLoader(urls, parentLoaders, pluginId, pluginDescriptor.getVersion(), pluginRoot);
  }
  catch (IOException e) {
    e.printStackTrace();
  }
  return null;
}
 
开发者ID:consulo,项目名称:consulo,代码行数:21,代码来源:PluginManagerCore.java


示例3: diagnosePluginDetection

import com.intellij.ide.plugins.cl.PluginClassLoader; //导入依赖的package包/类
@NotNull
private static String diagnosePluginDetection(String className, PluginId id) {
  String msg = "Detected plugin " + id + " by class " + className;
  IdeaPluginDescriptor descriptor = PluginManager.getPlugin(id);
  if (descriptor != null) {
    msg += "; ideaLoader=" + descriptor.getUseIdeaClassLoader();
    
    ClassLoader loader = descriptor.getPluginClassLoader();
    msg += "; loader=" + loader;
    if (loader instanceof PluginClassLoader) {
      msg += "; loaded class: " + ((PluginClassLoader)loader).hasLoadedClass(className);
    }
  }
  return msg;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:16,代码来源:IdeErrorsDialog.java


示例4: getDefaultClassLoader

import com.intellij.ide.plugins.cl.PluginClassLoader; //导入依赖的package包/类
protected ClassLoader getDefaultClassLoader() {
  int maxIndex = -1;
  ClassLoader bestLoader = null;
  ClassLoader nonPluginLoader = null;
  if (interfaces != null && interfaces.length > 0) {
    for (final Class anInterface : interfaces) {
      final ClassLoader loader = anInterface.getClassLoader();
      if (loader instanceof PluginClassLoader) {
        final int order = PluginManagerCore.getPluginLoadingOrder(((PluginClassLoader)loader).getPluginId());
        if (maxIndex < order) {
          maxIndex = order;
          bestLoader = loader;
        }
      }
      else if (nonPluginLoader == null) {
        nonPluginLoader = loader;
      }
    }
  }
  ClassLoader superLoader = null;
  if (superclass != null) {
    superLoader = superclass.getClassLoader();
    if (superLoader instanceof PluginClassLoader &&
        maxIndex < PluginManagerCore.getPluginLoadingOrder(((PluginClassLoader)superLoader).getPluginId())) {
      return superLoader;
    }
  }
  if (bestLoader != null) return bestLoader;
  return superLoader == null ? nonPluginLoader : superLoader;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:31,代码来源:AdvancedEnhancer.java


示例5: findLoadingPlugin

import com.intellij.ide.plugins.cl.PluginClassLoader; //导入依赖的package包/类
@Nullable
private static PluginId findLoadingPlugin(String className) {
  for (IdeaPluginDescriptor descriptor : PluginManagerCore.getPlugins()) {
    ClassLoader loader = descriptor.getPluginClassLoader();
    if (loader instanceof PluginClassLoader && ((PluginClassLoader)loader).hasLoadedClass(className)) {
      return descriptor.getPluginId();
    }
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:PluginClassCache.java


示例6: getPluginId

import com.intellij.ide.plugins.cl.PluginClassLoader; //导入依赖的package包/类
@Nullable
public PluginId getPluginId() {
  if (myLoader instanceof PluginClassLoader) {
    return ((PluginClassLoader)myLoader).getPluginId();
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:8,代码来源:IntentionActionMetaData.java


示例7: loadDefaultTemplates

import com.intellij.ide.plugins.cl.PluginClassLoader; //导入依赖的package包/类
private void loadDefaultTemplates() {
  final Set<URL> processedUrls = new HashSet<URL>();
  for (PluginDescriptor plugin : PluginManagerCore.getPlugins()) {
    if (plugin instanceof IdeaPluginDescriptorImpl && ((IdeaPluginDescriptorImpl)plugin).isEnabled()) {
      final ClassLoader loader = plugin.getPluginClassLoader();
      if (loader instanceof PluginClassLoader && ((PluginClassLoader)loader).getUrls().isEmpty()) {
        continue; // development mode, when IDEA_CORE's loader contains all the classpath
      }
      try {
        final Enumeration<URL> systemResources = loader.getResources(DEFAULT_TEMPLATES_ROOT);
        if (systemResources.hasMoreElements()) {
          while (systemResources.hasMoreElements()) {
            final URL url = systemResources.nextElement();
            if (processedUrls.contains(url)) {
              continue;
            }
            processedUrls.add(url);
            loadDefaultsFromRoot(url);
          }
        }
      }
      catch (IOException e) {
        LOG.error(e);
      }
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:28,代码来源:FileTemplatesLoader.java


示例8: copyResourceFile

import com.intellij.ide.plugins.cl.PluginClassLoader; //导入依赖的package包/类
/**
 * Method copies specified file from plugin resources
 *
 * @param resourceFile
 * @param destFile
 */
public static void copyResourceFile(String resourceFile, String destFile) {
    try {
        InputStream is = ((PluginClassLoader) AzurePlugin.class.getClassLoader()).findResource(resourceFile).openStream();
        File outputFile = new File(destFile);
        FileOutputStream fos = new FileOutputStream(outputFile);
        FileUtil.writeFile(is, fos);
    } catch (IOException e) {
        LOG.error(e.getMessage(), e);
    }
}
 
开发者ID:Microsoft,项目名称:Azure-Toolkit-for-IntelliJ,代码行数:17,代码来源:AzurePlugin.java


示例9: loadDefaultTemplates

import com.intellij.ide.plugins.cl.PluginClassLoader; //导入依赖的package包/类
private void loadDefaultTemplates() {
  final Set<URL> processedUrls = new HashSet<URL>();
  for (PluginDescriptor plugin : PluginManager.getPlugins()) {
    if (plugin instanceof IdeaPluginDescriptorImpl && ((IdeaPluginDescriptorImpl)plugin).isEnabled()) {
      final ClassLoader loader = plugin.getPluginClassLoader();
      if (loader instanceof PluginClassLoader && ((PluginClassLoader)loader).getUrls().isEmpty()) {
        continue; // development mode, when IDEA_CORE's loader contains all the classpath
      }
      try {
        final Enumeration<URL> systemResources = loader.getResources(DEFAULT_TEMPLATES_ROOT);
        if (systemResources != null && systemResources.hasMoreElements()) {
          while (systemResources.hasMoreElements()) {
            final URL url = systemResources.nextElement();
            if (processedUrls.contains(url)) {
              continue;
            }
            processedUrls.add(url);
            loadDefaultsFromRoot(url);
          }
        }
      }
      catch (IOException e) {
        LOG.error(e);
      }
    }
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:28,代码来源:FileTemplatesLoader.java


示例10: getContents

import com.intellij.ide.plugins.cl.PluginClassLoader; //导入依赖的package包/类
@Override
@SuppressWarnings({"ZeroLengthArrayAllocation"})
protected Object[][] getContents() {
    ClassLoader loader = getClass().getClassLoader();
    if (loader instanceof PluginClassLoader) {
        @NonNls String key = "plugin." + ((PluginClassLoader) loader).getPluginId() + ".description";
        return new Object[][]{{key, getText("Integration.description", getName())}};
    } else {
        return new Object[][]{};
    }
}
 
开发者ID:consulo,项目名称:consulo-javaee,代码行数:12,代码来源:JavaeeBundle.java


示例11: getDefaultClassLoader

import com.intellij.ide.plugins.cl.PluginClassLoader; //导入依赖的package包/类
protected ClassLoader getDefaultClassLoader() {
  int maxIndex = -1;
  ClassLoader bestLoader = null;
  ClassLoader nonPluginLoader = null;
  if (interfaces != null && interfaces.length > 0) {
    for (final Class anInterface : interfaces) {
      final ClassLoader loader = anInterface.getClassLoader();
      if (loader instanceof PluginClassLoader) {
        final int order = PluginManagerCore.getPluginLoadingOrder(((PluginClassLoader)loader).getPluginId());
        if (maxIndex < order) {
          maxIndex = order;
          bestLoader = loader;
        }
      }
      else if (nonPluginLoader == null) {
        nonPluginLoader = loader;
      }
    }
  }
  ClassLoader superLoader = null;
  if (superclass != null) {
    superLoader = superclass.getClassLoader();
    if (superLoader instanceof PluginClassLoader && maxIndex < PluginManagerCore.getPluginLoadingOrder(((PluginClassLoader)superLoader).getPluginId())) {
      return superLoader;
    }
  }
  if (bestLoader != null) return bestLoader;
  return superLoader == null ? nonPluginLoader : superLoader;
}
 
开发者ID:consulo,项目名称:consulo,代码行数:30,代码来源:AdvancedEnhancer.java


示例12: getPluginId

import com.intellij.ide.plugins.cl.PluginClassLoader; //导入依赖的package包/类
@Nullable
public static PluginId getPluginId(@Nonnull Class<?> clazz) {
  ClassLoader loader = clazz.getClassLoader();
  if (!(loader instanceof PluginClassLoader)) {
    return null;
  }
  return ((PluginClassLoader)loader).getPluginId();
}
 
开发者ID:consulo,项目名称:consulo,代码行数:9,代码来源:PluginManagerCore.java


示例13: getPluginId

import com.intellij.ide.plugins.cl.PluginClassLoader; //导入依赖的package包/类
@Nullable
public PluginId getPluginId() {
  if (myIntentionLoader instanceof PluginClassLoader) {
    return ((PluginClassLoader)myIntentionLoader).getPluginId();
  }
  return null;
}
 
开发者ID:consulo,项目名称:consulo,代码行数:8,代码来源:IntentionActionMetaData.java


示例14: loadDefaultTemplates

import com.intellij.ide.plugins.cl.PluginClassLoader; //导入依赖的package包/类
private void loadDefaultTemplates() {
  final Set<URL> processedUrls = new HashSet<>();
  for (PluginDescriptor plugin : PluginManagerCore.getPlugins()) {
    if (plugin instanceof IdeaPluginDescriptorImpl && ((IdeaPluginDescriptorImpl)plugin).isEnabled()) {
      final ClassLoader loader = plugin.getPluginClassLoader();
      if (loader instanceof PluginClassLoader && ((PluginClassLoader)loader).getUrls().isEmpty()) {
        continue; // development mode, when IDEA_CORE's loader contains all the classpath
      }
      try {
        final Enumeration<URL> systemResources = loader.getResources(DEFAULT_TEMPLATES_ROOT);
        if (systemResources.hasMoreElements()) {
          while (systemResources.hasMoreElements()) {
            final URL url = systemResources.nextElement();
            if (processedUrls.contains(url)) {
              continue;
            }
            processedUrls.add(url);
            loadDefaultsFromRoot(url);
          }
        }
      }
      catch (IOException e) {
        LOG.error(e);
      }
    }
  }
}
 
开发者ID:consulo,项目名称:consulo,代码行数:28,代码来源:FileTemplatesLoader.java


示例15: createSceneLoader

import com.intellij.ide.plugins.cl.PluginClassLoader; //导入依赖的package包/类
private static ClassLoader createSceneLoader(SceneBuilderInfo info) throws Exception {
  List<URL> urls = new ArrayList<URL>();

  File[] files = new File(info.libPath).listFiles();
  if (files == null) {
    throw new Exception(info.libPath + " wrong path");
  }

  for (File libFile : files) {
    if (libFile.isFile() && libFile.getName().endsWith(".jar")) {
      if (libFile.getName().equalsIgnoreCase("SceneBuilderApp.jar")) {
        JarFile appJar = new JarFile(libFile);
        String version = appJar.getManifest().getMainAttributes().getValue("Implementation-Version");
        appJar.close();

        if (version != null) {
          int index = version.indexOf(" ");
          if (index != -1) {
            version = version.substring(0, index);
          }
        }

        if (StringUtil.compareVersionNumbers(version, "2.0") < 0) {
          throw new Exception(info.path + " wrong version: " + version);
        }
      }

      urls.add(libFile.toURI().toURL());
    }
  }

  if (urls.isEmpty()) {
    throw new Exception(info.libPath + " no jar found");
  }

  final String parent = new File(PathUtil.getJarPathForClass(SceneBuilderCreatorImpl.class)).getParent();
  if (SceneBuilderCreatorImpl.class.getClassLoader() instanceof PluginClassLoader) {
    urls.add(new File(new File(parent).getParent(), "embedder.jar").toURI().toURL());
  }
  else {
    final File localEmbedder = new File(parent, "FXBuilderEmbedder");
    if (localEmbedder.exists()) {
      urls.add(localEmbedder.toURI().toURL());
    }
    else {
      File home = new File(PathManager.getHomePath(), "community");
      if (!home.exists()) {
        home = new File(PathManager.getHomePath());
      }
      urls.add(new File(home, "plugins/JavaFX/FxBuilderEmbedder/lib/embedder.jar").toURI().toURL());
    }
  }

  final String rtPath = PathUtil.getJarPathForClass(String.class);
  final File javaFxJar = new File(new File(new File(rtPath).getParentFile(), "ext"), "jfxrt.jar");
  if (javaFxJar.isFile()) {
    urls.add(javaFxJar.toURI().toURL());
  }

  return new URLClassLoader(urls.toArray(new URL[urls.size()]), SceneBuilderCreatorImpl.class.getClassLoader());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:62,代码来源:SceneBuilderCreatorImpl.java


示例16: upgradePluginComponent

import com.intellij.ide.plugins.cl.PluginClassLoader; //导入依赖的package包/类
/**
     * Checks for pluginComponent file.
     * If exists checks its version.
     * If it has latest version then no upgrade action is needed,
     * else checks with older componentsets.xml,
     * if identical then deletes existing and copies new one
     * else renames existing and copies new one.
     *
     * @param pluginComponentPath
     * @param resource
     * @param componentType
     * @throws Exception
     */
    private void upgradePluginComponent(String pluginComponentPath, String resource,
                                        String oldResource, String componentType) throws Exception {
        File pluginComponentFile = new File(pluginComponentPath);
        if (pluginComponentFile.exists()) {
            String pluginComponentVersion = null;
            String resourceFileVersion = null;
//        	File resourceFile = new File(((PluginClassLoader)AzurePlugin.class.getClassLoader()).findResource(resource).toURI());
            try {
                if (COMPONENTSETS_TYPE.equals(componentType)) {
                    pluginComponentVersion = WindowsAzureProjectManager.getComponentSetsVersion(pluginComponentFile);
                    resourceFileVersion = COMPONENTSETS_VERSION; //WindowsAzureProjectManager.getComponentSetsVersion(resourceFile);
                } else {
                    pluginComponentVersion = WindowsAzureProjectManager.getPreferenceSetsVersion(pluginComponentFile);
                    resourceFileVersion = PREFERENCESETS_VERSION; //WindowsAzureProjectManager.getPreferenceSetsVersion(resourceFile);
                }
            } catch (Exception e) {
                LOG.error("Error occured while getting version of plugin component " + componentType + ", considering version as null");
            }
            if ((pluginComponentVersion != null
                    && !pluginComponentVersion.isEmpty())
                    && pluginComponentVersion.equals(resourceFileVersion)) {
                // Do not do anything
            } else {
                // Check with old plugin component for upgrade scenarios
                URL oldPluginComponentUrl = ((PluginClassLoader) AzurePlugin.class.getClassLoader()).findResource(oldResource);
//                InputStream oldPluginComponentIs = AzurePlugin.class.getResourceAsStream(oldResourceFile);
                boolean isIdenticalWithOld = WAHelper.isFilesIdentical(oldPluginComponentUrl, pluginComponentFile);
                if (isIdenticalWithOld) {
                    // Delete old one
                    pluginComponentFile.delete();
                } else {
                    // Rename old one
                    DateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmmss");
                    Date date = new Date();
                    WAHelper.copyFile(pluginComponentPath, pluginComponentPath + ".old" + dateFormat.format(date));
                }
                copyResourceFile(resource, pluginComponentPath);
            }
        } else {
            copyResourceFile(resource, pluginComponentPath);
        }
    }
 
开发者ID:Microsoft,项目名称:Azure-Toolkit-for-IntelliJ,代码行数:56,代码来源:AzurePlugin.java


示例17: getPluginId

import com.intellij.ide.plugins.cl.PluginClassLoader; //导入依赖的package包/类
@Nullable public PluginId getPluginId() {
  if (myIntentionLoader instanceof PluginClassLoader) {
    return ((PluginClassLoader)myIntentionLoader).getPluginId();
  }
  return null;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:7,代码来源:IntentionActionMetaData.java



注:本文中的com.intellij.ide.plugins.cl.PluginClassLoader类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Polyline类代码示例发布时间:2022-05-22
下一篇:
Java ScmException类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap