1 /* Copyright (c) 2009 Peter Troshin
\r
3 * JAva Bioinformatics Analysis Web Services (JABAWS) @version: 1.0
\r
5 * This library is free software; you can redistribute it and/or modify it under the terms of the
\r
6 * Apache License version 2 as published by the Apache Software Foundation
\r
8 * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
\r
9 * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Apache
\r
10 * License for more details.
\r
12 * A copy of the license is in apache_license.txt. It is also available here:
\r
13 * @see: http://www.apache.org/licenses/LICENSE-2.0.txt
\r
15 * Any republication or derived work distributed in source code form
\r
16 * must include this copyright and license notice.
\r
19 package compbio.ws.server;
\r
21 import javax.jws.WebService;
\r
22 import javax.xml.ws.Endpoint;
\r
25 * This class publish a web service. This is not a production implementation.
\r
26 * Should be used only for during development and testing
\r
29 * @date October 2009
\r
31 public class SimpleWSPublisher {
\r
33 public SimpleWSPublisher(Object exec, String context) {
\r
37 public static void main(String[] args) {
\r
38 if (args.length != 2) {
\r
39 System.out.println("Usage: ");
\r
40 System.out.println("SimpleWSPublisher context class");
\r
42 .println("where context is a context name, the name after the address by "
\r
43 + "which web service can be called e.g. Clustal "
\r
44 + " and class is a web service implementation class");
\r
47 String context = args[0];
\r
48 String clazzName = args[1];
\r
50 Class<?> clazz = Class.forName(clazzName);
\r
51 if (!clazz.isAnnotationPresent(WebService.class)) {
\r
52 System.out.println("Can only start web services. "
\r
53 + "Please check whether the class provided is "
\r
54 + "annotated with Webservice annotation");
\r
57 Endpoint.publish("http://127.0.0.1:7979/" + context, clazz
\r
59 } catch (InstantiationException e) {
\r
60 e.printStackTrace();
\r
62 } catch (IllegalAccessException e) {
\r
63 e.printStackTrace();
\r
65 } catch (ClassNotFoundException e) {
\r
66 e.printStackTrace();
\r
68 } catch (IllegalArgumentException e) {
\r
69 e.printStackTrace();
\r