aboutsummaryrefslogtreecommitdiffstats
path: root/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http
diff options
context:
space:
mode:
Diffstat (limited to 'policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http')
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/HttpClient.java9
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/HttpClientConfigException.java44
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/HttpClientFactory.java17
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/HttpClientFactoryInstance.java37
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/IndexedHttpClientFactory.java14
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/HttpServletServer.java28
-rw-r--r--policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/HttpServletServerFactoryInstance.java38
7 files changed, 147 insertions, 40 deletions
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/HttpClient.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/HttpClient.java
index 2e3b9afb..2fe46fb3 100644
--- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/HttpClient.java
+++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/HttpClient.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -33,11 +33,6 @@ import org.onap.policy.common.capabilities.Startable;
public interface HttpClient extends Startable {
/**
- * Factory.
- */
- HttpClientFactory factory = new IndexedHttpClientFactory();
-
- /**
* GET request.
*
* @param path context uri path.
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/HttpClientConfigException.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/HttpClientConfigException.java
new file mode 100644
index 00000000..98ec576f
--- /dev/null
+++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/HttpClientConfigException.java
@@ -0,0 +1,44 @@
+/*
+ * ============LICENSE_START=======================================================
+ * ONAP
+ * ================================================================================
+ * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.common.endpoints.http.client;
+
+/**
+ * Exception generated by HttpClient builder.
+ */
+public class HttpClientConfigException extends Exception {
+ private static final long serialVersionUID = 1L;
+
+ public HttpClientConfigException() {
+ super();
+ }
+
+ public HttpClientConfigException(String message) {
+ super(message);
+ }
+
+ public HttpClientConfigException(Throwable cause) {
+ super(cause);
+ }
+
+ public HttpClientConfigException(String message, Throwable cause) {
+ super(message, cause);
+ }
+}
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/HttpClientFactory.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/HttpClientFactory.java
index 5f4c4c9d..b155f729 100644
--- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/HttpClientFactory.java
+++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/HttpClientFactory.java
@@ -8,9 +8,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -21,8 +21,6 @@
package org.onap.policy.common.endpoints.http.client;
-import java.security.KeyManagementException;
-import java.security.NoSuchAlgorithmException;
import java.util.List;
import java.util.Properties;
import org.onap.policy.common.endpoints.event.comm.bus.internal.BusTopicParams;
@@ -35,17 +33,16 @@ public interface HttpClientFactory {
/**
* Build and http client with the following parameters.
*/
- HttpClient build(BusTopicParams busTopicParams)
- throws KeyManagementException, NoSuchAlgorithmException, ClassNotFoundException;
+ HttpClient build(BusTopicParams busTopicParams) throws HttpClientConfigException;
/**
* Build http client from properties.
*/
- List<HttpClient> build(Properties properties) throws KeyManagementException, NoSuchAlgorithmException;
+ List<HttpClient> build(Properties properties) throws HttpClientConfigException;
/**
* Get http client.
- *
+ *
* @param name the name
* @return the http client
*/
@@ -53,14 +50,14 @@ public interface HttpClientFactory {
/**
* List of http clients.
- *
+ *
* @return http clients
*/
List<HttpClient> inventory();
/**
* Destroy by name.
- *
+ *
* @param name name
*/
void destroy(String name);
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/HttpClientFactoryInstance.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/HttpClientFactoryInstance.java
new file mode 100644
index 00000000..c2921640
--- /dev/null
+++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/HttpClientFactoryInstance.java
@@ -0,0 +1,37 @@
+/*
+ * ============LICENSE_START=======================================================
+ * ONAP
+ * ================================================================================
+ * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.common.endpoints.http.client;
+
+import lombok.Getter;
+
+public class HttpClientFactoryInstance {
+
+ /**
+ * The client factory.
+ */
+ @Getter
+ private static final HttpClientFactory clientFactory = new IndexedHttpClientFactory();
+
+
+ private HttpClientFactoryInstance() {
+ // do nothing
+ }
+}
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/IndexedHttpClientFactory.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/IndexedHttpClientFactory.java
index c2d0e400..edf8ff6f 100644
--- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/IndexedHttpClientFactory.java
+++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/client/IndexedHttpClientFactory.java
@@ -47,14 +47,17 @@ class IndexedHttpClientFactory implements HttpClientFactory {
protected HashMap<String, HttpClient> clients = new HashMap<>();
@Override
- public synchronized HttpClient build(BusTopicParams busTopicParams)
- throws KeyManagementException, NoSuchAlgorithmException, ClassNotFoundException {
+ public synchronized HttpClient build(BusTopicParams busTopicParams) throws HttpClientConfigException {
if (clients.containsKey(busTopicParams.getClientName())) {
return clients.get(busTopicParams.getClientName());
}
- JerseyClient client =
- new JerseyClient(busTopicParams);
+ JerseyClient client;
+ try {
+ client = new JerseyClient(busTopicParams);
+ } catch (KeyManagementException | NoSuchAlgorithmException | ClassNotFoundException e) {
+ throw new HttpClientConfigException(e);
+ }
if (busTopicParams.isManaged()) {
clients.put(busTopicParams.getClientName(), client);
@@ -64,8 +67,7 @@ class IndexedHttpClientFactory implements HttpClientFactory {
}
@Override
- public synchronized List<HttpClient> build(Properties properties)
- throws KeyManagementException, NoSuchAlgorithmException {
+ public synchronized List<HttpClient> build(Properties properties) throws HttpClientConfigException {
ArrayList<HttpClient> clientList = new ArrayList<>();
String clientNames = properties.getProperty(PolicyEndPointProperties.PROPERTY_HTTP_CLIENT_SERVICES);
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/HttpServletServer.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/HttpServletServer.java
index b674e265..73b1e544 100644
--- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/HttpServletServer.java
+++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/HttpServletServer.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -27,22 +27,16 @@ import org.onap.policy.common.capabilities.Startable;
*/
public interface HttpServletServer extends Startable {
-
- /**
- * Factory of Http Servlet Servers.
- */
- HttpServletServerFactory factory = new IndexedHttpServletServerFactory();
-
/**
* Get the port.
- *
+ *
* @return port
*/
int getPort();
/**
* Enables basic authentication with user and password on the the relative path relativeUriPath.
- *
+ *
* @param user user
* @param password password
* @param relativeUriPath relative path
@@ -63,7 +57,7 @@ public interface HttpServletServer extends Startable {
/**
* Sets the serialization provider to be used when classes are added to the service.
- *
+ *
* @param provider the provider to use for message serialization and de-serialization
*/
void setSerializationProvider(String provider);
@@ -78,10 +72,10 @@ public interface HttpServletServer extends Startable {
/**
* Adds a JAX-RS servlet class to serve REST requests.
- *
+ *
* @param servletPath servlet path
* @param restClass JAX-RS API Class
- *
+ *
* @throws IllegalArgumentException unable to process because of invalid input
* @throws IllegalStateException unable to process because of invalid state
*/
@@ -89,10 +83,10 @@ public interface HttpServletServer extends Startable {
/**
* Adds a package containing JAX-RS classes to serve REST requests.
- *
+ *
* @param servletPath servlet path
* @param restPackage JAX-RS package to scan
- *
+ *
* @throws IllegalArgumentException unable to process because of invalid input
* @throws IllegalStateException unable to process because of invalid state
*/
@@ -100,10 +94,10 @@ public interface HttpServletServer extends Startable {
/**
* Blocking start of the http server.
- *
+ *
* @param maxWaitTime max time to wait for the start to take place
* @return true if start was successful
- *
+ *
* @throws IllegalArgumentException if arguments are invalid
* @throws InterruptedException if the blocking operation is interrupted
*/
diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/HttpServletServerFactoryInstance.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/HttpServletServerFactoryInstance.java
new file mode 100644
index 00000000..a56be701
--- /dev/null
+++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/http/server/HttpServletServerFactoryInstance.java
@@ -0,0 +1,38 @@
+/*
+ * ============LICENSE_START=======================================================
+ * ONAP
+ * ================================================================================
+ * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.common.endpoints.http.server;
+
+import lombok.Getter;
+
+public class HttpServletServerFactoryInstance {
+
+ /**
+ * The servlet factory.
+ */
+ @Getter
+ private static final HttpServletServerFactory serverFactory = new IndexedHttpServletServerFactory();
+
+
+ private HttpServletServerFactoryInstance() {
+ // do nothing
+ }
+
+}