Provides a stable API for looking up where on the Grid a particular webdriver instance is running. This class responds to the following URLs: Verb URL Template Meaning DELETE
| 69 | * </table> |
| 70 | */ |
| 71 | public abstract class SessionMap implements HasReadyState, Routable { |
| 72 | |
| 73 | protected final Tracer tracer; |
| 74 | |
| 75 | private final Route routes; |
| 76 | |
| 77 | public abstract boolean add(Session session); |
| 78 | |
| 79 | public abstract Session get(SessionId id) throws NoSuchSessionException; |
| 80 | |
| 81 | public abstract void remove(SessionId id); |
| 82 | |
| 83 | public URI getUri(SessionId id) throws NoSuchSessionException { |
| 84 | return get(id).getUri(); |
| 85 | } |
| 86 | |
| 87 | public SessionMap(Tracer tracer) { |
| 88 | this.tracer = Require.nonNull("Tracer", tracer); |
| 89 | |
| 90 | Json json = new Json(); |
| 91 | routes = |
| 92 | combine( |
| 93 | Route.get("/se/grid/session/{sessionId}/uri") |
| 94 | .to(params -> new GetSessionUri(this, sessionIdFrom(params))), |
| 95 | post("/se/grid/session").to(() -> new AddToSessionMap(tracer, json, this)), |
| 96 | Route.get("/se/grid/session/{sessionId}") |
| 97 | .to(params -> new GetFromSessionMap(tracer, this, sessionIdFrom(params))), |
| 98 | delete("/se/grid/session/{sessionId}") |
| 99 | .to(params -> new RemoveFromSession(tracer, this, sessionIdFrom(params)))); |
| 100 | } |
| 101 | |
| 102 | private SessionId sessionIdFrom(Map<String, String> params) { |
| 103 | return new SessionId(params.get("sessionId")); |
| 104 | } |
| 105 | |
| 106 | @Override |
| 107 | public boolean matches(HttpRequest req) { |
| 108 | return routes.matches(req); |
| 109 | } |
| 110 | |
| 111 | @Override |
| 112 | public HttpResponse execute(HttpRequest req) { |
| 113 | return routes.execute(req); |
| 114 | } |
| 115 | } |
nothing calls this directly
no outgoing calls
no test coverage detected