Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 156313 Details for
Bug 299756
org.eclipse.core.net is not using/providing a java.net.ProxySelector
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
This is a possible java.net.ProxySelector implementation for eclipse
EclipseProxySelector.java (text/plain), 2.34 KB, created by
Ivan Motsch
on 2010-01-16 11:28:24 EST
(
hide
)
Description:
This is a possible java.net.ProxySelector implementation for eclipse
Filename:
MIME Type:
Creator:
Ivan Motsch
Created:
2010-01-16 11:28:24 EST
Size:
2.34 KB
patch
obsolete
>package org.eclipse.core.net; > >import java.io.IOException; >import java.net.InetSocketAddress; >import java.net.Proxy; >import java.net.ProxySelector; >import java.net.SocketAddress; >import java.net.URI; >import java.net.URL; >import java.util.ArrayList; >import java.util.List; > >import org.eclipse.core.net.proxy.IProxyData; >import org.eclipse.core.net.proxy.IProxyService; >import org.osgi.framework.BundleContext; >import org.osgi.framework.ServiceReference; > >/** > * Implementation of a java.net {@link ProxySelector}. > * To activate this selector, call {@link ProxySelector#setDefault(ProxySelector)}. > * This will enable the full capability of the eclipse proxy selector to the java.net world. > * > * To make a connection, just create an {@link URL} and call {@link URL#openConnection()}. > * The {@link ProxySelector} will take care of all proxy related issues automatically. > */ >public class EclipseProxySelector extends ProxySelector{ > > @Override > public List<Proxy> select(URI uri){ > ArrayList<Proxy> list=new ArrayList<Proxy>(); > // > BundleContext context=Activator.getDefault().getBundle().getBundleContext(); > ServiceReference ref=context.getServiceReference(IProxyService.class.getName()); > if(ref!=null){ > try{ > IProxyService service=(IProxyService)context.getService(ref); > IProxyData[] datas=service.select(uri); > if(datas!=null){ > for(IProxyData data: datas){ > Proxy.Type javaNetType=null; > if(data.getType().equals(IProxyData.SOCKS_PROXY_TYPE)){ > javaNetType=Proxy.Type.SOCKS; > } > else if(data.getType().equals(IProxyData.HTTP_PROXY_TYPE)){ > javaNetType=Proxy.Type.HTTP; > } > else if(data.getType().equals(IProxyData.HTTPS_PROXY_TYPE)){ > javaNetType=Proxy.Type.HTTP; > } > if(javaNetType!=null){ > Proxy javaNetProxy=new Proxy(javaNetType,InetSocketAddress.createUnresolved(data.getHost(),data.getPort())); > list.add(javaNetProxy); > } > } > } > } > finally{ > context.ungetService(ref); > } > } > if(list.size()==0){ > list.add(Proxy.NO_PROXY); > } > return list; > } > > @Override > public void connectFailed(URI uri, SocketAddress sa, IOException ioe){ > } > >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 299756
: 156313