Skip to content
Markus Enax edited this page Oct 1, 2016 · 18 revisions

java-systemd

This Java library provides access to systemd via D-Bus. It features:

  • Simultaneous connectivity to the system bus and the session bus of the Java process owner
  • Access to the particular instance-wide 'Manager' interface, including
  • Method calls (ListUnits, StartUnit, StopUnit, RestartUnit, etc.)
  • Property access (Environment, SystemState, KernelTimestamp, etc.)
  • Convenience methods for instantiation of unit wrappers (see next bullet)
  • Access to methods and properties of the 'Unit' interface and all derived interfaces, like
  • Device
  • Mount
  • Service
  • Target
  • ...
  • Encapsulation of complex properties into objects with meaningful fields
  • Utility methods (timestamp conversion, path escaping, etc.)

Requirements

dbus-java is required for this library to work. At the time of writing there is only one pre-built JAR available on Maven Central. You might consider building your own artifact manually for your local repository. A Maven compatible fork which includes JNI-based packaging of the required low-level Unix socket library is available on this account under the name dbus-java-maven.

Building

Maven is used as the primary build system.

Testing

Unit tests are based on TestNG and Mockito. Test methods which require a deployed systemd environment are grouped in TestNG group "requireSystemd". There are two TestNG suites available:

  • src/test/resources/suites/auto-systemd.xml (executes all tests)
  • src/test/resources/suites/auto.xml (excludes group "requireSystemd")

Use "auto.xml" for platform independent build systems.

License

LGPL v2 and AFL v2.1 - just like dbus-java.

Clone this wiki locally