org.freedesktop.dbus.connections.PendingCallbackManager Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of dbus-java-core Show documentation
Show all versions of dbus-java-core Show documentation
Improved version of the DBus-Java library provided by freedesktop.org (https://dbus.freedesktop.org/doc/dbus-java/).
package org.freedesktop.dbus.connections;
import java.lang.reflect.Method;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.freedesktop.dbus.DBusAsyncReply;
import org.freedesktop.dbus.interfaces.CallbackHandler;
import org.freedesktop.dbus.messages.MethodCall;
public class PendingCallbackManager {
private Map> pendingCallbacks;
private Map> pendingCallbackReplys;
PendingCallbackManager() {
pendingCallbacks = new ConcurrentHashMap<>();
pendingCallbackReplys = new ConcurrentHashMap<>();
}
public synchronized void queueCallback(MethodCall _call, Method _method, CallbackHandler> _callback, AbstractConnection _connection) {
pendingCallbacks.put(_call, _callback);
pendingCallbackReplys.put(_call, new DBusAsyncReply<>(_call, _method, _connection));
}
public synchronized CallbackHandler extends Object> removeCallback(MethodCall _methodCall) {
pendingCallbackReplys.remove(_methodCall);
return pendingCallbacks.remove(_methodCall);
}
public synchronized CallbackHandler extends Object> getCallback(MethodCall _methodCall) {
return pendingCallbacks.get(_methodCall);
}
public synchronized DBusAsyncReply> getCallbackReply(MethodCall _methodCall) {
return pendingCallbackReplys.get(_methodCall);
}
}