< prev index next >

src/java.logging/share/classes/java/util/logging/LogManager.java

Print this page




1822      *   For each <i>k</i>, the mapped function <i>f</i> will
1823      *   be invoked with the value associated with <i>k</i> in the old
1824      *   configuration (i.e <i>o</i>) and the value associated with
1825      *   <i>k</i> in the new configuration (i.e. <i>n</i>).
1826      *   <br>A {@code null} value for <i>o</i> or <i>n</i> indicates that no
1827      *   value was present for <i>k</i> in the corresponding configuration.
1828      *
1829      * @throws  SecurityException  if a security manager exists and if
1830      *          the caller does not have LoggingPermission("control"), or
1831      *          does not have the permissions required to set up the
1832      *          configuration (e.g. open file specified for FileHandlers
1833      *          etc...)
1834      *
1835      * @throws  NullPointerException  if {@code mapper} returns a {@code null}
1836      *         function when invoked.
1837      *
1838      * @throws  IOException if there are problems reading from the
1839      *          logging configuration file.
1840      *
1841      * @see #updateConfiguration(java.io.InputStream, java.util.function.Function)

1842      */
1843     public void updateConfiguration(Function<String, BiFunction<String,String,String>> mapper)
1844             throws IOException {
1845         checkPermission();
1846         ensureLogManagerInitialized();
1847         drainLoggerRefQueueBounded();
1848 
1849         String fname = getConfigurationFileName();
1850         try (final InputStream in = new FileInputStream(fname)) {
1851             final BufferedInputStream bin = new BufferedInputStream(in);
1852             updateConfiguration(bin, mapper);
1853         }
1854     }
1855 
1856     /**
1857      * Updates the logging configuration.
1858      * <p>
1859      * For each configuration key in the {@linkplain
1860      * #getProperty(java.lang.String) existing configuration} and
1861      * the given input stream configuration, the given {@code mapper} function


2018      *   assumed.
2019      *   <br>
2020      *   For each <i>k</i>, the mapped function <i>f</i> will
2021      *   be invoked with the value associated with <i>k</i> in the old
2022      *   configuration (i.e <i>o</i>) and the value associated with
2023      *   <i>k</i> in the new configuration (i.e. <i>n</i>).
2024      *   <br>A {@code null} value for <i>o</i> or <i>n</i> indicates that no
2025      *   value was present for <i>k</i> in the corresponding configuration.
2026      *
2027      * @throws  SecurityException if a security manager exists and if
2028      *          the caller does not have LoggingPermission("control"), or
2029      *          does not have the permissions required to set up the
2030      *          configuration (e.g. open files specified for FileHandlers)
2031      *
2032      * @throws  NullPointerException if {@code ins} is null or if
2033      *          {@code mapper} returns a null function when invoked.
2034      *
2035      * @throws  IOException if there are problems reading from the stream,
2036      *          or the given stream is not in the
2037      *          {@linkplain java.util.Properties properties file} format.

2038      */
2039     public void updateConfiguration(InputStream ins,
2040             Function<String, BiFunction<String,String,String>> mapper)
2041             throws IOException {
2042         checkPermission();
2043         ensureLogManagerInitialized();
2044         drainLoggerRefQueueBounded();
2045 
2046         final Properties previous;
2047         final Set<String> updatePropertyNames;
2048         List<LoggerContext> cxs = Collections.emptyList();
2049         final VisitedLoggers visited = new VisitedLoggers();
2050         final Properties next = new Properties();
2051 
2052         try {
2053             // Load the properties
2054             next.load(ins);
2055         } catch (IllegalArgumentException x) {
2056             // props.load may throw an IllegalArgumentException if the stream
2057             // contains malformed Unicode escape sequences.




1822      *   For each <i>k</i>, the mapped function <i>f</i> will
1823      *   be invoked with the value associated with <i>k</i> in the old
1824      *   configuration (i.e <i>o</i>) and the value associated with
1825      *   <i>k</i> in the new configuration (i.e. <i>n</i>).
1826      *   <br>A {@code null} value for <i>o</i> or <i>n</i> indicates that no
1827      *   value was present for <i>k</i> in the corresponding configuration.
1828      *
1829      * @throws  SecurityException  if a security manager exists and if
1830      *          the caller does not have LoggingPermission("control"), or
1831      *          does not have the permissions required to set up the
1832      *          configuration (e.g. open file specified for FileHandlers
1833      *          etc...)
1834      *
1835      * @throws  NullPointerException  if {@code mapper} returns a {@code null}
1836      *         function when invoked.
1837      *
1838      * @throws  IOException if there are problems reading from the
1839      *          logging configuration file.
1840      *
1841      * @see #updateConfiguration(java.io.InputStream, java.util.function.Function)
1842      * @since 9
1843      */
1844     public void updateConfiguration(Function<String, BiFunction<String,String,String>> mapper)
1845             throws IOException {
1846         checkPermission();
1847         ensureLogManagerInitialized();
1848         drainLoggerRefQueueBounded();
1849 
1850         String fname = getConfigurationFileName();
1851         try (final InputStream in = new FileInputStream(fname)) {
1852             final BufferedInputStream bin = new BufferedInputStream(in);
1853             updateConfiguration(bin, mapper);
1854         }
1855     }
1856 
1857     /**
1858      * Updates the logging configuration.
1859      * <p>
1860      * For each configuration key in the {@linkplain
1861      * #getProperty(java.lang.String) existing configuration} and
1862      * the given input stream configuration, the given {@code mapper} function


2019      *   assumed.
2020      *   <br>
2021      *   For each <i>k</i>, the mapped function <i>f</i> will
2022      *   be invoked with the value associated with <i>k</i> in the old
2023      *   configuration (i.e <i>o</i>) and the value associated with
2024      *   <i>k</i> in the new configuration (i.e. <i>n</i>).
2025      *   <br>A {@code null} value for <i>o</i> or <i>n</i> indicates that no
2026      *   value was present for <i>k</i> in the corresponding configuration.
2027      *
2028      * @throws  SecurityException if a security manager exists and if
2029      *          the caller does not have LoggingPermission("control"), or
2030      *          does not have the permissions required to set up the
2031      *          configuration (e.g. open files specified for FileHandlers)
2032      *
2033      * @throws  NullPointerException if {@code ins} is null or if
2034      *          {@code mapper} returns a null function when invoked.
2035      *
2036      * @throws  IOException if there are problems reading from the stream,
2037      *          or the given stream is not in the
2038      *          {@linkplain java.util.Properties properties file} format.
2039      * @since 9
2040      */
2041     public void updateConfiguration(InputStream ins,
2042             Function<String, BiFunction<String,String,String>> mapper)
2043             throws IOException {
2044         checkPermission();
2045         ensureLogManagerInitialized();
2046         drainLoggerRefQueueBounded();
2047 
2048         final Properties previous;
2049         final Set<String> updatePropertyNames;
2050         List<LoggerContext> cxs = Collections.emptyList();
2051         final VisitedLoggers visited = new VisitedLoggers();
2052         final Properties next = new Properties();
2053 
2054         try {
2055             // Load the properties
2056             next.load(ins);
2057         } catch (IllegalArgumentException x) {
2058             // props.load may throw an IllegalArgumentException if the stream
2059             // contains malformed Unicode escape sequences.


< prev index next >