JWS-111 & JWS-109 Fixed some typos.
[jabaws.git] / website / man_server_dev.jsp
1 <%--<?xml version="1.0" encoding="ISO-8859-1" ?>--%>
2 <%--<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>--%>
3
4 <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
5 <%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
6 <%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
7 <%@ taglib uri="http://displaytag.sf.net" prefix="dt" %>
8
9
10 <c:import url="template_header.jsp" >
11         <c:param name="title">Documentation</c:param>
12 </c:import>
13
14 <ol class="breadcrumb">
15         <li><a href="${pageContext.request.contextPath}/index.jsp">Home</a></li>
16         <li><a href="man_docs.jsp">Documentation</a></li>
17         <li class="active"><a href="man_server_dev.jsp">Develop JABAWS</a></li>
18 </ol>
19 <div class="row">
20         <div class="col-md-12">
21                 <div class="panel panel-default">
22                         <div class="panel panel-heading">
23                                 <h1 class="panel-title">For JABAWS Developers</h1>
24                         </div>
25                         <div class="panel-body">
26                                 <!--<h4>JABAWS Server Virtual Appliance</h4>-->
27                                 <ul>
28                                         <li><a href="#api">The API</a></li>
29                                         <li><a href="#thesrc">The source code</a></li>
30                                         <li><a href="#projstruct">Structure of the project</a></li>
31                                         <li><a href="#thecode">The code structure</a></li>
32                                         <li><a href="#runtests">Running tests</a></li>
33                                         <li><a href="#prepexec">Preparing distributive's</a></li>
34                                         <li><a href="#buildstubs">Building web services artifacts</a></li>
35                                         <li><a href="#addnewws">Adding a new web service (rough guide)</a></li>
36                                 </ul>
37                                 <!--<p class="justify">-->
38                                 <!--</p>-->
39                         </div>
40                 </div>
41         </div>
42 </div>
43 <div class="row" id="api">
44         <div class="col-md-12">
45                 <div class="panel panel-default">
46                         <div class="panel panel-heading">
47                                 <h1 class="panel-title">The API</h1>
48                         </div>
49                         <div class="panel-body">
50                                 <p>This page is for anyone who wants to add a new webservice into the JABAWS framework.</p>
51                                 <p><a href="dm_javadoc/index.html">Data model</a> javadoc- read this if your are coding
52                                         against JABA Web Services
53                                 </p>
54                                 <p><a href="full_javadoc/index.html">Complete</a> javadoc - for developers who want to
55                                         use JABAWS framework and use Engines and Executables directly
56                                 </p>
57                                 <p class="text-right">
58                                         <a href="#">Back to top <i class="fa fa-arrow-up" aria-hidden="true"></i></a>
59                                 </p>
60                         </div>
61                 </div>
62         </div>
63 </div>
64 <div class="row" id="thesrc">
65         <div class="col-md-12">
66                 <div class="panel panel-default">
67                         <div class="panel panel-heading">
68                                 <h1 class="panel-title">The source code</h1>
69                         </div>
70                         <div class="panel-body">
71                                 <p><a name="svn">Publicly available Git repository:</a>
72                                         <a href="http://source.jalview.org/gitweb/?p=jabaws.git;a=summary">
73                                                 http://source.jalview.org/gitweb/?p=jabaws.git;a=summary</a></p>
74                                 <p>Another publicly available JABAWS repository, containing the code for each
75                                         JABAWS public release, is located at
76                                         <a href="https://jabaws.googlecode.com">jabaws.googlecode.com</a></p>
77                                 <p>The repositories contain a complete JABAWS
78                                         <a href="http://www.eclipse.org">Eclipse</a> project. </p>
79                                 <p>Of course if you want to make a modification to the source code you would need to
80                                         generate distributives yourself. To do that, first generate JAX-WS artifacts using
81                                         <em2>build-server</em2> task from <em2>wsbuild.xml</em2>
82                                         ant script, then you could use build.xml tasks to generate any of the distributives you need.
83                                 </p>
84                                 <p class="text-right">
85                                         <a href="#">Back to top <i class="fa fa-arrow-up" aria-hidden="true"></i></a>
86                                 </p>
87                         </div>
88                 </div>
89         </div>
90 </div>
91 <div class="row" id="projstruct">
92         <div class="col-md-12">
93                 <div class="panel panel-default">
94                         <div class="panel panel-heading">
95                                 <h1 class="panel-title">Structure of the project</h1>
96                         </div>
97                         <div class="panel-body">
98                                 <ul>
99                                         <li><i class="fa fa-folder-o" aria-hidden="true"></i> <span class="directory">binaries</span>   contains native executables e.g. clustalw</li>
100                                         <li style="list-style-position:inside"><i class="fa fa-folder-o" aria-hidden="true"></i> <span class="directory">src</span>     contains sources of native executables</li>
101                                         <li style="list-style-position:inside"><i class="fa fa-folder-o" aria-hidden="true"></i> <span class="directory">windows</span> contains pre-compiled Windows binaries</li>
102                                         <li style="list-style-position:inside"><i class="fa fa-folder-o" aria-hidden="true"></i> compilebin.sh - the script to complile binaries</li>
103                                         <li style="list-style-position:inside"><i class="fa fa-folder-o" aria-hidden="true"></i> setexecflag.sh - the script to set executable flag for the binaries</li>
104                                         <li><span class="directory"><i class="fa fa-folder-o" aria-hidden="true"></i> conf</span>       contains JABAWS configuration files     </li>
105                                         <li><span class="directory"><i class="fa fa-folder-o" aria-hidden="true"></i> ExecutionStatistics</span>        the database for storing collected execution statistics </li>
106                                         <li><span class="directory"><i class="fa fa-folder-o" aria-hidden="true"></i> jobsout</span> a default folder for temporary job directories </li>
107                                         <li><span class="directory"><i class="fa fa-folder-o" aria-hidden="true"></i> statpages</span> the web pages for execution statistics display</li>
108                                         <li><span class="directory"><i class="fa fa-folder-o" aria-hidden="true"></i> WEB-INF</span> default </li>
109                                         <li><span class="directory"><i class="fa fa-folder-o" aria-hidden="true"></i> website</span> contains the JABAWS web pages </li>
110                                         <li style="list-style-position:inside"><i class="fa fa-folder-o" aria-hidden="true"></i> <span class="directory">archive</span> contains JABAWS packages, the WAR and JAR files</li>
111                                 </ul>
112                                 <p class="text-right">
113                                         <a href="#">Back to top <i class="fa fa-arrow-up" aria-hidden="true"></i></a>
114                                 </p>
115                         </div>
116                 </div>
117         </div>
118 </div>
119 <div class="row" id="thecode">
120         <div class="col-md-12">
121                 <div class="panel panel-default">
122                         <div class="panel panel-heading">
123                                 <h1 class="panel-title">The code structure</h1>
124                         </div>
125                         <div class="panel-body">
126                                 <ul>
127                                         <li><span class="directory"><i class="fa fa-folder-o" aria-hidden="true"></i> datamodel</span> contains the JABAWS datamodel </li>
128                                         <li><span class="directory"><i class="fa fa-folder-o" aria-hidden="true"></i> engine</span> contains the JABAWS engine - the code that abstract the execution environment and executes native binaries</li>
129                                         <li><span class="directory"><i class="fa fa-folder-o" aria-hidden="true"></i> runner</span> contains the JABAWS runners - thin wrappers for native binaries </li>
130                                         <li><span class="directory"><i class="fa fa-folder-o" aria-hidden="true"></i> webservices</span> contains the JABAWS SOAP web services </li>
131                                         <li><span class="directory"><i class="fa fa-folder-o" aria-hidden="true"></i> testsrc</span> contains the JABAWS unit tests</li>
132                                 </ul>
133                                 <p class="justify">
134                                         Each source folder depends on the upper folders for compilation. For example, the datamodel
135                                         is the top level folder so it has no other dependencies on other JABAWS code.
136                                         The Engine level depends on the datamodel to compile etc. The web services folder is the
137                                         bottom layer and depends on all the other source code.
138                                 </p>
139                                 <p class="justify">
140                                         So the JABAWS project is split into 4 layers. From bottom-up the first layer
141                                         consists from the value classes used by all other layers of the hierarchy, in
142                                         particular web services. So, to be able to use JABAWS one needs to have these
143                                         classes. At the same time classes on this layer does not have any dependencies
144                                         on the layers above.
145                                 </p>
146                                 <p class="justify">
147                                         The second layer contains code for execution of the wrappers, which are the
148                                         abstraction describing native executables. JABAWS can execute tasks locally
149                                         that is on the same machine as JVM and on the cluster. Thus currently code on
150                                         this layer contain two engines. This layer depends on the layer underneath, the
151                                         data model layer, but is completely independent from the code above.
152                                 </p>
153                                 <p class="justify">
154                                         The third layer consists of the wrappers for the native executables and classes to
155                                         handle their configuration. It depends on the engines and the data model, but know
156                                         nothing about the web services.
157                                 </p>
158                                 <p class="justify">
159                                         Finally, the upper layer contains the web services, that depend on all the layers below.
160                                 </p>
161                                 <p class="justify">
162                                         The layer isolation is archived though specially designed compilation task which is
163                                         executed sequentially in several stages so that the first layer compiles before
164                                         any other layers, second layer compiles after that and process continies before
165                                         all the code is compiled.  Any violation of the layer boundaries results in the
166                                         compilation failure. Use Ant &quot;Compile&quot; or &quot;Complile_with_debug&quot;
167                                         tasks to perform the staged compilation.
168                                 </p>
169                                 <p class="justify">
170                                         A client package contains only classes from data model layer and a simple web
171                                         services client. Framework package is for anyone who want to use JABAWS framework
172                                         for controlling native executables in local or cluster environments. Framework exclude
173                                         the web services layer. Server package contains all the code.
174                                 </p>
175                                 <p class="text-right">
176                                         <a href="#">Back to top <i class="fa fa-arrow-up" aria-hidden="true"></i></a>
177                                 </p>
178                         </div>
179                 </div>
180         </div>
181 </div>
182 <div class="row" id="runtests">
183         <div class="col-md-12">
184                 <div class="panel panel-default">
185                         <div class="panel panel-heading">
186                                 <h1 class="panel-title">Running tests</h1>
187                         </div>
188                         <div class="panel-body">
189                                 <p class="justify">
190                                         JABAWS uses TestNG framework for testing. The test results for the JABAWS
191                                         package offered for download can be found at:
192                                         <a href="http://www.compbio.dundee.ac.uk/user/www-jws2/tests/index.html">
193                                                 Test Results</a><br/>
194                                         JABAWS uses <a href="http://testng.org/doc/index.html">TestNG</a>
195                                         for testing. There is a TestNG plugin available for Eclipse
196                                         which has functionality similar to JUnit. However, no plugins are
197                                         necessary to run the test cases, as testng jar is supplied
198                                         with JABAWS together with an ant tasks to run the test cases.
199                                 </p>
200                                 <p class="justify">
201                                         The best way to ensure that JABAWS framework is completely functional on your
202                                         system is to run all test cases.
203                                         Test cases tests all aspects of JABAWS functionality. Consequently, one need
204                                         to have non windows operation system and support
205                                         of the cluster to be able to run all tests. If your system does not support
206                                         cluster, then you could run all test excluding those that depends on the cluster.
207                                 </p>
208
209                                 <p>Several testing groups are supported:</p>
210                                 <ul>
211                                         <li>All tests (Test)</li>
212                                         <li>Cluster tests (Run_cluster_dependent_test)</li>
213                                         <li>Cluster independent tests () </li>
214                                         <li>Windows only tests (All_cluster_independent_windows_only_tests) </li>
215                                         <li>Performance and stability tests (Long_tests) </li>
216                                         <li>Re-run failed tests (Rerun_failed_tests) </li>
217                                         <li>Run custom test (CustomTest) </li>
218                                 </ul>
219
220                                 <p class="justify">
221                                         To run the tests you need to download all sources from <a href="#svn">repository</a>.
222                                         Once you have done that, enter into the command line mode, change directory to the
223                                         project directory and type:
224                                 </p>
225                                 <pre><code class="bash">ant -f build.xml &lt;test group name&gt;</code></pre>
226                                 <p class="justify">
227                                         Make sure you have <a href="http://ant.apache.org/">Apache Ant</a>
228                                         installed and path to ant executable is defined in your path environmental variable.
229                                         Replace test group name with the one of the names given in the list above to run required group of tests e.g for running cluster only tests
230                                         use the following
231                                         command:</p>
232                                 <pre><code class="bash">ant -f build.xml Run_cluster_dependent_test</code></pre>
233                                 <p class="justify">
234                                         If you work under Linux you could use a simple script from the root folder of repository called <em2>runtests.sh</em2>
235                                         This script simply contains a collection of the test commands described above and paths to java home directory and an ant executable,
236                                         which you can define once for your system and then reuse.
237                                 </p>
238                                 <p class="justify">
239                                         A handy feature of TestNG is its ability to re-run failed tests. Failed test
240                                         ant file is stored in
241                                         <em2>test-output/testng-failed.xml</em2>. and is used in the ant task called
242                                         <em2>Rerun_failed_tests</em2>. So re-running failed tests requires no more
243                                         work than running any other test group and could be accomplished with the command:
244                                 </p>
245                                 <pre><code class="bash">ant -f build.xml Rerun_failed_tests</code></pre>
246                                 <p class="justify">
247                                         CustomTest runs the test defined in the project root directory file called
248                                         <em2>temp-testng-customsuite.xml</em2>. This
249                                         file is generated by TestNG plugin every time you run the test from Eclipse.
250                                         Thus an easy way to run a test in a different environment is to run it from
251                                         Eclipse first and then from ant using a custom test procedure.
252                                 </p>
253                                 <p class="justify">
254                                         For cluster execution make sure that the property
255                                         LD_LIBRARY_PATH defined in build.xml points to cluster engine LD
256                                         libraries directory in your local system.
257                                 </p>
258                                 <p class="text-right">
259                                         <a href="#">Back to top <i class="fa fa-arrow-up" aria-hidden="true"></i></a>
260                                 </p>
261                         </div>
262                 </div>
263         </div>
264 </div>
265 <div class="row" id="prepexec">
266         <div class="col-md-12">
267                 <div class="panel panel-default">
268                         <div class="panel panel-heading">
269                                 <h1 class="panel-title">Preparing distributive's</h1>
270                         </div>
271                         <div class="panel-body">
272                                 <p class="justify">
273                                         There are a number of ant tasks aimed for preparing distributives for download.
274                                         Currently a few types of JABAWS packages are offered:
275                                 </p>
276                                 <ol>
277                                         <li>Client only (contains classes required to access JABA Web Services)</li>
278                                         <li>Platform specific JABAWS (windows and other)</li>
279                                         <li>JABAWS without binaries</li>
280                                         <li>JABAWS framework </li>
281                                 </ol>
282                                 <p>Corresponding build task names are:</p>
283                                 <ol>
284                                         <li>min-jaba-client</li>
285                                         <li>jaba-windows, jaba-complete</li>
286                                         <li>jaba-no-binaries</li>
287                                         <li>full-jaba-client</li>
288                                 </ol>
289                                 <p class="justify">
290                                         The easiest way to build all distributives is to call
291                                         <em2>build-all</em2> ant task.
292                                         There are more tasks defined in build.xml than described here.
293                                         They are mostly self explanatory.
294                                 </p>
295                                 <p class="justify">
296                                         If you made any changes to the data model and
297                                         would like to generate a complete JABAWS
298                                         distro make sure you have rebuilt jaxws artifact as described below.
299                                 </p>
300                                 <p class="text-right">
301                                         <a href="#">Back to top <i class="fa fa-arrow-up" aria-hidden="true"></i></a>
302                                 </p>
303                         </div>
304                 </div>
305         </div>
306 </div>
307 <div class="row" id="buildstubs">
308         <div class="col-md-12">
309                 <div class="panel panel-default">
310                         <div class="panel panel-heading">
311                                 <h1 class="panel-title">Building web services artifacts</h1>
312                         </div>
313                         <div class="panel-body">
314                                 <p class="justify">
315                                         Server side artifacts should be rebuild whenever the data model, meta model or MSA
316                                         interface were changed.
317                                         To do that run build-server task from wsbuild.xml ant build file. WSDL files will
318                                         be generated in
319                                         <em2>webservices/compbio/ws/server/resource</em2> directory. It is not necessary to
320                                         edit them if any of the JABAWS clients are used. JABAWS are the standard JAX-WS web
321                                         services, which are WS-I basic profile compatible.
322                                 </p>
323                                 <p class="text-right">
324                                         <a href="#">Back to top <i class="fa fa-arrow-up" aria-hidden="true"></i></a>
325                                 </p>
326                         </div>
327                 </div>
328         </div>
329 </div>
330 <div class="row" id="addnewws">
331         <div class="col-md-12">
332                 <div class="panel panel-default">
333                         <div class="panel panel-heading">
334                                 <h1 class="panel-title">Adding a new web service (rough guide)</h1>
335                         </div>
336                         <div class="panel-body">
337                                 <ol>
338                                         <li>
339                                                 <p>Add a new executable which you'd like to wrap as a JABAWS web service to the binaries folder.
340                                                         If it has the source code and can be recompiled for different platforms include it under
341                                                         <em2>binaries/src</em2>. Edit <em2>setexecutableflag.sh</em2>
342                                                         and <em2>compilebin.sh</em2> scripts in <em2>binaries/src</em2>
343                                                         accordingly.</p>
344                                         </li><li>
345                                         <p>Make sure that all the dependencies of the software being installed are satisfied.
346                                                 If there are other binaries they should be included as well. Keep the dependent
347                                                 binaries in a subfolder for the main executable. Update
348                                                 <em2>compilebin.sh</em2> and <em2>setexecflag.sh</em2> scripts accordingly.</p>
349                                 </li><li>
350                                         <p>Make sure that the new executable does not have any hard links to its dependencies, e.g. is able to run from
351                                                 any installation folder and does not contain any hard coded paths.</p>
352                                 </li><li>
353                                         <p>Describe executable in <em2>conf/Exectuable.properties</em2> file. The lowercase name of
354                                                 the wrapper should be included
355                                                 in the name of the property for example Clustal properties all include clustal as a
356                                                 part of the name e.g. local.clustalw.bin.
357                                                 The same property for MAFFT will be called local.mafft.bin. For more help please refer
358                                                 to the Executable.properties file.
359                                         </p>
360                                 </li><li>
361                                         <p>Describe the executable supported parameters in the
362                                                 <em2>&lt;ExecutableName&gt;Parameters.xml</em2>, presets in the
363                                                 <em2>&lt;ExecutableName&gt;Presets.xml</em2> and the execution limits in the
364                                                 <em2>&lt;ExecutableName&gt;Limit.xml</em2>. By convention these files are stored
365                                                 in <em2>conf/settings</em2>. All of these are optional. If the executable
366                                                 does not support parameters you do not have to mention the <em2>XXXParameter.xml</em2> file
367                                                 in the <em2>Executable.properties</em2> file at all. The same is true for
368                                                 Presets and Limits.</p>
369                                 </li><li>
370                                         <p>Create a Java wrapper class for your executable. Create it within <em2>runner</em2> source directory.
371                                                 Examples of other wrappers can be found in <em2>compbio.runner.msa</em2> or
372                                                 in other <em2>compbio.runner.*</em2> packages. Wrapper should extend
373                                                 <em2>SkeletalExecutable&lt;T&gt;</em2> and implement
374                                                 <em2>PipedExecutable&lt;T&gt;</em2>
375                                                 if you need to pass the input or collect the results from the standard in/out. Please see Mafft
376                                                 code as example. Wrapper should expend <em2>SkeletalExecutable&lt;T&gt;</em2>
377                                                 if input/output can be set as a parameter for an executable. Please see the ClustalW code as example.</p>
378                                 </li><li>
379                                         <p>Create a testcase suit for your wrapper in <em2>testsrc</em2> and run the test cases.</p>
380                                 </li><li>
381                                         <p>Create parser for the output files of your executable. Suggested location
382                                                 compbio.data.sequence.SequenceUtil . </p>
383                                 </li><li>
384                                         <p>Test the parser.</p>
385                                 </li><li>
386                                         <p>Decide which web services interfaces your executable is going to match. For example
387                                                 if the executable output can be represented as SequenceAnnotation then SequenceAnnotation
388                                                 interface might be appropriate. For multiple sequence alignment an Msa interface should be used.</p>
389                                 </li><li>
390                                         <p>If you find a web interface that matches your returning data type, then
391                                                 implement a web service which confirms to it within a webservices source folder. </p>
392                                 </li><li>
393                                         <p>Register web service in <em2>WEB-INF/web.xml</em2>
394                                                 and <em2>WEB-INF/sun-jaxws.xml</em2>.</p>
395                                 </li><li>
396                                         <p>Add generated wsdl to wsbuild.xml ant script to generate the stubs.</p>
397                                 </li><li>
398                                         <p>Run build-server task in wsbuild file. Watch for errors. If the task fails that means
399                                                 that JAXB cannot serialize some of your new data structures. Add appropriate annotations to your data types.
400                                                 Also check that: </p>
401                                         <ul>
402                                                 <li>you do not have interfaces to serialize, since JAXB cannot serialize them</li>
403                                                 <li>you have a default no args constructor (can be private if you do not need it)</li>
404                                                 <li>JAXB cannot serialize Java Map class, use a custom data structure instead</li>
405                                                 <li>Enum cannot be serialized as its abstract class (do not confuse with enum which is fine)</li>
406                                                 <li> Fields serialization leaves a little more space for manoeuvre.
407                                                         If you do this then you may accept<br/> and return interfaces, e.g. List, Map; abstract classes etc, from your methods
408                                                 </li>
409                                         </ul>
410                                         <p>If you have the data on the server side, but nothing is coming through to the
411                                                 client, this is a JAXB serialization problem. They tend to be very silent and
412                                                 thus hard to debug. Check your data structure can be serialized!</p>
413                                 </li><li>
414                                         <p>Modify the client to work with your new web service. Update Services
415                                                 enumeration to include new service and ensure that all the methods of this
416                                                 enumeration take into account the new service. Update the client help text
417                                                 (client_help.txt) and insert it into the Constraints class.</p>
418                                 </li><li>
419                                         <p>Test the web service with the client.</p>
420                                 </li><li>
421                                         <p>Test on the cluster.</p>
422                                 </li>
423                                 </ol>
424                         </div>
425                 </div>
426         </div>
427 </div>
428
429 <jsp:include page="template_footer.jsp" />