forked from hypfvieh/dbus-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathremote-objects.html
More file actions
130 lines (120 loc) · 5.67 KB
/
Copy pathremote-objects.html
File metadata and controls
130 lines (120 loc) · 5.67 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
<!DOCTYPE html>
<!--
| Generated by Apache Maven Doxia Site Renderer 2.0.0 from src/site/markdown/remote-objects.md at 2025-12-23
| Rendered using Apache Maven Fluido Skin 2.1.0
-->
<html xmlns="http://www.w3.org/1999/xhtml" lang="">
<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>Remote Objects – 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 class="topBarDisabled">
<div class="container-fluid">
<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><a href="code-generation.html">Code Generation</a></li>
<li><a href="exporting-objects.html">Exporting Objects</a></li>
<li class="active"><a>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">
<hr />
<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="Remote_Objects"></a>
<h1>Remote Objects</h1>
<p>If you want to call a method on another application, it's very simple to create
the interface and call the method. If we use the same interface as we used
in the <a href="./exporting-objects.html">exporting objects</a> example, we come up with
the following code:</p>
<pre class="prettyprint"><code class="language-java">package com.foo;
import org.freedesktop.dbus.connections.impl.DBusConnection;
import org.freedesktop.dbus.connections.impl.DBusConnectionBuilder;
import org.freedesktop.dbus.exceptions.DBusException;
public class RemoteExample {
private DBusConnection m_conn;
RemoteExample() throws DBusException {
/* Get a connection to the session bus so we can get data */
m_conn = DBusConnectionBuilder.forSessionBus().build();
/* Get the remote object */
IntInterface i = m_conn.getRemoteObject( "test.dbusjava.export", "/", IntInterface.class );
System.out.println( i.add( 5, 7 ) );
}
public static void main(String[] _args) throws DBusException {
new RemoteExample();
}
}
</code></pre>
<p>Once we have a reference to the remote object, we can call methods on this
object exactly as if it were an object that we had created on our process. The
actual calling of the method, as well as the marshalling/unmarshalling of the
data is handled completely transparently.</p>
<p><em>Note:</em> The one issue that this does have is that the method calls are all
blocking. If the remote application has an issue, your application will stall
until the method call times out.</p></section> </main>
</div>
</div>
<hr/>
<footer>
<div class="container-fluid">
<div class="row-fluid">
<p>© 2025
</p>
</div>
</div>
</footer>
</body>
</html>