Decorates the input such that the {@link RequestContext#current() current request context} and
the and the {@link CurrentTraceContext#get() current trace context} at assembly time is made
current when task is executed.
357140
static Executor makeContextAware(Executor delegate, CurrentTraceContext currentTraceContext) {
    class TracingCurrentRequestContextExecutor implements Executor {
      @Override public void execute(Runnable task) {
        delegate.execute(RequestContext.current().makeContextAware(currentTraceContext.wrap(task)));
      }
    }
    return new TracingCurrentRequestContextExecutor();
  }
702274
public OkVolley init(Context context) {
        this.mContext = context;
        InstanceRequestQueue = newRequestQueue(context);
        mUserAgent = generateUserAgent(context);
        mRequestHeaders = new HashMap<>();
        mRequestHeaders.put(OkRequest.HEADER_USER_AGENT, mUserAgent);
        mRequestHeaders.put(OkRequest.HEADER_ACCEPT_CHARSET, OkRequest.CHARSET_UTF8);
        return this;
    }
1008150
protected void beforeSend(RpcInternalContext context, SofaRequest request) {
        currentRequests.incrementAndGet();
        context.getStopWatch().tick().read();
        context.setLocalAddress(localAddress());
        if (EventBus.isEnable(ClientBeforeSendEvent.class)) {
            EventBus.post(new ClientBeforeSendEvent(request));
        }
    }
880452
public ThreadDelegatedContext getContext()
    {
        ThreadDelegatedContext context = threadLocal.get();
        if (context == null) {
            context = new ThreadDelegatedContext();
            threadLocal.set(context);
        }
        return context;
    }
173257
public static JKContext getCurrentContext() {
		JKContext context = (JKContext) JKThreadLocal.getValue(JKContextConstants.JK_CONTEXT);
		if (context == null) {
			context = getInstance().createDesktopContext();
			JKThreadLocal.setValue(JKContextConstants.JK_CONTEXT, context);
		}
		return context;
	}
572985
public static void setCurrent(SiteContext current) {
        threadLocal.set(current);

        MDC.put(SITE_NAME_MDC_KEY, current.getSiteName());
    }
1169049
public void writeTo(HttpRequest request) {
		if (!initialized.get()) { // to avoid npe
			init(null);
		}
		
		long time = System.currentTimeMillis();
		long processTime = time - contextTsCurrent.get();
		contextMsProcess.set(contextMsProcess.get() + processTime);
		contextTsCurrent.set(time);
		
		final String uri = request.getRequestLine().getUri();
		contextRequest.set(uri);
		
		List<Cookie> cookiez = new ArrayList<>();
		StringBuilder cookiesDump = new StringBuilder();
		for (String name : forwardedCookies) {
			Cookie c = requestCookies.get().get(name);
			if (c != null) {
				cookiez.add(c);
				cookiesDump.append(c.toString()).append(";");
			}
		}
		if (!cookiez.isEmpty()) { // ...or formatCookies() throws error
			for (Header h : cookieSpec.formatCookies(cookiez)) {
				request.addHeader(h);
			}
		}

		request.setHeader(HEADER_X_FORWARDED_FOR, clientIp.get());

		if (verbose) log.info("    Time " + String.valueOf(time - contextTsStart.get()) + " (+" + processTime + "p) >>> [" + contextUrl.get() + "] >>> " + uri + ". thread local cookies " + cookiesDump.toString());
	}
75069
private ThreadContext getOrCreateContext(Channel channel) {
    ThreadContext context = ThreadContext.currentContext();
    if (context != null) {
      return context;
    }
    return new SingleThreadContext(Thread.currentThread(), channel.eventLoop(), this.context.serializer().clone());
  }
329651
public void init(Object workingMemoryContext,
                     Object context,
                     Tuple leftTuple,
                     Declaration[] declarations,
                     WorkingMemory workingMemory) throws Exception {
        ((CollectContext) context).result = this.collect.instantiateResultObject( (InternalWorkingMemory) workingMemory );
    }
620643
public void processRequest(RequestContext context) throws Exception {
        if (processorIterator.hasNext()){
            RequestSecurityProcessor processor = processorIterator.next();

            logger.debug("Executing processor {}", processor);

            processor.processRequest(context, this);
        }
    }
1252006
private void submit(final ActiveContext context) {
    try {
      LOG.log(Level.INFO, "Send task to context: {0}", new Object[]{context});
      if (JobDriver.this.handlerManager.getActiveContextHandler() == 0) {
        throw new RuntimeException("Active Context Handler not initialized by CLR.");
      }
      final ActiveContextBridge activeContextBridge = activeContextBridgeFactory.getActiveContextBridge(context);
      NativeInterop.clrSystemActiveContextHandlerOnNext(JobDriver.this.handlerManager.getActiveContextHandler(),
          activeContextBridge, JobDriver.this.interopLogger);
    } catch (final Exception ex) {
      LOG.log(Level.SEVERE, "Fail to submit task to active context");
      context.close();
      throw new RuntimeException(ex);
    }
  }
428871
@Override
    public void visitClassContext(ClassContext classContext) {
        currentClass = classContext.getJavaClass();

        if (currentClass.getMajor() >= Const.MAJOR_1_8) {
            try {
                stack = new OpcodeStack();
                activeStackOps = new ArrayDeque<>();
                super.visitClassContext(classContext);
            } finally {
                activeStackOps = null;
                stack = null;
            }
        }
        currentClass = null;
    }
295858
function onAct(context, next) {
  const pattern = context._pattern

  const parentContext = context._parentContext
  const cleanPattern = context._cleanPattern
  const currentTime = Util.nowHrTime()

  // shared context
  context.context$ = pattern.context$ || parentContext.context$

  // set metadata by passed pattern or current message context
  Object.assign(context.meta$, pattern.meta$)
  // is only passed by msg
  context.delegate$ = pattern.delegate$ || {}

  // tracing
  if (pattern.trace$) {
    context.trace$ = {
      spanId: pattern.trace$.spanId || context._idGenerator(),
      traceId: pattern.trace$.traceId || context._idGenerator()
    }
    context.trace$.parentSpanId = pattern.trace$.parentSpanId || parentContext.trace$.spanId
  } else {
    context.trace$ = {
      spanId: parentContext.trace$.spanId || context._idGenerator(),
      traceId: parentContext.trace$.traceId || context._idGenerator()
    }
    context.trace$.parentSpanId = parentContext.trace$.spanId
  }

  context.trace$.timestamp = currentTime
  context.trace$.service = pattern.topic
  context.trace$.method = Util.pattern(pattern)

  // detect recursion
  if (context._config.maxRecursion > 1) {
    const callSignature = `${context.trace$.traceId}:${context.trace$.method}`
    if (context.meta$ && context.meta$.referrers) {
      let count = context.meta$.referrers[callSignature]
      count += 1
      context.meta$.referrers[callSignature] = count
      if (count > context._config.maxRecursion) {
        context.meta$.referrers = null
        return next(
          new Errors.MaxRecursionError({
            count: --count
          })
        )
      }
    } else {
      context.meta$.referrers = {}
      context.meta$.referrers[callSignature] = 1
    }
  }

  // request
  context.request$ = {
    id: pattern.requestId$ || context._idGenerator(),
    type: pattern.pubsub$ === true ? 'pubsub' : 'request',
    service: pattern.topic,
    method: context.trace$.method
  }

  if (context._config.traceLog === true) {
    context.log = context.log.child({
      tag: context._config.tag,
      requestId: context.request$.id,
      parentSpanId: context.trace$.parentSpanId,
      traceId: context.trace$.traceId,
      spanId: context.trace$.spanId
    })
    context.log.info(
      {
        pattern: context.trace$.method
      },
      'Request started'
    )
  } else {
    context.log.info(
      {
        requestId: context.request$.id,
        pattern: context.trace$.method
      },
      'Request started'
    )
  }

  // build msg
  const message = {
    pattern: cleanPattern,
    meta: context.meta$,
    delegate: context.delegate$,
    trace: context.trace$,
    request: context.request$
  }

  context._message = message

  next()
}
162144
public void pushContextData(){
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
            Tr.entry(tc, "pushContextData");
        }
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            Tr.debug(tc, "Setting the original thread's class loader and saving off the current one");
        }
        //Set the original Context Class Loader
        this.currentCL = AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() {
            public ClassLoader run() {
                ClassLoader cl = Thread.currentThread().getContextClassLoader();
                Thread.currentThread().setContextClassLoader(originalCL);
                return cl;
            }
        });
        
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            Tr.debug(tc, "Saving the current thread's context data");
        }
        //We are going to save off the current threads component metadata and context
        //We will restore this when we pop later on
        this.currentCD = saveContextData();
        
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            Tr.debug(tc, "Setting the original thread's context data : " + this.originalCD);
        }
        if (this.originalCD != null) {

            //Push the data onto the thread that we have hooks into
            ComponentMetaDataAccessorImpl cmdai = ComponentMetaDataAccessorImpl.getComponentMetaDataAccessor();
            ComponentMetaData cmd = (ComponentMetaData) this.originalCD.get(ComponentMetaData);
            if (cmd != null) {
                if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                    Tr.debug(tc, "Calling begin on the ComponentMetaData : " + cmdai + ", with : " + cmd);
                }
                cmdai.beginContext(cmd);
            }
            
            //Each producer service of the Transfer service is accessed in order to get the thread context data
          Iterator<ITransferContextService> TransferIterator = com.ibm.ws.webcontainer.osgi.WebContainer.getITransferContextServices();
          if (TransferIterator != null) {
            while(TransferIterator.hasNext()){
              ITransferContextService tcs = TransferIterator.next();
              if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                  Tr.debug(tc, "Calling restoreState on: " + tcs);
              }
              tcs.restoreState(this.originalCD);
            }
          }
        }
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
            Tr.exit(tc, "pushContextData");
        }
    }
1026966
private void initialDecodeTasks(final ChannelHandlerContext ctx) {
        currentRequest = sentRequestQueue.poll();
        currentDecodingState = DecodingState.STARTED;

        if (currentRequest != null) {
            Long st = sentRequestTimings.poll();
            if (st != null) {
                currentOpTime = System.nanoTime() - st;
            } else {
                currentOpTime = -1;
            }
        }

        if (env().operationTracingEnabled()) {
            Span dispatchSpan = dispatchSpans.poll();
            if (dispatchSpan != null) {
                currentDispatchSpan = dispatchSpan;
            }
        }

        if (traceEnabled) {
            LOGGER.trace("{}Started decoding of {}", logIdent(ctx, endpoint), currentRequest);
        }
    }
680878
private void initRequestFromRpcContext(CmsContainerPageRpcContext context) {

        if (context.getTemplateContext() != null) {
            getRequest().setAttribute(
                CmsTemplateContextManager.ATTR_RPC_CONTEXT_OVERRIDE,
                context.getTemplateContext());
        }
    }
248265
@Override
	public void preparePaintComponent(final Request request) {
		String dateStr = "The current date is " + new Date();
		dynamicText.setText(dateStr);
	}