Class TransportBuilder
- Since:
- v4.0.0 - 2021-09-17
- Author:
- hypfvieh
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumRepresents supported SASL authentication modes. -
Method Summary
Modifier and TypeMethodDescriptionbuild()Create the transport with the previously provided configuration.static TransportBuilderCreates a newTransportBuilderinstance with the given address.static TransportBuildercreate(BusAddress _address) Creates a newTransportBuilderinstance with the given address.static StringcreateDynamicSession(String _busType, boolean _listeningAddress) Creates a new dynamic bus address for the given bus type.static TransportBuildercreateWithDynamicSession(String _transportType) Creates a newTransportBuilderwith a dynamically created address.The currently configured BusAddress.Returns aListof all bustypes supported in the current runtime.isListening(boolean _listen) Toggle the created transport to be a listening (server) or initiating (client) connection.withAutoConnect(boolean _connect) Instantly connect to DBus whenbuild()is called.withSaslAuthMode(TransportBuilder.SaslAuthMode _authMode) Set a different SASL authentication mode.withTimeout(int _timeout) Set the connection timeout (usually only used for TCP based transports).withUnixSocketFileGroup(String _group) The group of the socket file if a unix socket is used and this is a server transport.withUnixSocketFileOwner(String _user) The owner of the socket file if a unix socket is used and this is a server transport.withUnixSocketFilePermissions(PosixFilePermission... _permissions) The permissions which will be set on socket file if a unix socket is used and this is a server transport.
-
Method Details
-
create
Creates a newTransportBuilderinstance with the given address.- Parameters:
_address- address, never null- Returns:
- new
TransportBuilder - Throws:
DBusException- if invalid address provided
-
create
Creates a newTransportBuilderinstance with the given address.- Parameters:
_address- address, never null- Returns:
- new
TransportBuilder - Throws:
DBusException- if invalid address provided
-
createWithDynamicSession
Creates a newTransportBuilderwith a dynamically created address.- Parameters:
_transportType- type of session (e.g. UNIX or TCP)- Returns:
TransportBuilder- Throws:
DBusException- when invalid/unknown/unsupported transport type given
-
withTimeout
Set the connection timeout (usually only used for TCP based transports).- Parameters:
_timeout- timeout, if < 0 default timeout ofAbstractConnection.TCP_CONNECT_TIMEOUTwill be used- Returns:
- this
-
isListening
Toggle the created transport to be a listening (server) or initiating (client) connection.Default is a client connection.
- Parameters:
_listen- true to create a listening transport (e.g. for server usage)- Returns:
-
withAutoConnect
Instantly connect to DBus whenbuild()is called.default: true
- Parameters:
_connect- boolean- Returns:
- this
-
withSaslAuthMode
Set 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
-
withUnixSocketFileOwner
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
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
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
-
build
Create the transport with the previously provided configuration.- Returns:
AbstractTransportinstance- Throws:
DBusException- when creating transport failsIOException- when autoconnect is true and connection to DBus failed
-
getAddress
The currently configured BusAddress.- Returns:
BusAddress
-
getRegisteredBusTypes
Returns aListof all bustypes supported in the current runtime.- Returns:
List, maybe empty
-
createDynamicSession
Creates a new dynamic bus address for the given bus type.- Parameters:
_busType- bus type (e.g. UNIX or TCP), never null_listeningAddress- true if a listening (server) address should be created, false otherwise- Returns:
- String containing BusAddress or null
-