Class TransportFactory

    • Constructor Detail

      • TransportFactory

        public TransportFactory()
    • Method Detail

      • createTransport

        public Transport createTransport​(java.net.URI remoteURI)
                                  throws java.lang.Exception
        Creates an instance of the given Transport and configures it using the properties set on the given remote broker URI.
        Parameters:
        remoteURI - The URI used to connect to a remote Peer.
        Returns:
        a new Transport instance.
        Throws:
        java.lang.Exception - if an error occurs while creating the Transport instance.
      • doCreateTransportOptions

        protected TransportOptions doCreateTransportOptions()
        Create and return an instance of TransportOptions appropriate for the Transport type that this factory will return.
        Returns:
        a newly allocated TransportOptions instance appropriate to the factory.
      • applyTransportConfiguration

        protected TransportOptions applyTransportConfiguration​(TransportOptions transportOptions,
                                                               java.util.Map<java.lang.String,​java.lang.String> transportURIOptions)
        Apply URI options to a freshly created TransportOptions instance which will be used when the actual Transport is created.
        Parameters:
        transportOptions - The TransportOptions instance to configure.
        transportURIOptions - The URI options to apply to the given TransportOptions.
        Returns:
      • doCreateTransport

        protected abstract Transport doCreateTransport​(java.net.URI remoteURI,
                                                       TransportOptions transportOptions)
                                                throws java.lang.Exception
        Create the actual Transport instance for this factory using the provided URI and TransportOptions instances.
        Parameters:
        remoteURI - The URI used to connect to a remote Peer.
        transportOptions - The TransportOptions used to configure the new Transport.
        Returns:
        a newly created and configured Transport instance.
        Throws:
        java.lang.Exception - if an error occurs while creating the Transport instance.
      • getName

        public abstract java.lang.String getName()
        Returns:
        the name of this Transport.
      • isSecure

        public boolean isSecure()
        Returns:
        true if the Transport that this factory provides uses a secure channel.
      • create

        public static Transport create​(java.lang.String transportKey,
                                       java.net.URI remoteURI)
                                throws java.lang.Exception
        Static create method that performs the TransportFactory search and handles the configuration and setup.
        Parameters:
        transportKey - The transport type name used to locate a TransportFactory.
        remoteURI - the URI of the remote peer.
        Returns:
        a new Transport instance that is ready for use.
        Throws:
        java.lang.Exception - if an error occurs while creating the Transport instance.
      • findTransportFactory

        public static TransportFactory findTransportFactory​(java.lang.String transportKey)
                                                     throws java.io.IOException
        Searches for a TransportFactory by using the scheme from the given key. The search first checks the local cache of Transport factories before moving on to search in the class-path.
        Parameters:
        transportKey - The transport type name used to locate a TransportFactory.
        Returns:
        a Transport factory instance matching the transport key.
        Throws:
        java.io.IOException - if an error occurs while locating the factory.