X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fws%2Fjws2%2FJws2Discoverer.java;h=bd4d3525dcb2763eaeb749f4bdcad681c6275ac7;hb=a83adb45bdf9554e270921b4baad94defd314b36;hp=516a7190aa3d7329737b7493b3e8e49b8cb429cc;hpb=d4ec118f86b5c9dee801e743c46aaacc7bb521d1;p=jalview.git diff --git a/src/jalview/ws/jws2/Jws2Discoverer.java b/src/jalview/ws/jws2/Jws2Discoverer.java index 516a719..bd4d352 100644 --- a/src/jalview/ws/jws2/Jws2Discoverer.java +++ b/src/jalview/ws/jws2/Jws2Discoverer.java @@ -21,6 +21,8 @@ package jalview.ws.jws2; import jalview.bin.Cache; +import jalview.bin.ApplicationSingletonProvider; +import jalview.bin.ApplicationSingletonProvider.ApplicationSingletonI; import jalview.gui.AlignFrame; import jalview.gui.Desktop; import jalview.gui.JvSwingUtils; @@ -60,8 +62,29 @@ import compbio.ws.client.Services; * @author JimP * */ -public class Jws2Discoverer implements Runnable, WSMenuEntryProviderI +public class Jws2Discoverer + implements Runnable, WSMenuEntryProviderI, ApplicationSingletonI { + + /** + * Returns the singleton instance of this class. + * + * @return + */ + public static Jws2Discoverer getInstance() + { + return (Jws2Discoverer) ApplicationSingletonProvider + .getInstance(Jws2Discoverer.class); + } + + /** + * Private constructor enforces use of singleton via getDiscoverer() + */ + private Jws2Discoverer() + { + // use getInstance(); + } + public static final String COMPBIO_JABAWS = "http://www.compbio.dundee.ac.uk/jabaws"; /* @@ -70,11 +93,6 @@ public class Jws2Discoverer implements Runnable, WSMenuEntryProviderI private final static String JWS2HOSTURLS = "JWS2HOSTURLS"; /* - * Singleton instance - */ - private static Jws2Discoverer discoverer; - - /* * Override for testing only */ private static List testUrls = null; @@ -82,7 +100,7 @@ public class Jws2Discoverer implements Runnable, WSMenuEntryProviderI // preferred url has precedence over others private String preferredUrl; - private PropertyChangeSupport changeSupport = new PropertyChangeSupport( + protected PropertyChangeSupport changeSupport = new PropertyChangeSupport( this); private Vector invalidServiceUrls = null; @@ -103,13 +121,6 @@ public class Jws2Discoverer implements Runnable, WSMenuEntryProviderI protected Vector services; /** - * Private constructor enforces use of singleton via getDiscoverer() - */ - private Jws2Discoverer() - { - } - - /** * change listeners are notified of "services" property changes * * @param listener @@ -190,7 +201,7 @@ public class Jws2Discoverer implements Runnable, WSMenuEntryProviderI oldthread = Thread.currentThread(); try { - Class foo = getClass().getClassLoader() + getClass().getClassLoader() .loadClass("compbio.ws.client.Jws2Client"); } catch (ClassNotFoundException e) { @@ -591,19 +602,19 @@ public class Jws2Discoverer implements Runnable, WSMenuEntryProviderI testUrls.add(url); } } - Thread runner = getDiscoverer() + Thread runner = getInstance() .startDiscoverer(new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { - if (getDiscoverer().services != null) + if (getInstance().services != null) { System.out.println("Changesupport: There are now " - + getDiscoverer().services.size() + " services"); + + getInstance().services.size() + " services"); int i = 1; - for (Jws2Instance instance : getDiscoverer().services) + for (Jws2Instance instance : getInstance().services) { System.out.println("Service " + i++ + " " + instance.getClass() + "@" + instance.getHost() @@ -630,20 +641,6 @@ public class Jws2Discoverer implements Runnable, WSMenuEntryProviderI } } - /** - * Returns the singleton instance of this class. - * - * @return - */ - public static Jws2Discoverer getDiscoverer() - { - if (discoverer == null) - { - discoverer = new Jws2Discoverer(); - } - return discoverer; - } - public boolean hasServices() { return !running && services != null && services.size() > 0;