X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;ds=sidebyside;f=org.simantics.district.maps%2Fsrc%2Forg%2Fsimantics%2Fmaps%2Fpojo%2FAppletProxyUtil.java;fp=org.simantics.district.maps%2Fsrc%2Forg%2Fsimantics%2Fmaps%2Fpojo%2FAppletProxyUtil.java;h=1234bd42286d44cd8c6c5d5ef2bdbffc46a7db21;hb=e9f74f09e0cedb603c0b4de9e542de8dd64a5ce3;hp=0000000000000000000000000000000000000000;hpb=16ee01dc5a40981c58fd5b478b89552e5814e8bb;p=simantics%2Fdistrict.git
diff --git a/org.simantics.district.maps/src/org/simantics/maps/pojo/AppletProxyUtil.java b/org.simantics.district.maps/src/org/simantics/maps/pojo/AppletProxyUtil.java
new file mode 100644
index 00000000..1234bd42
--- /dev/null
+++ b/org.simantics.district.maps/src/org/simantics/maps/pojo/AppletProxyUtil.java
@@ -0,0 +1,48 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Association for Decentralized Information Management
+ * in Industry THTH ry.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * VTT Technical Research Centre of Finland - initial API and implementation
+ *******************************************************************************/
+package org.simantics.maps.pojo;
+
+import java.net.Proxy;
+import java.net.ProxySelector;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.List;
+
+import org.simantics.maps.IProxyUtil;
+
+/**
+ * @author Tuukka Lehtonen
+ */
+public class AppletProxyUtil implements IProxyUtil {
+
+ /**
+ * @return IProxyService of the platform or null
if the
+ * service is not available.
+ */
+ public Proxy getProxyService(final String url) {
+ List l;
+ try {
+ l = ProxySelector.getDefault().select(new URI(url));
+ } catch (URISyntaxException e) {
+ e.printStackTrace();
+ return null;
+ }
+
+ for(Proxy proxy : l) {
+ if(proxy.type() == Proxy.Type.HTTP && proxy.address() != null) {
+ return proxy;
+ }
+ }
+ return null;
+ }
+
+}