當前位置: 首頁>>代碼示例>>Java>>正文


Java Configurator類代碼示例

本文整理匯總了Java中org.jboss.logmanager.Configurator的典型用法代碼示例。如果您正苦於以下問題:Java Configurator類的具體用法?Java Configurator怎麽用?Java Configurator使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Configurator類屬於org.jboss.logmanager包,在下文中一共展示了Configurator類的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getOrCreateConfigurationPersistence

import org.jboss.logmanager.Configurator; //導入依賴的package包/類
/**
 * 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);
    final ConfigurationPersistence result;
    synchronized (LOCK) {
        Configurator configurator = root.getAttachment(Configurator.ATTACHMENT_KEY);
        if (configurator == null) {
            configurator = new ConfigurationPersistence(logContext);
            Configurator existing = root.attachIfAbsent(Configurator.ATTACHMENT_KEY, configurator);
            if (existing != null) {
                configurator = existing;
            }
        }
        if (configurator instanceof ConfigurationPersistence) {
            // We have the correct configurator
            result = (ConfigurationPersistence) configurator;
        } else if (configurator instanceof PropertyConfigurator) {
            // Create a new configurator delegating to the configurator found
            result = new ConfigurationPersistence((PropertyConfigurator) configurator);
            root.attach(Configurator.ATTACHMENT_KEY, result);
        } else {
            // An unknown configurator, log a warning and replace
            LoggingLogger.ROOT_LOGGER.replacingConfigurator(configurator);
            result = new ConfigurationPersistence(logContext);
            root.attach(Configurator.ATTACHMENT_KEY, result);
        }
    }
    return result;
}
 
開發者ID:wildfly,項目名稱:wildfly-core,代碼行數:36,代碼來源:ConfigurationPersistence.java

示例2: clearLogContext

import org.jboss.logmanager.Configurator; //導入依賴的package包/類
/**
 * Attempts to clear the global log context used for embedded servers.
 */
static synchronized void clearLogContext() {
    final LogContext embeddedLogContext = Holder.LOG_CONTEXT;
    // Remove the configurator and clear the log context
    final Configurator configurator = embeddedLogContext.getLogger("").detach(Configurator.ATTACHMENT_KEY);
    // If this was a PropertyConfigurator we can use the LogContextConfiguration API to tear down the LogContext
    if (configurator instanceof PropertyConfigurator) {
        final LogContextConfiguration logContextConfiguration = ((PropertyConfigurator) configurator).getLogContextConfiguration();
        clearLogContext(logContextConfiguration);
    } else if (configurator instanceof LogContextConfiguration) {
        clearLogContext((LogContextConfiguration) configurator);
    } else {
        // Remove all the handlers and close them as well as reset the loggers
        final List<String> loggerNames = Collections.list(embeddedLogContext.getLoggerNames());
        for (String name : loggerNames) {
            final Logger logger = embeddedLogContext.getLoggerIfExists(name);
            if (logger != null) {
                final Handler[] handlers = logger.clearHandlers();
                if (handlers != null) {
                    for (Handler handler : handlers) {
                        handler.close();
                    }
                }
                logger.setFilter(null);
                logger.setUseParentFilters(false);
                logger.setUseParentHandlers(true);
                logger.setLevel(Level.INFO);
            }
        }
    }
}
 
開發者ID:wildfly,項目名稱:wildfly-core,代碼行數:34,代碼來源:EmbeddedLogContext.java

示例3: getConfigurationPersistence

import org.jboss.logmanager.Configurator; //導入依賴的package包/類
/**
 * Gets the property configurator. If the {@link ConfigurationPersistence} does not exist a {@code null} is
 * returned.
 *
 * @param logContext the log context used to find the property configurator or to attach it to.
 *
 * @return the property configurator or {@code null}
 */
public static ConfigurationPersistence getConfigurationPersistence(final LogContext logContext) {
    if (logContext == null) return null;
    return (ConfigurationPersistence) logContext.getAttachment(CommonAttributes.ROOT_LOGGER_NAME, Configurator.ATTACHMENT_KEY);
}
 
開發者ID:wildfly,項目名稱:wildfly-core,代碼行數:13,代碼來源:ConfigurationPersistence.java

示例4: replacingConfigurator

import org.jboss.logmanager.Configurator; //導入依賴的package包/類
/**
 * Logs a warning message indicating the configurator class is an unknown type and will be replaced.
 *
 * @param c the class that is being replaced
 */
@LogMessage(level = WARN)
@Message(id = 13, value = "A configurator class, '%s', is not a known configurator and will be replaced.")
void replacingConfigurator(@Transform(TransformType.GET_CLASS) Configurator c);
 
開發者ID:wildfly,項目名稱:wildfly-core,代碼行數:9,代碼來源:LoggingLogger.java


注:本文中的org.jboss.logmanager.Configurator類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。