2 * ===============================LICENSE_START======================================
4 * ================================================================================
5 * Copyright © 2017 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
11 * http://www.apache.org/licenses/LICENSE-2.0
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===========================================
21 package org.openecomp.dcae.apod.analytics.common.service.processor;
23 import com.google.common.base.Function;
24 import com.google.common.base.Optional;
26 import java.io.Serializable;
30 * A message processor can be used to process incoming messages.
31 * It uses implementations of {@link ProcessorContext} as input and output
34 * @param <P> Message Processor Context implementations
36 * @author Rajiv Singla . Creation Date: 11/7/2016.
38 public interface MessageProcessor<P extends ProcessorContext> extends Function<P, P>, Serializable {
41 * Returns processor information
43 * @return processor Information
45 ProcessorInfo getProcessorInfo();
49 * Does pre-processing of {@link ProcessorContext} e.g. validate input conditions and return
50 * pre processed context
52 * @param processorContext incoming Processor Context
53 * @return Pre processed Processor Context
55 P preProcessor(P processorContext);
59 * Return processing state of a processor
61 * @return Processing State
63 ProcessingState getProcessingState();
67 * May return a message from a processor which indicates the reason for {@link ProcessingState} especially if
68 * there was some failure in processing
70 * @return processing Message
72 Optional<String> getProcessingMessage();
76 * Does post-processing of {@link ProcessorContext}
78 * @param processorContext incoming Processor Context
79 * @return processor Context after post processing is finished
81 P postProcessor(P processorContext);