Adding registry web service and changes to WStester and JWS2Client code. Bugs in...
authorpvtroshin <pvtroshin@e3abac25-378b-4346-85de-24260fe3988d>
Mon, 6 Jun 2011 18:16:36 +0000 (18:16 +0000)
committerpvtroshin <pvtroshin@e3abac25-378b-4346-85de-24260fe3988d>
Mon, 6 Jun 2011 18:16:36 +0000 (18:16 +0000)
git-svn-id: link to svn.lifesci.dundee.ac.uk/svn/barton/ptroshin/JABA2@4223 e3abac25-378b-4346-85de-24260fe3988d

17 files changed:
TODO.txt
WEB-INF/sun-jaxws.xml
WEB-INF/web.xml
conf/Executable.properties
engine/compbio/engine/client/SkeletalExecutable.java
testsrc/compbio/ws/client/WSTesterTester.java [new file with mode: 0644]
testsrc/compbio/ws/server/RegistryWSTester.java [new file with mode: 0644]
webservices/compbio/data/msa/RegistryWS.java [new file with mode: 0644]
webservices/compbio/ws/client/Jws2Client.java
webservices/compbio/ws/client/Services.java
webservices/compbio/ws/client/WSTester.java
webservices/compbio/ws/server/AAConWS.java
webservices/compbio/ws/server/DisemblWS.java
webservices/compbio/ws/server/GlobPlotWS.java
webservices/compbio/ws/server/JronnWS.java
webservices/compbio/ws/server/MuscleWS.java
webservices/compbio/ws/server/RegistryWS.java [new file with mode: 0644]

index 539954e..74a7d13 100644 (file)
--- a/TODO.txt
+++ b/TODO.txt
@@ -4,6 +4,9 @@ webservices - 1 week
 client - 1 week\r
 docs - 1 week\r
 \r
+make sure that aacon checks its input (must be alignment) and log errors/throws\r
+exceptions if the input is not correct or absent! \r
+\r
 Cluster stats: \r
  +cancelled should not be reported as incomplete!\r
  -Remove hyperlinks from tasks which workdirs were removed \r
index 94da952..f3158ed 100644 (file)
@@ -1,6 +1,10 @@
 <?xml version="1.0" encoding="UTF-8"?>\r
 <endpoints xmlns='http://java.sun.com/xml/ns/jax-ws/ri/runtime' version='2.0'>\r
     <endpoint\r
+        name='RegistryWS'\r
+        implementation='compbio.ws.server.RegistryWS'\r
+        url-pattern='/RegistryWS'/>\r
+    <endpoint\r
         name='ClustalWS'\r
         implementation='compbio.ws.server.ClustalWS'\r
         url-pattern='/ClustalWS'/>\r
index 4f75bd5..2e44c07 100644 (file)
     </servlet>\r
     \r
     <servlet>\r
+        <servlet-name>RegistryWS</servlet-name>\r
+        <servlet-class>com.sun.xml.ws.transport.http.servlet.WSServlet</servlet-class>\r
+        <load-on-startup>1</load-on-startup>\r
+    </servlet>\r
+    \r
+    <servlet>\r
         <servlet-name>ClustalWS</servlet-name>\r
         <servlet-class>com.sun.xml.ws.transport.http.servlet.WSServlet</servlet-class>\r
         <load-on-startup>1</load-on-startup>\r
        </servlet-mapping> \r
        \r
     <servlet-mapping>\r
+       <servlet-name>RegistryWS</servlet-name>\r
+       <url-pattern>/RegistryWS</url-pattern>\r
+    </servlet-mapping>\r
+    \r
+    <servlet-mapping>\r
        <servlet-name>ClustalWS</servlet-name>\r
        <url-pattern>/ClustalWS</url-pattern>\r
     </servlet-mapping>\r
index fcd6057..d621a3b 100644 (file)
@@ -61,7 +61,7 @@ probcons.limits.file=conf/settings/ProbconsLimits.xml
 probcons.cluster.settings=-l h_cpu=24:00:00 -l h_vmem=6000M -l ram=6000M\r
 \r
 ### Jronn configuration ### \r
-local.jronn.bin.windows=D:\\Java\\jdk1.6.0_14\\bin\\java.exe \r
+local.jronn.bin.windows=D:\\Java\\jdk1.6.0_24\\bin\\java.exe \r
 local.jronn.bin=/sw/java/latest/bin/java\r
 cluster.jronn.bin=/sw/java/latest/bin/java\r
 jronn.jar.file=binaries/jronn3.1.jar\r
@@ -90,7 +90,7 @@ globplot.cluster.settings=-l h_cpu=24:00:00 -l h_vmem=6000M -l ram=6000M
 \r
 \r
 ### AACon configuration ###\r
-local.aacon.bin.windows=D:\\Java\\jdk1.6.0_14\\bin\\java.exe \r
+local.aacon.bin.windows=D:\\Java\\jdk1.6.0_24\\bin\\java.exe \r
 local.aacon.bin=/sw/java/latest/bin/java\r
 cluster.aacon.bin=/sw/java/latest/bin/java\r
 aacon.jar.file=binaries/aaconservation.jar\r
