本文整理汇总了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);
}
}
}
示例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);
}
}
}
示例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());
}
示例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());
}
示例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();
}
}
示例6: testGetImmutableStackReturnsEmptyStackIfEmpty
import org.apache.logging.log4j.ThreadContext; //导入方法依赖的package包/类
public static void testGetImmutableStackReturnsEmptyStackIfEmpty() {
ThreadContext.clearStack();
assertTrue(ThreadContext.getImmutableStack().asList().isEmpty());
}