final class LogManagerProperties
extends java.util.Properties
This class also emulates the LogManager functions for creating new objects from string class names. This is to support initial setup of objects such as log filters, formatters, error managers, etc.
This class should never be exposed outside of this package. Keep this class package private (default access).
Modifier and Type | Field and Description |
---|---|
private static java.util.logging.LogManager |
LOG_MANAGER
Caches the LogManager so we only read the config once.
|
private java.lang.String |
prefix
The namespace prefix to search LogManager and defaults.
|
private static java.lang.String[] |
REFLECT_NAMES
Caches the read only reflection class names string array.
|
private static long |
serialVersionUID
Generated serial id.
|
Constructor and Description |
---|
LogManagerProperties(java.util.Properties parent,
java.lang.String prefix)
Creates a log manager properties object.
|
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
clone()
Returns a properties object that contains a snapshot of the current
state.
|
boolean |
containsKey(java.lang.Object key)
Required to work with PropUtil.
|
boolean |
equals(java.lang.Object o)
It is assumed that this method will never be called.
|
private java.util.Properties |
exportCopy(java.util.Properties parent)
Creates a public snapshot of this properties object using the given
parent properties.
|
private static java.lang.Class<?> |
findClass(java.lang.String name)
This code is modified from the LogManager, which explictly states
searching the system class loader first, then the context class loader.
|
java.lang.Object |
get(java.lang.Object key)
Required to work with PropUtil.
|
private static java.lang.ClassLoader[] |
getClassLoaders()
Gets the class loaders using elevated privileges.
|
(package private) static java.util.logging.LogManager |
getLogManager()
Gets the LogManger for the running JVM.
|
java.lang.String |
getProperty(java.lang.String key)
Searches defaults, then searches the log manager by the prefix property,
and then by the key itself.
|
java.lang.String |
getProperty(java.lang.String key,
java.lang.String def)
Calls getProperty directly.
|
int |
hashCode()
It is assumed that this method will never be called.
|
(package private) static boolean |
isReflectionClass(java.lang.String name)
Determines if the given class name is a reflection class name responsible
for invoking methods and or constructors.
|
(package private) static boolean |
isStaticUtilityClass(java.lang.String name)
Determines if the given class name identifies a utility class.
|
(package private) static Authenticator |
newAuthenticator(java.lang.String name)
Creates a new authenticator from the given class name.
|
(package private) static java.util.Comparator<? super java.util.logging.LogRecord> |
newComparator(java.lang.String name)
Creates a new log record comparator from the given class name.
|
(package private) static java.util.logging.ErrorManager |
newErrorManager(java.lang.String name)
Creates a new error manager from the given class name.
|
(package private) static java.util.logging.Filter |
newFilter(java.lang.String name)
Creates a new filter from the given class name.
|
(package private) static java.util.logging.Formatter |
newFormatter(java.lang.String name)
Creates a new formatter from the given class name.
|
private static <T> T |
newObjectFrom(java.lang.String name,
java.lang.Class<T> type)
Creates a new object from the given class name.
|
private static java.lang.Exception |
paramOrError(java.lang.reflect.InvocationTargetException ite)
Returns the given exception or throws the escaping cause.
|
private java.lang.Object |
preWrite(java.lang.Object key)
Called before a write operation of a key.
|
java.util.Enumeration<?> |
propertyNames()
It is assumed that this method will never be called.
|
java.lang.Object |
put(java.lang.Object key,
java.lang.Object value)
Required to work with PropUtil.
|
private static java.lang.String[] |
reflectionClassNames()
Determines all of the reflection class names used to invoke methods.
|
java.lang.Object |
remove(java.lang.Object key)
Required to work with PropUtil.
|
(package private) static <T> java.util.Comparator<T> |
reverseOrder(java.util.Comparator<T> c)
Returns a comparator that imposes the reverse ordering of the specified
Comparator . |
java.lang.Object |
setProperty(java.lang.String key,
java.lang.String value)
Calls the put method directly.
|
(package private) static java.lang.String |
toLanguageTag(java.util.Locale locale)
Converts a locale to a language tag.
|
private static java.lang.Class<?> |
tryLoad(java.lang.String name,
java.lang.ClassLoader l)
Loads a class using the given loader or the class loader of this class.
|
private static java.lang.reflect.InvocationTargetException |
wrapOrThrow(java.lang.ExceptionInInitializerError eiie)
Throws the given error if the cause is an error otherwise the given error
is wrapped.
|
private java.lang.Object |
writeReplace()
It is assumed that this method will never be called.
|
list, list, load, load, loadFromXML, save, store, store, storeToXML, storeToXML, stringPropertyNames
private static final long serialVersionUID
private static final java.util.logging.LogManager LOG_MANAGER
private static volatile java.lang.String[] REFLECT_NAMES
private final java.lang.String prefix
LogManagerProperties(java.util.Properties parent, java.lang.String prefix)
parent
- the parent properties.prefix
- the namespace prefix.java.lang.NullPointerException
- if prefix or parent is
null.static java.util.logging.LogManager getLogManager()
static java.lang.String toLanguageTag(java.util.Locale locale)
locale
- the locale to convert.java.lang.NullPointerException
- if the given locale is null.static java.util.logging.Filter newFilter(java.lang.String name) throws java.lang.Exception
name
- the fully qualified class name.java.lang.ClassCastException
- if class name does not match the type.java.lang.ClassNotFoundException
- if the class name was not found.java.lang.IllegalAccessException
- if the constructor is inaccessible.java.lang.InstantiationException
- if the given class name is abstract.java.lang.reflect.InvocationTargetException
- if the constructor throws an exception.java.lang.LinkageError
- if the linkage fails.java.lang.ExceptionInInitializerError
- if the static initializer fails.java.lang.Exception
- to match the error method of the ErrorManager.java.lang.NoSuchMethodException
- if the class name does not have a no
argument constructor.static java.util.logging.Formatter newFormatter(java.lang.String name) throws java.lang.Exception
name
- the fully qualified class name.java.lang.ClassCastException
- if class name does not match the type.java.lang.ClassNotFoundException
- if the class name was not found.java.lang.IllegalAccessException
- if the constructor is inaccessible.java.lang.InstantiationException
- if the given class name is abstract.java.lang.reflect.InvocationTargetException
- if the constructor throws an exception.java.lang.LinkageError
- if the linkage fails.java.lang.ExceptionInInitializerError
- if the static initializer fails.java.lang.Exception
- to match the error method of the ErrorManager.java.lang.NoSuchMethodException
- if the class name does not have a no
argument constructor.static java.util.Comparator<? super java.util.logging.LogRecord> newComparator(java.lang.String name) throws java.lang.Exception
name
- the fully qualified class name.java.lang.ClassCastException
- if class name does not match the type.java.lang.ClassNotFoundException
- if the class name was not found.java.lang.IllegalAccessException
- if the constructor is inaccessible.java.lang.InstantiationException
- if the given class name is abstract.java.lang.reflect.InvocationTargetException
- if the constructor throws an exception.java.lang.LinkageError
- if the linkage fails.java.lang.ExceptionInInitializerError
- if the static initializer fails.java.lang.Exception
- to match the error method of the ErrorManager.java.lang.NoSuchMethodException
- if the class name does not have a no
argument constructor.LogRecord
static <T> java.util.Comparator<T> reverseOrder(java.util.Comparator<T> c)
Comparator
. If the given comparator declares a public
reverseOrder method that method is called first and the return value is
used. If that method is not declared or the caller does not have access
then a comparator wrapping the given comparator is returned.T
- the element type to be comparedc
- a comparator whose ordering is to be reversed by the returned
comparatorjava.lang.NullPointerException
- if the given comparator is null.static java.util.logging.ErrorManager newErrorManager(java.lang.String name) throws java.lang.Exception
name
- the fully qualified class name.java.lang.ClassCastException
- if class name does not match the type.java.lang.ClassNotFoundException
- if the class name was not found.java.lang.IllegalAccessException
- if the constructor is inaccessible.java.lang.InstantiationException
- if the given class name is abstract.java.lang.reflect.InvocationTargetException
- if the constructor throws an exception.java.lang.LinkageError
- if the linkage fails.java.lang.ExceptionInInitializerError
- if the static initializer fails.java.lang.Exception
- to match the error method of the ErrorManager.java.lang.NoSuchMethodException
- if the class name does not have a no
argument constructor.static Authenticator newAuthenticator(java.lang.String name) throws java.lang.Exception
name
- the fully qualified class name.java.lang.ClassCastException
- if class name does not match the type.java.lang.ClassNotFoundException
- if the class name was not found.java.lang.IllegalAccessException
- if the constructor is inaccessible.java.lang.InstantiationException
- if the given class name is abstract.java.lang.reflect.InvocationTargetException
- if the constructor throws an exception.java.lang.LinkageError
- if the linkage fails.java.lang.ExceptionInInitializerError
- if the static initializer fails.java.lang.Exception
- to match the error method of the ErrorManager.java.lang.NoSuchMethodException
- if the class name does not have a no
argument constructor.static boolean isStaticUtilityClass(java.lang.String name) throws java.lang.Exception
name
- the fully qualified class name.java.lang.ClassNotFoundException
- if the class name was not found.java.lang.IllegalAccessException
- if the constructor is inaccessible.java.lang.LinkageError
- if the linkage fails.java.lang.ExceptionInInitializerError
- if the static initializer fails.java.lang.Exception
- to match the error method of the ErrorManager.java.lang.SecurityException
- if unable to inspect properties of class.static boolean isReflectionClass(java.lang.String name) throws java.lang.Exception
name
- the fully qualified class name.java.lang.ClassNotFoundException
- if the class name was not found.java.lang.IllegalAccessException
- if the constructor is inaccessible.java.lang.LinkageError
- if the linkage fails.java.lang.ExceptionInInitializerError
- if the static initializer fails.java.lang.Exception
- to match the error method of the ErrorManager.java.lang.SecurityException
- if unable to inspect properties of class.private static java.lang.String[] reflectionClassNames() throws java.lang.Exception
java.lang.Exception
- if there is a problem.private static <T> T newObjectFrom(java.lang.String name, java.lang.Class<T> type) throws java.lang.Exception
T
- The generic class type.name
- the fully qualified class name.type
- the assignable type for the given name.java.lang.ClassCastException
- if class name does not match the type.java.lang.ClassNotFoundException
- if the class name was not found.java.lang.IllegalAccessException
- if the constructor is inaccessible.java.lang.InstantiationException
- if the given class name is abstract.java.lang.reflect.InvocationTargetException
- if the constructor throws an exception.java.lang.LinkageError
- if the linkage fails.java.lang.ExceptionInInitializerError
- if the static initializer fails.java.lang.Exception
- to match the error method of the ErrorManager.java.lang.NoSuchMethodException
- if the class name does not have a no
argument constructor.private static java.lang.Exception paramOrError(java.lang.reflect.InvocationTargetException ite)
ite
- any invocation target.java.lang.VirtualMachineError
- if present as cause.java.lang.ThreadDeath
- if present as cause.private static java.lang.reflect.InvocationTargetException wrapOrThrow(java.lang.ExceptionInInitializerError eiie)
eiie
- the error.private static java.lang.Class<?> findClass(java.lang.String name) throws java.lang.ClassNotFoundException
name
- full class namejava.lang.LinkageError
- if the linkage fails.java.lang.ClassNotFoundException
- if the class name was not found.java.lang.ExceptionInInitializerError
- if static initializer fails.private static java.lang.Class<?> tryLoad(java.lang.String name, java.lang.ClassLoader l) throws java.lang.ClassNotFoundException
name
- the class name.l
- any class loader or null.java.lang.ClassNotFoundException
- if not found.private static java.lang.ClassLoader[] getClassLoaders()
public java.lang.Object clone()
clone
in class java.util.Hashtable<java.lang.Object,java.lang.Object>
public java.lang.String getProperty(java.lang.String key)
getProperty
in class java.util.Properties
key
- a non null key.public java.lang.String getProperty(java.lang.String key, java.lang.String def)
getProperty
in class java.util.Properties
key
- a key to search for.def
- the default value to use if not found.public java.lang.Object get(java.lang.Object key)
get
in interface java.util.Map<java.lang.Object,java.lang.Object>
get
in class java.util.Hashtable<java.lang.Object,java.lang.Object>
key
- any key.public java.lang.Object put(java.lang.Object key, java.lang.Object value)
put
in interface java.util.Map<java.lang.Object,java.lang.Object>
put
in class java.util.Hashtable<java.lang.Object,java.lang.Object>
key
- any key.public java.lang.Object setProperty(java.lang.String key, java.lang.String value)
setProperty
in class java.util.Properties
key
- any key.public boolean containsKey(java.lang.Object key)
containsKey
in interface java.util.Map<java.lang.Object,java.lang.Object>
containsKey
in class java.util.Hashtable<java.lang.Object,java.lang.Object>
key
- any key.public java.lang.Object remove(java.lang.Object key)
remove
in interface java.util.Map<java.lang.Object,java.lang.Object>
remove
in class java.util.Hashtable<java.lang.Object,java.lang.Object>
key
- any key.public java.util.Enumeration<?> propertyNames()
propertyNames
in class java.util.Properties
public boolean equals(java.lang.Object o)
equals
in interface java.util.Map<java.lang.Object,java.lang.Object>
equals
in class java.util.Hashtable<java.lang.Object,java.lang.Object>
o
- any object or null.public int hashCode()
hashCode
in interface java.util.Map<java.lang.Object,java.lang.Object>
hashCode
in class java.util.Hashtable<java.lang.Object,java.lang.Object>
private java.lang.Object preWrite(java.lang.Object key)
key
- the key to search.private java.util.Properties exportCopy(java.util.Properties parent)
parent
- the defaults to use with the snapshot.private java.lang.Object writeReplace() throws java.io.ObjectStreamException
java.io.ObjectStreamException
- if there is a problem.