/*- * ========================LICENSE_START================================= * O-RAN-SC * %% * Copyright (C) 2020 Nordix Foundation * %% * 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.oransc.policyagent.clients; import org.oransc.policyagent.clients.A1Client.A1ProtocolType; import org.oransc.policyagent.configuration.ApplicationConfig; import org.oransc.policyagent.repository.Ric; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import reactor.core.publisher.Mono; /** * Factory for A1 clients that supports four different protocol versions of the * A1 api. */ public class A1ClientFactory { private static final Logger logger = LoggerFactory.getLogger(A1ClientFactory.class); private final ApplicationConfig appConfig; @Autowired public A1ClientFactory(ApplicationConfig appConfig) { this.appConfig = appConfig; } /** * Creates an A1 client with the correct A1 protocol for the provided Ric. * *
* It detects the protocol version by trial and error, since there is no * getVersion method specified in the A1 api yet. * *
* As a side effect it also sets the protocol version in the provided Ric. This
* means that after the first successful creation it won't have to try which
* protocol to use, but can create the client directly.
*
* @param ric The RIC to get a client for.
* @return a client with the correct protocol, or a ServiceException if none of
* the protocols are supported by the Ric.
*/
public Mono