org.springframework.web.context.request.RequestContextHolder#resetRequestAttributes ( )源码实例Demo

下面列出了org.springframework.web.context.request.RequestContextHolder#resetRequestAttributes ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: Milkomeda   文件: RequestContextDecorator.java
@Override
public Runnable decorate(Runnable runnable) {
    RequestAttributes context;
    try {
        context = RequestContextHolder.currentRequestAttributes();
    } catch (Exception e) {
        return runnable;
    }
    RequestAttributes finalContext = context;
    return () -> {
        try {
            RequestContextHolder.setRequestAttributes(finalContext);
            runnable.run();
        } finally {
            RequestContextHolder.resetRequestAttributes();
        }
    };
}
 
源代码2 项目: staffjoy   文件: ContextCopyingDecorator.java
@Override
public Runnable decorate(Runnable runnable) {
    RequestAttributes context = RequestContextHolder.currentRequestAttributes();
    return () -> {
        try {
            RequestContextHolder.setRequestAttributes(context);
            runnable.run();
        } finally {
            RequestContextHolder.resetRequestAttributes();
        }
    };
}
 
@Override
public T call() throws Exception {
    try {
        RequestContextHolder.setRequestAttributes(requestAttributes);
        return target.call();
    }
    finally {
        RequestContextHolder.resetRequestAttributes();
    }
}
 
@Override
public T call() throws Exception {
    try {
        RequestContextHolder.setRequestAttributes(requestAttributes);
        return target.call();
    } finally {
        RequestContextHolder.resetRequestAttributes();
    }
}
 
/**
 * @since 4.3
 */
@Test
public void activateListenerWithoutExistingRequestAttributes() throws Exception {
	BDDMockito.<Class<?>> given(testContext.getTestClass()).willReturn(NoAtWebAppConfigWebTestCase.class);
	given(testContext.getAttribute(ServletTestExecutionListener.ACTIVATE_LISTENER)).willReturn(true);

	RequestContextHolder.resetRequestAttributes();
	listener.beforeTestClass(testContext);
	assertRequestAttributesDoNotExist();

	assertWebAppConfigTestCase();
}
 
@Override
public T call() throws Exception {
    try {
        RequestContextHolder.setRequestAttributes(requestAttributes);
        return target.call();
    } finally {
        RequestContextHolder.resetRequestAttributes();
    }
}
 
源代码7 项目: mogu_blog_v2   文件: RequestAwareRunnable.java
@Override
public void run() {
    try {
        RequestContextHolder.setRequestAttributes(requestAttributes);
        onRun();
    } finally {
        if (Thread.currentThread() != thread) {
            RequestContextHolder.resetRequestAttributes();
        }
        thread = null;
    }
}
 
源代码8 项目: mogu_blog_v2   文件: RequestAwareRunnable.java
@Override
public void run() {
    try {
        RequestContextHolder.setRequestAttributes(requestAttributes);
        onRun();
    } finally {
        if (Thread.currentThread() != thread) {
            RequestContextHolder.resetRequestAttributes();
        }
        thread = null;
    }
}
 
@After
public void resetRequestContextHolder() {
	RequestContextHolder.resetRequestAttributes();
}
 
@After
public void teardown() {
	RequestContextHolder.resetRequestAttributes();
}
 
@After
public void reset() {
	RequestContextHolder.resetRequestAttributes();
}
 
private void resetContextHolders() {
	LocaleContextHolder.resetLocaleContext();
	RequestContextHolder.resetRequestAttributes();
}
 
@After
public void teardown() {
	RequestContextHolder.resetRequestAttributes();
}
 
@After
public void reset() {
	RequestContextHolder.resetRequestAttributes();
}
 
@After
public void tearDown() throws Exception {
	RequestContextHolder.resetRequestAttributes();
}
 
@After
public void tearDown() throws Exception {
	RequestContextHolder.resetRequestAttributes();
}
 
@After
public void teardown() {
	RequestContextHolder.resetRequestAttributes();
}
 
@After
public void resetRequestContextHolder() {
	RequestContextHolder.resetRequestAttributes();
}
 
@After
public void teardown() {
	RequestContextHolder.resetRequestAttributes();
}
 
源代码20 项目: spring-webmvc-support   文件: WebMvcUtilsTest.java
@Before
public void init() {

    servletContext = new MockServletContext();

    request = new MockHttpServletRequest(servletContext);

    RequestContextHolder.resetRequestAttributes();

}