Package org.apache.tomcat.jdbc.pool
Class PoolUtilities
- java.lang.Object
-
- org.apache.tomcat.jdbc.pool.PoolUtilities
-
public class PoolUtilities extends java.lang.ObjectUtility methods for managing JDBC pool properties: the copy the connect path hands to the JDBC driver, and the password-masked copies the JMX and bean property getters expose, are all built here.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringPROP_PASSWORDProperty key for the database password.static java.lang.StringPROP_USERProperty key for the database user name.
-
Constructor Summary
Constructors Constructor Description PoolUtilities()Default constructor.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.util.Propertiesclone(java.util.Properties p)Creates a shallow copy of the given properties.static java.util.PropertiescloneWithoutPassword(java.util.Properties p)Creates a copy of the given properties asclone(Properties)does, with every credential entry removed.
-
-
-
Field Detail
-
PROP_USER
public static final java.lang.String PROP_USER
Property key for the database user name.- See Also:
- Constant Field Values
-
PROP_PASSWORD
public static final java.lang.String PROP_PASSWORD
Property key for the database password.- See Also:
- Constant Field Values
-
-
Method Detail
-
clone
public static java.util.Properties clone(java.util.Properties p)
Creates a shallow copy of the given properties. Entries that the source resolves to a String through a defaults table are materialized into the copy as plain values, so the copy resolves every String the source resolves and needs no defaults table of its own; the defaults table itself is not carried over. A String directly present in the source under the same key shadows the defaults there and takes precedence in the copy. A non-String directly present value shadows nothing, becauseProperties.getProperty(String)falls through to the defaults whenever the direct value is not a String, so where the source resolves a String under such a key the resolved String takes its place in the copy; entries the source resolves to no String are copied as they are, and a non-String held only in a defaults table - which neither the source nor the copy resolves - does not appear in the copy at all.The copy is per-key best effort against a source modified concurrently: an entry the modification removes may still be copied, and an entry it adds is copied only if it was already there when the copy sampled the source. A caller that needs the copy to show one state the source was actually in must serialize it against the modifications itself.
- Parameters:
p- the properties to clone, notnull- Returns:
- a new Properties instance, without a defaults table, resolving every String the source resolves and carrying over its other direct entries
- Throws:
java.lang.NullPointerException- if the source isnull
-
cloneWithoutPassword
public static java.util.Properties cloneWithoutPassword(java.util.Properties p)
Creates a copy of the given properties asclone(Properties)does, with every credential entry removed. A credential entry is one whose key is recognised byisCredentialKey(String):password,passandpwd, ignoring case and surrounding whitespace. The copy carries no defaults table, so the removal also reaches a credential the source only resolved through its defaults - a reference copy would let the remove walk past the defaults table and leave the credential resolvable.- Parameters:
p- the properties to clone, notnull- Returns:
- a new Properties instance with all entries except the credentials
- Throws:
java.lang.NullPointerException- if the source isnull
-
-