Class TransportBuilder


  • public final class TransportBuilder
    extends java.lang.Object
    Builder to create transports of different types.
    Since:
    v4.0.0 - 2021-09-17
    • Method Detail

      • getTransportProvider

        static java.util.Map<java.lang.String,​ITransportProvider> getTransportProvider()
      • createWithDynamicSession

        public static TransportBuilder createWithDynamicSession​(java.lang.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
      • 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
      • 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 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​(java.lang.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​(java.nio.file.attribute.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
      • build

        public AbstractTransport build()
                                throws DBusException,
                                       java.io.IOException
        Create the transport with the previously provided configuration.
        Returns:
        AbstractTransport instance
        Throws:
        DBusException - when creating transport fails
        java.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 a List of 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