@Override public void run() { getContext().runWithContext(new Runnable() { @Override public void run() { runInContext(); } }); }
private void processRequest(final HttpServletRequest req, final HttpServletResponse resp) { managedContext.runWithContext(new Runnable() { @Override public void run() { processRequestInContext(req, resp); } }); }
@Override public void run() { runInContext(); } });
boolean reentry = !ManagedContextUtils.setAndCheckOwner(owner); Throwable firstError = null; data = listener.onEnterContext(reentry); } catch (Throwable t) { invocations.push(new ListenerInvocation((ManagedContextListener<Object>)listener, data)); throwException(firstError); return null; ListenerInvocation invocation = invocations.pop(); try { invocation.listener.onLeaveContext(invocation.data, reentry); } catch (Throwable t) { lastError = t; throwException(lastError); if (ManagedContextUtils.clearOwner(owner)) ManagedThreadLocal.reset();
@Override public void runWithContext(final Runnable run) { try { callWithContext(new Callable<Object>() { @Override public Object call() throws Exception { run.run(); return null; } }); } catch (Exception e) { /* Only care about non-checked exceptions * as the nature of runnable prevents checked * exceptions from happening */ ManagedContextUtils.rethrowException(e); } }
protected void throwException(Throwable t) throws Exception { ManagedContextUtils.rethrowException(t); if (t instanceof Exception) { throw (Exception)t; } }
@Override protected void runInContext() { ManagedContextTimerTask.this.runInContext(); } }.run();
@Override public final void run() { new ManagedContextRunnable() { @Override protected void runInContext() { ManagedContextTimerTask.this.runInContext(); } }.run(); }
@Override public synchronized boolean cancel() { // TimerTask.cancel may fail depends on the calling context if (!cancelled) { cancelled = true; _startupWait = _startupWaitDefault; s_logger.debug("Startup task cancelled"); return super.cancel(); } return true; }
public static ManagedContext initializeGlobalContext(ManagedContext context) { setManagedContext(true); return ManagedContextRunnable.context = context; }
private static void validateInContext(Object tl) { if (s_validateContext && !ManagedContextUtils.isInContext()) { String msg = "Using a managed thread local in a non managed context this WILL cause errors at runtime. TL [" + tl + "]"; log.error(msg, new IllegalStateException(msg)); } }
@Override public void run() { // register place-holder context to avoid installing system account call context if (CallContext.current() == null) CallContext.registerPlaceHolderContext(); String related = job.getRelated(); String logContext = job.getShortUuid(); if (related != null && !related.isEmpty()) { NDC.push("job-" + related + "/" + "job-" + job.getId()); AsyncJob relatedJob = _jobDao.findByIdIncludingRemoved(Long.parseLong(related)); if (relatedJob != null) { logContext = relatedJob.getShortUuid(); } } else { NDC.push("job-" + job.getId()); } MDC.put("logcontextid", logContext); try { super.run(); } finally { NDC.pop(); } }
@Override final public void run() { getContext().runWithContext(new Runnable() { @Override public void run() { runInContext(); } }); }
@Override public void run() { while (true) { try { _managedContext.runWithContext(new Runnable() { @Override public void run() { work(); } }); } catch (final Throwable th) { s_logger.error("SG Work: Caught this throwable, ", th); } } } }
@Override public void run() { runInContext(); } });
protected void throwException(Throwable t) throws Exception { ManagedContextUtils.rethrowException(t); if (t instanceof Exception) { throw (Exception) t; } }
@Override protected void runInContext() { ManagedContextTimerTask.this.runInContext(); } }.run();
@Override public final void run() { new ManagedContextRunnable() { @Override protected void runInContext() { ManagedContextTimerTask.this.runInContext(); } }.run(); }
@Override public synchronized boolean cancel() { if (!cancelled) { cancelled = true; s_logger.debug("Agent load balancer task cancelled"); return super.cancel(); } return true; }
@Override public void run() { s_logger.info("Starting work"); while (!_stopped) { _managedContext.runWithContext(new Runnable() { @Override public void run() { runWithContext(); } }); } s_logger.info("Time to go home!"); }