/*
Push the original context data from the original thread onto the current thread
Pushes the context ClassLoader, ComponentMetaData, and ThreadContext data
Saves off some of the current thread's data to restore it later
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");
        }
    }
147500
public static Context pushContext(Map<String, Object> current) {
        Context context = new Context(getContext(), current);
        LOCAL.set(context);
        return context;
    }
208043
@Override
  boolean push(TraceMethod traceMethod) {
    boolean success;
    TracingContext currentTracingContext = getCurrentTracingContext();
    if (currentTracingContext != null && !currentTracingContext.isCorrupted()) {
      if (currentTracingContext.getMethodStack().size() >= STACK_SIZE) {
        currentTracingContext.setCorrupted(true);
        throw new ThreadMap.RuntimeException("Stacksize is exceeded.");
      }
      else {
        currentTracingContext.getMethodStack().push(traceMethod);
        success = true;
      }
    }
    else
      success = false;
    
    return success;
  }
466592
static void push(Span span, boolean autoClose) {
    if (isCurrent(span)) {
      return;
    }
    setSpanContextInternal(new SpanContext(span, autoClose));
  }
938530
function pushLoadingState(xhrEvent, stateName, modelOrCollection, context, force) {
        var currentLoads = getState(stateName, context),
            currentlyLoading = currentLoads && currentLoads.length;
        if (!currentLoads) {
            currentLoads = [];
        }
        if (_.isArray(currentLoads)) {
            if (_.indexOf(currentLoads, xhrEvent) >= 0) {
                if (!force) {
                    return;
                }
                
            } else {
                currentLoads.push(xhrEvent);
            }
            
            if (!currentlyLoading) {
                var toSet = {};
                toSet[stateName] = currentLoads;
                setState(toSet, context);
            }

            xhrEvent.on('complete', function() {
                popLoadingState(xhrEvent, stateName, modelOrCollection, context);
            });
        }
    }
512768
public void popContextData(){
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
            Tr.entry(tc, "popContextData");
        }
        
        // If we pushed thread context onto the thread, be sure to reset it before
        // taking it off.
        if (this.originalCD != null) {
          //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 resetState on: " + tcs);
              }
              tcs.resetState();
            }
          }
        }
        
        
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            Tr.debug(tc, "Restoring the current thread's class loader");
        }
        if(currentCL != null){
            //Revert back to the thread's current class loader
            AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() {
                public ClassLoader run() {
                    Thread.currentThread().setContextClassLoader(currentCL);
                    return currentCL;
                }
            });
        }
        
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            Tr.debug(tc, "Restoring the current thread's context data");
        }
        //When popping we are going to reset the thread context to clear everything off, then we are going to set it back to the state when we first pushed
        //our stuff onto the thread
        if(currentCD != null){
            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(currentCD);
                }  
            }
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            Tr.debug(tc, "Ending the current ComponentMetaData context");
        }
        //Reset data for other components that we already have hooks into
        ComponentMetaDataAccessorImpl cmdai = ComponentMetaDataAccessorImpl.getComponentMetaDataAccessor();
        cmdai.endContext();
        
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
            Tr.exit(tc, "popContextData");
        }
    }
334933
public void setThreadContextLoader() {
        if (isContextLoaderSaved) {
            throw new BuildException("Context loader has not been reset");
        }
        if (LoaderUtils.isContextLoaderAvailable()) {
            savedContextLoader = LoaderUtils.getContextClassLoader();
            ClassLoader loader = this;
            if (project != null && "only".equals(project.getProperty("build.sysclasspath"))) {
                loader = this.getClass().getClassLoader();
            }
            LoaderUtils.setContextClassLoader(loader);
            isContextLoaderSaved = true;
        }
    }
1262697
public void push(E ele) {
        if (mElements.size() > mSize)
            mElements.set(mSize, ele);
        else
            mElements.add(ele);
        mSize++;
    }
645888
def PushEvent(self, timestamp, event_data):
    
    heap_values = (timestamp, event_data)
    heapq.heappush(self._heap, heap_values)
    self.data_size += len(event_data)
728497
public static synchronized void pushCCMContext(String key, Throwable callstack)
   {
      log.tracef("%s", new TraceEvent("CachedConnectionManager", "NONE", TraceEvent.PUSH_CCM_CONTEXT,
                                      "NONE", key, callstack != null ? toString(callstack) : ""));
   }
971533
static ServiceWrapper newFromPushedData (AsyncContextImpl asynContext) { // PM90834: added method
      ServiceWrapper orginalServiceWrapper = asynContext.serviceWrapper;
      ServiceWrapper sw = new ServiceWrapper(asynContext);
      sw.setContextData(orginalServiceWrapper.getContextData());
      sw.originalCL = orginalServiceWrapper.originalCL;
      sw.newCL= orginalServiceWrapper.newCL;             //PI92334 newCL is the current thread's classLoader

      if (com.ibm.ejs.ras.TraceComponent.isAnyTracingEnabled() && logger.isLoggable(Level.FINEST)) {           
          logger.logp(Level.FINEST, CLASS_NAME, "newFromPushedData","created ServiceWrapper [" + sw +"] , original ServiceWrapper ["+orginalServiceWrapper+"]");
          logger.logp(Level.FINEST, CLASS_NAME, "newFromPushedData","transferred to new ServiceWrapper, originalCL [" + sw.originalCL +"] , newCL ["+ sw.newCL +"]");
      }

      return sw;
  }
14080
protected void pushContext() {
    antOut = System.out;
    antErr = System.err;
    System.setOut(new PrintStream(out));
    System.setErr(out == err ? System.out : new PrintStream(err));
  }
266124
private void ensureContextInstantiatedForReading(EndianAwareDataInputStream is, ThirdPartyParseable bean){
		//if(pc==null) pc= registerParseContext();
		os=null;this.is=is;
		pushBean(bean);
		//System.out.println("pushing bean: "+bean);
		parseMode=ParseMode.READ;
		}
378788
@Override
    public void visitClassContext(ClassContext classContext) {
        try {
            JavaClass cls = classContext.getJavaClass();
            if (isSingleton(cls)) {
                syncBlockBranchResetValues = new HashMap<>();
                stack = new OpcodeStack();
                super.visitClassContext(classContext);
            }
        } finally {
            syncBlockBranchResetValues = null;
            stack = null;
        }
    }
1119685
public void pushClassLoader(BeanMetaData bmd)
    {
        ClassLoader classLoader = bmd.ivContextClassLoader; // F85059
        Object origCL = svThreadContextAccessor.pushContextClassLoaderForUnprivileged(classLoader);
        ivClassLoaderStack.push(origCL);

        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
            Tr.debug(tc, "pushClassLoader: " +
                         (origCL == ThreadContextAccessor.UNCHANGED ?
                                         "already " + Util.identity(classLoader) :
                                         Util.identity(origCL) + " -> " + Util.identity(classLoader)));
    }
381500
public function pushContext($key, $context)
    {
        $newContext = $this->getCurrentContext();
        $newContext[$key] = $context;
        $this->contextStack[] = $newContext;
    }
287300
@Override
	public void updateContext() {

		String newInstancePath = (this.parentInstancePath == null ? "" : this.parentInstancePath) + "/" + this.instanceName;
		this.context.instancePathToComponentName.put( newInstancePath, this.componentName );
	}