JAL-3851 tidy up REMOVEME logging
[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 API instance = null;
18
19   public static API getInstance() throws BindException
20   {
21     synchronized (API.class)
22     {
23       if (instance == null)
24       {
25         instance = new API();
26       }
27     }
28     return instance;
29   }
30
31   private API() throws BindException
32   {
33     super();
34   }
35
36   private boolean init = false;
37
38   @Override
39   protected void init() throws BindException
40   {
41     if (init)
42       return;
43     super.init(MY_PATH);
44
45     // add endpoints here
46     addEndpoint(new FetchSequenceEndpoint(this));
47     addEndpoint(new OpenAlignmentEndpoint(this));
48     addEndpoint(new HighlightSequenceEndpoint(this));
49
50     setPath(MY_PATH);
51     this.registerHandler();
52
53     init = true;
54   }
55
56   /*
57    * Shared methods below here
58    */
59
60   @Override
61   public String getPath()
62   {
63     return MY_PATH;
64   }
65
66   protected static Map<String, Status> getStatusMap()
67   {
68     return statusMap;
69   }
70
71   protected static Map<String, String> getRequestMap()
72   {
73     return requestMap;
74   }
75 }