Class DBusConnectionBuilder
- java.lang.Object
-
- org.freedesktop.dbus.connections.impl.BaseConnectionBuilder<DBusConnectionBuilder,DBusConnection>
-
- org.freedesktop.dbus.connections.impl.DBusConnectionBuilder
-
public final class DBusConnectionBuilder extends BaseConnectionBuilder<DBusConnectionBuilder,DBusConnection>
Builder to create a new DBusConnection.- Version:
- 4.1.0 - 2022-02-04
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.StringmachineIdprivate booleanregisterSelfprivate booleanshared
-
Constructor Summary
Constructors Modifier Constructor Description privateDBusConnectionBuilder(BusAddress _address, java.lang.String _machineId)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description DBusConnectionbuild()Create the newDBusConnection.static DBusConnectionBuilderforAddress(java.lang.String _address)Use the given address to create the connection (e.g.static DBusConnectionBuilderforAddress(BusAddress _address)Use the given address to create the connection (e.g.static DBusConnectionBuilderforSessionBus()Create a new default connection connecting to the DBus session bus.static DBusConnectionBuilderforSessionBus(java.lang.String _machineIdFileLocation)Create a new default connection connecting to DBus session bus but use an alternative input for the machineID.static DBusConnectionBuilderforSystemBus()Create new default connection to the DBus system bus.static DBusConnectionBuilderforType(DBusConnection.DBusBusType _type)Create a default connection to DBus using the given bus type.static DBusConnectionBuilderforType(DBusConnection.DBusBusType _type, java.lang.String _machineIdFile)Create a default connection to DBus using the given bus type and machineIdFile.static bytegetSystemEndianness()Deprecated, for removal: This API element is subject to removal in a future version.if required, useBaseConnectionBuilder.getSystemEndianness()private static BusAddressvalidateTransportAddress(BusAddress _address)Checks if the given address can be used with the available transports.DBusConnectionBuilderwithRegisterSelf(boolean _register)Register the new connection on DBus using 'hello' message.DBusConnectionBuilderwithShared(boolean _shared)Use this connection as shared connection.-
Methods inherited from class org.freedesktop.dbus.connections.impl.BaseConnectionBuilder
buildThreadConfig, buildTransportConfig, getDisconnectCallback, getEndianess, isWeakReference, receivingThreadConfig, self, transportConfig, withDisconnectCallback, withEndianess, withErrorHandlerThreadCount, withMethodCallThreadCount, withMethodReturnThreadCount, withSignalThreadCount, withWeakReferences
-
-
-
-
Constructor Detail
-
DBusConnectionBuilder
private DBusConnectionBuilder(BusAddress _address, java.lang.String _machineId)
-
-
Method Detail
-
forSessionBus
public static DBusConnectionBuilder forSessionBus(java.lang.String _machineIdFileLocation)
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
public static DBusConnectionBuilder forSystemBus()
Create new default connection to the DBus system bus.- Returns:
DBusConnectionBuilder
-
forSessionBus
public static DBusConnectionBuilder forSessionBus()
Create a new default connection connecting to the DBus session bus.- Returns:
DBusConnectionBuilder
-
forType
public static DBusConnectionBuilder forType(DBusConnection.DBusBusType _type)
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, java.lang.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
public static DBusConnectionBuilder forAddress(java.lang.String _address)
Use the given address to create the connection (e.g. used for remote TCP connected DBus daemons).- Parameters:
_address- address to use- Returns:
- this
-
forAddress
public static DBusConnectionBuilder forAddress(BusAddress _address)
Use the given address to create the connection (e.g. used for remote TCP connected DBus daemons).- Parameters:
_address- address to use- Returns:
- this
- Since:
- 4.2.0 - 2022-07-18
-
validateTransportAddress
private static BusAddress validateTransportAddress(BusAddress _address)
Checks if the given address can be used with the available transports. Will fallback to TCP if no address given and TCP transport is available.- Parameters:
_address- address to check- Returns:
- address, maybe fallback address
-
withRegisterSelf
public DBusConnectionBuilder withRegisterSelf(boolean _register)
Register the new connection on DBus using 'hello' message. Default is true.- Parameters:
_register- boolean- Returns:
- this
-
withShared
public DBusConnectionBuilder withShared(boolean _shared)
Use this connection as shared connection. Shared connection means that the same connection is used multiple times if the connection parameter did not change. Default is true.- Parameters:
_shared- boolean- Returns:
- this
-
build
public DBusConnection build() throws DBusException
Create the newDBusConnection.- Specified by:
buildin classBaseConnectionBuilder<DBusConnectionBuilder,DBusConnection>- Returns:
DBusConnection- Throws:
DBusException- when DBusConnection could not be opened
-
getSystemEndianness
@Deprecated(forRemoval=true, since="4.2.0") public static byte getSystemEndianness()Deprecated, for removal: This API element is subject to removal in a future version.if required, useBaseConnectionBuilder.getSystemEndianness()Get the default system endianness.- Returns:
- LITTLE or BIG
-
-