类 ConnectionUrl

    • 构造器详细资料

      • ConnectionUrl

        protected ConnectionUrl()
        Empty constructor. Required for subclasses initialization.
      • ConnectionUrl

        public ConnectionUrl​(String origUrl)
        Constructor for unsupported URLs
        参数:
        origUrl - URLs
      • ConnectionUrl

        protected ConnectionUrl​(ConnectionUrlParser connStrParser,
                                Properties info)
        Constructs an instance of ConnectionUrl, performing all the required initializations.
        参数:
        connStrParser - a ConnectionUrlParser instance containing the parsed version of the original connection string
        info - the connection arguments map
    • 方法详细资料

      • getConnectionUrlInstance

        public static ConnectionUrl getConnectionUrlInstance​(String connString,
                                                             Properties info)
        Static factory method that returns either a new instance of a ConnectionUrl or a cached one. Returns "null" it can't handle the connection string.
        参数:
        connString - the connection string
        info - the connection arguments map
        返回:
        an instance of a ConnectionUrl or "null" if isn't able to handle the connection string
      • acceptsUrl

        public static boolean acceptsUrl​(String connString)
        Checks if this ConnectionUrl is able to process the given database URL.
        参数:
        connString - the connection string
        返回:
        true if this class is able to process the given URL, false otherwise
      • collectProperties

        protected void collectProperties​(ConnectionUrlParser connStrParser,
                                         Properties info)
        Joins the connection arguments from the connection string with the ones from the given connection arguments map collecting them in a single map. Additionally may also collect other connection arguments from configuration files.
        参数:
        connStrParser - the ConnectionUrlParser from where to collect the properties
        info - the connection arguments map
      • expandPropertiesFromConfigFiles

        protected void expandPropertiesFromConfigFiles​(Map<String,​String> props)
        Expands the connection argument "useConfig" by reading the mentioned configuration files.
        参数:
        props - a connection arguments map from where to read the "useConfig" property and where to save the loaded properties.
      • getPropertiesFromConfigFiles

        public static Properties getPropertiesFromConfigFiles​(String configFiles)
        Returns a map containing the properties read from the given configuration files. Multiple files can be referenced using a comma as separator.
        参数:
        configFiles - the list of the configuration files to read
        返回:
        the map containing all the properties read
      • injectPerTypeProperties

        protected void injectPerTypeProperties​(Map<String,​String> props)
        Subclasses must override this method if they need to inject additional properties in the connection arguments map while it's being constructed.
        参数:
        props - the properties already containing all known connection arguments
      • replaceLegacyPropertyValues

        protected void replaceLegacyPropertyValues​(Map<String,​String> props)
        Some acceptable property values have changed in c/J 8.0 but old values remain hard-coded in widely used software. So, old values must be accepted and translated to new ones.
        参数:
        props - the host properties map to fix
      • fixHostInfo

        protected HostInfo fixHostInfo​(HostInfo hi)
        Fixes the host information by moving data around and filling in missing data. Applies properties transformations to the collected properties if ConnectionPropertiesTransform was declared in the connection arguments.
        参数:
        hi - the host information data to fix
        返回:
        a new HostInfo with all required data
      • preprocessPerTypeHostProperties

        protected void preprocessPerTypeHostProperties​(Map<String,​String> hostProps)
        Subclasses should override this to perform any required pre-processing on the host information properties.
        参数:
        hostProps - the host properties map to process
      • getDefaultHost

        public String getDefaultHost()
        Returns the default host. Subclasses must override this method if they have different default host value.
        返回:
        the default host
      • getDefaultPort

        public int getDefaultPort()
        Returns the default port. Subclasses must override this method if they have different default port value.
        返回:
        the default port
      • fixProtocolDependencies

        protected void fixProtocolDependencies​(Map<String,​String> hostProps)
        Fixes the protocol (TCP vs PIPE) dependencies for the given host properties map.
        参数:
        hostProps - the host properties map to fix
      • getType

        public ConnectionUrl.Type getType()
        Returns this connection URL type.
        返回:
        the connection URL type
      • getDatabaseUrl

        public String getDatabaseUrl()
        Returns the original database URL that produced this connection string.
        指定者:
        getDatabaseUrl 在接口中 DatabaseUrlContainer
        返回:
        the original database URL
      • getDatabase

        public String getDatabase()
        Returns the database from this connection URL. Note that a "DBNAME" property overrides the database identified in the connection string.
        返回:
        the database name
      • hostsCount

        public int hostsCount()
        Returns the number of hosts in this connection URL.
        返回:
        the number of hosts
      • getMainHost

        public HostInfo getMainHost()
        Returns the single or first host info structure.
        返回:
        the first host info structure
      • getHostsList

        public List<HostInfo> getHostsList()
        Returns a list of the hosts in this connection URL.
        返回:
        the hosts list from this connection URL
      • getHostsList

        public List<HostInfo> getHostsList​(HostsListView view)
        Returns a list of the hosts in this connection URL, filtered for the given view. By default returns all hosts. Subclasses should override this method in order to implement support for different views, usually by splitting the global hosts into smaller sub-lists.
        参数:
        view - the type of the view to use in the returned list of hosts. This argument is ignored in this implementation.
        返回:
        the hosts list from this connection URL, filtered for the given view.
      • getHostOrSpawnIsolated

        public HostInfo getHostOrSpawnIsolated​(String hostPortPair)
        Returns an existing host info with the same host:port part or spawns a new isolated host info based on this connection URL if none was found.
        参数:
        hostPortPair - the host:port part to search for
        返回:
        the existing host info or a new independent one
      • getHostOrSpawnIsolated

        public HostInfo getHostOrSpawnIsolated​(String hostPortPair,
                                               List<HostInfo> hostsList)
        Returns an existing host info with the same host:port part or spawns a new isolated host info based on this connection URL if none was found.
        参数:
        hostPortPair - the host:port part to search for
        hostsList - the hosts list from where to search the host list
        返回:
        the existing host info or a new independent one
      • buildHostInfo

        protected HostInfo buildHostInfo​(String host,
                                         int port,
                                         String user,
                                         String password,
                                         Map<String,​String> hostProps)
        Creates a new HostInfo structure with the given components, passing through the properties transformer if there is one defined in this connection string;
        参数:
        host - the host
        port - the port
        user - the user name
        password - the password
        hostProps - the host properties map
        返回:
        a new instance of HostInfo
      • getOriginalProperties

        public Map<String,​String> getOriginalProperties()
        Returns the original (common to all hosts) connection arguments as provided in the connection string query section.
        返回:
        the original (common to all hosts) connection arguments
      • getConnectionArgumentsAsProperties

        public Properties getConnectionArgumentsAsProperties()
        Returns a Properties instance containing the connection arguments extracted from the URL query section, i.e., per host attributes are excluded. Applies properties transformations to the collected properties if ConnectionPropertiesTransform was declared in the connection arguments.
        返回:
        a Properties instance containing the common connection arguments.
      • getHostsListFromDnsSrv

        public List<HostInfo> getHostsListFromDnsSrv​(HostInfo srvHost)
        Returns a hosts list built from the result of the DNS SRV lookup for the original host name.
        参数:
        srvHost - the HostInfo from where to get the DNS SRV service name to lookup.
        返回:
        the hosts list from the result of the DNS SRV lookup, filtered for the given view.
      • toString

        public String toString()
        Returns a string representation of this object.
        覆盖:
        toString 在类中 Object
        返回:
        a string representation of this object