2 * Copyright (C) 2022 CMCC, Inc. and others. All rights reserved.
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.
16 package org.onap.usecaseui.intentanalysis.clldeliveryIntentmgt;
19 import lombok.extern.slf4j.Slf4j;
20 import org.onap.usecaseui.intentanalysis.Thread.CreateCallable;
21 import org.onap.usecaseui.intentanalysis.bean.models.Intent;
22 import org.onap.usecaseui.intentanalysis.bean.models.IntentGoalBean;
23 import org.onap.usecaseui.intentanalysis.intentBaseService.IntentManagementFunction;
24 import org.onap.usecaseui.intentanalysis.intentBaseService.intentModule.ActuationModule;
25 import org.onap.usecaseui.intentanalysis.intentBaseService.intentModule.DecisionModule;
26 import org.onap.usecaseui.intentanalysis.intentBaseService.intentModule.KnowledgeModule;
27 import org.springframework.beans.factory.annotation.Autowired;
28 import org.springframework.context.ApplicationContext;
29 import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
30 import org.springframework.stereotype.Component;
32 import javax.annotation.Resource;
33 import java.time.LocalDateTime;
34 import java.util.concurrent.FutureTask;
38 @Component("CLLDeliveryIntentManagementFunction")
39 public class CLLDeliveryIntentManagementFunction extends IntentManagementFunction {
40 @Resource(name = "CLLDeliveryActuationModule")
41 public void setActuationModule(ActuationModule actuationModule) {
42 this.actuationModule = actuationModule;
45 @Resource(name = "CLLDeliveryKnowledgeModule")
46 public void setKnowledgeModule(KnowledgeModule knowledgeModule) {
47 this.knowledgeModule = knowledgeModule;
50 @Resource(name = "CLLDeliveryDecisionModule")
51 public void setDecisionModule(DecisionModule decisionModule) {
52 this.decisionModule = decisionModule;
56 ApplicationContext applicationContext;
57 @Resource(name = "intentTaskExecutor")
58 ThreadPoolTaskExecutor executor;
61 public void receiveIntentAsOwner(IntentGoalBean intentGoalBean) {
65 public void receiveIntentAsHandler(Intent originalIntent, IntentGoalBean intentGoalBean, IntentManagementFunction handler) {
66 //ask knowledgeModole of handler imf for permision and operate
68 log.debug("cllDelivery Intent create begin time:" + LocalDateTime.now());
69 CreateCallable deliveryCallable = new CreateCallable(originalIntent, intentGoalBean, handler, applicationContext);
70 FutureTask<String> futureTask = new FutureTask<>(deliveryCallable);
71 executor.submit(futureTask);
72 log.info(futureTask.get());
73 } catch (Exception ex) {
74 log.error("exception is {}", ex.getMessage());