X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fws%2Fjws2%2Fjabaws2%2FJws2Instance.java;h=36a42ab5309899f558cefdb3e6153338d13d45d6;hb=7b9f93ca2c7f5e5d9347f00be309522f76e3e778;hp=3bff20bbef5a05f132fbccf47fd2e9aa136a57f3;hpb=1da7e0f4efb175c55ded1b68e14bc4a9f955ec29;p=jalview.git diff --git a/src/jalview/ws/jws2/jabaws2/Jws2Instance.java b/src/jalview/ws/jws2/jabaws2/Jws2Instance.java index 3bff20b..36a42ab 100644 --- a/src/jalview/ws/jws2/jabaws2/Jws2Instance.java +++ b/src/jalview/ws/jws2/jabaws2/Jws2Instance.java @@ -20,19 +20,16 @@ */ package jalview.ws.jws2.jabaws2; -import jalview.gui.AlignFrame; import jalview.gui.Desktop; import jalview.util.MessageManager; +import jalview.ws.api.JalviewServiceEndpointProviderI; import jalview.ws.api.ServiceWithParameters; import jalview.ws.jws2.JabaParamStore; -import jalview.ws.jws2.MsaWSClient; -import jalview.ws.jws2.SequenceAnnotationWSClient; import jalview.ws.params.ParamDatastoreI; import jalview.ws.params.ParamManager; import java.io.Closeable; - -import javax.swing.JMenu; +import java.net.URL; import compbio.data.msa.JABAService; import compbio.data.msa.MsaWS; @@ -41,12 +38,11 @@ import compbio.metadata.PresetManager; import compbio.metadata.RunnerConfig; public class Jws2Instance extends ServiceWithParameters + implements AutoCloseable { public JABAService service; - public String docUrl; - /** * * @param hosturl @@ -66,14 +62,38 @@ public class Jws2Instance extends ServiceWithParameters { super(action, action, serviceType, description, hosturl); this.service = service; + if (service instanceof MsaWS) + { + style = ServiceClient.MSAWSCLIENT; + } + else if (service instanceof SequenceAnnotation) + { + style = ServiceClient.SEQUENCEANNOTATIONWSCLIENT; + } + int p = description.indexOf("MORE INFORMATION:"); if (p > -1) { - docUrl = description.substring(description.indexOf("http", p)).trim(); + String docUrl = description.substring(description.indexOf("http", p)) + .trim(); if (docUrl.indexOf('\n') > -1) { docUrl = docUrl.substring(0, docUrl.indexOf("\n")).trim(); } + if (docUrl.length() > 0) + { + try + { + URL url = new URL(docUrl); + if (url != null) + { + setDocumentationUrl(docUrl); + } + } catch (Exception x) + { + + } + } } } @@ -135,7 +155,7 @@ public class Jws2Instance extends ServiceWithParameters } @Override - protected void finalize() throws Throwable + public void close() { if (service != null) { @@ -147,7 +167,7 @@ public class Jws2Instance extends ServiceWithParameters // ignore } } - super.finalize(); + // super.finalize(); } @Override @@ -158,7 +178,7 @@ public class Jws2Instance extends ServiceWithParameters try { paramStore = new JabaParamStore(this, - (Desktop.instance != null ? Desktop.getUserParameterStore() + (Desktop.getInstance() != null ? Desktop.getUserParameterStore() : null)); } catch (Exception ex) { @@ -170,20 +190,9 @@ public class Jws2Instance extends ServiceWithParameters return paramStore; } - public String getUri() - { - // TODO verify that service parameter sets in projects are consistent with - // Jalview 2.10.4 - // this is only valid for Jaba 1.0 - this formula might have to change! - return getHostURL() - + (getHostURL().lastIndexOf("/") == (getHostURL().length() - 1) - ? "" - : "/") - + getName(); - } - private boolean hasParams = false, lookedForParams = false; + @Override public boolean hasParameters() { if (!lookedForParams) @@ -200,31 +209,6 @@ public class Jws2Instance extends ServiceWithParameters return hasParams; } - public void attachWSMenuEntry(JMenu atpoint, AlignFrame alignFrame) - { - if (service instanceof MsaWS) - { - new MsaWSClient().attachWSMenuEntry(atpoint, this, alignFrame); - } - else if (service instanceof SequenceAnnotation) - { - new SequenceAnnotationWSClient().attachWSMenuEntry(atpoint, this, - alignFrame); - } - } - - public String getNameURI() - { - return "java:" + getName(); - } - - jalview.ws.uimodel.AlignAnalysisUIText aaui; - - public jalview.ws.uimodel.AlignAnalysisUIText getAlignAnalysisUI() - { - return aaui; - } - /** * initialise a parameter store for this service * @@ -239,4 +223,48 @@ public class Jws2Instance extends ServiceWithParameters paramStore = new JabaParamStore(this, userParameterStore); } } + + /** + * an object that implements one or more interfaces in jalview.ws.api + * + * @return + */ + @Override + public Object getEndpoint() + { + if (service instanceof MsaWS) + { + if (aaui != null) + { + throw new Error( + "JABAWS MsaWS based instant calculation not implemented."); + + } + else + { + return new JabawsMsaInstance(this); + } + } + else + { + if (service instanceof compbio.data.msa.SequenceAnnotation) + { + if (aaui != null) + { + try + { + // probably a factory would be nicer but.. + return aaui.getClient().getConstructor(getClass()) + .newInstance(this); + } catch (Throwable t) + { + throw new Error("Implementation Error in web service framework", + t); + } + } + return new AADisorderClient(this); + } + return null; + } + } }