本文整理了Java中org.apache.wicket.ThreadContext.setRequestCycle()
方法的一些代码示例,展示了ThreadContext.setRequestCycle()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ThreadContext.setRequestCycle()
方法的具体详情如下:
包路径:org.apache.wicket.ThreadContext
类名称:ThreadContext
方法名:setRequestCycle
[英]Binds the RequestCycle to current thread.
[中]将RequestCycle绑定到当前线程。
代码示例来源:origin: org.apache.wicket/wicket-core
/**
*
* @param requestCycle
*/
private static void set(RequestCycle requestCycle)
{
ThreadContext.setRequestCycle(requestCycle);
}
代码示例来源:origin: apache/wicket
/**
*
* @param requestCycle
*/
private static void set(RequestCycle requestCycle)
{
ThreadContext.setRequestCycle(requestCycle);
}
代码示例来源:origin: at.molindo/molindo-wicket-utils
/**
* @deprecated use {@link ThreadContext#setRequestCycle(RequestCycle)}
* directly
*/
@Deprecated
public static void set(RequestCycle requestCycle) {
ThreadContext.setRequestCycle(null);
}
}
代码示例来源:origin: at.molindo/molindo-wicket-utils
/**
* @deprecated use {@link ThreadContext#setRequestCycle(RequestCycle)}
* directly
*/
@Deprecated
public static void unset(RequestCycle requestCycle) {
ThreadContext.setRequestCycle(null);
}
代码示例来源:origin: OrienteerBAP/Orienteer
private void executeInNewThread(Runnable runnable) {
OrienteerWebSession session = OrienteerWebSession.get();
OrienteerWebApplication app = OrienteerWebApplication.get();
RequestCycle requestCycle = RequestCycle.get();
new Thread(() -> {
ThreadContext.setSession(session);
ThreadContext.setApplication(app);
ThreadContext.setRequestCycle(requestCycle);
runnable.run();
}).start();
}
代码示例来源:origin: apache/wicket
@Override
protected boolean processRequestCycle(final RequestCycle requestCycle, final WebResponse webResponse,
final HttpServletRequest httpServletRequest, final HttpServletResponse httpServletResponse,
final FilterChain chain)
throws IOException, ServletException
{
// Assume we are able to handle the request
boolean res = true;
ThreadContext.setRequestCycle(requestCycle);
if (acceptWebSocket(httpServletRequest, httpServletResponse) || httpServletResponse.isCommitted())
{
res = true;
}
else if (requestCycle.processRequestAndDetach() || httpServletResponse.isCommitted())
{
webResponse.flush();
}
else
{
if (chain != null)
{
chain.doFilter(httpServletRequest, httpServletResponse);
}
res = false;
}
return res;
}
代码示例来源:origin: org.apache.wicket/wicket-native-websocket-core
protected boolean processRequestCycle(final RequestCycle requestCycle, final WebResponse webResponse,
final HttpServletRequest httpServletRequest, final HttpServletResponse httpServletResponse,
final FilterChain chain)
throws IOException, ServletException
{
// Assume we are able to handle the request
boolean res = true;
ThreadContext.setRequestCycle(requestCycle);
if (acceptWebSocket(httpServletRequest, httpServletResponse) || httpServletResponse.isCommitted())
{
res = true;
}
else if (requestCycle.processRequestAndDetach() || httpServletResponse.isCommitted())
{
webResponse.flush();
}
else
{
if (chain != null)
{
chain.doFilter(httpServletRequest, httpServletResponse);
}
res = false;
}
return res;
}
代码示例来源:origin: OrienteerBAP/Orienteer
@Override
public CompletableFuture<Void> fetchMailsAsync(OMailSettings settings, String folderName, Consumer<Message> consumer) {
OrienteerWebSession session = OrienteerWebSession.get();
OrienteerWebApplication app = OrienteerWebApplication.get();
RequestCycle requestCycle = RequestCycle.get();
return CompletableFuture.runAsync(() -> {
ThreadContext.setSession(session);
ThreadContext.setApplication(app);
ThreadContext.setRequestCycle(requestCycle);
try {
fetchMails(settings, folderName, consumer);
} catch (Exception ex) {
LOG.error("Error during fetching mails: {}", settings, ex);
}
});
}
代码示例来源:origin: OrienteerBAP/Orienteer
private void performTask(OSendMailTaskSessionRuntime runtime) {
OrienteerWebSession session = OrienteerWebSession.get();
OrienteerWebApplication app = OrienteerWebApplication.get();
RequestCycle requestCycle = RequestCycle.get();
new Thread(() -> {
ThreadContext.setSession(session);
ThreadContext.setApplication(app);
ThreadContext.setRequestCycle(requestCycle);
DBClosure.sudoConsumer(db -> {
try {
sendMails(runtime);
} catch (Exception ex) {
LOG.error("Error occurred during perform task {}", OSendMailTask.this, ex);
} finally {
runtime.finish();
}
});
}).start();
}
代码示例来源:origin: org.apache.wicket/wicket-core
/**
* Collects the html generated by rendering a page.
*
* @param page
* supplier of the page
* @return the html rendered by the panel
*/
public CharSequence renderPage(final Supplier<? extends Page> page)
{
return inThreadContext(() -> {
Request request = newRequest();
BufferedWebResponse response = new BufferedWebResponse(null);
RequestCycle cycle = application.createRequestCycle(request, response);
ThreadContext.setRequestCycle(cycle);
page.get().renderPage();
return response.getText();
});
}
代码示例来源:origin: apache/wicket
/**
* Collects the html generated by rendering a page.
*
* @param page
* supplier of the page
* @return the html rendered by the panel
*/
public CharSequence renderPage(final Supplier<? extends Page> page)
{
return inThreadContext(() -> {
Request request = newRequest();
BufferedWebResponse response = new BufferedWebResponse(null);
RequestCycle cycle = application.createRequestCycle(request, response);
ThreadContext.setRequestCycle(cycle);
page.get().renderPage();
return response.getText();
});
}
代码示例来源:origin: org.apache.wicket/wicket-core
/**
* Collects the Html generated by the rendering a page.
* <p>
* Important note: Must be called on a thread bound to an application's {@link ThreadContext}!
*
* @param pageProvider
* the provider of the page class/instance and its parameters
* @return the html rendered by a page
*
* @see ThreadContext
*/
public static CharSequence renderPage(final PageProvider pageProvider)
{
Application application = Application.get();
RequestCycle originalRequestCycle = RequestCycle.get();
BufferedWebResponse tempResponse = new BufferedWebResponse(null);
RequestCycle tempRequestCycle = application
.createRequestCycle(originalRequestCycle.getRequest(), tempResponse);
try
{
ThreadContext.setRequestCycle(tempRequestCycle);
pageProvider.getPageInstance().renderPage();
}
finally
{
ThreadContext.setRequestCycle(originalRequestCycle);
}
return tempResponse.getText();
}
代码示例来源:origin: apache/wicket
/**
* Collects the Html generated by the rendering a page.
* <p>
* Important note: Must be called on a thread bound to an application's {@link ThreadContext}!
*
* @param pageProvider
* the provider of the page class/instance and its parameters
* @return the html rendered by a page
*
* @see ThreadContext
*/
public static CharSequence renderPage(final PageProvider pageProvider)
{
Application application = Application.get();
RequestCycle originalRequestCycle = RequestCycle.get();
BufferedWebResponse tempResponse = new BufferedWebResponse(null);
RequestCycle tempRequestCycle = application
.createRequestCycle(originalRequestCycle.getRequest(), tempResponse);
try
{
ThreadContext.setRequestCycle(tempRequestCycle);
pageProvider.getPageInstance().renderPage();
}
finally
{
ThreadContext.setRequestCycle(originalRequestCycle);
}
return tempResponse.getText();
}
代码示例来源:origin: com.norconex.commons/norconex-commons-wicket
/**
* Invoke this method in the new thread before doing something with Wicket.
*/
public void mock() {
ThreadContext.setApplication(application);
ThreadContext.setSession(session);
final MockServletContext context =
new MockServletContext(application, SystemUtils.JAVA_IO_TMPDIR);
ThreadContext.setRequestCycle(
application.createRequestCycle(new MockWebRequest(
Url.parse("http://localhost/mock")) {
@Override
public Object getContainerRequest() {
return new MockHttpServletRequest(
application, new MockHttpSession(context), context);
}
},
new MockWebResponse())
);
}
}
代码示例来源:origin: apache/wicket
ThreadContext.setRequestCycle(requestCycle);
ThreadContext.setRequestCycle(oldRequestCycle);
ThreadContext.setSession(oldSession);
代码示例来源:origin: org.apache.wicket/wicket-native-websocket-core
ThreadContext.setRequestCycle(requestCycle);
ThreadContext.setRequestCycle(oldRequestCycle);
ThreadContext.setSession(oldSession);
代码示例来源:origin: theonedev/onedev
ThreadContext.setRequestCycle(requestCycle);
ThreadContext.setRequestCycle(oldRequestCycle);
ThreadContext.setSession(oldSession);
代码示例来源:origin: at.molindo/molindo-wicket-utils
ThreadContext.setRequestCycle(webApplication.createRequestCycle(request, response));
代码示例来源:origin: org.apache.wicket/wicket-core
requestCycle = application.createRequestCycle(servletWebRequest,
newServletWebResponse(servletWebRequest));
ThreadContext.setRequestCycle(requestCycle);
代码示例来源:origin: apache/wicket
requestCycle = application.createRequestCycle(servletWebRequest,
newServletWebResponse(servletWebRequest));
ThreadContext.setRequestCycle(requestCycle);
内容来源于网络,如有侵权,请联系作者删除!