JAL-3851 Added GetCrossReferencesEndpoint. Quite a bit of refactorying of Async error...
[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     addEndpoint(new GetCrossReferencesEndpoint(this));
53
54     setPath(MY_PATH);
55     this.registerHandler();
56
57     init = true;
58   }
59
60   /*
61    * Shared methods below here
62    */
63
64   @Override
65   public String getPath()
66   {
67     return MY_PATH;
68   }
69
70   protected static Map<String, Status> getStatusMap()
71   {
72     return statusMap;
73   }
74
75   protected static Map<String, String> getRequestMap()
76   {
77     return requestMap;
78   }
79
80   protected static Map<String, Object> getObjectMap()
81   {
82     return objectMap;
83   }
84 }