当前位置: 首页>>代码示例>>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;未经允许,请勿转载。