2 * Copyright 2016 Huawei Technologies Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package org.openo.nfvo.jujuvnfmadapter.common.servicetoken;
19 import java.util.HashMap;
22 import org.openo.baseservice.roa.util.restclient.HttpRest;
23 import org.openo.baseservice.roa.util.restclient.Restful;
24 import org.slf4j.Logger;
25 import org.slf4j.LoggerFactory;
29 * Http rest help class.<br>
34 * @version NFVO 0.5 Sep 12, 2016
36 public class HttpRestHelp {
38 public static final String PROTO_HTTP = "http";
40 private static final Logger LOG = LoggerFactory.getLogger(HttpRestHelp.class);
42 private static final Map<String, Restful> INSTANCES = new HashMap<>(2);
44 private HttpRestHelp() {
48 private static Restful createHttpsRest(String ssloptionfile, String restoptionfile, boolean isHttps) {
50 HttpRest rest = new HttpRest();
51 setHttpsRestOption(rest, restoptionfile);
57 * Get rest instance class.<br>
59 * @param ssloptionfile
60 * @param restoptionfile
65 public static synchronized Restful getRestInstance(String ssloptionfile, String restoptionfile, boolean isHttps) {
66 Restful rest = INSTANCES.get(PROTO_HTTP);
70 rest = createHttpsRest(ssloptionfile, restoptionfile, isHttps);
71 INSTANCES.put(PROTO_HTTP, rest);
75 private static void setHttpsRestOption(HttpRest httpRest, String restoptfile) {
76 LOG.info("setHttpsRestOption");