Class TransportBuilder

java.lang.Object
org.freedesktop.dbus.connections.transports.TransportBuilder

public final class TransportBuilder extends Object
Builder to create transports of different types.
Since:
v4.0.0 - 2021-09-17
  • Field Details

  • Constructor Details

  • Method Details

    • getTransportProvider

      static Map<String,ITransportProvider> getTransportProvider()
    • create

      public static TransportBuilder create(String _address) throws DBusException
      Creates a new TransportBuilder instance 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 new TransportBuilder instance 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 new TransportBuilder instance 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 new TransportBuilder instance with the given address.
      Parameters:
      _address - address, never null
      Returns:
      new TransportBuilder
      Throws:
      DBusException - if invalid address provided
    • createWithDynamicSession

      public static TransportBuilder createWithDynamicSession(String _transportType) throws DBusException
      Creates a new TransportBuilder with 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 use configure()
      Set the connection timeout (usually only used for TCP based transports).

      default: AbstractConnection.TCP_CONNECT_TIMEOUT

      Parameters:
      _timeout - timeout, if < 0 default timeout of AbstractConnection.TCP_CONNECT_TIMEOUT will 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 use configure()
      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 use configure()
      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 use configure()
      Instantly connect to DBus when build() 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 use configure()
      Set a different SASL authentication mode.

      Usually when a unixsocket based transport is used, TransportBuilder.SaslAuthMode.AUTH_EXTERNAL will be used. For TCP based transport TransportBuilder.SaslAuthMode.AUTH_COOKIE will 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(String _user)
      Deprecated, for removal: This API element is subject to removal in a future version.
      please use configure()
      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(String _group)
      Deprecated, for removal: This API element is subject to removal in a future version.
      please use configure()
      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(PosixFilePermission... _permissions)
      Deprecated, for removal: This API element is subject to removal in a future version.
      please use configure()
      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

      Returns the configuration builder to configure the transport.
      Returns:
      TransportConfigBuilder
    • build

      Create the transport with the previously provided configuration.
      Returns:
      AbstractTransport instance
      Throws:
      DBusException - when creating transport fails
      IOException - when autoconnect is true and connection to DBus failed
    • getAddress

      public BusAddress getAddress()
      The currently configured BusAddress.
      Returns:
      BusAddress
    • getRegisteredBusTypes

      public static List<String> getRegisteredBusTypes()
      Returns a List of all bustypes supported in the current runtime.
      Returns:
      List, maybe empty
    • createDynamicSession

      public static String createDynamicSession(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