3e15c1be4e7f23d7092992febcc48199fa0c41fd
[policy/models.git] /
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP
4  * ================================================================================
5  * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.onap.policy.controlloop.actorserviceprovider.impl;
22
23 import java.util.Map;
24 import java.util.concurrent.Executor;
25 import lombok.Getter;
26 import org.onap.policy.controlloop.actorserviceprovider.Operator;
27
28 /**
29  * Partial implementation of an operator.
30  */
31 public abstract class OperatorPartial extends StartConfigPartial<Map<String, Object>> implements Operator {
32
33     /**
34      * Executor to be used for tasks that may perform blocking I/O. The default executor
35      * simply launches a new thread for each command that is submitted to it.
36      * <p/>
37      * The "get" method may be overridden by junit tests.
38      */
39     @Getter
40     private final Executor blockingExecutor = command -> {
41         Thread thread = new Thread(command);
42         thread.setDaemon(true);
43         thread.start();
44     };
45
46     @Getter
47     private final String actorName;
48
49     @Getter
50     private final String name;
51
52     /**
53      * Constructs the object.
54      *
55      * @param actorName name of the actor with which this operator is associated
56      * @param name operation name
57      */
58     public OperatorPartial(String actorName, String name) {
59         super(actorName + "." + name);
60         this.actorName = actorName;
61         this.name = name;
62     }
63
64     /**
65      * This method does nothing.
66      */
67     @Override
68     protected void doConfigure(Map<String, Object> parameters) {
69         // do nothing
70     }
71
72     /**
73      * This method does nothing.
74      */
75     @Override
76     protected void doStart() {
77         // do nothing
78     }
79
80     /**
81      * This method does nothing.
82      */
83     @Override
84     protected void doStop() {
85         // do nothing
86     }
87
88     /**
89      * This method does nothing.
90      */
91     @Override
92     protected void doShutdown() {
93         // do nothing
94     }
95 }