DeviceMessageQueueImpl.java
1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* org.apache.felix.scr.annotations.Component
* org.apache.felix.scr.annotations.Service
*/
package com.adobe.cq.screens.impl;
import com.adobe.cq.screens.DeviceMessageQueue;
import java.util.ArrayDeque;
import java.util.HashMap;
import java.util.Map;
import java.util.Queue;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Service;
@Component
@Service(value={DeviceMessageQueue.class})
public class DeviceMessageQueueImpl
implements DeviceMessageQueue {
private final Map<String, Queue<String>> events = new HashMap<String, Queue<String>>();
@Override
public synchronized void queue(String path, String message) {
Queue<String> queue = this.events.get(path);
if (queue == null) {
queue = new ArrayDeque<String>();
this.events.put(path, queue);
}
if (!queue.contains(message)) {
queue.add(message);
}
}
@Override
public synchronized String dequeue(String path) {
Queue<String> queue = this.events.get(path);
if (queue == null) {
return null;
}
return queue.poll();
}
}