本文整理汇总了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;
}
示例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));
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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();
}
}
}