+ /**
+ * the jalview .properties entry for JWS2 URLS
+ */
+ final static String JWS2HOSTURLS = "JWS2HOSTURLS";
+
+ public static void setServiceUrls(Vector<String> urls)
+ {
+ if (urls != null)
+ {
+ StringBuffer urlbuffer = new StringBuffer();
+ String sep = "";
+ for (String url : urls)
+ {
+ urlbuffer.append(sep);
+ urlbuffer.append(url);
+ sep = ",";
+ }
+ Cache.setProperty(JWS2HOSTURLS, urlbuffer.toString());
+ }
+ else
+ {
+ Cache.removeProperty(JWS2HOSTURLS);
+ }
+ }
+
+ public static Vector<String> getServiceUrls()
+ {
+ String surls = Cache.getDefault(JWS2HOSTURLS,
+ "http://www.compbio.dundee.ac.uk/jabaws");
+ Vector<String> urls = new Vector<String>();
+ try
+ {
+ StringTokenizer st = new StringTokenizer(surls, ",");
+ while (st.hasMoreElements())
+ {
+ String url = null;
+ try
+ {
+ java.net.URL u = new java.net.URL(url = st.nextToken());
+ if (!urls.contains(url))
+ {
+ urls.add(url);
+ }
+ else
+ {
+ jalview.bin.Cache.log.info("Ignoring duplicate url in "
+ + JWS2HOSTURLS + " list");
+ }
+ } catch (Exception ex)
+ {
+ jalview.bin.Cache.log
+ .warn("Problem whilst trying to make a URL from '"
+ + ((url != null) ? url : "<null>") + "'");
+ jalview.bin.Cache.log
+ .warn("This was probably due to a malformed comma separated list"
+ + " in the "
+ + JWS2HOSTURLS
+ + " entry of $(HOME)/.jalview_properties)");
+ jalview.bin.Cache.log.debug("Exception was ", ex);
+ }
+ }
+ } catch (Exception ex)
+ {
+ jalview.bin.Cache.log.warn(
+ "Error parsing comma separated list of urls in "
+ + JWS2HOSTURLS + " preference.", ex);
+ }
+ if (urls.size() >= 0)
+ {
+ return urls;
+ }
+ return null;
+ }
+
+ public Vector<Jws2Instance> getServices()
+ {
+ return (services == null) ? new Vector<Jws2Instance>()
+ : new Vector<Jws2Instance>(services);
+ }
+
+ /**
+ * test the given URL with the JabaWS test code
+ *
+ * @param foo
+ * @return
+ */
+ public static boolean testServiceUrl(URL foo)
+ {
+ try
+ {
+ compbio.ws.client.WSTester.main(new String[]
+ { "-h=" + foo.toString() });
+ } catch (Exception e)
+ {
+ return false;
+ } catch (OutOfMemoryError e)
+ {
+ return false;
+ } catch (Error e)
+ {
+ return false;
+ }
+ return true;
+ }
+