本文整理汇总了Java中com.intellij.ide.plugins.cl.PluginClassLoader类的典型用法代码示例。如果您正苦于以下问题:Java PluginClassLoader类的具体用法?Java PluginClassLoader怎么用?Java PluginClassLoader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PluginClassLoader类属于com.intellij.ide.plugins.cl包,在下文中一共展示了PluginClassLoader类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例6: getPluginId
import com.intellij.ide.plugins.cl.PluginClassLoader; //导入依赖的package包/类
@Nullable
public PluginId getPluginId() {
if (myLoader instanceof PluginClassLoader) {
return ((PluginClassLoader)myLoader).getPluginId();
}
return null;
}
示例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);
}
}
}
}
示例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);
}
}
示例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);
}
}
}
}
示例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[][]{};
}
}
示例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;
}
示例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();
}
示例13: getPluginId
import com.intellij.ide.plugins.cl.PluginClassLoader; //导入依赖的package包/类
@Nullable
public PluginId getPluginId() {
if (myIntentionLoader instanceof PluginClassLoader) {
return ((PluginClassLoader)myIntentionLoader).getPluginId();
}
return null;
}
示例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);
}
}
}
}
示例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());
}