update to Jaba_r1 minimal client distribution, and resolve issues JAL-602
authorjprocter <Jim Procter>
Tue, 20 Jul 2010 09:05:46 +0000 (09:05 +0000)
committerjprocter <Jim Procter>
Tue, 20 Jul 2010 09:05:46 +0000 (09:05 +0000)
.classpath
lib/min-jaba-client.jar [moved from lib/min-jws2-client-1.0.jar with 64% similarity]
src/jalview/ws/jws2/Jws2Discoverer.java

index d29d712..7ec0109 100644 (file)
@@ -18,7 +18,7 @@
        <classpathentry kind="lib" path="lib/castor-1.1-cycle-xml.jar" sourcepath="C:/Documents and Settings/JimP/workspace-3.3/castor/src/main/java"/>
        <classpathentry kind="lib" path="lib/JGoogleAnalytics-0.2.1-SNAPSHOT.jar" sourcepath="/JGoogleAnalytics/src/main/java"/>
        <classpathentry kind="lib" path="lib/vamsas-client.jar"/>
-       <classpathentry kind="lib" path="lib/min-jws2-client-1.0.jar"/>
        <classpathentry kind="lib" path="lib/Jmol-12.0.RC18.jar" sourcepath="D:/BartonStuff/jmol/src.zip"/>
+       <classpathentry kind="lib" path="lib/min-jaba-client.jar"/>
        <classpathentry kind="output" path="classes"/>
 </classpath>
similarity index 64%
rename from lib/min-jws2-client-1.0.jar
rename to lib/min-jaba-client.jar
index fcd8443..82c33dc 100644 (file)
Binary files a/lib/min-jws2-client-1.0.jar and b/lib/min-jaba-client.jar differ
index 95100e0..2230d11 100644 (file)
@@ -5,6 +5,7 @@ import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
 import java.beans.PropertyChangeEvent;
 import java.beans.PropertyChangeListener;
+import java.io.Closeable;
 import java.net.ConnectException;
 import java.net.URL;
 import java.util.HashSet;
@@ -26,8 +27,8 @@ import compbio.metadata.Option;
 import compbio.metadata.Preset;
 import compbio.metadata.PresetManager;
 import compbio.metadata.RunnerConfig;
-import compbio.ws.client.Jws2Base;
-import compbio.ws.client.Jws2Base.Services;
+import compbio.ws.client.Jws2Client;
+import compbio.ws.client.Services;
 
 /**
  * discoverer for jws2 services. Follows the lightweight service discoverer
@@ -81,7 +82,7 @@ public class Jws2Discoverer implements Runnable, WSMenuEntryProviderI
     try
     {
       Class foo = getClass().getClassLoader().loadClass(
-              "compbio.ws.client.Jws2Base");
+              "compbio.ws.client.Jws2Client");
     } catch (ClassNotFoundException e)
     {
       System.err
@@ -98,15 +99,15 @@ public class Jws2Discoverer implements Runnable, WSMenuEntryProviderI
     {
       try
       {
-        if (Jws2Base.validURL(jwsservers))
+        if (Jws2Client.validURL(jwsservers))
         {
           // look for services
-          for (Services srv : Jws2Base.Services.values())
+          for (Services srv : Services.values())
           {
             MsaWS service = null;
             try
             {
-              service = Jws2Base.connect(jwsservers, srv);
+              service = Jws2Client.connect(jwsservers, srv);
             } catch (Exception e)
             {
               System.err.println("Jws2 Discoverer: Problem on "
@@ -205,37 +206,51 @@ public class Jws2Discoverer implements Runnable, WSMenuEntryProviderI
     public String getHost()
     {
       return hosturl;
-/*      try
-      {
-        URL serviceurl = new URL(hosturl);
-        if (serviceurl.getPort()!=80)
-        {
-          return serviceurl.getHost()+":"+serviceurl.getPort();
-        }
-        return serviceurl.getHost();
-      } catch (Exception e)
-      {
-        System.err.println("Failed to parse service URL '" + hosturl
-                + "' as a valid URL!");
-      }
-      return null; */
+      /*
+       * try { URL serviceurl = new URL(hosturl); if (serviceurl.getPort()!=80)
+       * { return serviceurl.getHost()+":"+serviceurl.getPort(); } return
+       * serviceurl.getHost(); } catch (Exception e) {
+       * System.err.println("Failed to parse service URL '" + hosturl +
+       * "' as a valid URL!"); } return null;
+       */
     }
+
     /**
      * @return short description of what the service will do
      */
