Module org.freedesktop.dbus
Class DBusConnectionBuilder
java.lang.Object
org.freedesktop.dbus.connections.impl.DBusConnectionBuilder
Builder to create a new DBusConnection.
- Version:
- 4.1.0 - 2022-02-04
- Author:
- hypfvieh
-
Method Summary
Modifier and TypeMethodDescriptionbuild()Create the newDBusConnection.static DBusConnectionBuilderforAddress(String _address) Use the given address to create the connection (e.g. used for remote TCP connected DBus daemons).static DBusConnectionBuilderCreate a new default connection connecting to the DBus session bus.static DBusConnectionBuilderforSessionBus(String _machineIdFileLocation) Create a new default connection connecting to DBus session bus but use an alternative input for the machineID.static DBusConnectionBuilderCreate new default connection to the DBus system bus.static DBusConnectionBuilderCreate a default connection to DBus using the given bus type.static DBusConnectionBuilderforType(DBusConnection.DBusBusType _type, String _machineIdFile) Create a default connection to DBus using the given bus type and machineIdFile.static byteGet the default system endianness.withDisconnectCallback(IDisconnectCallback _disconnectCallback) Set the given disconnect callback to the created connection.withEndianess(byte _endianess) Set the endianess for the connection Default is based on system endianess.withErrorHandlerThreadCount(int _threads) Set the size of the thread-pool used to handle error messages received on the bus.withMethodCallThreadCount(int _threads) Set the size of the thread-pool used to handle methods calls previously sent to the bus.withMethodReturnThreadCount(int _threads) Set the size of the thread-pool used to handle method return values received on the bus.withRegisterSelf(boolean _register) Register the new connection on DBus using 'hello' message.withShared(boolean _shared) Use this connection as shared connection.withSignalThreadCount(int _threads) Set the size of the thread-pool used to handle signals from the bus.withTimeout(int _timeout) Set the timeout for the connection (used for TCP connections only).withWeakReferences(boolean _weakRef) Enable/Disable weak references on connection.
-
Method Details
-
forSessionBus
Create a new default connection connecting to DBus session bus but use an alternative input for the machineID.- Parameters:
_machineIdFileLocation- file with machine ID- Returns:
DBusConnectionBuilder
-
forSystemBus
Create new default connection to the DBus system bus.- Returns:
DBusConnectionBuilder
-
forSessionBus
Create a new default connection connecting to the DBus session bus.- Returns:
DBusConnectionBuilder
-
forType
Create a default connection to DBus using the given bus type.- Parameters:
_type- bus type- Returns:
- this
-
forType
public static DBusConnectionBuilder forType(DBusConnection.DBusBusType _type, String _machineIdFile) Create a default connection to DBus using the given bus type and machineIdFile.- Parameters:
_type- bus type_machineIdFile- machineId file- Returns:
- this
-
forAddress
Use the given address to create the connection (e.g. used for remote TCP connected DBus daemons).- Parameters:
_address- address to use- Returns:
- this
-
withRegisterSelf
Register the new connection on DBus using 'hello' message. Default is true.- Parameters:
_register- boolean- Returns:
- this
-
withTimeout
Set the timeout for the connection (used for TCP connections only). Default is .- Parameters:
_timeout- timeout- Returns:
- this
-
withSignalThreadCount
Set the size of the thread-pool used to handle signals from the bus. Caution: Using thread-pool size > 1 may cause signals to be handled out-of-orderDefault: 1
- Parameters:
_threads- int >= 1- Returns:
- this
-
withErrorHandlerThreadCount
Set the size of the thread-pool used to handle error messages received on the bus.Default: 1
- Parameters:
_threads- int >= 1- Returns:
- this
-
withMethodCallThreadCount
Set the size of the thread-pool used to handle methods calls previously sent to the bus. The thread pool size has to be > 1 to handle recursive calls.Default: 4
- Parameters:
_threads- int >= 1- Returns:
- this
-
withMethodReturnThreadCount
Set the size of the thread-pool used to handle method return values received on the bus.Default: 1
- Parameters:
_threads- int >= 1- Returns:
- this
-
withEndianess
Set the endianess for the connection Default is based on system endianess.- Parameters:
_endianess- or- Returns:
- this
-
withDisconnectCallback
Set the given disconnect callback to the created connection.- Parameters:
_disconnectCallback- callback- Returns:
- this
-
withWeakReferences
Enable/Disable weak references on connection. Default is false.- Parameters:
_weakRef- true to enable- Returns:
- this
-
build
Create the newDBusConnection.- Returns:
DBusConnection- Throws:
DBusException- when DBusConnection could not be opened
-
getSystemEndianness
public static byte getSystemEndianness()Get the default system endianness.- Returns:
- LITTLE or BIG
-