* ========================LICENSE_START=================================
* O-RAN-SC
* %%
- * Copyright (C) 2019 AT&T Intellectual Property and Nokia
+ * Copyright (C) 2019 AT&T Intellectual Property
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
package org.oransc.ric.portal.dashboard.config;
import java.lang.invoke.MethodHandles;
-import java.net.MalformedURLException;
-import java.net.URL;
-import org.oransc.ric.a1med.client.api.A1MediatorApi;
-import org.oransc.ric.a1med.client.invoker.ApiClient;
+import org.oransc.ric.portal.dashboard.model.RicInstanceList;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
-import org.springframework.web.client.RestTemplate;
/**
- * Creates an A1 mediator client as a bean to be managed by the Spring
+ * Creates an A1 mediator client builder as a bean to be managed by the Spring
* container.
*/
@Configuration
-@Profile("!mock")
+@Profile("!test")
public class A1MediatorConfiguration {
private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
// Populated by the autowired constructor
- private final String a1medUrl;
+ private final String urlSuffix;
+ private final RicInstanceList instanceConfig;
@Autowired
- public A1MediatorConfiguration(@Value("${a1med.url}") final String url) throws MalformedURLException {
- logger.info("Configuring A1 Mediator at URL {}", url);
- new URL(url);
- this.a1medUrl = url;
- }
-
- private ApiClient apiClient() {
- ApiClient apiClient = new ApiClient(new RestTemplate());
- apiClient.setBasePath(a1medUrl);
- return apiClient;
+ public A1MediatorConfiguration(@Value("${a1med.url.suffix}") final String urlSuffix,
+ final RicInstanceList instanceConfig) {
+ logger.info("ctor: URL suffix {}", urlSuffix);
+ this.urlSuffix = urlSuffix;
+ this.instanceConfig = instanceConfig;
}
@Bean
- public A1MediatorApi a1MediatorApi() {
- return new A1MediatorApi(apiClient());
+ // The bean (method) name must be globally unique
+ public A1MediatorApiBuilder a1MediatorApiBuilder() {
+ return new A1MediatorApiBuilder(instanceConfig, urlSuffix);
}
}