package jalview.ws.jws2;
import jalview.bin.Cache;
+import jalview.bin.ApplicationSingletonProvider;
+import jalview.bin.ApplicationSingletonProvider.ApplicationSingletonI;
import jalview.gui.AlignFrame;
import jalview.util.MessageManager;
import jalview.ws.ServiceChangeListener;
* @author JimP
*
*/
-public class Jws2Discoverer implements WSDiscovererI, Runnable
+public class Jws2Discoverer implements WSDiscovererI, Runnable, ApplicationSingletonI
{
+
+ /**
+ * Returns the singleton instance of this class.
+ *
+ * @return
+ */
+ public static Jws2Discoverer getInstance()
+ {
+ return (Jws2Discoverer) ApplicationSingletonProvider
+ .getInstance(Jws2Discoverer.class);
+ }
+
public static final String COMPBIO_JABAWS = "http://www.compbio.dundee.ac.uk/jabaws";
/*
private final static String JWS2HOSTURLS = "JWS2HOSTURLS";
/*
- * Singleton instance
- */
- private static Jws2Discoverer discoverer;
-
- /*
* Override for testing only
*/
- private static List<String> testUrls = null;
+ private List<String> testUrls = null;
// preferred url has precedence over others
private String preferredUrl;
private Set<ServiceChangeListener> serviceListeners = new CopyOnWriteArraySet<>();
-
private Vector<String> invalidServiceUrls = null;
private Vector<String> urlsWithoutServices = null;
*/
public static void main(String[] args)
{
+ Jws2Discoverer instance = getInstance();
if (args.length > 0)
{
- testUrls = new ArrayList<>();
+ instance.testUrls = new ArrayList<>();
for (String url : args)
{
- testUrls.add(url);
+ instance.testUrls.add(url);
}
}
- var discoverer = getDiscoverer();
+ var discoverer = getInstance();
discoverer.addServiceChangeListener((_discoverer, _services) -> {
if (discoverer.services != null)
{
System.out.println("Changesupport: There are now "
+ discoverer.services.size() + " services");
int i = 1;
- for (ServiceWithParameters instance : discoverer.services)
+ for (ServiceWithParameters s_instance : discoverer.services)
{
System.out.println(
- "Service " + i++ + " " + instance.getClass()
- + "@" + instance.getHostURL() + ": "
- + instance.getActionText());
+ "Service " + i++ + " " + s_instance.getClass()
+ + "@" + s_instance.getHostURL() + ": "
+ + s_instance.getActionText());
}
}
}
}
- /**
- * Returns the singleton instance of this class.
- *
- * @return
- */
- public static Jws2Discoverer getDiscoverer()
- {
- if (discoverer == null)
- {
- discoverer = new Jws2Discoverer();
- }
- return discoverer;
- }
@Override
public boolean hasServices()