Interface IProxyService
-
public interface IProxyService
Manages the proxy data and related information. The proxy service is registered as an OSGi service. Clients can obtain an instance of the service from their bundle context or from a service tracker.Clients that wish to make a connection and need to determine whether to use a proxy or not should call either
getProxyDataForHost(String)
orgetProxyDataForHost(String, String)
.- Since:
- 1.0
- Restriction:
- This interface is not intended to be implemented by clients.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Deprecated Methods Modifier and Type Method Description void
addProxyChangeListener(IProxyChangeListener listener)
Registers a listener that will be notified when proxy related information changes.String[]
getNonProxiedHosts()
Returns the list of hosts for which non proxy should be used.IProxyData[]
getProxyData()
Returns the list of know proxy types and their settings.IProxyData
getProxyData(String type)
Returns the proxy data for the proxy of the given type ornull
if the proxy type is not known by this service.IProxyData[]
getProxyDataForHost(String host)
Deprecated.This method is deprecated because of its ambiguity.IProxyData
getProxyDataForHost(String host, String type)
Deprecated.This method is deprecated because of its ambiguity.boolean
hasSystemProxies()
Returns whether system proxy support is available.boolean
isProxiesEnabled()
Returns whether proxy support should be enabled.boolean
isSystemProxiesEnabled()
Returns whether system proxy should be used when the proxy support is enabled.void
removeProxyChangeListener(IProxyChangeListener listener)
Removes a listener.IProxyData[]
select(URI uri)
Returns all the applicable proxy data to access the specified URI.void
setNonProxiedHosts(String[] hosts)
Sets the list of hosts for which non proxy should be used.void
setProxiesEnabled(boolean enabled)
Sets whether proxy support should be enabled.void
setProxyData(IProxyData[] proxies)
Sets the information associated with known proxy types.void
setSystemProxiesEnabled(boolean enabled)
Sets whether system proxies should be used, when the proxy support is enabled.
-
-
-
Method Detail
-
setProxiesEnabled
void setProxiesEnabled(boolean enabled)
Sets whether proxy support should be enabled. The current proxy settings are still kept so clients should check the enablement usingisProxiesEnabled()
before calling thegetProxyData()
orgetProxyData(String)
method. However, thegetProxyDataForHost(String)
andgetProxyDataForHost(String, String)
method will check the enablement and only return data if the service is enabled.- Parameters:
enabled
- whether proxy support should be enabled
-
isProxiesEnabled
boolean isProxiesEnabled()
Returns whether proxy support should be enabled. When disabled, all connections will be direct.Returns
false
, when the system proxies support is enabled buthasSystemProxies()
returnsfalse
.- Returns:
- whether proxy support should be enabled
-
hasSystemProxies
boolean hasSystemProxies()
Returns whether system proxy support is available.- Returns:
- whether system proxy support is available
- Since:
- 1.1
-
setSystemProxiesEnabled
void setSystemProxiesEnabled(boolean enabled)
Sets whether system proxies should be used, when the proxy support is enabled.- Parameters:
enabled
- whether system proxies should be used- Since:
- 1.1
-
isSystemProxiesEnabled
boolean isSystemProxiesEnabled()
Returns whether system proxy should be used when the proxy support is enabled.- Returns:
- whether system proxy is used when the proxy support is enabled
- Since:
- 1.1
-
getProxyData
IProxyData[] getProxyData()
Returns the list of know proxy types and their settings. Some of the returned proxy types may not be enabled (i.e, their hosts may benull
.Clients that wish to make a connection and need to determine whether to use a proxy or not should call either
getProxyDataForHost(String)
orgetProxyDataForHost(String, String)
.This method returns the proxies set via
setProxyData(IProxyData[])
- Returns:
- the list of know proxy types and their settings
-
select
IProxyData[] select(URI uri)
Returns all the applicable proxy data to access the specified URI.Clients that wish to make a connection and need to determine whether to use a proxy should use this method.
- Parameters:
uri
- the URI for which proxies are returned- Returns:
- list of all applicable proxy data, if no proxy is applicable then an empty array is returned
- Since:
- 1.2
-
getProxyDataForHost
@Deprecated IProxyData[] getProxyDataForHost(String host)
Deprecated.This method is deprecated because of its ambiguity. Useselect(URI)
instead.Returns the list of known proxy types and their settings for the given host. If proxies are disabled or if the host matches any entries in the non-proxied hosts lists or if a matching proxy type has no data, then an empty array is returned.Clients that wish to make a connection and need to determine whether to use a proxy should use this method.
- Parameters:
host
- the host for which a connection is desired- Returns:
- the list of known proxy types and their settings for the given host
-
getProxyData
IProxyData getProxyData(String type)
Returns the proxy data for the proxy of the given type ornull
if the proxy type is not known by this service.Clients that wish to make a connection and need to determine whether to use a proxy or not should call either
getProxyDataForHost(String)
orgetProxyDataForHost(String, String)
.This method returns the proxies set via
setProxyData(IProxyData[])
- Parameters:
type
- the proxy type- Returns:
- the proxy data for the proxy of the given type or
null
- See Also:
IProxyData.HTTP_PROXY_TYPE
,IProxyData.HTTPS_PROXY_TYPE
,IProxyData.SOCKS_PROXY_TYPE
-
getProxyDataForHost
@Deprecated IProxyData getProxyDataForHost(String host, String type)
Deprecated.This method is deprecated because of its ambiguity. Useselect(URI)
instead.Returns the proxy data for the proxy of the given type ornull
if the proxy type is not known by this service, the proxy data is empty for that type or the host is in the non-proxied host list.Clients that wish to make a connection and need to determine whether to use a proxy should use this method.
- Parameters:
host
- the host for which a connection is desiredtype
- the proxy type- Returns:
- the proxy data for the proxy of the given type or
null
- See Also:
IProxyData.HTTP_PROXY_TYPE
,IProxyData.HTTPS_PROXY_TYPE
,IProxyData.SOCKS_PROXY_TYPE
-
setProxyData
void setProxyData(IProxyData[] proxies) throws CoreException
Sets the information associated with known proxy types. If an unknown type is provided, it will be ignored. Any known types that are not present in the list of the provided proxy data will be unaffected.This method affects only proxies defined in Eclipse by user and doesn't affect settings of the system proxies (being used when the system support is enabled).
- Parameters:
proxies
- the proxy data whose information is to be set.- Throws:
CoreException
- if the proxy could not be set
-
getNonProxiedHosts
String[] getNonProxiedHosts()
Returns the list of hosts for which non proxy should be used. The values returned from this method should only be used for displaying the non-proxed hosts list.Clients that wish to make a connection and need to determine whether to use a proxy or not should call either
getProxyDataForHost(String)
orgetProxyDataForHost(String, String)
.This method returns the hosts set via
setNonProxiedHosts(String[])
- Returns:
- the list of hosts for which non proxy should be used.
- See Also:
getProxyDataForHost(String)
,getProxyDataForHost(String, String)
-
setNonProxiedHosts
void setNonProxiedHosts(String[] hosts) throws CoreException
Sets the list of hosts for which non proxy should be used.This method affects only non-proxied hosts defined in Eclipse by user and doesn't affect settings of the system proxies (being used when the system support is enabled).
- Parameters:
hosts
- the list of hosts for which non proxy should be used- Throws:
CoreException
- if the non-proxied host list could not be set
-
addProxyChangeListener
void addProxyChangeListener(IProxyChangeListener listener)
Registers a listener that will be notified when proxy related information changes. Adding a listener that is already registered has no effect.- Parameters:
listener
- a change listener
-
removeProxyChangeListener
void removeProxyChangeListener(IProxyChangeListener listener)
Removes a listener. Removing a listener that is not registered has no effect.- Parameters:
listener
- a change listener
-
-