X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;f=lib%2Flinux%2Forg.argeo.slc.systemd%2Fsrc%2Forg%2Fargeo%2Fslc%2Fsystemd%2Fdbus%2FPlainDBusTest.java;fp=lib%2Flinux%2Forg.argeo.slc.systemd%2Fsrc%2Forg%2Fargeo%2Fslc%2Fsystemd%2Fdbus%2FPlainDBusTest.java;h=b43a033ee47698e008e64a3d4e92ac7d128ee7ae;hb=3ecf8cf48d400f3f7c8389b435d473bf9c374919;hp=0000000000000000000000000000000000000000;hpb=16621a76c90a11ae1893933c53c0b5cb274acbf2;p=gpl%2Fargeo-slc.git diff --git a/lib/linux/org.argeo.slc.systemd/src/org/argeo/slc/systemd/dbus/PlainDBusTest.java b/lib/linux/org.argeo.slc.systemd/src/org/argeo/slc/systemd/dbus/PlainDBusTest.java new file mode 100644 index 000000000..b43a033ee --- /dev/null +++ b/lib/linux/org.argeo.slc.systemd/src/org/argeo/slc/systemd/dbus/PlainDBusTest.java @@ -0,0 +1,41 @@ +package org.argeo.slc.systemd.dbus; + +import java.util.Map; + +import org.freedesktop.dbus.connections.impl.DBusConnection; +import org.freedesktop.dbus.interfaces.DBusInterface; +import org.freedesktop.dbus.interfaces.Introspectable; +import org.freedesktop.dbus.interfaces.Properties; +import org.freedesktop.dbus.types.Variant; + +public class PlainDBusTest { + final static String SYSTEMD_SERVICE = "org.freedesktop.systemd1.Service"; + + public static void main(String[] args) throws Exception { +// try (DBusConnection dBusConnection = DBusConnectionBuilder.forSystemBus().build()) { + + try (DBusConnection dBusConnection = DBusConnection.getConnection(DBusConnection.DBusBusType.SYSTEM)) { + + String source = "org.freedesktop.systemd1"; + String objectPath = "/org/freedesktop/systemd1/unit/ipsec_2eservice"; +// String objectPath = "/org/freedesktop/systemd1"; + DBusInterface object = dBusConnection.getExportedObject(source, objectPath); + System.out.println(object); +// +// Introspectable introspectable = dBusConnection.getExportedObject(source, objectPath, Introspectable.class); +// System.out.println(introspectable.Introspect()); +// + Properties props = dBusConnection.getExportedObject(source, objectPath, Properties.class); +// System.out.println(props); + + System.out.println(props.Get(SYSTEMD_SERVICE, "CPUUsageNSec").toString()); + + Map> values = props.GetAll(SYSTEMD_SERVICE); + for (String key : values.keySet()) { + Variant value = values.get(key); + System.out.println(key + "=" + value.getValue() + " (" + value.getType() + ") " + value.getSig()); + } + } + } + +}