add new API for programmatic registration of web Servlet, Filter, etc.
[aaa.git] / web / api / src / main / java / org / opendaylight / aaa / web / WebServer.java
1 /*
2  * Copyright (c) 2018 Red Hat, Inc. and others. All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.aaa.web;
9
10 import javax.servlet.ServletException;
11
12 /**
13  * Web server (HTTP). This service API allows ODL applications to register web
14  * components programmatically, instead of using a web.xml declaratively; see
15  * the {@link WebContext} for why this is preferable.
16  *
17  * <p>
18  * This API has an OSGi-based as well as a "standalone" implementation suitable
19  * e.g. for tests.
20  *
21  * @author Michael Vorburger.ch
22  */
23 public interface WebServer {
24
25     /**
26      * Register a new web context.
27      *
28      * @param webContext the web context
29      * @return registration which allows to close the context (and remove its servlets etc.)
30      * @throws ServletException if registration of any of the components of the web context failed
31      */
32     WebContextRegistration registerWebContext(WebContext webContext) throws ServletException;
33
34     /**
35      * Base URL of this web server, without any contexts. In production, this would
36      * likely be HTTPS with a well known hostname and fixed port configured e.g. in
37      * a Karaf etc/ configuration file. In tests, this would be typically be HTTP on
38      * localhost and an arbitrarily chosen port.
39      *
40      * @return base URL, with http[s] prefix and port, NOT ending in slash
41      */
42     String getBaseURL();
43
44 }