0
在测试中,我试图以编程方式更改Eclipse代理设置而不直接影响System
属性。IProxyService.setProxyData影响系统属性
我现在的尝试是这样:
httpProxyData.setHost(host)
httpProxyData.setPort(port)
httpProxyData.setUserid(userId)
httpProxyData.setPassword(password)
proxyService.setProxyData((IProxyData[]) [
httpProxyData
])
我的代理服务设置如下:
proxyService.setProxiesEnabled(true)
proxyService.setSystemProxiesEnabled(false)
当proxyService.setProxyData
执行,System.getproperty("http.proxyHost")
立即变为host
。 IProxyService API指出System
属性不会受到影响。我希望它能使System
属性只受到我在稍后或更早时间设置System.setProperty(..., ...)
的影响。
我做错了什么吗?
感谢greg-449。你指的是什么代码?我看了一下'ProxyManager',但是我找不到任何设置系统属性的东西。 – Citronen
'org.eclipse.core.internal.net.ProxyType'。它实际上调用'System.getProperties'并操作返回的属性。 –
有趣。在一个全新的项目中,当我在首选项(通过UI)中设置Eclipse代理设置时,然后创建一个程序来查询像'System.getProperty(“http.proxyHost”);'',它返回'null'。你碰巧知道如果使用UI调用'proxyService.setProxyData'的行吗? – Citronen