当前位置: 首页>>代码示例>>Java>>正文


Java ThreadContext.clearStack方法代码示例

本文整理汇总了Java中org.apache.logging.log4j.ThreadContext.clearStack方法的典型用法代码示例。如果您正苦于以下问题:Java ThreadContext.clearStack方法的具体用法?Java ThreadContext.clearStack怎么用?Java ThreadContext.clearStack使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.logging.log4j.ThreadContext的用法示例。


在下文中一共展示了ThreadContext.clearStack方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: beforeExecute

import org.apache.logging.log4j.ThreadContext; //导入方法依赖的package包/类
@Override
protected void beforeExecute(Thread t, Runnable r) {
    ThreadContext.clearMap();
    ThreadContext.clearStack();

    ThreadAroundHook debugHook = null;
    List<ThreadAroundHook> tmpHooks;       
    synchronized (_hooks) {
        tmpHooks = new ArrayList<ThreadAroundHook>(_hooks);
    }
    
    for (ThreadAroundHook hook : tmpHooks) {
        debugHook = hook;
        try {
            hook.beforeExecute(t, r);
        } catch (Exception e) {
            _logger.warn("Unhandle exception happend during executing ThreadAroundHook: " + debugHook.getClass().getCanonicalName(), e);
        }
    }
}
 
开发者ID:zstackio,项目名称:zstack,代码行数:21,代码来源:ScheduledThreadPoolExecutorExt.java

示例2: afterExecute

import org.apache.logging.log4j.ThreadContext; //导入方法依赖的package包/类
@Override
protected void afterExecute(Runnable r, Throwable t) {
    ThreadContext.clearMap();
    ThreadContext.clearStack();

    ThreadAroundHook debugHook = null;
    List<ThreadAroundHook> tmpHooks;
    synchronized (_hooks) {
        tmpHooks = new ArrayList<ThreadAroundHook>(_hooks);
    }
    
    for (ThreadAroundHook hook : tmpHooks) {
        debugHook = hook;
        try {
            hook.afterExecute(r, t);
        } catch (Exception e) {
            _logger.warn("Unhandle exception happend during executing ThreadAroundHook: " + debugHook.getClass().getCanonicalName(), e);
        }
    }
}
 
开发者ID:zstackio,项目名称:zstack,代码行数:21,代码来源:ScheduledThreadPoolExecutorExt.java

示例3: testConvert01

import org.apache.logging.log4j.ThreadContext; //导入方法依赖的package包/类
@Test
public void testConvert01() {
    ThreadContext.clearStack();
    final ThreadContext.ContextStack stack = new MutableThreadContextStack(
            Arrays.asList("value1", "another2"));

    final String converted = this.converter.convertToDatabaseColumn(stack);

    assertNotNull("The converted value should not be null.", converted);

    final ThreadContext.ContextStack reversed = this.converter
            .convertToEntityAttribute(converted);

    assertNotNull("The reversed value should not be null.", reversed);
    assertEquals("The reversed value is not correct.", stack.asList(),
            reversed.asList());
}
 
开发者ID:OuZhencong,项目名称:log4j2,代码行数:18,代码来源:ContextStackJsonAttributeConverterTest.java

示例4: testConvert02

import org.apache.logging.log4j.ThreadContext; //导入方法依赖的package包/类
@Test
public void testConvert02() {
    ThreadContext.clearStack();
    final ThreadContext.ContextStack stack = new MutableThreadContextStack(
            Arrays.asList("key1", "value2", "my3"));

    final String converted = this.converter.convertToDatabaseColumn(stack);

    assertNotNull("The converted value should not be null.", converted);

    final ThreadContext.ContextStack reversed = this.converter
            .convertToEntityAttribute(converted);

    assertNotNull("The reversed value should not be null.", reversed);
    assertEquals("The reversed value is not correct.", stack.asList(),
            reversed.asList());
}
 
开发者ID:OuZhencong,项目名称:log4j2,代码行数:18,代码来源:ContextStackJsonAttributeConverterTest.java

示例5: before

import org.apache.logging.log4j.ThreadContext; //导入方法依赖的package包/类
@Override
protected void before() throws Throwable {
    threadContextHolder = new ThreadContextHolder(restoreMap, restoreStack);
    if (restoreMap) {
        ThreadContext.clearMap();
    }
    if (restoreStack) {
        ThreadContext.clearStack();
    }
}
 
开发者ID:apache,项目名称:logging-log4j2,代码行数:11,代码来源:ThreadContextRule.java

示例6: testGetImmutableStackReturnsEmptyStackIfEmpty

import org.apache.logging.log4j.ThreadContext; //导入方法依赖的package包/类
public static void testGetImmutableStackReturnsEmptyStackIfEmpty() {
    ThreadContext.clearStack();
    assertTrue(ThreadContext.getImmutableStack().asList().isEmpty());
}
 
开发者ID:apache,项目名称:logging-log4j2,代码行数:5,代码来源:ThreadContextUtilityClass.java


注:本文中的org.apache.logging.log4j.ThreadContext.clearStack方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。