< prev index next >

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

Print this page




 100      */
 101     public MemoryHandler() {
 102         // configure with specific defaults for MemoryHandler
 103         super(Level.ALL, new SimpleFormatter(), null);
 104 
 105         LogManager manager = LogManager.getLogManager();
 106         String cname = getClass().getName();
 107         pushLevel = manager.getLevelProperty(cname +".push", Level.SEVERE);
 108         size = manager.getIntProperty(cname + ".size", DEFAULT_SIZE);
 109         if (size <= 0) {
 110             size = DEFAULT_SIZE;
 111         }
 112         String targetName = manager.getProperty(cname+".target");
 113         if (targetName == null) {
 114             throw new RuntimeException("The handler " + cname
 115                     + " does not specify a target");
 116         }
 117         Class<?> clz;
 118         try {
 119             clz = ClassLoader.getSystemClassLoader().loadClass(targetName);
 120             target = (Handler) clz.newInstance();


 121         } catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) {
 122             throw new RuntimeException("MemoryHandler can't load handler target \"" + targetName + "\"" , e);
 123         }
 124         init();
 125     }
 126 
 127     // Initialize.  Size is a count of LogRecords.
 128     private void init() {
 129         buffer = new LogRecord[size];
 130         start = 0;
 131         count = 0;
 132     }
 133 
 134     /**
 135      * Create a {@code MemoryHandler}.
 136      * <p>
 137      * The {@code MemoryHandler} is configured based on {@code LogManager}
 138      * properties (or their default values) except that the given {@code pushLevel}
 139      * argument and buffer size argument are used.
 140      *




 100      */
 101     public MemoryHandler() {
 102         // configure with specific defaults for MemoryHandler
 103         super(Level.ALL, new SimpleFormatter(), null);
 104 
 105         LogManager manager = LogManager.getLogManager();
 106         String cname = getClass().getName();
 107         pushLevel = manager.getLevelProperty(cname +".push", Level.SEVERE);
 108         size = manager.getIntProperty(cname + ".size", DEFAULT_SIZE);
 109         if (size <= 0) {
 110             size = DEFAULT_SIZE;
 111         }
 112         String targetName = manager.getProperty(cname+".target");
 113         if (targetName == null) {
 114             throw new RuntimeException("The handler " + cname
 115                     + " does not specify a target");
 116         }
 117         Class<?> clz;
 118         try {
 119             clz = ClassLoader.getSystemClassLoader().loadClass(targetName);
 120             @SuppressWarnings("deprecation")
 121             Object o = clz.newInstance();
 122             target = (Handler) o;
 123         } catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) {
 124             throw new RuntimeException("MemoryHandler can't load handler target \"" + targetName + "\"" , e);
 125         }
 126         init();
 127     }
 128 
 129     // Initialize.  Size is a count of LogRecords.
 130     private void init() {
 131         buffer = new LogRecord[size];
 132         start = 0;
 133         count = 0;
 134     }
 135 
 136     /**
 137      * Create a {@code MemoryHandler}.
 138      * <p>
 139      * The {@code MemoryHandler} is configured based on {@code LogManager}
 140      * properties (or their default values) except that the given {@code pushLevel}
 141      * argument and buffer size argument are used.
 142      *


< prev index next >