From 344bb951ea08871076500f04569c5fdbf1ff9249 Mon Sep 17 00:00:00 2001 From: pvtroshin Date: Fri, 12 Aug 2011 12:32:00 +0000 Subject: [PATCH] Services class refactored to get rid of engines and runners dependencies. Build script has new task to pack client sources git-svn-id: link to svn.lifesci.dundee.ac.uk/svn/barton/ptroshin/JABA2@4500 e3abac25-378b-4346-85de-24260fe3988d --- .settings/net.sf.jautodoc.prefs | 4 +- TODO.txt | 1 + build.xml | 25 ++++- .../stat/collector/ExecutionStatCollector.java | 7 +- webservices/compbio/ws/client/Services.java | 93 +------------------ webservices/compbio/ws/client/ServicesUtil.java | 96 ++++++++++++++++++++ 6 files changed, 131 insertions(+), 95 deletions(-) create mode 100644 webservices/compbio/ws/client/ServicesUtil.java diff --git a/.settings/net.sf.jautodoc.prefs b/.settings/net.sf.jautodoc.prefs index f9f3e1b..4c1e231 100644 --- a/.settings/net.sf.jautodoc.prefs +++ b/.settings/net.sf.jautodoc.prefs @@ -1,7 +1,7 @@ -#Fri Jul 16 12:02:13 BST 2010 +#Thu Aug 11 15:56:45 BST 2011 add_header=true eclipse.preferences.version=1 -header_text=/* Copyright (c) 2009 Peter Troshin\r\n * \r\n * JAva Bioinformatics Analysis Web Services (JABAWS) @version\: 1.0 \r\n * \r\n * This library is free software; you can redistribute it and/or modify it under the terms of the\r\n * Apache License version 2 as published by the Apache Software Foundation\r\n * \r\n * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without\r\n * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Apache \r\n * License for more details.\r\n * \r\n * A copy of the license is in apache_license.txt. It is also available here\:\r\n * @see\: http\://www.apache.org/licenses/LICENSE-2.0.txt\r\n * \r\n * Any republication or derived work distributed in source code form\r\n * must include this copyright and license notice.\r\n */ +header_text=/* Copyright (c) 2011 Peter Troshin\r\n * \r\n * JAva Bioinformatics Analysis Web Services (JABAWS) @version\: 2.0 \r\n * \r\n * This library is free software; you can redistribute it and/or modify it under the terms of the\r\n * Apache License version 2 as published by the Apache Software Foundation\r\n * \r\n * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without\r\n * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Apache \r\n * License for more details.\r\n * \r\n * A copy of the license is in apache_license.txt. It is also available here\:\r\n * @see\: http\://www.apache.org/licenses/LICENSE-2.0.txt\r\n * \r\n * Any republication or derived work distributed in source code form\r\n * must include this copyright and license notice.\r\n */ project_specific_settings=true replace_header=true replacements=\n\n\nGets the\nSets the\nAdds the\nEdits the\nRemoves the\nInits the\nParses the\nCreates the\nBuilds the\nChecks if is\nPrints the\nChecks for\n\n\n diff --git a/TODO.txt b/TODO.txt index 4ad000b..03ad987 100644 --- a/TODO.txt +++ b/TODO.txt @@ -1,3 +1,4 @@ +server war - obtaining command line binaries Write help on + execution stats diff --git a/build.xml b/build.xml index de21ce4..4a38ff3 100644 --- a/build.xml +++ b/build.xml @@ -23,6 +23,8 @@ + + @@ -181,7 +183,28 @@ - + + Jar file: JABAWS client source + + + + + + + + + + + + + + + + + + + + Jar file: Minimal WS client jar diff --git a/webservices/compbio/stat/collector/ExecutionStatCollector.java b/webservices/compbio/stat/collector/ExecutionStatCollector.java index cd97f4a..ad89058 100644 --- a/webservices/compbio/stat/collector/ExecutionStatCollector.java +++ b/webservices/compbio/stat/collector/ExecutionStatCollector.java @@ -38,6 +38,7 @@ import compbio.engine.client.SkeletalExecutable; import compbio.metadata.JobStatus; import compbio.util.FileUtil; import compbio.ws.client.Services; +import compbio.ws.client.ServicesUtil; /** * Number of runs of each WS = number of folders with name @@ -277,11 +278,11 @@ public class ExecutionStatCollector implements Runnable { } private Services getService() { - return Services.getServiceByJobDirectory(jobdir); + return ServicesUtil.getServiceByJobDirectory(jobdir); } long getResultSize() { - Class> name = Services + Class> name = ServicesUtil .getRunnerByJobDirectory(jobdir); File f = null; @@ -301,7 +302,7 @@ public class ExecutionStatCollector implements Runnable { } long getInputSize() { - Class> name = Services + Class> name = ServicesUtil .getRunnerByJobDirectory(jobdir); File input = files.get(SkeletalExecutable.INPUT); diff --git a/webservices/compbio/ws/client/Services.java b/webservices/compbio/ws/client/Services.java index 6626a5c..893117f 100644 --- a/webservices/compbio/ws/client/Services.java +++ b/webservices/compbio/ws/client/Services.java @@ -18,7 +18,6 @@ package compbio.ws.client; -import java.io.File; import java.net.URL; import java.util.Set; @@ -28,25 +27,16 @@ import javax.xml.ws.Service; import compbio.data.msa.JABAService; import compbio.data.msa.MsaWS; import compbio.data.msa.SequenceAnnotation; -import compbio.engine.client.ConfExecutable; -import compbio.engine.client.Executable; -import compbio.runner.conservation.AACon; -import compbio.runner.disorder.Disembl; -import compbio.runner.disorder.GlobPlot; -import compbio.runner.disorder.IUPred; -import compbio.runner.disorder.Jronn; -import compbio.runner.msa.ClustalO; -import compbio.runner.msa.ClustalW; -import compbio.runner.msa.Mafft; -import compbio.runner.msa.Muscle; -import compbio.runner.msa.Probcons; -import compbio.runner.msa.Tcoffee; /** * List of web services currently supported by JABAWS version 2 * */ public enum Services { + /* + * Make sure this class has NO references to runners or engines as it is a + * part of minimal client package. Such things should go into ServicesUtil + */ MafftWS, MuscleWS, ClustalWS, ClustalOWS, TcoffeeWS, ProbconsWS, AAConWS, JronnWS, DisemblWS, GlobPlotWS, IUPredWS; public static Services getService(String servName) { @@ -59,81 +49,6 @@ public enum Services { return null; } - public static Services getServiceByRunner( - Class> runnerClassName) { - assert runnerClassName != null; - String sname = runnerClassName.getSimpleName().toLowerCase(); - for (Services service : Services.values()) { - if (service.toString().toLowerCase().contains(sname)) { - return service; - } - } - return null; - } - - public Class> getServiceImpl() { - switch (this) { - case AAConWS : - return AACon.class; - case ClustalOWS : - return ClustalO.class; - case ClustalWS : - return ClustalW.class; - case MafftWS : - return Mafft.class; - case MuscleWS : - return Muscle.class; - case TcoffeeWS : - return Tcoffee.class; - case ProbconsWS : - return Probcons.class; - case DisemblWS : - return Disembl.class; - case GlobPlotWS : - return GlobPlot.class; - case JronnWS : - return Jronn.class; - case IUPredWS : - return IUPred.class; - default : - throw new RuntimeException( - "Unknown web service implementation class for service: " - + this); - } - } - - public static Class> getRunnerByJobDirectory( - File jobdir) { - Services service = getServiceByRunnerName(getRunnerNameByJobDirectory(jobdir)); - return service.getServiceImpl(); - } - - private static String getRunnerNameByJobDirectory(File jobdir) { - String name = jobdir.getName().split("#")[0]; - - if (name.startsWith(ConfExecutable.CLUSTER_TASK_ID_PREFIX)) { - assert ConfExecutable.CLUSTER_TASK_ID_PREFIX.length() == 1; - name = name.substring(1); - } - return name; - } - - public static Services getServiceByJobDirectory(File jobdir) { - return getServiceByRunnerName(getRunnerNameByJobDirectory(jobdir)); - } - - private static Services getServiceByRunnerName(String name) { - for (Services service : Services.values()) { - String runnerName = service.getServiceImpl().getSimpleName() - .toLowerCase(); - name = name.trim().toLowerCase(); - if (name.startsWith(runnerName)) { - return service; - } - } - return null; - } - Service getService(URL url, String sqname) { QName qname = new QName(sqname, this.toString()); return Service.create(url, qname); diff --git a/webservices/compbio/ws/client/ServicesUtil.java b/webservices/compbio/ws/client/ServicesUtil.java new file mode 100644 index 0000000..2646a09 --- /dev/null +++ b/webservices/compbio/ws/client/ServicesUtil.java @@ -0,0 +1,96 @@ +package compbio.ws.client; + +import java.io.File; + +import compbio.engine.client.ConfExecutable; +import compbio.engine.client.Executable; +import compbio.runner.conservation.AACon; +import compbio.runner.disorder.Disembl; +import compbio.runner.disorder.GlobPlot; +import compbio.runner.disorder.IUPred; +import compbio.runner.disorder.Jronn; +import compbio.runner.msa.ClustalO; +import compbio.runner.msa.ClustalW; +import compbio.runner.msa.Mafft; +import compbio.runner.msa.Muscle; +import compbio.runner.msa.Probcons; +import compbio.runner.msa.Tcoffee; + +public class ServicesUtil { + + public static Services getServiceByRunner( + Class> runnerClassName) { + assert runnerClassName != null; + String sname = runnerClassName.getSimpleName().toLowerCase(); + for (Services service : Services.values()) { + if (service.toString().toLowerCase().contains(sname)) { + return service; + } + } + return null; + } + + public static Class> getServiceImpl(Services service) { + switch (service) { + case AAConWS : + return AACon.class; + case ClustalOWS : + return ClustalO.class; + case ClustalWS : + return ClustalW.class; + case MafftWS : + return Mafft.class; + case MuscleWS : + return Muscle.class; + case TcoffeeWS : + return Tcoffee.class; + case ProbconsWS : + return Probcons.class; + case DisemblWS : + return Disembl.class; + case GlobPlotWS : + return GlobPlot.class; + case JronnWS : + return Jronn.class; + case IUPredWS : + return IUPred.class; + default : + throw new RuntimeException( + "Unknown web service implementation class for service: " + + service); + } + } + + public static Class> getRunnerByJobDirectory( + File jobdir) { + Services service = getServiceByRunnerName(getRunnerNameByJobDirectory(jobdir)); + return getServiceImpl(service); + } + + private static String getRunnerNameByJobDirectory(File jobdir) { + String name = jobdir.getName().split("#")[0]; + + if (name.startsWith(ConfExecutable.CLUSTER_TASK_ID_PREFIX)) { + assert ConfExecutable.CLUSTER_TASK_ID_PREFIX.length() == 1; + name = name.substring(1); + } + return name; + } + + public static Services getServiceByJobDirectory(File jobdir) { + return getServiceByRunnerName(getRunnerNameByJobDirectory(jobdir)); + } + + private static Services getServiceByRunnerName(String name) { + for (Services service : Services.values()) { + String runnerName = getServiceImpl(service).getSimpleName() + .toLowerCase(); + name = name.trim().toLowerCase(); + if (name.startsWith(runnerName)) { + return service; + } + } + return null; + } + +} -- 1.7.10.2