2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2019 Nordix Foundation.
4 * ================================================================================
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
17 * SPDX-License-Identifier: Apache-2.0
18 * ============LICENSE_END=========================================================
21 package org.onap.so.configuration.rest;
23 import java.util.concurrent.TimeUnit;
25 import org.springframework.beans.factory.annotation.Value;
26 import org.springframework.stereotype.Service;
29 * This class is used configure the parameters needed for
30 * {@link org.apache.http.impl.client.CloseableHttpClient}
32 * @author waqas.ikram@est.tech
35 public class HttpClientConnectionConfiguration {
37 @Value(value = "${rest.http.client.configuration.connTimeOutInSec:10}")
38 private int connectionTimeOutInSeconds;
40 @Value(value = "${rest.http.client.configuration.socketTimeOutInSec:180}")
41 private int socketTimeOutInSeconds;
43 @Value(value = "${rest.http.client.configuration.socketTimeOutInSec:600}")
44 private int timeToLiveInSeconds;
46 @Value(value = "${rest.http.client.configuration.maxConnections:10}")
47 private int maxConnections;
49 @Value(value = "${rest.http.client.configuration.maxConnectionsPerRoute:2}")
50 private int maxConnectionsPerRoute;
53 * @return the socket connection time out in milliseconds
55 public int getSocketTimeOutInMiliSeconds() {
56 return (int) TimeUnit.SECONDS.toMillis(socketTimeOutInSeconds);
60 * @return the maximum total connection value.
62 public int getMaxConnections() {
63 return maxConnections;
67 * @return the maximum connection per route value.
69 public int getMaxConnectionsPerRoute() {
70 return maxConnectionsPerRoute;
74 * @return the connect time out value in milliseconds.
76 public int getConnectionTimeOutInMilliSeconds() {
77 return (int) TimeUnit.SECONDS.toMillis(connectionTimeOutInSeconds);
81 * @return the connection time to live value in mintues.
83 public int getTimeToLiveInMins() {
84 return (int) TimeUnit.SECONDS.toMinutes(timeToLiveInSeconds);