Class BaseConnectionBuilder<R extends BaseConnectionBuilder<R,C>, C extends AbstractConnection>
- Type Parameters:
R- concrete type of connection builder
- Direct Known Subclasses:
DBusConnectionBuilder, DirectConnectionBuilder
- Since:
- 4.2.0 - 2022-07-13
- Author:
- hypfvieh
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedBaseConnectionBuilder(Class<R> _returnType, BusAddress _address) -
Method Summary
Modifier and TypeMethodDescriptionabstract Cbuild()protected ReceivingServiceConfigCreates the configuration to use forReceivingService.protected TransportConfigCreates the configuration to use forTransportBuilder.protected ConnectionConfigReturns the currently configured connection configuration.static byteGet the default system endianness.Returns the builder to configure the receiving thread pools.Returns the builder to configure the used transport.withDisconnectCallback(IDisconnectCallback _disconnectCallback) Set the given disconnect callback to the created connection.withExportWeakReferences(boolean _weakRef) Enable/Disable usage of weak references for exported objects.withImportWeakReferences(boolean _weakRef) Enable/Disable usage of weak references for imported objects.withUnknownSignalHandler(Consumer<DBusSignal> _handler) Configures a consumer which will receive any signal which could not be handled.withWeakReferences(boolean _weakRef) Deprecated, for removal: This API element is subject to removal in a future version.
-
Constructor Details
-
BaseConnectionBuilder
-
-
Method Details
-
buildThreadConfig
Creates the configuration to use forReceivingService.- Returns:
- config
-
buildTransportConfig
Creates the configuration to use forTransportBuilder.- Returns:
- config
-
getConnectionConfig
Returns the currently configured connection configuration.- Returns:
- config
-
receivingThreadConfig
Returns the builder to configure the receiving thread pools.- Returns:
- builder
-
transportConfig
Returns the builder to configure the used transport.- Returns:
- builder
-
withWeakReferences
@Deprecated(forRemoval=true, since="5.1.0 - 2024-07-12") public R withWeakReferences(boolean _weakRef) Deprecated, for removal: This API element is subject to removal in a future version.usewithExportWeakReferences(boolean)insteadEnable/Disable weak references on connection. Default is false.- Parameters:
_weakRef- true to enable- Returns:
- this
-
withExportWeakReferences
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.
Default is false.
Use with caution!- Parameters:
_weakRef- true to enable- Returns:
- this
-
withImportWeakReferences
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- true to enable- Returns:
- this
-
withDisconnectCallback
Set the given disconnect callback to the created connection.- Parameters:
_disconnectCallback- callback- Returns:
- this
-
withUnknownSignalHandler
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- callback which receives all unknown signals- Returns:
- this
- Since:
- 5.1.1 - 2024-09-11
-
build
- Throws:
DBusException
-
getSystemEndianness
public static byte getSystemEndianness()Get the default system endianness.- Returns:
- LITTLE or BIG
-
withExportWeakReferences(boolean)instead