本文整理汇总了Java中com.intellij.openapi.util.ClassLoaderUtil类的典型用法代码示例。如果您正苦于以下问题:Java ClassLoaderUtil类的具体用法?Java ClassLoaderUtil怎么用?Java ClassLoaderUtil使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ClassLoaderUtil类属于com.intellij.openapi.util包,在下文中一共展示了ClassLoaderUtil类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: executeRequestImpl
import com.intellij.openapi.util.ClassLoaderUtil; //导入依赖的package包/类
private static <T> T executeRequestImpl(final URI serverUri,
final Ref<Credentials> credentialsRef,
final Request<T> request,
final ProgressIndicator pi)
throws Exception {
return ClassLoaderUtil.runWithClassLoader(TfsRequestManager.class.getClassLoader(), new ThrowableComputable<T, Exception>() {
@Override
public T compute() throws Exception {
Credentials credentials = credentialsRef.get();
boolean needsAuthentication =
credentials == null ||
request.retrieveAuthorizedCredentials() && (credentials.getUserName().length() == 0 || credentials.getDomain().length() == 0);
if (needsAuthentication) {
TfsServerConnectionHelper.ServerDescriptor descriptor =
TfsServerConnectionHelper.connect(serverUri, credentialsRef.get(), true, pi);
credentialsRef.set(descriptor.authorizedCredentials);
}
return request.execute(credentialsRef.get(), serverUri, pi);
}
});
}
开发者ID:Microsoft,项目名称:vso-intellij,代码行数:22,代码来源:TfsRequestManager.java
示例2: runWithPatchedClassloader
import com.intellij.openapi.util.ClassLoaderUtil; //导入依赖的package包/类
private static <T> T runWithPatchedClassloader(ThrowableComputable<T, Exception> computable) throws Exception {
return ClassLoaderUtil.runWithClassLoader(new URLClassLoader(new URL[0], Thread.currentThread().getContextClassLoader()) {
@Override
public InputStream getResourceAsStream(String name) {
if (XML_ENTITIES_URL.equals(name)) {
String resource = XML_ENTITIES_CONTENT;
try {
return new ByteArrayInputStream(resource.getBytes("UTF-8"));
}
catch (UnsupportedEncodingException e) {
// should not happen, fallback
}
}
return super.getResourceAsStream(name);
}
}, computable);
}
开发者ID:Microsoft,项目名称:vso-intellij,代码行数:18,代码来源:MementoTest.java
示例3: getStubConfigurationContext
import com.intellij.openapi.util.ClassLoaderUtil; //导入依赖的package包/类
public static ConfigurationContext getStubConfigurationContext() {
return ClassLoaderUtil.runWithClassLoader(TFSVcs.class.getClassLoader(), new Computable<ConfigurationContext>() {
public ConfigurationContext compute() {
try {
ConfigurationContext configContext = ConfigurationContextFactory.createDefaultConfigurationContext();
configContext.getAxisConfiguration().addMessageBuilder(SOAP_BUILDER_KEY, new CustomSOAPBuilder());
return configContext;
}
catch (Exception e) {
LOG.error("Axis2 configuration error", e);
return null;
}
}
});
}
开发者ID:Microsoft,项目名称:vso-intellij,代码行数:16,代码来源:WebServiceHelper.java
示例4: getEngineForLanguage
import com.intellij.openapi.util.ClassLoaderUtil; //导入依赖的package包/类
@Nullable
@Override
public IdeScriptEngine getEngineForLanguage(@Nonnull final String language, @Nullable ClassLoader loader) {
ClassLoader l = ObjectUtils.notNull(loader, AllPluginsLoader.INSTANCE);
return ClassLoaderUtil.runWithClassLoader(l, new Computable<IdeScriptEngine>() {
@Override
public IdeScriptEngine compute() {
return createIdeScriptEngine(getScriptEngineManager().getEngineByName(language));
}
});
}
开发者ID:consulo,项目名称:consulo,代码行数:12,代码来源:Jsr223IdeScriptEngineManagerImpl.java
示例5: getEngineForFileExtension
import com.intellij.openapi.util.ClassLoaderUtil; //导入依赖的package包/类
@Nullable
@Override
public IdeScriptEngine getEngineForFileExtension(@Nonnull final String extension, @Nullable ClassLoader loader) {
ClassLoader l = ObjectUtils.notNull(loader, AllPluginsLoader.INSTANCE);
return ClassLoaderUtil.runWithClassLoader(l, new Computable<IdeScriptEngine>() {
@Override
public IdeScriptEngine compute() {
return createIdeScriptEngine(getScriptEngineManager().getEngineByExtension(extension));
}
});
}
开发者ID:consulo,项目名称:consulo,代码行数:12,代码来源:Jsr223IdeScriptEngineManagerImpl.java
示例6: eval
import com.intellij.openapi.util.ClassLoaderUtil; //导入依赖的package包/类
@Override
public Object eval(@Nonnull final String script) throws IdeScriptException {
return ClassLoaderUtil.runWithClassLoader(myLoader, new ThrowableComputable<Object, IdeScriptException>() {
@Override
public Object compute() throws IdeScriptException {
try {
return myEngine.eval(script);
}
catch (Throwable e) {
throw new IdeScriptException(e);
}
}
});
}
开发者ID:consulo,项目名称:consulo,代码行数:15,代码来源:Jsr223IdeScriptEngineManagerImpl.java
示例7: forcePluginClassLoader
import com.intellij.openapi.util.ClassLoaderUtil; //导入依赖的package包/类
public static <T, E extends Throwable> T forcePluginClassLoader(@NotNull ThrowableComputable<T, E> computable) throws E {
return ClassLoaderUtil.runWithClassLoader(null, computable);
}
开发者ID:Microsoft,项目名称:vso-intellij,代码行数:4,代码来源:TfsUtil.java
示例8: createFromTemplate
import com.intellij.openapi.util.ClassLoaderUtil; //导入依赖的package包/类
public static PsiElement createFromTemplate(@Nonnull final FileTemplate template,
@NonNls @Nullable String fileName,
@Nullable Map<String, Object> additionalProperties,
@Nonnull final PsiDirectory directory,
@Nullable ClassLoader classLoader) throws Exception {
final Project project = directory.getProject();
Map<String, Object> properties = new THashMap<>();
FileTemplateManager.getInstance(project).fillDefaultVariables(properties);
if(additionalProperties != null) {
properties.putAll(additionalProperties);
}
FileTemplateManager.getInstance(project).addRecentName(template.getName());
fillDefaultProperties(properties, directory);
final CreateFromTemplateHandler handler = findHandler(template);
if (fileName != null && properties.get(FileTemplate.ATTRIBUTE_NAME) == null) {
properties.put(FileTemplate.ATTRIBUTE_NAME, fileName);
}
else if (fileName == null && handler.isNameRequired()) {
fileName = (String)properties.get(FileTemplate.ATTRIBUTE_NAME);
if (fileName == null) {
throw new Exception("File name must be specified");
}
}
//Set escaped references to dummy values to remove leading "\" (if not already explicitely set)
String[] dummyRefs = calculateAttributes(template.getText(), properties, true, project);
for (String dummyRef : dummyRefs) {
properties.put(dummyRef, "");
}
handler.prepareProperties(properties);
final String fileName_ = fileName;
String mergedText =
ClassLoaderUtil.runWithClassLoader(classLoader != null ? classLoader : FileTemplateUtil.class.getClassLoader(), (ThrowableComputable<String, IOException>)() -> template.getText(properties));
final String templateText = StringUtil.convertLineSeparators(mergedText);
final Exception[] commandException = new Exception[1];
final PsiElement[] result = new PsiElement[1];
CommandProcessor.getInstance().executeCommand(project, () -> ApplicationManager.getApplication().runWriteAction(() -> {
try {
result[0] = handler.createFromTemplate(project, directory, fileName_, template, templateText, properties);
}
catch (Exception ex) {
commandException[0] = ex;
}
}), handler.commandName(template), null);
if (commandException[0] != null) {
throw commandException[0];
}
return result[0];
}
开发者ID:consulo,项目名称:consulo,代码行数:56,代码来源:FileTemplateUtil.java
示例9: initClassLoader
import com.intellij.openapi.util.ClassLoaderUtil; //导入依赖的package包/类
@Nonnull
public static ClassLoader initClassLoader(boolean updatePlugins) throws MalformedURLException {
PathManager.loadProperties();
Collection<URL> classpath = new LinkedHashSet<URL>();
addParentClasspath(classpath, false);
addIDEALibraries(classpath);
addAdditionalClassPath(classpath);
addParentClasspath(classpath, true);
UrlClassLoader.Builder builder =
UrlClassLoader.build().urls(filterClassPath(new ArrayList<URL>(classpath))).allowLock().usePersistentClasspathIndexForLocalClassDirectories()
.useCache();
if (Boolean.valueOf(System.getProperty(PROPERTY_ALLOW_BOOTSTRAP_RESOURCES, "true"))) {
builder.allowBootstrapResources();
}
ClassLoaderUtil.addPlatformLoaderParentIfOnJdk9(builder);
UrlClassLoader newClassLoader = builder.get();
StartupActionLogger logger = null;
try {
logger = new StartupActionLogger();
logger.info("start: update=" + updatePlugins);
// prepare plugins
if (updatePlugins) {
try {
StartupActionScriptManager.executeActionScript(logger);
}
catch (IOException e) {
logger.error(e);
Main.showMessage("Plugin Installation Error", e);
}
}
}
finally {
if (logger != null) {
try {
logger.close();
}
catch (IOException ignored) {
}
}
}
Thread.currentThread().setContextClassLoader(newClassLoader);
return newClassLoader;
}
开发者ID:consulo,项目名称:consulo,代码行数:52,代码来源:BootstrapClassLoaderUtil.java
注:本文中的com.intellij.openapi.util.ClassLoaderUtil类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论