Thanks for the guys phản ứng,
Điều này có thể được thực hiện bằng cách sử dụng lớp IProxyService trong nhật thực. Đoạn mã dưới đây đã sử dụng sự phản chiếu trong một số trường hợp mà bạn có thể bỏ qua. Ngoài ra hãy xem tại liên kết này (http://www.vogella.de/blog/2009/12/08/eclipse-rcp-proxy-preference/)
1) Nhận proxy tracker
private ServiceTracker getProxyTracker() throws ClassNotFoundException, SecurityException, NoSuchMethodException, IllegalArgumentException, IllegalAccessException, InvocationTargetException {
if (proxyTracker != null)
return proxyTracker;
String proxyServiceClassName = "org.eclipse.core.net.proxy.IProxyService";
String bundleClassName = "org.osgi.framework.Bundle";
Class bundleClass = Class.forName(bundleClassName);
Method getBundleContextMth = bundleClass.getMethod("getBundleContext", null);
getBundleContextMth.setAccessible(true);
BundleContext bundleCntx = (BundleContext) getBundleContextMth.invoke(bundle, null);
proxyTracker = new ServiceTracker(bundleCntx, proxyServiceClassName, null);
proxyTracker.open();
return proxyTracker;
}
2) Sử dụng phương pháp "isProxiesEnabled" để kiểm tra xem proxy được kích hoạt
3) Tùy theo Phiên bản nhật thực sử dụng phương thức "getProxyDataForHost" hoặc "chọn" để truy cập thông tin proxy nhật thực (máy chủ, userID, mật khẩu, v.v.).
Nguồn
2011-05-20 18:37:52
Không động = tính theo hàm javascript, dựa trên máy chủ đích không? Bạn đã thử sử dụng phương pháp IProxyService.select (URI) và chỉ định url mục tiêu của bạn ở đó chưa? –