All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.freedesktop.dbus.connections.PendingCallbackManager Maven / Gradle / Ivy

Go to download

Improved version of the DBus-Java library provided by freedesktop.org (https://dbus.freedesktop.org/doc/dbus-java/).

There is a newer version: 5.1.0
Show newest version
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 removeCallback(MethodCall _methodCall) {
        pendingCallbackReplys.remove(_methodCall);
        return pendingCallbacks.remove(_methodCall);
    }

    public synchronized CallbackHandler getCallback(MethodCall _methodCall) {
        return pendingCallbacks.get(_methodCall);
    }
    
    public synchronized DBusAsyncReply getCallbackReply(MethodCall _methodCall) {
        return pendingCallbackReplys.get(_methodCall);
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy