1 package org
.argeo
.slc
.systemd
.dbus
;
5 import org
.freedesktop
.dbus
.connections
.impl
.DBusConnection
;
6 import org
.freedesktop
.dbus
.interfaces
.DBusInterface
;
7 import org
.freedesktop
.dbus
.interfaces
.Introspectable
;
8 import org
.freedesktop
.dbus
.interfaces
.Properties
;
9 import org
.freedesktop
.dbus
.types
.Variant
;
11 public class PlainDBusTest
{
12 final static String SYSTEMD_SERVICE
= "org.freedesktop.systemd1.Service";
14 public static void main(String
[] args
) throws Exception
{
15 // try (DBusConnection dBusConnection = DBusConnectionBuilder.forSystemBus().build()) {
17 try (DBusConnection dBusConnection
= DBusConnection
.getConnection(DBusConnection
.DBusBusType
.SYSTEM
)) {
19 String source
= "org.freedesktop.systemd1";
20 String objectPath
= "/org/freedesktop/systemd1/unit/ipsec_2eservice";
21 // String objectPath = "/org/freedesktop/systemd1";
22 DBusInterface object
= dBusConnection
.getExportedObject(source
, objectPath
);
23 System
.out
.println(object
);
25 // Introspectable introspectable = dBusConnection.getExportedObject(source, objectPath, Introspectable.class);
26 // System.out.println(introspectable.Introspect());
28 Properties props
= dBusConnection
.getExportedObject(source
, objectPath
, Properties
.class);
29 // System.out.println(props);
31 System
.out
.println(props
.Get(SYSTEMD_SERVICE
, "CPUUsageNSec").toString());
33 Map
<String
, Variant
<?
>> values
= props
.GetAll(SYSTEMD_SERVICE
);
34 for (String key
: values
.keySet()) {
35 Variant
<?
> value
= values
.get(key
);
36 System
.out
.println(key
+ "=" + value
.getValue() + " (" + value
.getType() + ") " + value
.getSig());