JAL-3785 renaming, adding to interface, tidying
[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
52     setPath(MY_PATH);
53     this.registerHandler();
54
55     init = true;
56   }
57
58   /*
59    * Shared methods below here
60    */
61
62   @Override
63   public String getPath()
64   {
65     return MY_PATH;
66   }
67
68   protected static Map<String, Status> getStatusMap()
69   {
70     return statusMap;
71   }
72
73   protected static Map<String, String> getRequestMap()
74   {
75     return requestMap;
76   }
77
78   protected static Map<String, Object> getObjectMap()
79   {
80     return objectMap;
81   }
82 }