import java.beans.PropertyChangeListener;
import java.net.URL;
import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashSet;
import java.util.Hashtable;
import java.util.List;
import java.util.StringTokenizer;
}
return -2;
}
+
+ /**
+ * pick the user's preferred service based on a set of URLs (jaba server locations) and service URIs (specifying version and service interface class)
+ *
+ * @param serviceURL
+ * @return null or best match for given uri/ls.
+ */
+ public Jws2Instance getPreferredServiceFor(String[] serviceURLs)
+ {
+ HashSet<String> urls=new HashSet<String>();
+ urls.addAll(Arrays.asList(serviceURLs));
+ Jws2Instance match=null;
+ for (Jws2Instance svc:services)
+ {
+ if (urls.contains(svc.getServiceTypeURI()))
+ {
+ if (match==null) {
+ // for moment we always pick service from server ordered first in user's preferences
+ match=svc;
+ }
+ if (urls.contains(svc.getUri()))
+ {
+ // stop and return - we've matched type URI and URI for service endpoint
+ return svc;
+ }
+ }
+ }
+ return match;
+ }
}