forked from hypfvieh/dbus-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcode-generation.html
More file actions
144 lines (136 loc) · 6.78 KB
/
Copy pathcode-generation.html
File metadata and controls
144 lines (136 loc) · 6.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
<!DOCTYPE html>
<!--
| Generated by Apache Maven Doxia Site Renderer 2.0.0 from src/site/markdown/code-generation.md at 2025-12-23
| Rendered using Apache Maven Fluido Skin 2.1.0
-->
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="generator" content="Apache Maven Doxia Site Renderer 2.0.0" />
<title>Code Generation – dbus-java</title>
<link rel="stylesheet" href="./css/apache-maven-fluido-2.1.0.min.css" />
<link rel="stylesheet" href="./css/site.css" />
<link rel="stylesheet" href="./css/print.css" media="print" />
<script src="./js/apache-maven-fluido-2.1.0.min.js"></script>
</head>
<body>
<div class="container-fluid container-fluid-top">
<header>
<div id="banner">
<div class="pull-left"></div>
<div class="pull-right"></div>
<div class="clear"><hr/></div>
</div>
<div id="breadcrumbs">
<ul class="breadcrumb">
<li id="publishDate">Last Published: 2025-12-21</li>
<li id="projectVersion" class="pull-right">Version: 5.2.1-SNAPSHOT</li>
<li class="pull-right"><span class="divider">|</span>
<a href="https://search.maven.org/search?q=g:com.github.hypfvieh%20dbus-java">Maven Central</a></li>
<li class="pull-right"><span class="divider">|</span>
<a href="https://www.github.com/hypfvieh/dbus-java/wiki">GitHub Wiki</a></li>
<li class="pull-right"><a href="https://www.github.com/hypfvieh/dbus-java">GitHub Repository</a></li>
</ul>
</div>
</header>
<div class="row-fluid">
<header id="leftColumn" class="span2">
<nav class="well sidebar-nav">
<ul class="nav nav-list">
<li class="nav-header">Overview</li>
<li><a href="index.html">Home</a></li>
<li><a href="quick-start.html">Quickstart</a></li>
<li class="active"><a>Code Generation</a></li>
<li><a href="exporting-objects.html">Exporting Objects</a></li>
<li><a href="remote-objects.html">Calling Remote Objects</a></li>
<li><a href="properties.html">Properties</a></li>
<li><a href="variant-handling.html">Variant</a></li>
<li><a href="using-signals.html">Signals</a></li>
<li><a href="howto.html">Howto...</a></li>
<li class="nav-header">Project Documentation</li>
<li><a href="project-info.html"><span class="icon-chevron-right"></span>Project Information</a></li>
<li><a href="project-reports.html"><span class="icon-chevron-right"></span>Project Reports</a></li>
<li class="nav-header">Modules</li>
<li><a href="dbus-java-core/index.html">dbus-java-core</a></li>
<li><a href="dbus-java-osgi/index.html">dbus-java-osgi</a></li>
<li><a href="dbus-java-utils/index.html">dbus-java-utils</a></li>
<li><a href="dbus-java-transport-jnr-unixsocket/index.html">dbus-java-transport-jnr-unixsocket</a></li>
<li><a href="dbus-java-transport-junixsocket/index.html">dbus-java-transport-junixsocket</a></li>
<li><a href="dbus-java-transport-native-unixsocket/index.html">dbus-java-transport-native-unixsocket</a></li>
<li><a href="dbus-java-transport-tcp/index.html">dbus-java-transport-tcp</a></li>
<li><a href="dbus-java-bom/index.html">dbus-java-bom</a></li>
<li><a href="dbus-java-tests/index.html">dbus-java-tests</a></li>
<li><a href="dbus-java-examples/index.html">dbus-java-examples</a></li>
</ul>
</nav>
<div class="well sidebar-nav">
<div id="poweredBy">
<div class="clear"></div>
<div class="clear"></div>
<a href="https://maven.apache.org/" class="builtBy" target="_blank"><img class="builtBy" alt="Built by Maven" src="./images/logos/maven-feather.png" /></a>
</div>
</div>
</header>
<main id="bodyColumn" class="span10">
<section><a id="Code_Generation"></a>
<h1>Code Generation</h1>
<p>Since DBus provides a mechanism for introspecting objects via the
<code>org.freedesktop.DBus.Introspectable</code> interface, it is possible to query an
already running application for information about interfaces that it has. This
will then return an XML file, which you can then run the code generator against
in order to produce a Java interface that you can then use to get a remote
object, or use as an interface for your program.</p>
<p>The instructions below will assume you use the dbus-java source to run the code generator.
It is also possible to run the code generator using the dbus-java-utils artificat, but this
requires the classpath with all dependencies and transitive dependencies.
Therefore it is recommended to run the code generator using Maven or your development IDE
(e.g. Eclipse) to execute the code generator.</p><section><a id="Requirements"></a>
<h2>Requirements</h2>
<ul>
<li>dbus-java sources (<a href="https://github.com/hypfvieh/dbus-java/archive/master.zip" class="externalLink">https://github.com/hypfvieh/dbus-java/archive/master.zip</a>)</li>
<li>Maven</li>
</ul></section><section><a id="Prerequisites"></a>
<h2>Prerequisites</h2>
<ul>
<li>Install Maven</li>
<li>Download and extract the dbus-java sources</li>
<li>Open a terminal and change to the directory where you extracted the dbus-java sources</li>
<li>Build the sources: <code>mvn clean install -DskipTests=true</code></li>
<li>Change to the sub directory <code>dbus-java-utils</code></li>
<li>Now you can continue with the steps below</li>
</ul></section><section><a id="New_code_generation"></a>
<h2>New code generation</h2>
<ul>
<li>
<p>You can directly obtain the required interface information by reading the introspection data directly from DBus:</p>
<pre><code class="nohighlight nocode"> mvn exec:java \
-Dexec.mainClass="org.freedesktop.dbus.utils.generator.InterfaceCodeGenerator" \
-Dexec.executable="java" \
-Dexec.args="--system --outputDir /tmp/classes org.bluez /org/bluez"
</code></pre></li>
<li>
<p>You may replace <code>org.bluez</code> and <code>/org/bluez</code> with the busname and object path of the DBus service
you want to generate java classes for.</p></li>
<li>
<p>You can also use introspection data which is stored in an xml file:</p>
<pre><code class="nohighlight nocode"> mvn exec:java \
-Dexec.mainClass="org.freedesktop.dbus.utils.generator.InterfaceCodeGenerator" \
-Dexec.executable="java" \
-Dexec.args="--inputFile /tmp/org.freedesktop.UDisks2.xml --outputDir /tmp/classes ' '"
</code></pre></li>
</ul>
<p>In both cases the generated classes/interfaces will be written to the provided output directory.</p></section></section> </main>
</div>
</div>
<hr/>
<footer>
<div class="container-fluid">
<div class="row-fluid">
<p>© 2025
</p>
</div>
</div>
</footer>
</body>
</html>