index 0e6422d..f974302 100644 (file)
@@ -42,9 +42,13 @@ public abstract class SkeletalExecutable<T> implements Executable<T> {
        // Cache for Limits information\r
        private LimitsManager<T> limits;\r
 \r
-       protected String inputFile = "input.txt";\r
-       protected String outputFile = "output.txt";\r
-       protected String errorFile = "error.txt";\r
+       public static final String INPUT = "input.txt";\r
+       public static final String OUTPUT = "result.txt";\r
+       public static final String ERROR = "error.txt";\r
+\r
+       protected String inputFile = INPUT;\r
+       protected String outputFile = OUTPUT;\r
+       protected String errorFile = ERROR;\r
 \r
        private boolean isInputSet = false;\r
        private boolean isOutputSet = false;\r
diff --git a/testsrc/compbio/ws/client/WSTesterTester.java b/testsrc/compbio/ws/client/WSTesterTester.java
new file mode 100644 (file)
index 0000000..43204e5
--- /dev/null
@@ -0,0 +1,47 @@
+package compbio.ws.client;\r
+\r
+import static org.testng.Assert.assertTrue;\r
+\r
+import java.io.PrintWriter;\r
+\r
+import org.testng.annotations.Test;\r
+\r
+import compbio.data.msa.JABAService;\r
+import compbio.metadata.AllTestSuit;\r
+\r
+public class WSTesterTester {\r
+\r
+       public static final String SERVER = "http://localhost:8080/jabaws";\r
+\r
+       @Test(groups = {AllTestSuit.test_group_runner})\r
+       public void testAllWindowsWS() {\r
+               WSTester tester = new WSTester(new PrintWriter(System.out, true));\r
+               JABAService ws = Jws2Client.connect(SERVER, Services.AAConWS);\r
+               assertTrue(tester.checkService(ws));\r
+\r
+               ws = Jws2Client.connect(SERVER, Services.JronnWS);\r
+               assertTrue(tester.checkService(ws));\r
+\r
+               ws = Jws2Client.connect(SERVER, Services.ClustalWS);\r
+               assertTrue(tester.checkService(ws));\r
+\r
+               ws = Jws2Client.connect(SERVER, Services.MuscleWS);\r
+               assertTrue(tester.checkService(ws));\r
+\r
+               // Will throw UnsupportedRuntimeException on windows\r
+               // ws = Jws2Client.connect(SERVER, Services.MafftWS);\r
+               // assertTrue(tester.checkService(ws));\r
+\r
+       }\r
+\r
+       @Test(groups = {AllTestSuit.test_group_non_windows})\r
+       public void testAllWS() {\r
+               WSTester tester = new WSTester(new PrintWriter(System.out));\r
+\r
+               for (Services service : Services.values()) {\r
+                       JABAService ws = Jws2Client.connect(SERVER, service);\r
+                       assertTrue(tester.checkService(ws));\r
+               }\r
+       }\r
+\r
+}\r
diff --git a/testsrc/compbio/ws/server/RegistryWSTester.java b/testsrc/compbio/ws/server/RegistryWSTester.java
new file mode 100644 (file)
index 0000000..4093626
--- /dev/null
@@ -0,0 +1,25 @@
+package compbio.ws.server;\r
+\r
+import org.testng.annotations.Test;\r
+\r
+import compbio.ws.client.Jws2Client;\r
+import compbio.ws.client.Services;\r
+import compbio.ws.client.WSTesterTester;\r
+\r
+public class RegistryWSTester {\r
+\r
+       @Test\r
+       public void testGetSupportedServices() {\r
+               compbio.data.msa.RegistryWS reg = Jws2Client\r
+                               .connectToRegistry(WSTesterTester.SERVER);\r
+               System.out.println(reg.getSupportedServices());\r
+       }\r
+\r
+       @Test\r
+       public void testTestService() {\r
+               compbio.data.msa.RegistryWS reg = Jws2Client\r
+                               .connectToRegistry(WSTesterTester.SERVER);\r
+               System.out.println(reg.testService(Services.AAConWS));\r
+       }\r
+\r
+}\r
diff --git a/webservices/compbio/data/msa/RegistryWS.java b/webservices/compbio/data/msa/RegistryWS.java
new file mode 100644 (file)
index 0000000..3dd89b5
--- /dev/null
@@ -0,0 +1,18 @@
+package compbio.data.msa;\r
+\r
+import java.util.Date;\r
+import java.util.Set;\r
+\r
+import javax.jws.WebService;\r
+\r
+import compbio.ws.client.Services;\r
+\r
+@WebService(targetNamespace = "http://msa.data.compbio/01/12/2010/")\r
+public interface RegistryWS extends JABAService {\r
+       Set<Services> getSupportedServices();\r
+       Date getLastTestedOn(Services service);\r
+       String testAllServices();\r
+       String testService(Services service);\r
+       boolean isOperating(Services service);\r
+\r
+}\r
index eda6533..ceb9501 100644 (file)
@@ -41,6 +41,7 @@ import java.util.List;
 import java.util.logging.Level;\r
 import java.util.logging.Logger;\r
 \r
+import javax.xml.namespace.QName;\r
 import javax.xml.ws.Service;\r
 import javax.xml.ws.WebServiceException;\r
 \r
@@ -68,8 +69,8 @@ import compbio.metadata.WrongParameterException;
 public class Jws2Client {\r
 \r
        /*\r
-        * Use java.util.Logger instead of log4j logger to reduce the size of the\r
-        * client package\r
+        * TODO Use java.util.Logger instead of log4j logger to reduce the size of\r
+        * the client package\r
         */\r
        private static final Logger log = Logger.getLogger(Jws2Client.class\r
                        .getCanonicalName());\r
@@ -201,15 +202,12 @@ public class Jws2Client {
         * @return Set<Score> the conservation scores\r
         * @throws UnknownFileFormatException\r
         */\r
-       <T> ScoreManager analize(File file, SequenceAnnotation<T> wsproxy,\r
-                       Preset<T> preset, List<Option<T>> customOptions) {\r
+       static <T> ScoreManager analize(List<FastaSequence> fastalist,\r
+                       SequenceAnnotation<T> wsproxy, Preset<T> preset,\r
+                       List<Option<T>> customOptions) {\r
 \r
-               List<FastaSequence> fastalist = null;\r
                ScoreManager scores = null;\r
                try {\r
-                       fastalist = SequenceUtil.openInputStream(file.getAbsolutePath());\r
-                       assert !fastalist.isEmpty() : "Input is empty!";\r
-\r
                        String jobId = null;\r
                        if (customOptions != null && preset != null) {\r
                                System.out\r
@@ -220,19 +218,12 @@ public class Jws2Client {
                        } else if (preset != null) {\r
                                jobId = wsproxy.presetAnalize(fastalist, preset);\r
                        } else {\r
-                               System.out.println("\n\ncalling analise.........");\r
                                jobId = wsproxy.analize(fastalist);\r
                        }\r
-                       Thread.sleep(2000);\r
-\r
+                       System.out.println("\n\ncalling analise.........");\r
+                       Thread.sleep(1000);\r
                        scores = wsproxy.getAnnotation(jobId);\r
 \r
-               } catch (IOException e) {\r
-                       System.err\r
-                                       .println("Exception while reading the input file. "\r
-                                                       + "Check that the input file contains a list of fasta formatted sequences! "\r
-                                                       + "Exception details are below:");\r
-                       e.printStackTrace();\r
                } catch (JobSubmissionException e) {\r
                        System.err\r
                                        .println("Exception while submitting job to a web server. "\r
@@ -242,14 +233,49 @@ public class Jws2Client {
                        System.err.println("Exception while waiting for results. "\r
                                        + "Exception details are below:");\r
                        e.printStackTrace();\r
-               } catch (InterruptedException ignored) {\r
+               } catch (InterruptedException e) {\r
                        // ignore and propagate an interruption\r
                        Thread.currentThread().interrupt();\r
+                       System.err.println("Exception while waiting for results. "\r
+                                       + "Exception details are below:");\r
+                       e.printStackTrace();\r
                } catch (WrongParameterException e) {\r
                        System.err\r
                                        .println("Exception while parsing the web method input parameters. "\r
                                                        + "Exception details are below:");\r
                        e.printStackTrace();\r
+               }\r
+               return scores;\r
+\r
+       }\r
+\r
+       /**\r
+        * Calculate conservation for sequences loaded from the file\r
+        * \r
+        * @param wsproxy\r
+        *            a web service proxy\r
+        * @param file\r
+        *            the file to read the results from\r
+        * @param preset\r
+        *            Preset to use optional\r
+        * @param customOptions\r
+        *            the list of options\r
+        * @return Set<Score> the conservation scores\r
+        * @throws IOException\r
+        * @throws UnknownFileFormatException\r
+        */\r
+       static <T> ScoreManager analize(File file, SequenceAnnotation<T> wsproxy,\r
+                       Preset<T> preset, List<Option<T>> customOptions) {\r
+               List<FastaSequence> fastalist = null;\r
+               try {\r
+                       fastalist = SequenceUtil.openInputStream(file.getAbsolutePath());\r
+                       assert !fastalist.isEmpty() : "Input is empty!";\r
+               } catch (IOException e) {\r
+                       System.err\r
+                                       .println("Exception while reading the input file. "\r
+                                                       + "Check that the input file contains a list of fasta formatted sequences! "\r
+                                                       + "Exception details are below:");\r
+                       e.printStackTrace();\r
                } catch (UnknownFileFormatException e) {\r
                        System.err\r
                                        .println("Exception while attempting to read the input file "\r
@@ -257,9 +283,8 @@ public class Jws2Client {
                        System.out.println(e.getMessage());\r
                        e.printStackTrace();\r
                }\r
-               return scores;\r
+               return analize(fastalist, wsproxy, preset, customOptions);\r
        }\r
-\r
        /**\r
         * Connects to a web service by the host and the service name\r
         * \r
@@ -284,7 +309,7 @@ public class Jws2Client {
                try {\r
                        serv = service.getService(url, QUALIFIED_SERVICE_NAME);\r
                } catch (WebServiceException wse) {\r
-                       System.out.println("Conecting to JABAWS version 2 service");\r
+                       System.out.println("Connecting to JABAWS version 2 service");\r
                        if (isV2service(wse)) {\r
                                serv = service.getService(url, V2_QUALIFIED_SERVICE_NAME);\r
                        }\r
@@ -311,6 +336,36 @@ public class Jws2Client {
                return false;\r
        }\r
 \r
+       public static compbio.data.msa.RegistryWS connectToRegistry(String host)\r
+                       throws WebServiceException {\r
+               URL url = null;\r
+               String service = "RegistryWS";\r
+               log.log(Level.FINE, "Attempting to connect...");\r
+\r
+               try {\r
+                       url = new URL(host + "/" + service + "?wsdl");\r
+               } catch (MalformedURLException e) {\r
+                       e.printStackTrace();\r
+                       // ignore as the host name is already verified\r
+               }\r
+               QName qname = new QName(V2_QUALIFIED_SERVICE_NAME, service);\r
+               Service serv = Service.create(url, qname);\r
+\r
+               if (serv == null) {\r
+                       System.err.println("Could not connect to " + url\r
+                                       + " the server is down?");\r
+               }\r
+\r
+               QName portName = new QName(serv.getServiceName().getNamespaceURI(),\r
+                               service + "Port");\r
+               compbio.data.msa.RegistryWS serviceIF = serv.getPort(portName,\r
+                               compbio.data.msa.RegistryWS.class);\r
+\r
+               log.log(Level.INFO, "Connected to " + service + " successfully!");\r
+\r
+               return serviceIF;\r
+       }\r
+\r
        /**\r
         * Align sequences from the file using MsaWS\r
         * \r
@@ -347,6 +402,7 @@ public class Jws2Client {
                        } else {\r
                                jobId = msaws.align(fastalist);\r
                        }\r
+                       System.out.println("\n\ncalling align.........");\r
                        Thread.sleep(1000);\r
                        alignment = msaws.getResult(jobId);\r
 \r
index bff43e3..01b4827 100644 (file)
@@ -95,7 +95,8 @@ public enum Services {
                }\r
        }\r
 \r
-       public static Class<? extends Executable<?>> getRunnerByJobDirectory(File jobdir) {\r
+       public static Class<? extends Executable<?>> getRunnerByJobDirectory(\r
+                       File jobdir) {\r
                Services service = getServiceByRunnerName(getRunnerNameByJobDirectory(jobdir));\r
                return service.getServiceImpl();\r
        }\r
index 544ecad..05bd0b8 100644 (file)
@@ -25,19 +25,27 @@ import static compbio.ws.client.Constraints.servicekey;
 import java.io.ByteArrayInputStream;\r
 import java.io.Closeable;\r
 import java.io.IOException;\r
+import java.io.PrintWriter;\r
 import java.util.Arrays;\r
 import java.util.List;\r
 \r
 import javax.xml.ws.WebServiceException;\r
 \r
+import org.apache.log4j.Logger;\r
+\r
+import compbio.data.msa.JABAService;\r
+import compbio.data.msa.Metadata;\r
 import compbio.data.msa.MsaWS;\r
+import compbio.data.msa.SequenceAnnotation;\r
 import compbio.data.sequence.Alignment;\r
 import compbio.data.sequence.FastaSequence;\r
+import compbio.data.sequence.ScoreManager;\r
 import compbio.data.sequence.SequenceUtil;\r
 import compbio.metadata.JobStatus;\r
 import compbio.metadata.JobSubmissionException;\r
 import compbio.metadata.Limit;\r
 import compbio.metadata.LimitsManager;\r
+import compbio.metadata.Option;\r
 import compbio.metadata.Preset;\r
 import compbio.metadata.PresetManager;\r
 import compbio.metadata.ResultNotAvailableException;\r
@@ -54,21 +62,28 @@ import compbio.metadata.WrongParameterException;
  */\r
 public class WSTester {\r
 \r
+       private static Logger log = Logger.getLogger(WSTester.class);\r
        /**\r
         * Sequences to be used as input for all WS\r
         */\r
-       static final String fastaInput = ">Foobar\n"\r
-                       + "MTADGPRELLQLRAAVRHRPQDFVAWLMLADAELGMGDTTAGEMAVQRGLALHPGHPEAVARLGRVRWTQQRHAEAAVLLQQASDAAPEHPGIALWLGHALEDAGQAEAAAAAYTRAHQLLPEEPYITAQLLNWRRRLCDWRALDVLSAQVRAAVAQGVGAVEPFAFLSEDASAAEQLACARTRAQAIAASVRPLAPTRVRSKGPLRVGFVSNGFGAHPTGLLTVALFEALQRRQPDLQMHLFATSGDDGSTLRTRLAQASTLHDVTALGHLATAKHIRHHGIDLLFDLRGWGGGGRPEVFALRPAPVQVNWLAYPGTSGAPWMDYVLGDAFALPPALEPFYSEHVLRLQGAFQPSDTSRVVAEPPSRTQCGLPEQGVVLCCFNNSYKLNPQSMARMLAVLREVPDSVLWLLSGPGEADARLRAFAHAQGVDAQRLVFMPKLPHPQYLARYRHADLFLDTHPYNAHTTASDALWTGCPVLTTPGETFAARVAGSLNHHLGLDEMNVADDAAFVAKA"\r
-                       + "\n>Barbar\n"\r
-                       + "ASDAAPEHPGIALWLHALEDAGQAEAAAAYTRAHQLLPEEPYITAQLLNAVAQGVGAVEPFAFLSEDASAAESVRPLAPTRVRSKGPLRVGFVSNGFGAHPTGLLTVALFEALQRRQPDLQMHLFATSGDDGSTLRTRLAQASTLHDVTALGHLATAKHIRHHGIDLLFDLRGWGGGGRPEVFALRPAPVQVNWLAYPGTSGAPWMDYVLGDAFALPPALEPFYSEHVLRLQGAFQPSDTSRVVAEPPSRTQCGLPEQGVVLCCFNNSYKLNPQSMARMLAVLREVPDSVLWLLSGPGEADARLRAFAHAQGVDAQRLVFMPKLPHPQYLARYRHADLFLDTHPYNAHTTASDALWTGCPVLTTPGETFAARVAGSLNHHLGLDEMNVADDAAFVAKAVALASDPAALTALHARVDVLRRESGVFEMDGFADDFGALLQALARRHGWLGI"\r
-                       + "\n>Foofriend\n"\r
-                       + "MTADGPRELLQLRAAVRHRPQDVAWLMLADAELGMGDTTAGEMAVQRGLALHPGHPEAVARLGRVRWTQQRHAEAAVLLQQASDAAPEHPGIALWLGHALEDHQLLPEEPYITAQLDVLSAQVRAAVAQGVGAVEPFAFLSEDASAAEQLACARTRAQAIAASVRPLAPTRVRSKGPLRVGFVSNGFGAHPTGLLTVALFEALQRRQPDLQMHLFATSGDDGSTLRTRLAQASTLHDVTALGHLATAKHIRHHGIDLLFDLRGWGGGGRPEVFALRPAPVQVNWLAYPGTSGAPWMDYVLGDAFALPPALEPFYSEHVLRLQGAFQPSDTSRVVAEPPSRTQCGLPEQGVVLCCFNNSYKLNPQSMARMLAVLREVPDSVLWLLSGPGEADARLRAFAHAQGVDAQRLVFMPKLPHPQYLARYRHADLFLDTHPYNAHTTASDALWTGCPVLTTPGETFAARVAGSLNHHLGLDEMNVADDAAFVAKAVALASDPAALTALHARVDVLRRESI\n";\r
+       static final String fastaInput = ">Foo\n"\r
+                       + "MTADGPRELLQLRAAVRHRPQDFVAWLMLADAELGMGDTTAGEMAVQRGLALHPGHPEAV"\r
+                       + "\n>Bar\n"\r
+                       + "ASDAAPEHPGIALWLHALEDAGQAEAAAAYTRAHQLLPEEPYITAQLLNAVA";\r
+\r
+       static final String fastaAlignment = ">Foo\r\n"\r
+                       + "MTADGPRELLQLRAAVRHRPQDFVAWLMLADAELGMGDTTAGEMAVQRGLALHPGHPEAV--------\r\n"\r
+                       + ">Bar\r\n"\r
+                       + "ASDAAPEH------------PGIALWLHALE-DAGQAEAAA---AYTRAHQLLPEEPYITAQLLNAVA\r\n"\r
+                       + "";\r
 \r
        static final List<FastaSequence> seqs = loadSeqs();\r
 \r
        private static final String FAILED = "FAILED";\r
        private static final String OK = "OK";\r
 \r
+       private static final String UNSUPPORTED = "UNSUPPORTED";\r
+\r
        /**\r
         * Converting input to a form accepted by WS\r
         * \r
@@ -86,23 +101,43 @@ public class WSTester {
        }\r
 \r
        /**\r
+        * Converting input to a form accepted by WS\r
+        * \r
+        * @return List of FastaSequence records\r
+        */\r
+       static List<FastaSequence> loadAlignment() {\r
+               try {\r
+                       return SequenceUtil.readFasta(new ByteArrayInputStream(\r
+                                       fastaAlignment.getBytes()));\r
+               } catch (IOException ignored) {\r
+                       // Should not happen as a source is not a external stream\r
+                       ignored.printStackTrace();\r
+               }\r
+               return null;\r
+       }\r
+\r
+       private final PrintWriter writer;\r
+\r
+       public WSTester(PrintWriter writer) {\r
+               this.writer = writer;\r
+       }\r
+\r
+       /**\r
         * Prints usage\r
         */\r
-       static void printUsage() {\r
-               System.out.println("Usage: <Class or Jar file name> " + hostkey\r
+       void printUsage() {\r
+               writer.println("Usage: <Class or Jar file name> " + hostkey\r
                                + pseparator + "host_and_context " + "<" + servicekey\r
                                + pseparator + "serviceName>");\r
-               System.out.println();\r
-               System.out\r
-                               .println(hostkey\r
-                                               + pseparator\r
-                                               + "<host_and_context> - a full URL to the JABAWS web server including context path e.g. http://10.31.1.159:8080/ws");\r
-               System.out\r
-                               .println(servicekey\r
-                                               + pseparator\r
-                                               + "<ServiceName> - optional if unspecified all services are tested otherwise one of "\r
-                                               + Arrays.toString(Services.values()));\r
-               System.out.println();\r
+               writer.println();\r
+               writer.println(hostkey\r
+                               + pseparator\r
+                               + "<host_and_context> - a full URL to the JABAWS web server including context path e.g. http://10.31.1.159:8080/ws");\r
+               writer.println(servicekey\r
+                               + pseparator\r
+                               + "<ServiceName> - optional if unspecified all services are tested otherwise one of "\r
+                               + Arrays.toString(Services.values()));\r
+               writer.println();\r
 \r
        }\r
 \r
@@ -115,48 +150,66 @@ public class WSTester {
         *            list of the Preset\r
         * @throws UnsupportedRuntimeException\r
         */\r
-       static <T> boolean presetAlign(MsaWS<T> msaws, List<Preset<T>> presets)\r
+       <T> boolean presetAlign(MsaWS<T> msaws, List<Preset<T>> presets)\r
                        throws UnsupportedRuntimeException {\r
                boolean succeed = false;\r
                for (Preset<T> preset : presets) {\r
-                       System.out.print("Aligning with preset '" + preset.getName()\r
-                                       + "'... ");\r
+                       writer.print("Aligning with preset '" + preset.getName() + "'... ");\r
                        Alignment al = null;\r
                        try {\r
                                String taskId = msaws.presetAlign(seqs, preset);\r
                                al = msaws.getResult(taskId);\r
                                if (al != null) {\r
-                                       System.out.println(OK);\r
+                                       writer.println(OK);\r
                                }\r
                                succeed = true;\r
                        } catch (UnsupportedRuntimeException e) {\r
-                               System.out.println(FAILED);\r
+                               writer.println(FAILED);\r
                                // If executable is not supported than none of the presets are\r
                                // going to work\r
                                throw new UnsupportedRuntimeException(e);\r
                        } catch (JobSubmissionException e) {\r
                                // TODO custom message\r
-                               System.out.println(FAILED);\r
-                               System.out.println();\r
-                               e.printStackTrace();\r
+                               writer.println(FAILED);\r
+                               writer.println();\r
+                               writer.println(e.getLocalizedMessage());\r
+                               e.printStackTrace(writer);\r
                                continue;\r
                        } catch (WrongParameterException e) {\r
                                // TODO custom message\r
-                               System.out.println(FAILED);\r
-                               System.out.println();\r
-                               e.printStackTrace();\r
+                               writer.println(FAILED);\r
+                               writer.println();\r
+                               writer.println(e.getLocalizedMessage());\r
+                               e.printStackTrace(writer);\r
                                continue;\r
                        } catch (ResultNotAvailableException e) {\r
                                // TODO custom message\r
-                               System.out.println(FAILED);\r
-                               System.out.println();\r
-                               e.printStackTrace();\r
+                               writer.println(FAILED);\r
+                               writer.println();\r
+                               writer.println(e.getLocalizedMessage());\r
+                               e.printStackTrace(writer);\r
                                continue;\r
                        }\r
                }\r
                return succeed;\r
        }\r
 \r
+       private <T> boolean testMsaWS(MsaWS<T> msaws)\r
+                       throws UnsupportedRuntimeException {\r
+\r
+               boolean succeed = testDefaultAlignment(msaws);\r
+\r
+               // If exception above is thrown than the tests below is not run\r
+\r
+               PresetManager<T> pmanager = msaws.getPresets();\r
+               if (pmanager != null && pmanager.getPresets().size() > 0) {\r
+                       writer.println("Testing alignment with presets:");\r
+                       List<Preset<T>> plist = pmanager.getPresets();\r
+                       succeed = !succeed ? presetAlign(msaws, plist) : succeed;\r
+               }\r
+               testMetadata(msaws);\r
+               return succeed;\r
+       }\r
        /**\r
         * Call most of web services functions and check the output\r
         * \r
@@ -168,54 +221,120 @@ public class WSTester {
         *             the web service is not functional. e.g. when native\r
         *             executable does not exists for a server platform\r
         */\r
-       static <T> boolean checkService(MsaWS<T> msaws)\r
+       @SuppressWarnings("unchecked")\r
+       public <T> boolean checkService(JABAService wservice) {\r
+               try {\r
+                       if (wservice == null) {\r
+                               throw new NullPointerException(\r
+                                               "JABAService instance must be provided!");\r
+                       }\r
+                       if (wservice instanceof MsaWS) {\r
+                               return testMsaWS((MsaWS<T>) wservice);\r
+                       } else if (wservice instanceof SequenceAnnotation) {\r
+                               return testSequenceAnnotationWS((SequenceAnnotation<T>) wservice);\r
+                       } else {\r
+                               throw new UnsupportedOperationException("The service: "\r
+                                               + wservice.getClass() + " is not supported! ");\r
+                       }\r
+               } catch (UnsupportedRuntimeException e) {\r
+                       writer.println(e.getLocalizedMessage());\r
+                       e.printStackTrace(writer);\r
+                       return false;\r
+               }\r
+       }\r
+\r
+       private <T> boolean testSequenceAnnotationWS(SequenceAnnotation<T> wservice)\r
                        throws UnsupportedRuntimeException {\r
+               boolean success = testDefaultAnalyse(loadAlignment(), wservice, null,\r
+                               null);\r
+               PresetManager<T> presetman = wservice.getPresets();\r
+               if (presetman != null) {\r
+                       List<Preset<T>> presets = presetman.getPresets();\r
+                       if (presets != null && !presets.isEmpty()) {\r
+                               Preset<T> preset = presets.get(0);\r
+                               success = testDefaultAnalyse(loadAlignment(), wservice, preset,\r
+                                               null);\r
+                       }\r
+               }\r
+               testMetadata(wservice);\r
+               return success;\r
+       }\r
 \r
-               boolean succeed = testDefaultAlignment(msaws);\r
+       <T> boolean testDefaultAnalyse(List<FastaSequence> fastalist,\r
+                       SequenceAnnotation<T> wsproxy, Preset<T> preset,\r
+                       List<Option<T>> customOptions) throws UnsupportedRuntimeException {\r
 \r
-               // If exception above is thrown than the tests below is not run\r
+               ScoreManager scores = null;\r
+               try {\r
+                       String jobId = null;\r
+                       if (customOptions != null) {\r
+                               jobId = wsproxy.customAnalize(fastalist, customOptions);\r
+                       } else if (preset != null) {\r
+                               jobId = wsproxy.presetAnalize(fastalist, preset);\r
+                       } else {\r
+                               jobId = wsproxy.analize(fastalist);\r
+                       }\r
+                       writer.println("\n\ncalling analise.........");\r
+                       Thread.sleep(1000);\r
+                       scores = wsproxy.getAnnotation(jobId);\r
 \r
-               PresetManager<T> pmanager = msaws.getPresets();\r
-               if (pmanager != null && pmanager.getPresets().size() > 0) {\r
-                       System.out.println("Testing alignment with presets:");\r
-                       List<Preset<T>> plist = pmanager.getPresets();\r
-                       succeed = !succeed ? presetAlign(msaws, plist) : succeed;\r
+               } catch (JobSubmissionException e) {\r
+                       writer.println("Exception while submitting job to a web server. "\r
+                                       + "Exception details are below:");\r
+                       e.printStackTrace(writer);\r
+               } catch (ResultNotAvailableException e) {\r
+                       writer.println("Exception while waiting for results. "\r
+                                       + "Exception details are below:");\r
+                       e.printStackTrace(writer);\r
+               } catch (InterruptedException e) {\r
+                       // ignore and propagate an interruption\r
+                       Thread.currentThread().interrupt();\r
+                       writer.println("Exception while waiting for results. "\r
+                                       + "Exception details are below:");\r
+                       e.printStackTrace(writer);\r
+               } catch (WrongParameterException e) {\r
+                       writer.println("Exception while parsing the web method input parameters. "\r
+                                       + "Exception details are below:");\r
+                       e.printStackTrace(writer);\r
                }\r
+               return scores != null;\r
+       }\r
 \r
-               System.out.print("Querying presets...");\r
+       private <T> void testMetadata(Metadata<T> msaws)\r
+                       throws UnsupportedRuntimeException {\r
 \r
+               writer.print("Querying presets...");\r
+               PresetManager<T> pmanager = msaws.getPresets();\r
                if (pmanager != null && pmanager.getPresets().size() > 0) {\r
-                       System.out.println(OK);\r
+                       writer.println(OK);\r
                } else {\r
-                       System.out.println("UNSUPPORTED");\r
+                       writer.println(UNSUPPORTED);\r
                }\r
 \r
-               System.out.print("Querying Parameters...");\r
+               writer.print("Querying Parameters...");\r
                RunnerConfig<T> options = msaws.getRunnerOptions();\r
                if (options != null && options.getArguments().size() > 0) {\r
-                       System.out.println(OK);\r
+                       writer.println(OK);\r
                } else {\r
-                       System.out.println(FAILED);\r
-                       succeed = false;\r
+                       writer.println(UNSUPPORTED);\r
                }\r
 \r
-               System.out.print("Querying Limits...");\r
+               writer.print("Querying Limits...");\r
                LimitsManager<T> limits = msaws.getLimits();\r
                if (limits != null && limits.getLimits().size() > 0) {\r
-                       System.out.println(OK);\r
+                       writer.println(OK);\r
                } else {\r
-                       System.out.println("UNSUPPORTED");\r
+                       writer.println(UNSUPPORTED);\r
                }\r
 \r
-               System.out.print("Querying Local Engine Limits...");\r
+               writer.print("Querying Local Engine Limits...");\r
                Limit<T> localLimit = msaws\r
                                .getLimit(PresetManager.LOCAL_ENGINE_LIMIT_PRESET);\r
                if (localLimit != null) {\r
-                       System.out.println(OK);\r
+                       writer.println(OK);\r
                } else {\r
-                       System.out.println("UNSUPPORTED");\r
+                       writer.println(UNSUPPORTED);\r
                }\r
-               return succeed;\r
        }\r
 \r
        /**\r
@@ -225,37 +344,40 @@ public class WSTester {
         * @param msaws\r
         * @throws UnsupportedRuntimeException\r
         */\r
-       static <T> boolean testDefaultAlignment(MsaWS<T> msaws)\r
+       public <T> boolean testDefaultAlignment(MsaWS<T> msaws)\r
                        throws UnsupportedRuntimeException {\r
-               System.out.print("Testing alignment with default parameters:");\r
+               writer.print("Testing alignment with default parameters:");\r
                Alignment al = null;\r
                boolean succeed = false;\r
                try {\r
                        String taskId = msaws.align(seqs);\r
-                       System.out.print("\nQuerying job status...");\r
+                       writer.print("\nQuerying job status...");\r
                        JobStatus status = msaws.getJobStatus(taskId);\r
                        while (status != JobStatus.FINISHED) {\r
                                Thread.sleep(1000);\r
                                status = msaws.getJobStatus(taskId);\r
                        }\r
-                       System.out.println(OK);\r
-                       System.out.print("Retrieving results...");\r
+                       writer.println(OK);\r
+                       writer.print("Retrieving results...");\r
                        al = msaws.getResult(taskId);\r
                        succeed = true;\r
                } catch (ResultNotAvailableException e) {\r
-                       System.out.println(FAILED);\r
-                       e.printStackTrace();\r
+                       writer.println(FAILED);\r
+                       writer.println(e.getLocalizedMessage());\r
+                       e.printStackTrace(writer);\r
                } catch (JobSubmissionException e) {\r
-                       System.out.println(FAILED);\r
-                       System.out.println();\r
-                       e.printStackTrace();\r
+                       writer.println(FAILED);\r
+                       writer.println();\r
+                       writer.println(e.getLocalizedMessage());\r
+                       e.printStackTrace(writer);\r
                } catch (InterruptedException e) {\r
-                       System.out.println(FAILED);\r
-                       System.out.println();\r
-                       e.printStackTrace();\r
+                       writer.println(FAILED);\r
+                       writer.println();\r
+                       writer.println(e.getLocalizedMessage());\r
+                       e.printStackTrace(writer);\r
                }\r
                if (al != null) {\r
-                       System.out.println(OK);\r
+                       writer.println(OK);\r
                }\r
                return succeed;\r
        }\r
@@ -268,17 +390,19 @@ public class WSTester {
         * @param service\r
         * @return\r
         */\r
-       static <T> MsaWS<T> connect(String host, Services service) {\r
-               MsaWS<T> msaws = null;\r
+       <T> JABAService connect(String host, Services service) {\r
+               JABAService jabaservice = null;\r
                try {\r
-                       System.out.print("Connecting to service " + service + " on " + host\r
+                       writer.print("Connecting to service " + service + " on " + host\r
                                        + " ... ");\r
-                       msaws = (MsaWS<T>) Jws2Client.connect(host, service);\r
-                       System.out.println(OK);\r
+                       jabaservice = Jws2Client.connect(host, service);\r
+                       writer.println(OK);\r
                } catch (WebServiceException e) {\r
-                       System.out.println(FAILED);\r
+                       writer.println(FAILED);\r
+                       writer.println(e.getLocalizedMessage());\r
+                       e.printStackTrace(writer);\r
                }\r
-               return msaws;\r
+               return jabaservice;\r
        }\r
 \r
        /**\r
@@ -295,15 +419,15 @@ public class WSTester {
         * @throws IOException\r
         */\r
        public static <T> void main(String[] args) throws IOException {\r
-\r
+               WSTester tester = new WSTester(new PrintWriter(System.out, true));\r
                if (args == null || args.length < 1) {\r
-                       printUsage();\r
+                       tester.printUsage();\r
                        System.exit(0);\r
                }\r
                String host = CmdHelper.getHost(args);\r
                String serviceName = CmdHelper.getServiceName(args);\r
                if (!Jws2Client.validURL(host)) {\r
-                       System.out\r
+                       tester.writer\r
                                        .println("<host_and_context> parameter is not provided or is incorrect!");\r
                        System.exit(1);\r
                }\r
@@ -312,57 +436,52 @@ public class WSTester {
                if (serviceName != null) {\r
                        Services service = Services.getService(serviceName);\r
                        if (service == null) {\r
-                               System.out.println("Service '" + serviceName\r
+                               tester.writer.println("Service '" + serviceName\r
                                                + "' is not supported. Valid values are: "\r
                                                + Arrays.toString(Services.values()));\r
-                               System.out.println();\r
-                               printUsage();\r
+                               tester.writer.println();\r
+                               tester.printUsage();\r
                                System.exit(1);\r
                        }\r
 \r
-                       msaws = connect(host, service);\r
+                       msaws = (MsaWS<T>) tester.connect(host, service);\r
                        if (msaws == null) {\r
                                System.exit(1);\r
                        }\r
                        try {\r
-                               succeed = checkService(msaws);\r
-                       } catch (UnsupportedRuntimeException ignored) {\r
-                               System.exit(1);\r
+                               succeed = tester.checkService(msaws);\r
                        } finally {\r
                                ((Closeable) msaws).close();\r
                        }\r
-                       reportResults(service, succeed);\r
+                       // TODO test results printing!\r
+                       tester.reportResults(service, succeed);\r
                        System.exit(0);\r
                }\r
 \r
-               System.out\r
+               tester.writer\r
                                .println("<ServiceName> is not provided checking all known services...");\r
 \r
                for (Services serv : Services.values()) {\r
-                       System.out.println();\r
-                       msaws = connect(host, serv);\r
+                       tester.writer.println();\r
+                       msaws = (MsaWS<T>) tester.connect(host, serv);\r
                        if (msaws == null) {\r
                                continue;\r
                        }\r
                        try {\r
-                               succeed = checkService(msaws);\r
-                       } catch (UnsupportedRuntimeException ignored) {\r
-                               System.out.println("Service " + serv + " IS NOT FUNCTIONAL");\r
-                               continue;\r
+                               succeed = tester.checkService(msaws);\r
                        } finally {\r
                                ((Closeable) msaws).close();\r
                        }\r
-                       reportResults(serv, succeed);\r
+                       tester.reportResults(serv, succeed);\r
                }\r
 \r
        }\r
-\r
-       private static void reportResults(Services serv, boolean succeed) {\r
+       private void reportResults(Services serv, boolean succeed) {\r
                if (succeed) {\r
-                       System.out.println("Check is completed. The Service " + serv\r
+                       writer.println("Check is completed. The Service " + serv\r
                                        + " IS WORKING");\r
                } else {\r
-                       System.out.println("Check is completed. The Service " + serv\r
+                       writer.println("Check is completed. The Service " + serv\r
                                        + " HAS SOME PROBLEMS");\r
                }\r
        }\r
index 1ffbbf3..fab12b8 100644 (file)
@@ -2,7 +2,6 @@ package compbio.ws.server;
 \r
 import java.io.File;\r
 import java.util.Arrays;\r
-import java.util.HashSet;\r
 import java.util.List;\r
 \r
 import javax.annotation.Resource;\r
@@ -13,11 +12,11 @@ import org.apache.log4j.Logger;
 \r
 import compbio.data.msa.SequenceAnnotation;\r
 import compbio.data.sequence.FastaSequence;\r
-import compbio.data.sequence.Score;\r
 import compbio.data.sequence.ScoreManager;\r
 import compbio.engine.AsyncExecutor;\r
 import compbio.engine.Configurator;\r
 import compbio.engine.client.ConfiguredExecutable;\r
+import compbio.engine.client.SkeletalExecutable;\r
 import compbio.metadata.ChunkHolder;\r
 import compbio.metadata.JobStatus;\r
 import compbio.metadata.JobSubmissionException;\r
@@ -57,6 +56,8 @@ public class AAConWS implements SequenceAnnotation<AACon> {
        ConfiguredExecutable<AACon> init(List<FastaSequence> sequences)\r
                        throws JobSubmissionException {\r
                AACon aacon = new AACon();\r
+               aacon.setInput(SkeletalExecutable.INPUT).setOutput(\r
+                               SkeletalExecutable.OUTPUT);\r
                return Configurator.configureExecutable(aacon, sequences);\r
        }\r
 \r
@@ -67,12 +68,9 @@ public class AAConWS implements SequenceAnnotation<AACon> {
                AsyncExecutor asyncEngine = Configurator.getAsyncEngine(jobId);\r
                ConfiguredExecutable<AACon> aacon = (ConfiguredExecutable<AACon>) asyncEngine\r
                                .getResults(jobId);\r
-               HashSet<Score> mas = aacon.getResults();\r
-               // ScoreManager result = new HashMap<String, HashSet<Score>>();\r
-               // result.put("Alignment", mas);\r
+               ScoreManager mas = aacon.getResults();\r
                log.trace(jobId + " getConservation : " + mas);\r
-               // FIXME\r
-               return null;\r
+               return mas;\r
        }\r
        /*\r
         * @SuppressWarnings("unchecked") public JalviewAnnotation\r
index 213711c..50d249b 100644 (file)
@@ -14,6 +14,7 @@ import compbio.data.sequence.ScoreManager;
 import compbio.engine.AsyncExecutor;\r
 import compbio.engine.Configurator;\r
 import compbio.engine.client.ConfiguredExecutable;\r
+import compbio.engine.client.SkeletalExecutable;\r
 import compbio.metadata.ChunkHolder;\r
 import compbio.metadata.JobStatus;\r
 import compbio.metadata.JobSubmissionException;\r
@@ -53,6 +54,7 @@ public class DisemblWS implements SequenceAnnotation<Disembl> {
        ConfiguredExecutable<Disembl> init(List<FastaSequence> sequences)\r
                        throws JobSubmissionException {\r
                Disembl disembl = new Disembl();\r
+               disembl.setInput(SkeletalExecutable.INPUT);\r
                return Configurator.configureExecutable(disembl, sequences);\r
        }\r
 \r
index affe48e..4c15b7c 100644 (file)
@@ -14,6 +14,7 @@ import compbio.data.sequence.ScoreManager;
 import compbio.engine.AsyncExecutor;\r
 import compbio.engine.Configurator;\r
 import compbio.engine.client.ConfiguredExecutable;\r
+import compbio.engine.client.SkeletalExecutable;\r
 import compbio.metadata.ChunkHolder;\r
 import compbio.metadata.JobStatus;\r
 import compbio.metadata.JobSubmissionException;\r
@@ -53,9 +54,9 @@ public class GlobPlotWS implements SequenceAnnotation<GlobPlot> {
        ConfiguredExecutable<GlobPlot> init(List<FastaSequence> sequences)\r
                        throws JobSubmissionException {\r
                GlobPlot globPlot = new GlobPlot();\r
+               globPlot.setInput(SkeletalExecutable.INPUT);\r
                return Configurator.configureExecutable(globPlot, sequences);\r
        }\r
-\r
        @Override\r
        public ScoreManager getAnnotation(String jobId)\r
                        throws ResultNotAvailableException {\r
index 97d4ceb..dc37f3f 100644 (file)
@@ -15,6 +15,7 @@ import compbio.data.sequence.ScoreManager;
 import compbio.engine.AsyncExecutor;\r
 import compbio.engine.Configurator;\r
 import compbio.engine.client.ConfiguredExecutable;\r
+import compbio.engine.client.SkeletalExecutable;\r
 import compbio.metadata.ChunkHolder;\r
 import compbio.metadata.JobStatus;\r
 import compbio.metadata.JobSubmissionException;\r
@@ -55,6 +56,8 @@ public class JronnWS implements SequenceAnnotation<Jronn> {
        ConfiguredExecutable<Jronn> init(List<FastaSequence> sequences)\r
                        throws JobSubmissionException {\r
                Jronn jronn = new Jronn();\r
+               jronn.setInput(SkeletalExecutable.INPUT).setOutput(\r
+                               SkeletalExecutable.OUTPUT);\r
                return Configurator.configureExecutable(jronn, sequences);\r
        }\r
 \r
index 80f67b2..aea5bc0 100644 (file)
@@ -33,6 +33,7 @@ import compbio.data.sequence.FastaSequence;
 import compbio.engine.AsyncExecutor;\r
 import compbio.engine.Configurator;\r
 import compbio.engine.client.ConfiguredExecutable;\r
+import compbio.engine.client.SkeletalExecutable;\r
 import compbio.metadata.ChunkHolder;\r
 import compbio.metadata.JobStatus;\r
 import compbio.metadata.JobSubmissionException;\r
@@ -78,6 +79,9 @@ public class MuscleWS implements MsaWS<Muscle> {
        ConfiguredExecutable<Muscle> init(List<FastaSequence> sequences)\r
                        throws JobSubmissionException {\r
                Muscle muscle = new Muscle();\r
+               muscle.setInput(SkeletalExecutable.INPUT)\r
+                               .setOutput(SkeletalExecutable.OUTPUT)\r
+                               .setError(SkeletalExecutable.ERROR);\r
                return Configurator.configureExecutable(muscle, sequences);\r
        }\r
 \r
diff --git a/webservices/compbio/ws/server/RegistryWS.java b/webservices/compbio/ws/server/RegistryWS.java
new file mode 100644 (file)
index 0000000..869807b
--- /dev/null
@@ -0,0 +1,126 @@
+package compbio.ws.server;\r
+\r
+import java.io.PrintWriter;\r
+import java.io.StringWriter;\r
+import java.io.Writer;\r
+import java.util.Date;\r
+import java.util.Map;\r
+import java.util.Set;\r
+import java.util.concurrent.ConcurrentHashMap;\r
+\r
+import javax.annotation.Resource;\r
+import javax.jws.WebService;\r
+import javax.servlet.http.HttpServletRequest;\r
+import javax.xml.ws.WebServiceContext;\r
+import javax.xml.ws.handler.MessageContext;\r
+\r
+import org.apache.log4j.Logger;\r
+\r
+import compbio.data.msa.JABAService;\r
+import compbio.ws.client.Jws2Client;\r
+import compbio.ws.client.Services;\r
+import compbio.ws.client.WSTester;\r
+\r
+/**\r
+ * TODO\r
+ * \r
+ * @author pvtroshin\r
+ * \r
+ */\r
+@WebService(endpointInterface = "compbio.data.msa.RegistryWS", targetNamespace = "http://msa.data.compbio/01/12/2010/", serviceName = "RegistryWS")\r
+public class RegistryWS implements compbio.data.msa.RegistryWS, JABAService {\r
+\r
+       // Ask for resource injection\r
+       @Resource\r
+       WebServiceContext wsContext;\r
+\r
+       private static Logger statLog = Logger.getLogger("RegistryWS-stats");\r
+       private static Logger log = Logger.getLogger(RegistryWS.class);\r
+\r
+       private final static Map<Services, Date> operating = new ConcurrentHashMap<Services, Date>();\r
+\r
+       /**\r
+        * 1) Check that the actual executable is configured\r
+        * \r
+        * 2) Check whether the service is enabled?\r
+        * \r
+        * 3) Attempt to execute?\r
+        * \r
+        * @return\r
+        */\r
+       @Override\r
+       public Set<Services> getSupportedServices() {\r
+               init();\r
+               return operating.keySet();\r
+       }\r
+\r
+       private void init() {\r
+               // This can be run concurrently\r
+               if (operating.isEmpty()) {\r
+                       testAllServices();\r
+               }\r
+       }\r
+       @Override\r
+       public Date getLastTestedOn(Services service) {\r
+               return operating.get(service);\r
+       }\r
+\r
+       @Override\r
+       public String testAllServices() {\r
+               Writer testlog = new StringWriter();\r
+               PrintWriter writer = new PrintWriter(testlog, true);\r
+               WSTester tester = new WSTester(writer);\r
+\r
+               for (Services service : Services.values()) {\r
+                       JABAService ws = Jws2Client.connect(getServicePath(), service);\r
+                       if (tester.checkService(ws)) {\r
+                               operating.put(service, new Date());\r
+                       }\r
+               }\r
+               return testlog.toString();\r
+       }\r
+\r
+       private String getServicePath() {\r
+               assert wsContext != null : "WS context injection failed!";\r
+               MessageContext msContext = wsContext.getMessageContext();\r
+               HttpServletRequest request = (HttpServletRequest) msContext\r
+                               .get(MessageContext.SERVLET_REQUEST);\r
+\r
+               StringBuffer server = request.getRequestURL();\r
+               server = server.delete(server.lastIndexOf("/"), server.length());\r
+               return server.toString();\r
+       }\r
+\r
+       @Override\r
+       public String testService(Services service) {\r
+               String server = getServicePath();\r
+               Writer testlog = new StringWriter();\r
+               PrintWriter writer = new PrintWriter(testlog, true);\r
+               WSTester tester = new WSTester(writer);\r
+               writer.println("Attempting to connect to the service " + service\r
+                               + " on the server " + server + "...");\r
+               JABAService ws = Jws2Client.connect(server, service);\r
+               writer.println("Connected successfully!");\r
+               try {\r
+                       boolean succeed = tester.checkService(ws);\r
+                       if (succeed) {\r
+                               // TODO extract messages (see WSTester main)\r
+                               writer.println("Check is completed. The Service "\r
+                                               + service.toString() + " IS WORKING");\r
+                               operating.put(service, new Date());\r
+                       } else {\r
+                               writer.println("Check is completed. The Service "\r
+                                               + service.toString() + " HAS SOME PROBLEMS");\r
+                       }\r
+               } finally {\r
+                       writer.close();\r
+               }\r
+               return testlog.toString();\r
+       }\r
+       @Override\r
+       public boolean isOperating(Services service) {\r
+               init();\r
+               return operating.containsKey(service);\r
+       }\r
+\r
+}\r