-    public String getActionText() {
-      return "Align with "
-      + serviceType;
+    public String getActionText()
+    {
+      return "Align with " + serviceType;
     }
 
     /**
-     * non-thread safe - blocks whilst accessing service to get complete set of available options and parameters
+     * non-thread safe - blocks whilst accessing service to get complete set of
+     * available options and parameters
+     * 
      * @return
      */
     public RunnerConfig getRunnerConfig()
     {
       return service.getRunnerOptions();
     }
+
+    @Override
+    protected void finalize() throws Throwable
+    {
+      if (service != null)
+      {
+        try
+        {
+          Closeable svc = (Closeable) service;
+          service = null;
+          svc.close();
+        } catch (Exception e)
+        {
+        }
+        ;
+      }
+      super.finalize();
+    }
   };
 
   /**
@@ -245,6 +260,7 @@ public class Jws2Discoverer implements Runnable, WSMenuEntryProviderI
 
   /**
    * find or add a submenu with the given title in the given menu
+   * 
    * @param menu
    * @param submenu
    * @return the new or existing submenu
@@ -252,22 +268,24 @@ public class Jws2Discoverer implements Runnable, WSMenuEntryProviderI
   private JMenu findOrCreateMenu(JMenu menu, String submenu)
   {
     JMenu submenuinstance = null;
-    for (int i=0,iSize=menu.getMenuComponentCount(); i<iSize; i++)
+    for (int i = 0, iSize = menu.getMenuComponentCount(); i < iSize; i++)
     {
-      if (menu.getMenuComponent(i) instanceof JMenu && 
-               ((JMenu)menu.getMenuComponent(i)).getText().equals(submenu))
+      if (menu.getMenuComponent(i) instanceof JMenu
+              && ((JMenu) menu.getMenuComponent(i)).getText().equals(
+                      submenu))
       {
         submenuinstance = (JMenu) menu.getMenuComponent(i);
       }
     }
-    if (submenuinstance==null)
+    if (submenuinstance == null)
     {
       submenuinstance = new JMenu(submenu);
       menu.add(submenuinstance);
     }
     return submenuinstance;
-  
+
   }
+
   @Override
   public void attachWSMenuEntry(JMenu wsmenu, final AlignFrame alignFrame)
   {
@@ -283,7 +301,7 @@ public class Jws2Discoverer implements Runnable, WSMenuEntryProviderI
      */
     JMenu atpoint, jws2al = new JMenu("JABA Alignment");
     MsaWSClient msacl = new MsaWSClient();
-    Vector hostLabels=new Vector();
+    Vector hostLabels = new Vector();
     for (final Jws2Instance service : services)
     {
       atpoint = jws2al;
@@ -292,24 +310,27 @@ public class Jws2Discoverer implements Runnable, WSMenuEntryProviderI
       if (byhost)
       {
         atpoint = findOrCreateMenu(atpoint, host);
-        if (atpoint.getToolTipText()==null) {
-          atpoint.setToolTipText("Services at "+host);
+        if (atpoint.getToolTipText() == null)
+        {
+          atpoint.setToolTipText("Services at " + host);
         }
       }
       if (bytype)
       {
-        atpoint = findOrCreateMenu(atpoint,type);
-        if (atpoint.getToolTipText()==null) {
+        atpoint = findOrCreateMenu(atpoint, type);
+        if (atpoint.getToolTipText() == null)
+        {
           atpoint.setToolTipText(service.getActionText());
         }
       }
-      if (!byhost && !hostLabels.contains(host+service.getActionText()))
+      if (!byhost && !hostLabels.contains(host + service.getActionText()))
       {
         // add a marker indicating where this service is hosted
-        // relies on services from the same host being listed in a contiguous group 
+        // relies on services from the same host being listed in a contiguous
+        // group
         JMenuItem hitm;
         atpoint.addSeparator();
-        atpoint.add(hitm=new JMenuItem(host));
+        atpoint.add(hitm = new JMenuItem(host));
         hitm.setForeground(Color.blue);
         hostLabels.addElement(host);
       }
@@ -457,7 +478,8 @@ public class Jws2Discoverer implements Runnable, WSMenuEntryProviderI
 
   public Vector<Jws2Instance> getServices()
   {
-    return (services==null) ? new Vector<Jws2Instance>(): new Vector<Jws2Instance>(services);
+    return (services == null) ? new Vector<Jws2Instance>()
+            : new Vector<Jws2Instance>(services);
   }
 
 }