private static Logger doLegacyGetLogger(final String name) { final org.jboss.logmanager.Logger lmLogger = LogContext.getLogContext().getLogger(""); ConcurrentMap<String, Logger> loggers = lmLogger.getAttachment(LEGACY_KEY); if (loggers == null) { loggers = new ConcurrentHashMap<String, Logger>(); final ConcurrentMap<String, Logger> appearing = lmLogger.attachIfAbsent(LEGACY_KEY, loggers); if (appearing != null) { loggers = appearing; } } Logger l = loggers.get(name); if (l != null) { return l; } final org.jboss.logmanager.Logger logger = org.jboss.logmanager.Logger.getLogger(name); l = new JBossLogManagerLogger(name, logger); final Logger appearing = loggers.putIfAbsent(name, l); if (appearing == null) { return l; } return appearing; }
@Override public T run() { return logger.getAttachment(key); } });
static CopyOnWriteArrayList<Appender> getAppenderList(final Logger logger) { CopyOnWriteArrayList<Appender> result = logger.getAttachment(APPENDERS_KEY); if (result == null) { result = new CopyOnWriteArrayList<Appender>(); final CopyOnWriteArrayList<Appender> current; if (System.getSecurityManager() == null) { current = logger.attachIfAbsent(APPENDERS_KEY, result); } else { final CopyOnWriteArrayList<Appender> attachment = result; current = AccessController.doPrivileged(new PrivilegedAction<CopyOnWriteArrayList<Appender>>() { @Override public CopyOnWriteArrayList<Appender> run() { return logger.attachIfAbsent(APPENDERS_KEY, attachment); } }); } if (current != null) { result = current; } } return result; } }
private Map<String, Object> getAttributeMap() { final Logger rootLogger = Logger.getLogger(""); Map<String, Object> map = rootLogger.getAttachment(ATTRIBUTE_KEY); if (map == null) { map = Collections.synchronizedMap(new HashMap<String, Object>()); final Map<String, Object> appearing = rootLogger.attachIfAbsent(ATTRIBUTE_KEY, map); if (appearing != null) { map = appearing; } } return map; } }
public Logger getLogger(final String name) { final org.jboss.logmanager.Logger lmLogger = LogContext.getLogContext().getLogger(name); final Logger logger = lmLogger.getAttachment(key); if (logger != null) { return logger; } return doPrivileged(new PrivilegedAction<Logger>() { public Logger run() { final Slf4jLogger newLogger = new Slf4jLogger(lmLogger); final Logger appearingLogger = lmLogger.attachIfAbsent(key, newLogger); return appearingLogger != null ? appearingLogger : newLogger; } }); } }
public Logger getLogger(final String name) { final org.jboss.logmanager.Logger lmLogger = LogContext.getLogContext().getLogger(name); final Logger logger = lmLogger.getAttachment(reposKey); if (logger != null) { return logger; } return create(lmLogger); }
public LoggerPluginInstance getInstance(String name, String resourceBundleName) { Logger logger = resourceBundleName == null ? Logger.getLogger(name) : Logger.getLogger(name, resourceBundleName); LoggerPluginInstance lpi = logger.getAttachment(KEY); if (lpi == null) { final SecurityManager sm = System.getSecurityManager(); lpi = new LoggerPluginInstanceImpl(name, resourceBundleName, logger, this); if (sm != null) { return AccessController.doPrivileged(new AttachAction(logger, lpi)); } else { return doAttach(logger, lpi); } } return lpi; }
private static Logger doLegacyGetLogger(final String name) { final org.jboss.logmanager.Logger lmLogger = LogContext.getLogContext().getLogger(""); ConcurrentMap<String, Logger> loggers = lmLogger.getAttachment(LEGACY_KEY); if (loggers == null) { loggers = new ConcurrentHashMap<String, Logger>(); final ConcurrentMap<String, Logger> appearing = lmLogger.attachIfAbsent(LEGACY_KEY, loggers); if (appearing != null) { loggers = appearing; } } Logger l = loggers.get(name); if (l != null) { return l; } final org.jboss.logmanager.Logger logger = org.jboss.logmanager.Logger.getLogger(name); l = new JBossLogManagerLogger(name, logger); final Logger appearing = loggers.putIfAbsent(name, l); if (appearing == null) { return l; } return appearing; }
private static Logger doLegacyGetLogger(final String name) { final org.jboss.logmanager.Logger lmLogger = LogContext.getLogContext().getLogger(""); ConcurrentMap<String, Logger> loggers = lmLogger.getAttachment(LEGACY_KEY); if (loggers == null) { loggers = new ConcurrentHashMap<String, Logger>(); final ConcurrentMap<String, Logger> appearing = lmLogger.attachIfAbsent(LEGACY_KEY, loggers); if (appearing != null) { loggers = appearing; } } Logger l = loggers.get(name); if (l != null) { return l; } final org.jboss.logmanager.Logger logger = org.jboss.logmanager.Logger.getLogger(name); l = new JBossLogManagerLogger(name, logger); final Logger appearing = loggers.putIfAbsent(name, l); if (appearing == null) { return l; } return appearing; }
private static Logger doLegacyGetLogger(final String name) { final org.jboss.logmanager.Logger lmLogger = LogContext.getLogContext().getLogger(""); ConcurrentMap<String, Logger> loggers = lmLogger.getAttachment(LEGACY_KEY); if (loggers == null) { loggers = new ConcurrentHashMap<String, Logger>(); final ConcurrentMap<String, Logger> appearing = lmLogger.attachIfAbsent(LEGACY_KEY, loggers); if (appearing != null) { loggers = appearing; } } Logger l = loggers.get(name); if (l != null) { return l; } final org.jboss.logmanager.Logger logger = org.jboss.logmanager.Logger.getLogger(name); l = new JBossLogManagerLogger(name, logger); final Logger appearing = loggers.putIfAbsent(name, l); if (appearing == null) { return l; } return appearing; }
private static Logger doLegacyGetLogger(final String name) { final org.jboss.logmanager.Logger lmLogger = LogContext.getLogContext().getLogger(""); ConcurrentMap<String, Logger> loggers = lmLogger.getAttachment(LEGACY_KEY); if (loggers == null) { loggers = new ConcurrentHashMap<String, Logger>(); final ConcurrentMap<String, Logger> appearing = lmLogger.attachIfAbsent(LEGACY_KEY, loggers); if (appearing != null) { loggers = appearing; } } Logger l = loggers.get(name); if (l != null) { return l; } final org.jboss.logmanager.Logger logger = org.jboss.logmanager.Logger.getLogger(name); l = new JBossLogManagerLogger(name, logger); final Logger appearing = loggers.putIfAbsent(name, l); if (appearing == null) { return l; } return appearing; }
private static Logger doLegacyGetLogger(final String name) { final org.jboss.logmanager.Logger lmLogger = LogContext.getLogContext().getLogger(""); ConcurrentMap<String, Logger> loggers = lmLogger.getAttachment(LEGACY_KEY); if (loggers == null) { loggers = new ConcurrentHashMap<String, Logger>(); final ConcurrentMap<String, Logger> appearing = lmLogger.attachIfAbsent(LEGACY_KEY, loggers); if (appearing != null) { loggers = appearing; } } Logger l = loggers.get(name); if (l != null) { return l; } final org.jboss.logmanager.Logger logger = org.jboss.logmanager.Logger.getLogger(name); l = new JBossLogManagerLogger(name, logger); final Logger appearing = loggers.putIfAbsent(name, l); if (appearing == null) { return l; } return appearing; }
private static Logger doLegacyGetLogger(final String name) { final org.jboss.logmanager.Logger lmLogger = LogContext.getLogContext().getLogger(""); ConcurrentMap<String, Logger> loggers = lmLogger.getAttachment(LEGACY_KEY); if (loggers == null) { loggers = new ConcurrentHashMap<String, Logger>(); final ConcurrentMap<String, Logger> appearing = lmLogger.attachIfAbsent(LEGACY_KEY, loggers); if (appearing != null) { loggers = appearing; } } Logger l = loggers.get(name); if (l != null) { return l; } final org.jboss.logmanager.Logger logger = org.jboss.logmanager.Logger.getLogger(name); l = new JBossLogManagerLogger(name, logger); final Logger appearing = loggers.putIfAbsent(name, l); if (appearing == null) { return l; } return appearing; }
private static Logger doLegacyGetLogger(final String name) { final org.jboss.logmanager.Logger lmLogger = LogContext.getLogContext().getLogger(""); ConcurrentMap<String, Logger> loggers = lmLogger.getAttachment(LEGACY_KEY); if (loggers == null) { loggers = new ConcurrentHashMap<String, Logger>(); final ConcurrentMap<String, Logger> appearing = lmLogger.attachIfAbsent(LEGACY_KEY, loggers); if (appearing != null) { loggers = appearing; } } Logger l = loggers.get(name); if (l != null) { return l; } final org.jboss.logmanager.Logger logger = org.jboss.logmanager.Logger.getLogger(name); l = new JBossLogManagerLogger(name, logger); final Logger appearing = loggers.putIfAbsent(name, l); if (appearing == null) { return l; } return appearing; }
/** * Gets the property configurator. If the {@link ConfigurationPersistence} does not exist a new one is created. * * @param logContext the log context used to find the property configurator or to attach it to. * * @return the property configurator */ public static ConfigurationPersistence getOrCreateConfigurationPersistence(final LogContext logContext) { final Logger root = logContext.getLogger(CommonAttributes.ROOT_LOGGER_NAME); ConfigurationPersistence result = (ConfigurationPersistence) root.getAttachment(Configurator.ATTACHMENT_KEY); if (result == null) { result = new ConfigurationPersistence(logContext); ConfigurationPersistence existing = (ConfigurationPersistence) root.attachIfAbsent(Configurator.ATTACHMENT_KEY, result); if (existing != null) { result = existing; } } return result; }
private LogContextConfiguration getOrCreateConfiguration(final org.jboss.logmanager.Logger rootLogger) { Configurator configurator = rootLogger.getAttachment(Configurator.ATTACHMENT_KEY); if (configurator == null) { configurator = new PropertyConfigurator(rootLogger.getLogContext()); final Configurator appearing = rootLogger.attachIfAbsent(Configurator.ATTACHMENT_KEY, configurator); if (appearing != null) { configurator = appearing; } } if (configurator instanceof PropertyConfigurator) { return ((PropertyConfigurator) configurator).getLogContextConfiguration(); } if (configurator instanceof LogContextConfiguration) { return (LogContextConfiguration) configurator; } return null; } }
private LoggingConfigurationUpdater getOrCreateUpdater() { final LogContext logContext = LogContext.getLogContext(); final org.jboss.logmanager.Logger rootLogger = logContext.getLogger(""); LoggingConfigurationUpdater updater = rootLogger.getAttachment(KEY); if (updater == null) { final LogContextConfiguration logContextConfiguration = getOrCreateConfiguration(rootLogger); if (logContextConfiguration == null) { return null; } updater = new LoggingConfigurationUpdater(logContextConfiguration); final LoggingConfigurationUpdater appearing = rootLogger.attachIfAbsent(KEY, updater); if (appearing != null) { updater = appearing; } } return updater; }
@Override public StdioContext getStdioContext() { final LogContext logContext = LogContext.getLogContext(); final Logger root = logContext.getLogger(CommonAttributes.ROOT_LOGGER_NAME); StdioContext stdioContext = root.getAttachment(STDIO_CONTEXT_ATTACHMENT_KEY); if (stdioContext == null) { stdioContext = StdioContext.create( new NullInputStream(), new LoggingOutputStream(logContext.getLogger("stdout"), Level.INFO), new LoggingOutputStream(logContext.getLogger("stderr"), Level.ERROR) ); final StdioContext appearing = root.attachIfAbsent(STDIO_CONTEXT_ATTACHMENT_KEY, stdioContext); if (appearing != null) { stdioContext = appearing; } } return stdioContext; } }
@Override public StdioContext getStdioContext() { final LogContext logContext = LogContext.getLogContext(); final Logger root = logContext.getLogger(CommonAttributes.ROOT_LOGGER_NAME); StdioContext stdioContext = root.getAttachment(STDIO_CONTEXT_ATTACHMENT_KEY); if (stdioContext == null) { stdioContext = StdioContext.create( new NullInputStream(), new LoggingOutputStream(logContext.getLogger("stdout"), Level.INFO), new LoggingOutputStream(logContext.getLogger("stderr"), Level.ERROR) ); final StdioContext appearing = root.attachIfAbsent(STDIO_CONTEXT_ATTACHMENT_KEY, stdioContext); if (appearing != null) { stdioContext = appearing; } } return stdioContext; } }
@Override public StdioContext getStdioContext() { final LogContext logContext = LogContext.getLogContext(); final Logger root = logContext.getLogger(CommonAttributes.ROOT_LOGGER_NAME); StdioContext stdioContext = root.getAttachment(STDIO_CONTEXT_ATTACHMENT_KEY); if (stdioContext == null) { stdioContext = StdioContext.create( new NullInputStream(), new LoggingOutputStream(logContext.getLogger("stdout"), Level.INFO), new LoggingOutputStream(logContext.getLogger("stderr"), Level.ERROR) ); final StdioContext appearing = root.attachIfAbsent(STDIO_CONTEXT_ATTACHMENT_KEY, stdioContext); if (appearing != null) { stdioContext = appearing; } } return stdioContext; } }