{"id":20620777,"url":"https://github.com/lucimber/dbus-client-java","last_synced_at":"2025-06-26T15:34:24.160Z","repository":{"id":160932294,"uuid":"634152279","full_name":"lucimber/dbus-client-java","owner":"lucimber","description":"A framework that enables a Java based application to interact with a D-Bus instance in the role of a client.","archived":false,"fork":false,"pushed_at":"2025-06-26T07:07:30.000Z","size":867,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-26T08:23:05.608Z","etag":null,"topics":["dbus","framework","java"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lucimber.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-04-29T07:58:14.000Z","updated_at":"2025-06-26T07:06:31.000Z","dependencies_parsed_at":"2024-03-26T10:36:53.697Z","dependency_job_id":"3ede4e69-6c3e-4ec6-ae50-382b7f605277","html_url":"https://github.com/lucimber/dbus-client-java","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/lucimber/dbus-client-java","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lucimber%2Fdbus-client-java","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lucimber%2Fdbus-client-java/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lucimber%2Fdbus-client-java/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lucimber%2Fdbus-client-java/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lucimber","download_url":"https://codeload.github.com/lucimber/dbus-client-java/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lucimber%2Fdbus-client-java/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262095181,"owners_count":23258109,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dbus","framework","java"],"created_at":"2024-11-16T12:15:36.831Z","updated_at":"2025-06-26T15:34:24.135Z","avatar_url":"https://github.com/lucimber.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# A D-Bus Framework for Java based Applications\nThis software is a framework that enables a Java based\napplication to interact with a D-Bus instance in the role\nof a client. The D-Bus instance can be a system or\nsession bus. As of now, only Unix sockets are supported\nas transport by this framework. The type system, the wire\nformat and the message protocol are fully implemented as\nof D-Bus Specification 0.41.\n\n## What is D-Bus?\nD-Bus is a bus system commonly found on the Linux desktop.\nIt enables applications to communicate with each other\nindirectly via a bus. Applications can use this bus to signal state\nchanges to or exchange information with other applications.\nSince D-Bus defines a marshalling format for its type system,\nan application written in Java can talk to an application\nwritten in C via D-Bus. For in depth information about D-Bus,\nplease visit https://www.freedesktop.org/wiki/Software/dbus/.\n\n## Distinction\nThis D-Bus framework is written from scratch and doesn't\nsuffer the same architectural decisions as the reference\nimplementation. Furthermore, it can handle empty responses,\nand both byte orders (little and big endian)\non the wire format of D-Bus.\n\n## Architecture\nThis framework is based on a non-blocking I/O framework\ncalled [Netty](https://netty.io). Therefore, it's an asynchronous\nevent-driven network application framework.\n\nThe application needs to implement specific handlers\nthat will get called by this framework. Those handlers\nmust be programmed in a non-blocking fashion.\nUsing Future and CompletionStage is a good way to do so.\n\nThe type system of D-Bus is implemented by introducing\nwrappers to the data types of Java.\nThis choice makes the framework a bit more robust and\nthe use of this framework approachable.\n\n## Dependencies\n* Java Runtime 17 or higher\n* D-Bus 1.12 or higher\n\n## Examples\n\n### Bootstrap a connection\n```\nString userId = \"1000\";\nString cookiePath = \"~/.dbus-keyrings/\";\nString socketPath = \"/var/run/dbus/system_bus_socket\";\nConnectionFactory factory = new UnixSocketConnectionFactory(userId, cookiePath, socketPath);\nPipelineInitializer initializer = pipeline -\u003e\n    pipeline.addLast(EXAMPLE_HANDLER, new ExampleHandler());\nCompletionStage\u003cConnection\u003e connStage = factory.create(initializer);\n```\n\n### Make a method call\n```\nUInt32 serial = pipeline.getConnection().getNextSerial();\nDBusString destination = DBusString.valueOf(\"org.bluez\");\nObjectPath path = ObjectPath.valueOf(\"/\");\nDBusString name = DBusString.valueOf(\"GetManagedObjects\");\nOutboundMethodCall msg = new OutboundMethodCall(serial, destination, path, name);\nDBusString iface = DBusString.valueOf(\"org.freedesktop.DBus.ObjectManager\");\nmsg.setInterfaceName(iface);\npipeline.passOutboundMessage(msg);\n```\n\n### Example Handler (D-Bus Peer)\nIn this example, the handler implements the `org.freedesktop.DBus.Peer` interface,\nin order to respond to a ping request and/or to a request to return the machine-id.\n```java\npublic final class DbusPeerHandler implements Handler {\n  private static final DBusString INTERFACE = DBusString.valueOf(\"org.freedesktop.DBus.Peer\");\n  private final UUID machineId;\n\n  public DbusPeerHandler(final UUID machineId) {\n    this.machineId = Objects.requireNonNull(machineId);\n  }\n\n  private static void respondToPing(final HandlerContext ctx, final InboundMethodCall methodCall) {\n    final DBusString destination = methodCall.getSender();\n    final UInt32 serial = ctx.getPipeline().getConnection().getNextSerial();\n    final UInt32 replySerial = methodCall.getSerial();\n    final OutboundMethodReturn methodReturn = new OutboundMethodReturn(destination, serial, replySerial);\n    ctx.passOutboundMessage(methodReturn);\n  }\n\n  private void handleInboundMethodCall(final HandlerContext ctx, final InboundMethodCall methodCall) {\n    if (methodCall.getInterfaceName().orElse(DBusString.valueOf(\"\")).equals(INTERFACE)) {\n      if (methodCall.getName().equals(DBusString.valueOf(\"Ping\"))) {\n        respondToPing(ctx, methodCall);\n      } else if (methodCall.getName().equals(DBusString.valueOf(\"GetMachineId\"))) {\n        respondWithMachineId(ctx, methodCall);\n      } else {\n        ctx.passInboundMessage(methodCall);\n      }\n    } else {\n      ctx.passInboundMessage(methodCall);\n    }\n  }\n\n  private void respondWithMachineId(final HandlerContext ctx, final InboundMethodCall methodCall) {\n    final DBusString destination = methodCall.getSender();\n    final UInt32 serial = ctx.getPipeline().getConnection().getNextSerial();\n    final UInt32 replySerial = methodCall.getSerial();\n    final OutboundMethodReturn methodReturn = new OutboundMethodReturn(destination, serial, replySerial);\n    final List\u003cDBusType\u003e payload = new ArrayList\u003c\u003e();\n    payload.add(DBusString.valueOf(machineId.toString()));\n    methodReturn.setPayload(payload);\n    ctx.passOutboundMessage(methodReturn);\n  }\n\n  @Override\n  public void onInboundMessage(final HandlerContext ctx, final InboundMessage msg) {\n    if (msg instanceof InboundMethodCall) {\n      handleInboundMethodCall(ctx, (InboundMethodCall) msg);\n    } else {\n      ctx.passInboundMessage(msg);\n    }\n  }\n}\n```\n\n## Participation\nParticipation is welcome and endorsed by the chosen license\nand a simplified contributor agreement.\n\n### Contributor Agreement\nAs the chosen open source license implicitly serves\nas both the inbound (from contributors) and\noutbound (to other contributors and users) license,\nthere's no need for an additional contributor agreement.\n\nBut to be super safe, this project requires developers\nto state that each commit they make is authorized.\nA Developer Certificate of Origin requirement is how many\nprojects achieve this.\n\n\u003e By making a contribution to this project, I certify that:\n\u003e \n\u003e a. The contribution was created in whole or in part by me and I have the right to submit it under the open source license indicated in the file; or\n\u003e\n\u003e b. The contribution is based upon previous work that, to the best of my knowledge, is covered under an appropriate open source license and I have the right under that license to submit that work with modifications, whether created in whole or in part by me, under the same open source license (unless I am permitted to submit under a different license), as indicated in the file; or\n\u003e\n\u003e c. The contribution was provided directly to me by some other person who certified (a), (b) or (c) and I have not modified it.\n\u003e\n\u003e d. I understand and agree that this project and the contribution are public and that a record of the contribution (including all personal information I submit with it, including my sign-off) is maintained indefinitely and may be redistributed consistent with this project or the open source license(s) involved.\n\nTherefore the contributors to this project sign-off that\nthey adhere to these requirements by adding\na Signed-off-by line to commit messages.\n\n    This is an example commit message.\n    \n    Signed-off-by: Peter Peterson \u003cpp@example.org\u003e\n\n## License\nCopyright 2021 Lucimber UG\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n       http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flucimber%2Fdbus-client-java","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flucimber%2Fdbus-client-java","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flucimber%2Fdbus-client-java/lists"}