2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2019 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.onap.policy.pap.main.comm.msgdata;
23 import org.onap.policy.models.pdp.concepts.PdpMessage;
24 import org.onap.policy.models.pdp.concepts.PdpStatus;
25 import org.onap.policy.pap.main.comm.QueueToken;
26 import org.onap.policy.pap.main.notification.PolicyNotifier;
29 * Request data, whose message may be changed at any point, possibly triggering a restart
32 public interface Request {
35 * Gets the request priority. Higher priority requests are published before lower
38 * @return the request priority
40 public int getPriority();
43 * Gets the name with which this data is associated, used for logging purposes. This
44 * may be changed when this is reconfigured.
46 * @return the name with which this data is associated
48 public String getName();
51 * Gets the current message.
53 * @return the current message
55 public PdpMessage getMessage();
58 * Sets the listener that will receive request events.
60 * @param listener the request listener
62 public void setListener(RequestListener listener);
65 * Sets the notifier to track responses to the request.
67 * @param notifier notifier used to publish notifications
69 public void setNotifier(PolicyNotifier notifier);
72 * Determines if this request is currently being published.
74 * @return {@code true} if this request is being published, {@code false} otherwise
76 public boolean isPublishing();
79 * Starts the publishing process, registering any listeners or timeout handlers, and
80 * adding the request to the publisher queue.
82 public void startPublishing();
85 * Starts the publishing process.
87 * @param token2 token that can be used when publishing, or {@code null} to allocate a
90 public void startPublishing(QueueToken<PdpMessage> token2);
93 * Unregisters the listener, cancels the timer, and removes the message from the
96 public void stopPublishing();
99 * Unregisters the listener and cancels the timer.
101 * @param removeFromQueue {@code true} if the message should be removed from the
102 * queue, {@code false} otherwise
103 * @return the token that was being used to publish the message, or {@code null} if
104 * the request was not being published
106 public QueueToken<PdpMessage> stopPublishing(boolean removeFromQueue);
109 * Reconfigures the fields based on the {@link #message} type. Suspends publishing,
110 * updates the configuration, and then resumes publishing.
112 * @param newMessage the new message
113 * @param token2 token to use when publishing, or {@code null} to allocate a new token
115 public void reconfigure(PdpMessage newMessage, QueueToken<PdpMessage> token2);
118 * Checks the response to ensure it is as expected.
120 * @param response the response to check
121 * @return an error message, if a fatal error has occurred, {@code null} otherwise
123 public String checkResponse(PdpStatus response);
126 * Determines if this request has the same content as another request.
128 * @param other request against which to compare
129 * @return {@code true} if the requests have the same content, {@code false} otherwise
131 public boolean isSameContent(Request other);