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

public abstract Class BaseConnectionBuilder<R extends BaseConnectionBuilder<R, C>, C extends AbstractConnection>

extends Object
Class Inheritance
Known Direct Subclasses
org.freedesktop.dbus.connections.impl.DBusConnectionBuilder, org.freedesktop.dbus.connections.impl.DirectConnectionBuilder
Type Parameters
<R>
concrete type of connection builder
Imports
org.freedesktop.dbus.connections.AbstractConnection, .BusAddress, .IDisconnectCallback, org.freedesktop.dbus.connections.base.ReceivingService, org.freedesktop.dbus.connections.config.ReceivingServiceConfig, .ReceivingServiceConfigBuilder, .TransportConfig, .TransportConfigBuilder, org.freedesktop.dbus.connections.transports.TransportBuilder, org.freedesktop.dbus.exceptions.DBusException, org.freedesktop.dbus.messages.DBusSignal, org.freedesktop.dbus.messages.constants.Endian, java.nio.ByteOrder, java.util.function.Consumer

Base class for connection builders containing commonly used options.
Author
hypfvieh
Since
4.2.0 - 2022-07-13

Field Summary

Modifier and TypeField and Description
private final ConnectionConfig
private final Class<R>
private final ReceivingServiceConfigBuilder<R>
private final TransportConfigBuilder<?, R>

Constructor Summary

AccessConstructor and Description
protected
BaseConnectionBuilder(Class<R> _returnType, BusAddress _address)

Method Summary

Modifier and TypeMethod and Description
public abstract C
protected ReceivingServiceConfig

Returns:

config
buildThreadConfig
()

Creates the configuration to use for ReceivingService.

protected TransportConfig

Returns:

config
buildTransportConfig
()

Creates the configuration to use for TransportBuilder.

protected ConnectionConfig

Returns:

config
getConnectionConfig
()

Returns the currently configured connection configuration.

public static byte

Returns:

LITTLE or BIG
getSystemEndianness
()

Get the default system endianness.

public ReceivingServiceConfigBuilder<R>

Returns:

builder
receivingThreadConfig
()

Returns the builder to configure the receiving thread pools.

pack-priv R

Returns:

concrete version of this
self
()

Return ourselves.

public TransportConfigBuilder<?, R>

Returns:

builder
transportConfig
()

Returns the builder to configure the used transport.

public R

Returns:

this
withDisconnectCallback
(IDisconnectCallback
callback
_disconnectCallback
)

Set the given disconnect callback to the created connection.

public R

Returns:

this
withExportWeakReferences
(boolean
true to enable
_weakRef
)

Enable/Disable usage of weak references for exported objects.

public R

Returns:

this
withImportWeakReferences
(boolean
true to enable
_weakRef
)

Enable/Disable usage of weak references for imported objects.

public R

Returns:

this
withUnknownSignalHandler
(Consumer<DBusSignal>
callback which receives all unknown signals
_handler
)

Configures a consumer which will receive any signal which could not be handled.

public R

Returns:

this
withWeakReferences
(boolean
true to enable
_weakRef
)
Deprecated for removal since 5.1.0 - 2024-07-12. use withExportWeakReferences(boolean) instead

Enable/Disable weak references on connection.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

connectionConfigback to summary
private final ConnectionConfig connectionConfig
returnTypeback to summary
private final Class<R> returnType
rsConfigBuilderback to summary
private final ReceivingServiceConfigBuilder<R> rsConfigBuilder
transportConfigBuilderback to summary
private final TransportConfigBuilder<?, R> transportConfigBuilder

Constructor Detail

BaseConnectionBuilderback to summary
protected BaseConnectionBuilder(Class<R> _returnType, BusAddress _address)

Method Detail

buildback to summary
public abstract C build() throws DBusException
buildThreadConfigback to summary
protected ReceivingServiceConfig buildThreadConfig()

Creates the configuration to use for ReceivingService.

Returns:ReceivingServiceConfig

config

buildTransportConfigback to summary
protected TransportConfig buildTransportConfig()

Creates the configuration to use for TransportBuilder.

Returns:TransportConfig

config

getConnectionConfigback to summary
protected ConnectionConfig getConnectionConfig()

Returns the currently configured connection configuration.

Returns:ConnectionConfig

config

getSystemEndiannessback to summary
public static byte getSystemEndianness()

Get the default system endianness.

Returns:byte

LITTLE or BIG

receivingThreadConfigback to summary
public ReceivingServiceConfigBuilder<R> receivingThreadConfig()

Returns the builder to configure the receiving thread pools.

Returns:ReceivingServiceConfigBuilder<R>

builder

selfback to summary
pack-priv R self()

Return ourselves.

Returns:R

concrete version of this

transportConfigback to summary
public TransportConfigBuilder<?, R> transportConfig()

Returns the builder to configure the used transport.

Returns:TransportConfigBuilder<?, R>

builder

withDisconnectCallbackback to summary
public R withDisconnectCallback(IDisconnectCallback _disconnectCallback)

Set the given disconnect callback to the created connection.

Parameters
_disconnectCallback:IDisconnectCallback

callback

Returns:R

this

withExportWeakReferencesback to summary
public R withExportWeakReferences(boolean _weakRef)

Enable/Disable usage of weak references for exported objects.

Exported objects are objects provided by the application to DBus and are used through DBus by other applications.

Using weak references may allow the Garbage Collector to remove exported objects when they are no longer reachable. Enabling this feature may cause dbus-java to be forced to re-create exported objects because the GC already cleaned up the old references.
Use with caution!

Default is false.
Parameters
_weakRef:boolean

true to enable

Returns:R

this

withImportWeakReferencesback to summary
public R withImportWeakReferences(boolean _weakRef)

Enable/Disable usage of weak references for imported objects.

Imported objects are all objects which are created when calling interfaces which belong to any object provided by DBus.
E.g. when you want to use Bluetooth, you will query the bluez interfaces on the bus which will create a proxy object in dbus-java.
These objects are stored in an internal Map so re-querying the same object will return the cached object instead of creating a new proxy.

Usually all imported objects are dropped when the connection gets closed (by either side).
If the application will not close the connection and run for a long time the default behavior may cause high memory usage.
Enabling weak references may allow the Garbage Collector to remove imported objects when they are no longer reachable.
This will free up memory when no other references are kept on the remote imported object.

The current default is false.
Anyway it is considered to enable weak references for imported objects as default in the future.

Parameters
_weakRef:boolean

true to enable

Returns:R

this

withUnknownSignalHandlerback to summary
public R withUnknownSignalHandler(Consumer<DBusSignal> _handler)

Configures a consumer which will receive any signal which could not be handled.

By default, no handler is configured, so unknown/unhandled signals will be ignored and only be logged as warn message.

Parameters
_handler:Consumer<DBusSignal>

callback which receives all unknown signals

Returns:R

this

Since
5.1.1 - 2024-09-11
withWeakReferencesback to summary
public R withWeakReferences(boolean _weakRef)

Deprecated

for removal since 5.1.0 - 2024-07-12.

use withExportWeakReferences(boolean) instead

Enable/Disable weak references on connection. Default is false.

Parameters
_weakRef:boolean

true to enable

Returns:R

this

Annotations
@Deprecated
forRemoval:true
since:5.1.0 - 2024-07-12