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