Code example for ProtectionDomain

0
    private static final Logger disabledLogger = Logger.getLogger("disabled");
 
    private static AccessControlContext createLoggerControlAccCtxt() {
        final Permissions perms = new Permissions();
        perms.add(new LoggingPermission("control", null));
        return new AccessControlContext(new ProtectionDomain[] { new ProtectionDomain(null, perms) });
    } 
 
    static { 
        AccessController.doPrivileged(new PrivilegedAction<Void>() {
            @Override 
            public Void run() {
                Logging.disabledLogger.setLevel(Level.OFF);
                return null; 
            } 
        }, createLoggerControlAccCtxt()); 
    } 
 
    /** Maps logger name to loggers. Names are typically per package */ 
    private static final Map<String, Logger> loggers = new HashMap<>();