当前位置: 首页>>代码示例>>Java>>正文


Java IProxyService.select方法代码示例

本文整理汇总了Java中org.eclipse.core.net.proxy.IProxyService.select方法的典型用法代码示例。如果您正苦于以下问题:Java IProxyService.select方法的具体用法?Java IProxyService.select怎么用?Java IProxyService.select使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.core.net.proxy.IProxyService的用法示例。


在下文中一共展示了IProxyService.select方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createProxy

import org.eclipse.core.net.proxy.IProxyService; //导入方法依赖的package包/类
@VisibleForTesting
public Proxy createProxy(URI uri) {
  Preconditions.checkNotNull(uri, "uri is null");
  Preconditions.checkArgument(!"http".equals(uri.getScheme()), "http is not a supported schema");

  IProxyService proxyServiceCopy = proxyService;
  if (proxyServiceCopy == null) {
    return Proxy.NO_PROXY;
  }

  IProxyData[] proxyDataForUri = proxyServiceCopy.select(uri);
  for (final IProxyData iProxyData : proxyDataForUri) {
    switch (iProxyData.getType()) {
      case IProxyData.HTTPS_PROXY_TYPE:
        return new Proxy(Type.HTTP, new InetSocketAddress(iProxyData.getHost(),
                                                          iProxyData.getPort()));
      case IProxyData.SOCKS_PROXY_TYPE:
        return new Proxy(Type.SOCKS, new InetSocketAddress(iProxyData.getHost(),
                                                           iProxyData.getPort()));
      default:
        logger.warning("Unsupported proxy type: " + iProxyData.getType());
        break;
    }
  }
  return Proxy.NO_PROXY;
}
 
开发者ID:GoogleCloudPlatform,项目名称:google-cloud-eclipse,代码行数:27,代码来源:ProxyFactory.java

示例2: prepareProxySettings

import org.eclipse.core.net.proxy.IProxyService; //导入方法依赖的package包/类
public void prepareProxySettings(String uriString) {
	URI uri;
	try {
		uri = new URI(uriString);
		IProxyService proxyService = Activator.getDefault()
				.getProxyService();
		IProxyData[] proxyDataForHost = proxyService.select(uri);
		for (IProxyData data : proxyDataForHost) {
			if (data.getHost() != null) {
				System.setProperty("http.proxySet", "true");
				System.setProperty("http.proxyHost", data.getHost());
			}
			if (data.getHost() != null) {
				System.setProperty("http.proxyPort",
						String.valueOf(data.getPort()));
			}
		}
		// Close the service and close the service tracker
		proxyService = null;
	} catch (URISyntaxException e) {
		getLog().log(
				new Status(IStatus.WARNING, PLUGIN_ID, e.getMessage(), e));
	}
}
 
开发者ID:diverse-project,项目名称:melange-studio,代码行数:25,代码来源:Activator.java

示例3: setupProxy

import org.eclipse.core.net.proxy.IProxyService; //导入方法依赖的package包/类
@SuppressWarnings("restriction")
private static CachingHttpClientBuilder setupProxy(CachingHttpClientBuilder builder, URI url){
	final IProxyService proxyService = HybridCore.getDefault().getProxyService();
	if(proxyService != null ){
		IProxyData[] proxies = proxyService.select(url);
		if(proxies != null && proxies.length > 0){
			IProxyData proxy = proxies[0];
			CredentialsProvider credsProvider = new BasicCredentialsProvider();
			if(proxy.isRequiresAuthentication()){
				credsProvider.setCredentials(new AuthScope(proxy.getHost(), proxy.getPort()), 
						new UsernamePasswordCredentials(proxy.getUserId(), proxy.getPassword()));
			}
			builder.setDefaultCredentialsProvider(credsProvider);
			builder.setProxy(new HttpHost(proxy.getHost(), proxy.getPort()));
		}
	}
	return builder;
	
}
 
开发者ID:eclipse,项目名称:thym,代码行数:20,代码来源:HttpUtil.java

示例4: getProxy

import org.eclipse.core.net.proxy.IProxyService; //导入方法依赖的package包/类
public static HttpProxyConfiguration getProxy(URL url) {
	if (url == null) {
		return null;
	}
	// In certain cases, the activator would have stopped and the plugin may
	// no longer be available. Usually onl happens on shutdown.
	CloudFoundryPlugin plugin = CloudFoundryPlugin.getDefault();
	if (plugin != null) {
		IProxyService proxyService = plugin.getProxyService();
		if (proxyService != null) {
			try {
				IProxyData[] selectedProxies = proxyService.select(url.toURI());

				// No proxy configured or not found
				if (selectedProxies == null || selectedProxies.length == 0) {
					return null;
				}

				IProxyData data = selectedProxies[0];
				int proxyPort = data.getPort();
				String proxyHost = data.getHost();
				String user = data.getUserId();
				String password = data.getPassword();
				return proxyHost != null ? new HttpProxyConfiguration(proxyHost, proxyPort,
						data.isRequiresAuthentication(), user, password) : null;
			}
			catch (URISyntaxException e) {
				// invalid url (protocol, ...) => proxy will be null
			}
		}
	}
	return null;
}
 
开发者ID:eclipse,项目名称:cft,代码行数:34,代码来源:CloudFoundryClientFactory.java

示例5: getProxy

import org.eclipse.core.net.proxy.IProxyService; //导入方法依赖的package包/类
public static IProxyData getProxy(URL url) {
	if (url == null) {
		return null;
	}
	// In certain cases, the activator would have stopped and the plugin may
	// no longer be available. Usually onl happens on shutdown.
	CloudFoundryPlugin plugin = CloudFoundryPlugin.getDefault();
	if (plugin != null) {
		IProxyService proxyService = plugin.getProxyService();
		if (proxyService != null) {
			try {
				IProxyData[] selectedProxies = proxyService.select(url.toURI());

				// No proxy configured or not found
				if (selectedProxies == null || selectedProxies.length == 0) {
					return null;
				}

				return selectedProxies[0];
			}
			catch (URISyntaxException e) {
				// invalid url (protocol, ...) => proxy will be null
			}
		}
	}
	return null;
}
 
开发者ID:eclipse,项目名称:cft,代码行数:28,代码来源:CloudServerUtil.java

示例6: getProxyData

import org.eclipse.core.net.proxy.IProxyService; //导入方法依赖的package包/类
private IProxyData getProxyData(URI uri) {
	IProxyService proxyService = getProxyService();
	if (proxyService != null && proxyService.isProxiesEnabled()) {
		if (!proxyService.isSystemProxiesEnabled()) {
			IProxyData[] proxies = proxyService.select(uri);
			if (proxies.length > 0) {
				return proxies[0];
			}
		}
	}
	return null;
}
 
开发者ID:kwin,项目名称:cppcheclipse,代码行数:13,代码来源:HttpClientService.java

示例7: ProxyConfig

import org.eclipse.core.net.proxy.IProxyService; //导入方法依赖的package包/类
public ProxyConfig(IProxyService proxyService, URI uri){
	IProxyData[] proxyDataForHost = proxyService.select(uri);
	for (IProxyData data : proxyDataForHost) {
		if (data.getHost() != null) {
			host      = data.getHost();
			port      = data.getPort();
			userId    = data.getUserId();
			password  = data.getPassword();
		}
	}
}
 
开发者ID:Jarlakxen,项目名称:eclipse-sbt-plugin,代码行数:12,代码来源:SbtExecutor.java


注:本文中的org.eclipse.core.net.proxy.IProxyService.select方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。