Aharoni, Pavel (pa0916) | 8c70f07 | 2018-11-18 00:07:12 +0200 | [diff] [blame] | 1 | /*-
|
| 2 | * ============LICENSE_START=======================================================
|
| 3 | * OSAM
|
| 4 | * ================================================================================
|
| 5 | * Copyright (C) 2018 AT&T
|
| 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 | package org.onap.osam.job;
|
| 21 |
|
| 22 | import org.onap.osam.job.impl.JobSharedData;
|
| 23 |
|
| 24 | import java.util.Map;
|
| 25 |
|
| 26 |
|
| 27 | /**
|
| 28 | * A callable instance, with serializable characteristics.
|
| 29 | * Represents a step in a chain of steps, which eventualy
|
| 30 | * resides into a packing Job.
|
| 31 | */
|
| 32 | public interface IJobCommand {
|
| 33 |
|
| 34 | /**
|
| 35 | * Initialize the command state
|
| 36 | * @param sharedData shared data cross all job commands
|
| 37 | * @param commandData An input to be set into the command. Each implementation may expect different keys in the map.
|
| 38 | * @return Returns itself
|
| 39 | */
|
| 40 | default IJobCommand init(JobSharedData sharedData, Map<String, Object> commandData) {
|
| 41 | return this;
|
| 42 | }
|
| 43 |
|
| 44 | /**
|
| 45 | * @return Returns the inner state of the command. This state, once passed into init(), should
|
| 46 | * bring the command back to it's state.
|
| 47 | */
|
| 48 | Map<String, Object> getData();
|
| 49 |
|
| 50 | /**
|
| 51 | * Execute the command represented by this instance. Assumes the instance is already init().
|
| 52 | * @return A NextCommand containing the next command in chain of commands, or null if chain
|
| 53 | * should be terminated. Might return itself (packed in a NextCommand).
|
| 54 | */
|
| 55 | NextCommand call();
|
| 56 |
|
| 57 | default JobType getType() {
|
| 58 | return JobType.jobTypeOf(this.getClass());
|
| 59 | }
|
| 60 |
|
| 61 | }
|