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;
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
try
{
Class foo = getClass().getClassLoader().loadClass(
- "compbio.ws.client.Jws2Base");
+ "compbio.ws.client.Jws2Client");
} catch (ClassNotFoundException e)
{
System.err
{
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 "
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();
+ }
};
/**
/**
* find or add a submenu with the given title in the given menu
+ *
* @param menu
* @param submenu
* @return the new or existing submenu
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)
{
*/
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;
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);
}
public Vector<Jws2Instance> getServices()
{
- return (services==null) ? new Vector<Jws2Instance>(): new Vector<Jws2Instance>(services);
+ return (services == null) ? new Vector<Jws2Instance>()
+ : new Vector<Jws2Instance>(services);
}
}