in dbus-java/src/main/java/org/freedesktop/dbus/RemoteInvocationHandler.java [94:173]
public static Object executeRemoteMethod(RemoteObject ro, Method m, AbstractConnection conn, int syncmethod, CallbackHandler<?> callback, Object... args) throws DBusException {
Type[] ts = m.getGenericParameterTypes();
String sig = null;
if (ts.length > 0) {
try {
sig = Marshalling.getDBusType(ts);
args = Marshalling.convertParameters(args, ts, conn);
} catch (DBusException exDbe) {
throw new DBusExecutionException("Failed to construct D-Bus type: " + exDbe.getMessage());
}
}
MethodCall call;
byte flags = 0;
if (!ro.isAutostart()) {
flags |= Message.Flags.NO_AUTO_START;
}
if (syncmethod == CALL_TYPE_ASYNC) {
flags |= Message.Flags.ASYNC;
}
if (m.isAnnotationPresent(MethodNoReply.class)) {
flags |= Message.Flags.NO_REPLY_EXPECTED;
}
try {
String name;
if (m.isAnnotationPresent(DBusMemberName.class)) {
name = m.getAnnotation(DBusMemberName.class).value();
} else {
name = m.getName();
}
if (null == ro.getInterface()) {
call = new MethodCall(ro.getBusName(), ro.getObjectPath(), null, name, flags, sig, args);
} else {
if (null != ro.getInterface().getAnnotation(DBusInterfaceName.class)) {
call = new MethodCall(ro.getBusName(), ro.getObjectPath(), ro.getInterface().getAnnotation(DBusInterfaceName.class).value(), name, flags, sig, args);
} else {
call = new MethodCall(ro.getBusName(), ro.getObjectPath(), AbstractConnection.DOLLAR_PATTERN.matcher(ro.getInterface().getName()).replaceAll("."), name, flags, sig, args);
}
}
} catch (DBusException dbe) {
LOGGER.debug("Failed to construct outgoing method call.", dbe);
throw new DBusExecutionException("Failed to construct outgoing method call: " + dbe.getMessage());
}
if (!conn.isConnected()) {
throw new NotConnected("Not Connected");
}
switch (syncmethod) {
case CALL_TYPE_ASYNC:
conn.sendMessage(call);
return new DBusAsyncReply<>(call, m, conn);
case CALL_TYPE_CALLBACK:
conn.queueCallback(call, m, callback);
conn.sendMessage(call);
return null;
case CALL_TYPE_SYNC:
conn.sendMessage(call);
break;
}
// get reply
if (m.isAnnotationPresent(MethodNoReply.class)) {
return null;
}
Message reply = call.getReply();
if (null == reply) {
throw new NoReply("No reply within specified time");
}
if (reply instanceof Error) {
((Error) reply).throwException();
}
try {
return convertRV(reply.getSig(), reply.getParameters(), m, conn);
} catch (DBusException e) {
LOGGER.debug("", e);
throw new DBusExecutionException(e.getMessage());
}
}