Class TransportConfigBuilder<X extends TransportConfigBuilder<?,R>,R>
- java.lang.Object
-
- org.freedesktop.dbus.connections.config.TransportConfigBuilder<X,R>
-
public class TransportConfigBuilder<X extends TransportConfigBuilder<?,R>,R> extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description private TransportConfigconfigprivate java.util.function.Supplier<R>connectionBuilderprivate SaslConfigBuilder<R>saslConfigBuilder
-
Constructor Summary
Constructors Constructor Description TransportConfigBuilder(java.util.function.Supplier<R> _sup)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description Rback()Return to the previous builder.TransportConfigbuild()Returns the transport config.SaslConfigBuilder<R>configureSasl()Switch to theSaslConfigBuilderto configure the SASL authentication mechanism.
UseSaslConfigBuilder.back()to return to this builder when finished.BusAddressgetBusAddress()Returns the currently configured BusAddress.(package private) Xself()Return ourselves.XwithAdditionalConfig(java.lang.String _key, java.lang.Object _value)Adds an additional config key to the transport config.
Will overwrite value if key exists.XwithAutoConnect(boolean _connect)Instantly connect to DBus whenbuild()is called.XwithBusAddress(BusAddress _address)Set theBusAddresswhich should be used for the connection.XwithConfig(TransportConfig _config)Use the predefined TransportConfig.XwithListening(boolean _listen)Use true to use the transport as listener (server).XwithPreConnectCallback(java.util.function.Consumer<AbstractTransport> _callback)Set a callback which will be called right before the connection to the transport is established.XwithRemoveAdditionalConfig(java.lang.String _key)Removes an additional config key to of transport config.
Will do nothing if key does not exist.XwithSaslAuthMode(TransportBuilder.SaslAuthMode _authMode)Deprecated, for removal: This API element is subject to removal in a future version.useconfigureSasl()insteadXwithSaslUid(long _saslUid)Deprecated, for removal: This API element is subject to removal in a future version.useconfigureSasl()insteadXwithTimeout(int _timeout)Setup a timeout for the transport.XwithUnixSocketFileGroup(java.lang.String _group)The group of the socket file if a unix socket is used and this is a server transport.XwithUnixSocketFileOwner(java.lang.String _user)The owner of the socket file if a unix socket is used and this is a server transport.XwithUnixSocketFilePermissions(java.nio.file.attribute.PosixFilePermission... _permissions)The permissions which will be set on socket file if a unix socket is used and this is a server transport.
-
-
-
Field Detail
-
connectionBuilder
private final java.util.function.Supplier<R> connectionBuilder
-
config
private TransportConfig config
-
saslConfigBuilder
private final SaslConfigBuilder<R> saslConfigBuilder
-
-
Constructor Detail
-
TransportConfigBuilder
public TransportConfigBuilder(java.util.function.Supplier<R> _sup)
-
-
Method Detail
-
self
X self()
Return ourselves.- Returns:
- concrete version of this
-
withConfig
public X withConfig(TransportConfig _config)
Use the predefined TransportConfig.Using this will override any previous configuration and replaces the internal configuration object with the given instance.
- Parameters:
_config- configuration, never null- Returns:
- this
-
withBusAddress
public X withBusAddress(BusAddress _address)
Set theBusAddresswhich should be used for the connection.- Parameters:
_address- address to use- Returns:
- this
-
getBusAddress
public BusAddress getBusAddress()
Returns the currently configured BusAddress.- Returns:
- BusAddress, maybe null
-
withPreConnectCallback
public X withPreConnectCallback(java.util.function.Consumer<AbstractTransport> _callback)
Set a callback which will be called right before the connection to the transport is established.The given consumer will receive the created
AbstractTransportobject which is not yet connected. A callback should NEVER connect the transport, but is allowed to do further configuration if needed.- Parameters:
_callback- consumer to call, null to remove any callback- Returns:
- this
-
withAutoConnect
public X withAutoConnect(boolean _connect)
Instantly connect to DBus whenbuild()is called.default: true
- Parameters:
_connect- boolean- Returns:
- this
-
withSaslAuthMode
@Deprecated(forRemoval=true, since="4.2.2 - 2023-02-03") public X withSaslAuthMode(TransportBuilder.SaslAuthMode _authMode)Deprecated, for removal: This API element is subject to removal in a future version.useconfigureSasl()insteadSet a different SASL authentication mode.Usually when a unixsocket based transport is used,
TransportBuilder.SaslAuthMode.AUTH_EXTERNALwill be used. For TCP based transportTransportBuilder.SaslAuthMode.AUTH_COOKIEwill be used.- Parameters:
_authMode- authmode to use, if null is given, default mode will be used- Returns:
- this
-
configureSasl
public SaslConfigBuilder<R> configureSasl()
Switch to theSaslConfigBuilderto configure the SASL authentication mechanism.
UseSaslConfigBuilder.back()to return to this builder when finished.- Returns:
- SaslConfigBuilder
-
withListening
public X withListening(boolean _listen)
Use true to use the transport as listener (server).- Parameters:
_listen- true to be a listening connection- Returns:
- this
-
withTimeout
public X withTimeout(int _timeout)
Setup a timeout for the transport.This option might not be used by every transport (e.g. unix sockets do not support a timeout). Timeout cannot be less than zero.
- Parameters:
_timeout- true to be a listening connection- Returns:
- this
-
withSaslUid
@Deprecated(forRemoval=true, since="4.2.2 - 2023-02-03") public X withSaslUid(long _saslUid)Deprecated, for removal: This API element is subject to removal in a future version.useconfigureSasl()insteadSet to UID to present during SASL authentication.Default is the user of the running JVM process on Unix-like operating systems. On Windows, the default is zero.
- Parameters:
_saslUid- UID to set, if a negative long is given the default is used- Returns:
- this
-
withUnixSocketFileOwner
public X withUnixSocketFileOwner(java.lang.String _user)
The owner of the socket file if a unix socket is used and this is a server transport.Default is the user of the running JVM process.
Please note:
The running process user has to have suitable permissions to change the owner of the file. Otherwise the file owner will not be changed!- Parameters:
_user- user to set, if null is given JVM process user is used- Returns:
- this
-
withUnixSocketFileGroup
public X withUnixSocketFileGroup(java.lang.String _group)
The group of the socket file if a unix socket is used and this is a server transport.Default is the group of the running JVM process.
Please note:
The running process user has to have suitable permissions to change the group of the file. Otherwise the file group will not be changed!- Parameters:
_group- group to set, if null is given JVM process group is used- Returns:
- this
-
withUnixSocketFilePermissions
public X withUnixSocketFilePermissions(java.nio.file.attribute.PosixFilePermission... _permissions)
The permissions which will be set on socket file if a unix socket is used and this is a server transport.This method does nothing when used on windows systems. Please note:
The running process user has to have suitable permissions to change the permissions of the file. Otherwise the file permissions will not be changed!- Parameters:
_permissions- permissions to set, if null is given default permissions will be used- Returns:
- this
-
withAdditionalConfig
public X withAdditionalConfig(java.lang.String _key, java.lang.Object _value)
Adds an additional config key to the transport config.
Will overwrite value if key exists.- Parameters:
_key- key to use_value- value to use- Returns:
- this
-
withRemoveAdditionalConfig
public X withRemoveAdditionalConfig(java.lang.String _key)
Removes an additional config key to of transport config.
Will do nothing if key does not exist.- Parameters:
_key- key to remove- Returns:
- this
-
back
public R back()
Return to the previous builder.This allows you to return from the this builder to the builder which started this builder so you can continue using the previous builder.
- Returns:
- previous builder, maybe null
-
build
public TransportConfig build()
Returns the transport config.- Returns:
- config
-
-