Top Description Fields Constructors Methods
org.freedesktop.dbus.connections.impl

public final Class DBusConnectionBuilder

extends BaseConnectionBuilder<DBusConnectionBuilder, DBusConnection>
Class Inheritance
Static Imports
org.freedesktop.dbus.utils.AddressBuilder.getDbusMachineId

Builder to create a new DBusConnection.
Author
hypfvieh
Version
4.1.0 - 2022-02-04

Field Summary

Modifier and TypeField and Description
private final String
private boolean

Constructor Summary

AccessConstructor and Description
private
DBusConnectionBuilder(BusAddress _address, String _machineId)

Method Summary

Modifier and TypeMethod and Description
public DBusConnection
public static DBusConnectionBuilder

Returns:

this
forAddress
(String
address to use
_address
)

Use the given address to create the connection (e.g. used for remote TCP connected DBus daemons).

public static DBusConnectionBuilder

Returns:

this
forAddress
(BusAddress
address to use
_address
)

Use the given address to create the connection (e.g. used for remote TCP connected DBus daemons).

public static DBusConnectionBuilder
forSessionBus(String
file with machine ID
_machineIdFileLocation
)

Create a new default connection connecting to DBus session bus but use an alternative input for the machineID.

public static DBusConnectionBuilder
forSessionBus()

Create a new default connection connecting to the DBus session bus.

public static DBusConnectionBuilder
forSystemBus()

Create new default connection to the DBus system bus.

public static DBusConnectionBuilder

Returns:

this
forType
(DBusConnection.DBusBusType
bus type
_type
)

Create a default connection to DBus using the given bus type.

public static DBusConnectionBuilder

Returns:

this
forType
(DBusConnection.DBusBusType
bus type
_type
,
String
machineId file
_machineIdFile
)

Create a default connection to DBus using the given bus type and machineIdFile.

private DBusConnection

Returns:

connection if a valid shared connection found or null if no connection found or found connection was invalid
getSharedConnection
(String
bus address
_busAddr
)

Retrieve a existing shared connection.

private static BusAddress

Returns:

address, maybe fallback address
validateTransportAddress
(BusAddress
address to check
_address
)

Checks if the given address can be used with the available transports.

public DBusConnectionBuilder

Returns:

this
withShared
(boolean
boolean
_shared
)

Use this connection as shared connection.

Inherited from org.freedesktop.dbus.connections.impl.BaseConnectionBuilder:
buildThreadConfigbuildTransportConfiggetConnectionConfiggetSystemEndiannessreceivingThreadConfigselftransportConfigwithDisconnectCallbackwithExportWeakReferenceswithImportWeakReferenceswithUnknownSignalHandlerwithWeakReferences

Field Detail

machineIdback to summary
private final String machineId
sharedback to summary
private boolean shared

Constructor Detail

DBusConnectionBuilderback to summary
private DBusConnectionBuilder(BusAddress _address, String _machineId)

Method Detail

buildback to summary
public DBusConnection build() throws DBusException

Implements abstract org.freedesktop.dbus.connections.impl.BaseConnectionBuilder.build.

Create the new DBusConnection.

Returns:DBusConnection

DBusConnection

Annotations
@Override
Exceptions
DBusException:
when DBusConnection could not be opened
forAddressback to summary
public static DBusConnectionBuilder forAddress(String _address)

Use the given address to create the connection (e.g. used for remote TCP connected DBus daemons).

Parameters
_address:String

address to use

Returns:DBusConnectionBuilder

this

forAddressback to summary
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:BusAddress

address to use

Returns:DBusConnectionBuilder

this

Since
4.2.0 - 2022-07-18
forSessionBusback to summary
public static DBusConnectionBuilder forSessionBus(String _machineIdFileLocation)

Create a new default connection connecting to DBus session bus but use an alternative input for the machineID.

Parameters
_machineIdFileLocation:String

file with machine ID

Returns:DBusConnectionBuilder

DBusConnectionBuilder

forSessionBusback to summary
public static DBusConnectionBuilder forSessionBus()

Create a new default connection connecting to the DBus session bus.

Returns:DBusConnectionBuilder

DBusConnectionBuilder

forSystemBusback to summary
public static DBusConnectionBuilder forSystemBus()

Create new default connection to the DBus system bus.

Returns:DBusConnectionBuilder

DBusConnectionBuilder

forTypeback to summary
public static DBusConnectionBuilder forType(DBusConnection.DBusBusType _type)

Create a default connection to DBus using the given bus type.

Parameters
_type:DBusConnection.DBusBusType

bus type

Returns:DBusConnectionBuilder

this

forTypeback to summary
public static DBusConnectionBuilder forType(DBusConnection.DBusBusType _type, String _machineIdFile)

Create a default connection to DBus using the given bus type and machineIdFile.

Parameters
_type:DBusConnection.DBusBusType

bus type

_machineIdFile:String

machineId file

Returns:DBusConnectionBuilder

this

getSharedConnectionback to summary
private DBusConnection getSharedConnection(String _busAddr)

Retrieve a existing shared connection. Will remove existing shared connections when underlying transport is disconnected.

Parameters
_busAddr:String

bus address

Returns:DBusConnection

connection if a valid shared connection found or null if no connection found or found connection was invalid

validateTransportAddressback to summary
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:BusAddress

address to check

Returns:BusAddress

address, maybe fallback address

withSharedback to summary
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

boolean

Returns:DBusConnectionBuilder

this