本文整理了Java中org.apache.wicket.ThreadContext.detach()
方法的一些代码示例,展示了ThreadContext.detach()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ThreadContext.detach()
方法的具体详情如下:
包路径:org.apache.wicket.ThreadContext
类名称:ThreadContext
方法名:detach
[英]Cleans the ThreadContext and returns previous context.
[中]清除ThreadContext并返回上一个上下文。
代码示例来源:origin: org.apache.wicket/wicket-core
private void cleanupBoundApplicationAndSession()
{
ThreadContext.detach();
}
代码示例来源:origin: apache/wicket
private void cleanupBoundApplicationAndSession()
{
ThreadContext.detach();
}
代码示例来源:origin: at.molindo/molindo-wicket-utils
/**
* unset request and session to force mocking
*/
public static <V> V withNewRequest(WebApplication webApplication, IMockRequestCallback<V> callback) {
ThreadContext oldContext = ThreadContext.detach();
try {
return withRequest(webApplication, callback);
} finally {
ThreadContext.restore(oldContext);
}
}
代码示例来源:origin: org.apache.wicket/wicket-core
/**
* Destroys the tester. Restores {@link ThreadContext} to state before instance of
* {@link WicketTester} was created.
*/
public void destroy()
{
try
{
ThreadContext.setApplication(application);
application.internalDestroy();
}
finally
{
ThreadContext.detach();
}
}
代码示例来源:origin: org.apache.wicket/wicket-core
/**
* Get the result from the given supplier inside a bound {@link ThreadContext}.
*
* @param supplier
* supplier
* @return result of {@link Supplier#get()}
*/
private <T> T inThreadContext(Supplier<T> supplier)
{
ThreadContext oldContext = ThreadContext.detach();
try
{
ThreadContext.setApplication(application);
return supplier.get();
}
finally
{
ThreadContext.restore(oldContext);
}
}
代码示例来源:origin: apache/wicket
/**
* Get the result from the given supplier inside a bound {@link ThreadContext}.
*
* @param supplier
* supplier
* @return result of {@link Supplier#get()}
*/
private <T> T inThreadContext(Supplier<T> supplier)
{
ThreadContext oldContext = ThreadContext.detach();
try
{
ThreadContext.setApplication(application);
return supplier.get();
}
finally
{
ThreadContext.restore(oldContext);
}
}
代码示例来源:origin: apache/wicket
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable
{
boolean existed = ThreadContext.exists();
if (existed == false)
{
ThreadContext.setApplication(application);
}
try
{
return method.invoke(o, args);
}
finally
{
if (existed == false)
{
ThreadContext.detach();
}
}
}
});
代码示例来源:origin: apache/wicket
/**
* Destroys the tester. Restores {@link ThreadContext} to state before instance of
* {@link WicketTester} was created.
*/
public void destroy()
{
try
{
ThreadContext.setApplication(application);
application.internalDestroy();
}
finally
{
ThreadContext.detach();
}
}
代码示例来源:origin: apache/syncope
@Override
public String call() throws Exception {
ThreadContext.setApplication(application);
ThreadContext.setSession(session);
try {
final ConnInstanceTO connector = connectorRestClient.read(key);
return String.format("{ \"status\": \"%s\", \"target\": \"%s\"}",
connectorRestClient.check(connector).getLeft()
? TopologyNode.Status.REACHABLE : TopologyNode.Status.UNREACHABLE, key);
} catch (Exception e) {
LOG.warn("Error checking connection for {}", key, e);
return String.format("{ \"status\": \"%s\", \"target\": \"%s\"}",
TopologyNode.Status.FAILURE, key);
} finally {
ThreadContext.detach();
}
}
}
代码示例来源:origin: apache/syncope
@Override
public String call() throws Exception {
ThreadContext.setApplication(application);
ThreadContext.setSession(session);
try {
final ResourceTO resource = resourceRestClient.read(key);
return String.format("{ \"status\": \"%s\", \"target\": \"%s\"}",
resourceRestClient.check(resource).getLeft()
? TopologyNode.Status.REACHABLE : TopologyNode.Status.UNREACHABLE, key);
} catch (Exception e) {
LOG.warn("Error checking connection for {}", key, e);
return String.format("{ \"status\": \"%s\", \"target\": \"%s\"}",
TopologyNode.Status.FAILURE,
key);
} finally {
ThreadContext.detach();
}
}
}
代码示例来源:origin: org.apache.wicket/wicket-core
/**
* @see junit.framework.TestCase#setUp()
*/
@Before
public void commonBefore()
{
// make sure no leaked threadlocals are present
ThreadContext.detach();
WebApplication application = newApplication();
tester = newWicketTester(application);
}
代码示例来源:origin: org.apache.wicket/wicket-atmosphere
private void postToSingleResource(Object payload, AtmosphereResource resource)
{
AtmosphereEvent event = new AtmosphereEvent(payload, resource);
ThreadContext.detach();
ThreadContext.setApplication(application);
PageKey key;
Collection<EventSubscription> subscriptionsForPage;
synchronized (this)
{
key = trackedPages.get(resource.uuid());
subscriptionsForPage = Collections2.filter(
Collections.unmodifiableCollection(subscriptions.get(key)), new EventFilter(event));
}
if (key == null)
broadcaster.removeAtmosphereResource(resource);
else if (!subscriptionsForPage.isEmpty())
post(resource, key, subscriptionsForPage, event);
}
代码示例来源:origin: apache/wicket
/**
*/
@BeforeEach
public void commonBefore()
{
// make sure no leaked threadlocals are present
ThreadContext.detach();
WebApplication application = newApplication();
tester = newWicketTester(application);
}
代码示例来源:origin: org.apache.wicket.experimental.wicket8/wicket-atmosphere
private void postToSingleResource(Object payload, AtmosphereResource resource)
{
AtmosphereEvent event = new AtmosphereEvent(payload, resource);
ThreadContext.detach();
ThreadContext.setApplication(application);
PageKey key;
Iterable<EventSubscription> subscriptionsForPage;
synchronized (this)
{
key = trackedPages.get(resource.uuid());
Collection<EventSubscription> eventSubscriptions = subscriptions.get(key);
subscriptionsForPage = Iterables.filter(ImmutableList.copyOf(eventSubscriptions),
new EventFilter(event));
}
if (key == null)
getBroadcaster().removeAtmosphereResource(resource);
else
{
Iterator<EventSubscription> iterator = subscriptionsForPage.iterator();
if (iterator.hasNext())
post(resource, key, iterator, event);
}
}
代码示例来源:origin: apache/syncope
@Override
public void run() {
ThreadContext.setApplication(application);
ThreadContext.setSession(session);
try {
timeoutHandlingConnectionChecker(
new ResourceChecker(key, this.application),
resourceTestTimeout,
resources,
runningResCheck);
} finally {
ThreadContext.detach();
}
}
}
代码示例来源:origin: org.apache.wicket/wicket-core
ThreadContext.detach();
application = null;
代码示例来源:origin: apache/syncope
@Override
public void run() {
ThreadContext.setApplication(application);
ThreadContext.setSession(session);
try {
timeoutHandlingConnectionChecker(
new ConnectorChecker(key, this.application),
connectorTestTimeout,
connectors,
runningConnCheck);
} finally {
ThreadContext.detach();
}
}
}
代码示例来源:origin: org.apache.wicket/wicket-native-websocket-javax
@Override
public void onOpen(Session session, EndpointConfig endpointConfig)
{
String appName = getApplicationName(session);
WebApplication app = (WebApplication) WebApplication.get(appName);
app.getApplicationListeners().add(new ApplicationListener(applicationDestroyed));
try
{
ThreadContext.setApplication(app);
javaxWebSocketProcessor = new JavaxWebSocketProcessor(session, app, endpointConfig);
}
finally
{
ThreadContext.detach();
}
}
代码示例来源:origin: apache/wicket
@Override
public void onOpen(Session session, EndpointConfig endpointConfig)
{
String appName = getApplicationName(session);
WebApplication app = (WebApplication) WebApplication.get(appName);
app.getApplicationListeners().add(new ApplicationListener(applicationDestroyed));
try
{
ThreadContext.setApplication(app);
javaxWebSocketProcessor = new JavaxWebSocketProcessor(session, app, endpointConfig);
}
finally
{
ThreadContext.detach();
}
}
代码示例来源:origin: at.molindo/molindo-wicket-utils
ThreadContext oldContext = ThreadContext.detach();
内容来源于网络,如有侵权,请联系作者删除!