JAL-3851 some changes. HighlightSequenceEndpoint and SelectSequenceEndpoint
[jalview.git] / src / jalview / rest / API.java
1 package jalview.rest;
2
3 import java.net.BindException;
4 import java.util.HashMap;
5 import java.util.Map;
6
7 public class API extends RestHandler
8 {
9   private static final String MY_PATH = "api";
10
11   private static final String MY_NAME = "Jalview API";
12
13   private static Map<String, Status> statusMap = new HashMap<>();
14
15   private static Map<String, String> requestMap = new HashMap<>();
16
17   private static Map<String, Object> objectMap = new HashMap<>();
18
19   private static API instance = null;
20
21   public static API getInstance() throws BindException
22   {
23     synchronized (API.class)
24     {
25       if (instance == null)
26       {
27         instance = new API();
28       }
29     }
30     return instance;
31   }
32
33   private API() throws BindException
34   {
35     super();
36   }
37
38   private boolean init = false;
39
40   @Override
41   protected void init() throws BindException
42   {
43     if (init)
44       return;
45     super.init(MY_PATH);
46
47     // add endpoints here
48     addEndpoint(new FetchSequencesEndpoint(this));
49     addEndpoint(new InputAlignmentEndpoint(this));
50     addEndpoint(new HighlightSequenceEndpoint(this));
51     addEndpoint(new SelectSequencesEndpoint(this));
52
53     setPath(MY_PATH);
54     this.registerHandler();
55
56     init = true;
57   }
58
59   /*
60    * Shared methods below here
61    */
62
63   @Override
64   public String getPath()
65   {
66     return MY_PATH;
67   }
68
69   protected static Map<String, Status> getStatusMap()
70   {
71     return statusMap;
72   }
73
74   protected static Map<String, String> getRequestMap()
75   {
76     return requestMap;
77   }
78
79   protected static Map<String, Object> getObjectMap()
80   {
81     return objectMap;
82   }
83 }