Merge branch 'feature/JAL-3982_mouseover_highlighting_viaJAL-3860' into feature/JAL...
[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     addEndpoint(new HighlightGenomicRangeEndpoint(this));
54
55     setPath(MY_PATH);
56     this.registerHandler();
57
58     init = true;
59   }
60
61   /*
62    * Shared methods below here
63    */
64
65   @Override
66   public String getPath()
67   {
68     return MY_PATH;
69   }
70
71   protected static Map<String, Status> getStatusMap()
72   {
73     return statusMap;
74   }
75
76   protected static Map<String, String> getRequestMap()
77   {
78     return requestMap;
79   }
80
81   protected static Map<String, Object> getObjectMap()
82   {
83     return objectMap;
84   }
85 }