
com.adobe.cq.screens.DeviceMessageQueue Maven / Gradle / Ivy
/*************************************************************************
*
* ADOBE CONFIDENTIAL
* __________________
*
* Copyright 2016 Adobe Systems Incorporated
* All Rights Reserved.
*
* NOTICE: All information contained herein is, and remains
* the property of Adobe Systems Incorporated and its suppliers,
* if any. The intellectual and technical concepts contained
* herein are proprietary to Adobe Systems Incorporated and its
* suppliers and are protected by trade secret or copyright law.
* Dissemination of this information or reproduction of this material
* is strictly forbidden unless prior written permission is obtained
* from Adobe Systems Incorporated.
************************************************************************/
package com.adobe.cq.screens;
import javax.annotation.CheckForNull;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import org.apache.sling.commons.json.JSONObject;
import aQute.bnd.annotation.ConsumerType;
/**
* The device message queue allows to queue messages
* unidirectional to the devices
*/
@ConsumerType
public interface DeviceMessageQueue {
/**
* Queue message and payload
* @param path The path of the resource that this message belongs.
* @param entry The message queue entry.
*/
void queueEntry(@Nonnull String path, @Nonnull Entry entry);
/**
* Dequeue message and payload
* @param path The path of the resource that this message belongs.
* @return the next entry or {@code null} if the queue is empty.
*/
@CheckForNull
Entry dequeueEntry(@Nonnull String path);
/**
* Creates a new device message queue entry builder with the given message.
* @param message the message for the entry.
* @return the builder.
*/
@Nonnull
EntryBuilder createEntryBuilder(@Nonnull String message);
/**
* Queue message
*
* @param path The path of the resource that this message belongs.
* @param message A simple message with no payload.
*/
void queue(@Nonnull String path, @Nonnull String message);
/**
* Dequeue message
*
* @param path The path of the resource that this message belongs.
* @return the next message or {@code null} if the queue is empty.
*/
@CheckForNull
String dequeue(@Nonnull String path);
/**
* Entry that can be added to the queue.
*/
@ConsumerType
interface Entry {
/**
* Returns the message of the entry
* @return the message
*/
@Nonnull
String getMessage();
/**
* Returns the payload of the entry or {@code null} if it does not contain a payload.
* @return the payload.
*/
@CheckForNull
JSONObject getPayload();
}
/**
* Builder for device message queue entries.
*/
@ConsumerType
interface EntryBuilder {
/**
* Sets the payload of this entry
* @return {@code this} builder.
*/
@Nonnull
EntryBuilder setPayload(@Nullable JSONObject obj);
/**
* Creates the entry of this builder.
* @return the entry.
*/
@Nonnull
DeviceMessageQueue.Entry build();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy