Class TransportBuilder
- java.lang.Object
-
- org.freedesktop.dbus.connections.transports.TransportBuilder
-
public final class TransportBuilder extends java.lang.ObjectBuilder to create transports of different types.- Since:
- v4.0.0 - 2021-09-17
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classTransportBuilder.SaslAuthModeRepresents supported SASL authentication modes.
-
Field Summary
Fields Modifier and Type Field Description private static org.slf4j.LoggerLOGGERprivate static java.util.Map<java.lang.String,ITransportProvider>PROVIDERSprivate TransportConfigBuilder<TransportConfigBuilder<?,TransportBuilder>,TransportBuilder>transportConfigBuilder
-
Constructor Summary
Constructors Modifier Constructor Description privateTransportBuilder(TransportConfig _config)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description AbstractTransportbuild()Create the transport with the previously provided configuration.TransportConfigBuilder<TransportConfigBuilder<?,TransportBuilder>,TransportBuilder>configure()Returns the configuration builder to configure the transport.static TransportBuildercreate()Creates a newTransportBuilderinstance using a empty transport configuration.static TransportBuildercreate(java.lang.String _address)Creates a newTransportBuilderinstance with the given address.static TransportBuildercreate(BusAddress _address)Creates a newTransportBuilderinstance with the given address.static TransportBuildercreate(TransportConfig _config)Creates a newTransportBuilderinstance using the given configuration.static java.lang.StringcreateDynamicSession(java.lang.String _busType, boolean _listeningAddress)Creates a new dynamic bus address for the given bus type.static TransportBuildercreateWithDynamicSession(java.lang.String _transportType)Creates a newTransportBuilderwith a dynamically created address.BusAddressgetAddress()The currently configured BusAddress.static java.util.List<java.lang.String>getRegisteredBusTypes()Returns aListof all bustypes supported in the current runtime.(package private) static java.util.Map<java.lang.String,ITransportProvider>getTransportProvider()TransportBuilderisListening(boolean _listen)Deprecated, for removal: This API element is subject to removal in a future version.please useconfigure()TransportBuilderlistening(boolean _listen)Deprecated, for removal: This API element is subject to removal in a future version.please useconfigure()TransportBuilderwithAutoConnect(boolean _connect)Deprecated, for removal: This API element is subject to removal in a future version.please useconfigure()TransportBuilderwithSaslAuthMode(TransportBuilder.SaslAuthMode _authMode)Deprecated, for removal: This API element is subject to removal in a future version.please useconfigure()TransportBuilderwithTimeout(int _timeout)Deprecated, for removal: This API element is subject to removal in a future version.please useconfigure()TransportBuilderwithUnixSocketFileGroup(java.lang.String _group)Deprecated, for removal: This API element is subject to removal in a future version.please useconfigure()TransportBuilderwithUnixSocketFileOwner(java.lang.String _user)Deprecated, for removal: This API element is subject to removal in a future version.please useconfigure()TransportBuilderwithUnixSocketFilePermissions(java.nio.file.attribute.PosixFilePermission... _permissions)Deprecated, for removal: This API element is subject to removal in a future version.please useconfigure()
-
-
-
Field Detail
-
LOGGER
private static final org.slf4j.Logger LOGGER
-
PROVIDERS
private static final java.util.Map<java.lang.String,ITransportProvider> PROVIDERS
-
transportConfigBuilder
private TransportConfigBuilder<TransportConfigBuilder<?,TransportBuilder>,TransportBuilder> transportConfigBuilder
-
-
Constructor Detail
-
TransportBuilder
private TransportBuilder(TransportConfig _config) throws DBusException
- Throws:
DBusException
-
-
Method Detail
-
getTransportProvider
static java.util.Map<java.lang.String,ITransportProvider> getTransportProvider()
-
create
public static TransportBuilder create(java.lang.String _address) throws DBusException
Creates a newTransportBuilderinstance with the given address.- Parameters:
_address- address, never null- Returns:
- new
TransportBuilder - Throws:
DBusException- if invalid address provided
-
create
public static TransportBuilder create(TransportConfig _config) throws DBusException
Creates a newTransportBuilderinstance using the given configuration.- Parameters:
_config- config, never null- Returns:
- new
TransportBuilder - Throws:
DBusException- if invalid address provided
-
create
public static TransportBuilder create() throws DBusException
Creates a newTransportBuilderinstance using a empty transport configuration.- Returns:
- new
TransportBuilder - Throws:
DBusException- if invalid address provided
-
create
public static TransportBuilder create(BusAddress _address) throws DBusException
Creates a newTransportBuilderinstance with the given address.- Parameters:
_address- address, never null- Returns:
- new
TransportBuilder - Throws:
DBusException- if invalid address provided
-
createWithDynamicSession
public static TransportBuilder createWithDynamicSession(java.lang.String _transportType) throws DBusException
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
@Deprecated(since="4.2.0 - 2022-07-21", forRemoval=true) public TransportBuilder withTimeout(int _timeout)Deprecated, for removal: This API element is subject to removal in a future version.please useconfigure()Set the connection timeout (usually only used for TCP based transports).- Parameters:
_timeout- timeout, if < 0 default timeout ofAbstractConnection.TCP_CONNECT_TIMEOUTwill be used
-
isListening
@Deprecated(forRemoval=true, since="4.2.0 - 2022-05-23") public TransportBuilder isListening(boolean _listen)Deprecated, for removal: This API element is subject to removal in a future version.please useconfigure()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:
- this
-
listening
@Deprecated(since="4.2.0 - 2022-07-21", forRemoval=true) public TransportBuilder listening(boolean _listen)Deprecated, for removal: This API element is subject to removal in a future version.please useconfigure()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)
-
withAutoConnect
@Deprecated(since="4.2.0 - 2022-07-21", forRemoval=true) public TransportBuilder withAutoConnect(boolean _connect)Deprecated, for removal: This API element is subject to removal in a future version.please useconfigure()Instantly connect to DBus whenbuild()is called.default: true
- Parameters:
_connect- boolean- Returns:
- this
-
withSaslAuthMode
@Deprecated(since="4.2.0 - 2022-07-21", forRemoval=true) public TransportBuilder withSaslAuthMode(TransportBuilder.SaslAuthMode _authMode)Deprecated, for removal: This API element is subject to removal in a future version.please useconfigure()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
@Deprecated(since="4.2.0 - 2022-07-21", forRemoval=true) public TransportBuilder withUnixSocketFileOwner(java.lang.String _user)Deprecated, for removal: This API element is subject to removal in a future version.please useconfigure()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
@Deprecated(since="4.2.0 - 2022-07-21", forRemoval=true) public TransportBuilder withUnixSocketFileGroup(java.lang.String _group)Deprecated, for removal: This API element is subject to removal in a future version.please useconfigure()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
@Deprecated(since="4.2.0 - 2022-07-21", forRemoval=true) public TransportBuilder withUnixSocketFilePermissions(java.nio.file.attribute.PosixFilePermission... _permissions)Deprecated, for removal: This API element is subject to removal in a future version.please useconfigure()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
-
configure
public TransportConfigBuilder<TransportConfigBuilder<?,TransportBuilder>,TransportBuilder> configure()
Returns the configuration builder to configure the transport.- Returns:
- TransportConfigBuilder
-
build
public AbstractTransport build() throws DBusException, java.io.IOException
Create the transport with the previously provided configuration.- Returns:
AbstractTransportinstance- Throws:
DBusException- when creating transport failsjava.io.IOException- when autoconnect is true and connection to DBus failed
-
getAddress
public BusAddress getAddress()
The currently configured BusAddress.- Returns:
BusAddress
-
getRegisteredBusTypes
public static java.util.List<java.lang.String> getRegisteredBusTypes()
Returns aListof all bustypes supported in the current runtime.- Returns:
List, maybe empty
-
createDynamicSession
public static java.lang.String createDynamicSession(java.lang.String _busType, boolean _listeningAddress)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
-
-