4aecd1e027b5c52ad63fac35e41df03d98ea1a81
[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,2023 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 sniHostCheck SNI Host checking flag
40      * @param contextPath server base path
41      * @param swagger enable swagger documentation
42      * @param managed is it managed by infrastructure
43      * @return http server
44      * @throws IllegalArgumentException when invalid parameters are provided
45      */
46     HttpServletServer build(String name, boolean https, String host, int port, boolean sniHostCheck, String contextPath,
47         boolean swagger, boolean managed);
48
49     /**
50      * Builds an http rest server with support for servlets.
51      *
52      * @param name name
53      * @param host binding host
54      * @param port port
55      * @param contextPath server base path
56      * @param swagger enable swagger documentation
57      * @param managed is it managed by infrastructure
58      * @return http server
59      * @throws IllegalArgumentException when invalid parameters are provided
60      */
61     HttpServletServer build(String name, String host, int port, String contextPath, boolean swagger, boolean managed);
62
63     /**
64      * Build a list of http rest servers per properties.
65      *
66      * @param properties properties based configuration
67      * @return list of http servers
68      * @throws IllegalArgumentException when invalid parameters are provided
69      */
70     List<HttpServletServer> build(Properties properties);
71
72     /**
73      * Builds an http or https server to manage static resources.
74      *
75      * @param name name
76      * @param https use secured http over tls connection
77      * @param host binding host
78      * @param port port
79      * @param sniHostCheck SNI Host checking flag
80      * @param contextPath server base path
81      * @param managed is it managed by infrastructure
82      * @return http server
83      * @throws IllegalArgumentException when invalid parameters are provided
84      */
85     HttpServletServer buildStaticResourceServer(String name, boolean https, String host, int port, boolean sniHostCheck,
86         String contextPath, boolean managed);
87
88     /**
89      * Gets a server based on the port.
90      *
91      * @param port port
92      * @return http server
93      */
94     HttpServletServer get(int port);
95
96     /**
97      * Provides an inventory of servers.
98      *
99      * @return inventory of servers
100      */
101     List<HttpServletServer> inventory();
102
103     /**
104      * Destroys server bound to a port.
105      *
106      * @param port the port the server is bound to
107      */
108     void destroy(int port);
109
110     /**
111      * Destroys the factory and therefore all servers.
112      */
113     void destroy();
114 }