90c0db2e1ccf0084a7121ba31651ea7cec491978
[policy/common.git] /
1 /*
2  * ============LICENSE_START=======================================================
3  * policy-endpoints
4  * ================================================================================
5  * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
6  * Modifications Copyright (C) 2020 Nordix Foundation.
7  * ================================================================================
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  *      http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  * ============LICENSE_END=========================================================
20  */
21
22 package org.onap.policy.common.endpoints.http.server;
23
24 import java.util.List;
25 import java.util.Properties;
26
27 /**
28  * Factory of HTTP Servlet-Enabled Servlets.
29  */
30 public interface HttpServletServerFactory {
31
32     /**
33      * Builds an http or https rest server with support for servlets.
34      *
35      * @param name name
36      * @param https use secured http over tls connection
37      * @param host binding host
38      * @param port port
39      * @param contextPath server base path
40      * @param swagger enable swagger documentation
41      * @param managed is it managed by infrastructure
42      * @return http server
43      * @throws IllegalArgumentException when invalid parameters are provided
44      */
45     HttpServletServer build(String name, boolean https, String host, int port, String contextPath, boolean swagger,
46         boolean managed);
47
48     /**
49      * Builds an http rest server with support for servlets.
50      *
51      * @param name name
52      * @param host binding host
53      * @param port port
54      * @param contextPath server base path
55      * @param swagger enable swagger documentation
56      * @param managed is it managed by infrastructure
57      * @return http server
58      * @throws IllegalArgumentException when invalid parameters are provided
59      */
60     HttpServletServer build(String name, String host, int port, String contextPath, boolean swagger, boolean managed);
61
62     /**
63      * Build a list of http rest servers per properties.
64      *
65      * @param properties properties based configuration
66      * @return list of http servers
67      * @throws IllegalArgumentException when invalid parameters are provided
68      */
69     List<HttpServletServer> build(Properties properties);
70
71     /**
72      * Builds an http or https server to manage static resources.
73      *
74      * @param name name
75      * @param https use secured http over tls connection
76      * @param host binding host
77      * @param port port
78      * @param contextPath server base path
79      * @param managed is it managed by infrastructure
80      * @return http server
81      * @throws IllegalArgumentException when invalid parameters are provided
82      */
83     HttpServletServer buildStaticResourceServer(String name, boolean https, String host, int port, String contextPath,
84             boolean managed);
85
86     /**
87      * Gets a server based on the port.
88      *
89      * @param port port
90      * @return http server
91      */
92     HttpServletServer get(int port);
93
94     /**
95      * Provides an inventory of servers.
96      *
97      * @return inventory of servers
98      */
99     List<HttpServletServer> inventory();
100
101     /**
102      * Destroys server bound to a port.
103      *
104      * @param port the port the server is bound to
105      */
106     void destroy(int port);
107
108     /**
109      * Destroys the factory and therefore all servers.
110      */
111     void destroy();
112 }