Sets the current thread's context loader to this classloader, storing
the current loader value for later resetting.
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;
        }
    }
1103196
public void setContext(Context context) {
        log = Log.instance(context);
        options = Options.instance(context);
        classLoaderClass = options.get("procloader");
        locations.update(log, options, Lint.instance(context), FSInfo.instance(context));
    }
780963
public KryoInstantiator setThreadContextClassLoader() {
    return new KryoInstantiator() {
      public Kryo newKryo() {
        Kryo k = KryoInstantiator.this.newKryo();
        k.setClassLoader(Thread.currentThread().getContextClassLoader());
        return k;
      }
    };
  }
1195601
private void init() {
        final boolean trace = TraceComponent.isAnyTracingEnabled();

        Map<String, Map<String, Object>> threadContextConfigs = new HashMap<String, Map<String, Object>>();

        for (Enumeration<String> keys = properties.keys(); keys.hasMoreElements();) {
            String key = keys.nextElement();
            // Properties of flattened thread context configurations have the form:
            // threadContextConfigRef.0.*
            if (key.length() > 25 && key.charAt(22) == '.') {
                int dot = key.indexOf('.', 23);
                if (dot > 0) {
                    String group = key.substring(23, dot);
                    Map<String, Object> config = threadContextConfigs.get(group);
                    if (config == null)
                        threadContextConfigs.put(group, config = new TreeMap<String, Object>());
                    config.put(key.substring(dot + 1), properties.get(key));
                }
            } else if (trace && tc.isDebugEnabled() && !SUPPORTED_PROPERTIES.contains(key) && key.indexOf('.') < 0) {
                Tr.debug(this, tc, "unrecognized attribute: " + key);
                // TODO: once we have stricter variant of onError, do the following for it:
                //IllegalArgumentException x = ignoreWarnOrFail(null, IllegalArgumentException.class, "CWWKC1000.unrecognized.property", name, key);
                //if (x != null)
                //    throw x;
            }
        }

        threadContextConfigurations = new TreeMap<String, Map<String, ?>>();
        for (Map<String, Object> threadContextConfig : threadContextConfigs.values()) {
            String provider = (String) threadContextConfig.get("threadContextProvider");
            if (provider == null)
                provider = (String) threadContextConfig.get("config.referenceType") + ".provider";
            Map<String, ?> previous = threadContextConfigurations.put(provider, threadContextConfig);
            if (previous != null)
                throw new IllegalArgumentException(Tr.formatMessage(tc, "CWWKC1002.provider.cardinality.violation", name, previous.get("config.referenceType")));
        }

        // Inherit complementary thread context config from base instance
        ContextServiceImpl baseInstance = AccessController.doPrivileged(new PrivilegedAction<ContextServiceImpl>() {
            @Override
            public ContextServiceImpl run() {
                return (ContextServiceImpl) componentContext.locateService(BASE_INSTANCE);
            }
        });
        if (baseInstance != null)
            baseInstance.addComplementaryThreadContextConfigurationsTo(this);

        if (trace && tc.isDebugEnabled())
            Tr.debug(this, tc, "context configuration", threadContextConfigurations);
    }
551293
public static void bind(ApplicationContext context) {
        Object old = contextMap.putIfAbsent(getContextClassLoader(), context);
        if (old != null) {
            throw new IllegalStateException(
                "There is already a ApplicationContext associated with the context ClassLoader of the current thread!");
        }
    }
504181
public void setClassLoader(final GroovyClassLoader loader) {
        // Classloaders should only be created inside a doPrivileged block in case
        // this method is invoked by code that does not have security permissions
        this.classLoader = loader != null ? loader : AccessController.doPrivileged(new PrivilegedAction<GroovyClassLoader>() {
            public GroovyClassLoader run() {
                ClassLoader parent = Thread.currentThread().getContextClassLoader();
                if (parent == null) parent = ProcessingUnit.class.getClassLoader();
                return new GroovyClassLoader(parent, configuration);
            }
        });
    }
