forked from hypfvieh/dbus-java
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcode-generation.html
More file actions
128 lines (118 loc) · 6.12 KB
/
code-generation.html
File metadata and controls
128 lines (118 loc) · 6.12 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
<!DOCTYPE html>
<!--
| Generated by Apache Maven Doxia Site Renderer 1.9.2 from src/site/markdown/code-generation.md at 2021-01-05
| Rendered using Apache Maven Fluido Skin 1.8
-->
<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 1.9.2" />
<title>dbus-java – Code Generation</title>
<link rel="stylesheet" href="./css/apache-maven-fluido-1.8.min.css" />
<link rel="stylesheet" href="./css/site.css" />
<link rel="stylesheet" href="./css/print.css" media="print" />
<script src="./js/apache-maven-fluido-1.8.min.js"></script>
</head>
<body class="topBarDisabled">
<div class="container-fluid">
<header>
<div id="banner">
<div class="pull-left"><div id="bannerLeft"><h2>dbus-java</h2>
</div>
</div>
<div class="pull-right"></div>
<div class="clear"><hr/></div>
</div>
<div id="breadcrumbs">
<ul class="breadcrumb">
<li id="publishDate">Last Published: 2021-01-05</li>
<li id="projectVersion" class="pull-right">Version: 3.3.0-SNAPSHOT</li>
<li class="pull-right"><span class="divider">|</span>
<a href="https://search.maven.org/search?q=g:com.github.hypfvieh%20dbus-java" class="externalLink" title="Maven Central">Maven Central</a></li>
<li class="pull-right"><a href="https://www.github.com/hypfvieh/dbus-java" class="externalLink" title="GitHub Repository">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" title="Home"><span class="none"></span>Home</a></li>
<li><a href="quick-start.html" title="Quickstart"><span class="none"></span>Quickstart</a></li>
<li class="active"><a href="#"><span class="none"></span>Code Generation</a></li>
<li><a href="exporting-objects.html" title="Exporting Objects"><span class="none"></span>Exporting Objects</a></li>
<li><a href="remote-objects.html" title="Calling Remote Objects"><span class="none"></span>Calling Remote Objects</a></li>
<li class="nav-header">Project Documentation</li>
<li><a href="project-info.html" title="Project Information"><span class="icon-chevron-right"></span>Project Information</a></li>
<li class="nav-header">Modules</li>
<li><a href="dbus-java/index.html" title="dbus-java"><span class="none"></span>dbus-java</a></li>
<li><a href="dbus-java-osgi/index.html" title="dbus-java-osgi"><span class="none"></span>dbus-java-osgi</a></li>
<li><a href="dbus-java-utils/index.html" title="dbus-java-utils"><span class="none"></span>dbus-java-utils</a></li>
</ul>
</nav>
<div class="well sidebar-nav">
<hr />
<div id="poweredBy">
<div class="clear"></div>
<div class="clear"></div>
<div class="clear"></div>
<a href="http://maven.apache.org/" title="Built by Maven" class="poweredBy"><img class="builtBy" alt="Built by Maven" src="./images/logos/maven-feather.png" /></a>
</div>
</div>
</header>
<main id="bodyColumn" class="span10" >
<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><section>
<h2><a name="New_code_generation"></a>New code generation</h2>
<ul>
<li>You can directly obtain the required interface information by reading the introspection data directly from DBus:
<div class="source">
<div class="source"><pre class="prettyprint">mvn exec:java \
-Dexec.mainClass="org.freedesktop.dbus.utils.generator.InterfaceCodeGenerator" \
-Dexec.executable="java" \
-Dexec.args="%classpath --system --outputDir /tmp/classes org.bluez /org/bluez"
</pre></div></div>
</li>
<li>You can also use introspection data which is stored in an xml file:
<div class="source">
<div class="source"><pre class="prettyprint">mvn exec:java \
-Dexec.mainClass="org.freedesktop.dbus.utils.generator.InterfaceCodeGenerator" \
-Dexec.executable="java" \
-Dexec.args="%classpath --inputFile /tmp/org.freedesktop.UDisks2.xml --outputDir /tmp/classes ' '"
</pre></div></div>
</li>
</ul>
<p>In both cases the generated classes/interfaces will be written to the provided output directory.</p></section><section>
<h2><a name="Old_code_generation"></a>Old code generation</h2>
<ol style="list-style-type: decimal">
<li>
<p>Obtain the introspection XML file from the service that you wish to use or implement. These introspection XML files are often in the source code of the reference application. If the application is running on DBus, you can obtain the introspection XML using a dbus-send query such as the following (change the ‘dest’ and path as appropriate):</p>
<div class="source">
<div class="source"><pre class="prettyprint">dbus-send --print-reply=literal --type=method_call --dest=org.freedesktop.Notifications /org/freedesktop/Notifications org.freedesktop.DBus.Introspectable.Introspect
</pre></div></div>
</li>
<li>
<p>Run the code generator on the given XML file.</p>
<div class="source">
<div class="source"><pre class="prettyprint">org.freedesktop.dbus.utils.bin.CreateInterface /path/to/introspection.xml
</pre></div></div>
</li>
<li>
<p>The code will be printed to stdout; copy and paste it into a file.</p>
</li>
</ol></section>
</main>
</div>
</div>
<hr/>
<footer>
<div class="container-fluid">
<div class="row-fluid">
<p>Copyright © 2021..</p>
</div>
</div>
</footer>
</body>
</html>