1349558
void initialize() {
        // Cancel any running tasks
        Timer oldTimer = timer;
        timer = new Timer(true);
        if (Objects.nonNull(oldTimer)) {
            oldTimer.cancel();
        }
        // (re)initialize
        LoaderConfigurator configurator = new LoaderConfigurator(this);
        defaultLoaderServiceFacade = new DefaultLoaderServiceFacade(timer, listener, resources);
        configurator.load();
    }
22432
def set_threadlocal(self, **values):
        """"""
        with self._lock:
            self._ensure_threadlocal()
            self._tpayload.context = values
604303
public ClassLoader beginContextClassLoader(ClassLoader raClassLoader) {
        return raClassLoader == null ? null
                        : AccessController.doPrivileged(new GetAndSetContextClassLoader(raClassLoader));
    }
25250
function setLoading(value) {
      if (self.loading !== value) {
        self.loading = value;
      }

      // Always refresh the hidden variable as something else might have changed
      self.hidden = shouldHide();
    }
1060024
def context_loader(self, callback):
        
        if not callback or not callable(callback):
            raise Exception("Please pass in a callable that loads your context.")
        self.context_loader_callback = callback
        return callback
1249529
static ClassLoader setContextClassLoader(final ClassLoader cl)
   {
      if (System.getSecurityManager() == null)
      {
         ClassLoader result = Thread.currentThread().getContextClassLoader();
         if (cl != null)
            Thread.currentThread().setContextClassLoader(cl);
         return result;
      }
      else
      {
         try
         {
            return AccessController.doPrivileged(new PrivilegedExceptionAction<ClassLoader>() {
               public ClassLoader run() throws Exception
               {
                  try
                  {
                     ClassLoader result = Thread.currentThread().getContextClassLoader();
                     if (cl != null)
                        Thread.currentThread().setContextClassLoader(cl);
                     return result;
                  }
                  catch (Exception e)
                  {
                     throw e;
                  }
                  catch (Error e)
                  {
                     throw e;
                  }
                  catch (Throwable e)
                  {
                     throw new RuntimeException("Error setting context classloader", e);
                  }
               }
            });
         }
         catch (PrivilegedActionException e)
         {
            throw new RuntimeException("Error running privileged action", e.getCause());
         }
      }
   }
1070526
def set_context(self, context):
        """"""
        self._set_context(context, emit=False)
        self._modified = (not context.load_path)
        self.dataChanged.emit(self.CONTEXT_CHANGED |
                              self.REQUEST_CHANGED |
                              self.PACKAGES_PATH_CHANGED |
                              self.LOCKS_CHANGED |
                              self.LOADPATH_CHANGED |
                              self.PACKAGE_FILTER_CHANGED |
                              self.CACHING_CHANGED)
1154991
public static ClassLoader getClassLoader() {
        ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
        return (classLoader != null) ? classLoader : ClassLoaderUtils.class.getClassLoader();
    }
469830
public static ClassLoader getClassLoader()
    {
        try
        {
            ClassLoader cl = Thread.currentThread().getContextClassLoader();
            if ( cl != null ) return cl;
        }
        catch ( SecurityException e )
        {
            if ( _log.isDebugEnabled() )
            {
                _log.debug( "Could not get thread context classloader.", e );
            }
        }
        
        if ( _log.isTraceEnabled() )
        {
            _log.trace( "Can't use thread context classloader; using classloader for " + DiscoveryUtils.class.getName() );
        }
        
        return DiscoveryUtils.class.getClassLoader();
    }
210367
public static final ClassLoader getContextLoader() {
		return CClassLoader.contextLoader.get() != null ? (CClassLoader) ((WeakReference) CClassLoader.contextLoader
				.get()).get()
				: null;
	}
310764
public static ClassLoader getContextClassLoader() {
        ClassLoader loader = null;
        try {
            loader = Thread.currentThread().getContextClassLoader();
        } catch (Throwable e) {
        }
        if (loader == null) {
            loader = ClassUtils.class.getClassLoader();
        }
        return loader;
    }