Tabnine Logo
Thread.getContextClassLoader
Code IndexAdd Tabnine to your IDE (free)

How to use
getContextClassLoader
method
in
java.lang.Thread

Best Java code snippets using java.lang.Thread.getContextClassLoader (Showing top 20 results out of 58,680)

origin: apache/incubator-dubbo

@Override
public ClassLoader getClassLoader() {
  return Thread.currentThread().getContextClassLoader();
}
origin: apache/incubator-dubbo

@Override
public ClassLoader getClassLoader() {
  return Thread.currentThread().getContextClassLoader();
}
origin: apache/incubator-dubbo

public CompactedObjectInputStream(InputStream in) throws IOException {
  this(in, Thread.currentThread().getContextClassLoader());
}
origin: netty/netty

static ClassLoader getContextClassLoader() {
  if (System.getSecurityManager() == null) {
    return Thread.currentThread().getContextClassLoader();
  } else {
    return AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() {
      @Override
      public ClassLoader run() {
        return Thread.currentThread().getContextClassLoader();
      }
    });
  }
}
origin: apache/incubator-dubbo

private static Class<?> arrayForName(String className) throws ClassNotFoundException {
  return Class.forName(className.endsWith("[]")
      ? "[L" + className.substring(0, className.length() - 2) + ";"
      : className, true, Thread.currentThread().getContextClassLoader());
}
origin: apache/incubator-dubbo

private static Class<?> arrayForName(String className) throws ClassNotFoundException {
  return Class.forName(className.endsWith("[]")
      ? "[L" + className.substring(0, className.length() - 2) + ";"
      : className, true, Thread.currentThread().getContextClassLoader());
}
origin: apache/incubator-dubbo

public static Object deserialize(JavaBeanDescriptor beanDescriptor) {
  Object result = deserialize(
      beanDescriptor,
      Thread.currentThread().getContextClassLoader());
  return result;
}
origin: apache/incubator-dubbo

public static Object deserialize(JavaBeanDescriptor beanDescriptor) {
  Object result = deserialize(
      beanDescriptor,
      Thread.currentThread().getContextClassLoader());
  return result;
}
origin: apache/incubator-dubbo

@Override
@SuppressWarnings("unchecked")
public <T> T getProxy(Invoker<T> invoker, Class<?>[] interfaces) {
  return (T) Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(), interfaces, new InvokerInvocationHandler(invoker));
}
origin: apache/incubator-dubbo

@Override
@SuppressWarnings("unchecked")
public <T> T getProxy(Invoker<T> invoker, Class<?>[] interfaces) {
  return (T) Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(), interfaces, new InvokerInvocationHandler(invoker));
}
origin: spring-projects/spring-framework

@Override
public void contextInitialized(ServletContextEvent event) {
  CachedIntrospectionResults.acceptClassLoader(Thread.currentThread().getContextClassLoader());
}
origin: apache/incubator-dubbo

public static Class<?> forNameWithThreadContextClassLoader(String name)
    throws ClassNotFoundException {
  return forName(name, Thread.currentThread().getContextClassLoader());
}
origin: apache/incubator-dubbo

public static Class<?> forNameWithThreadContextClassLoader(String name)
    throws ClassNotFoundException {
  return forName(name, Thread.currentThread().getContextClassLoader());
}
origin: apache/incubator-dubbo

@Override
public Result invoke(Invoker<?> invoker, Invocation invocation) throws RpcException {
  ClassLoader ocl = Thread.currentThread().getContextClassLoader();
  Thread.currentThread().setContextClassLoader(invoker.getInterface().getClassLoader());
  try {
    return invoker.invoke(invocation);
  } finally {
    Thread.currentThread().setContextClassLoader(ocl);
  }
}
origin: apache/incubator-dubbo

@Override
public Result invoke(Invoker<?> invoker, Invocation invocation) throws RpcException {
  ClassLoader ocl = Thread.currentThread().getContextClassLoader();
  Thread.currentThread().setContextClassLoader(invoker.getInterface().getClassLoader());
  try {
    return invoker.invoke(invocation);
  } finally {
    Thread.currentThread().setContextClassLoader(ocl);
  }
}
origin: spring-projects/spring-framework

@Override
public void contextDestroyed(ServletContextEvent event) {
  CachedIntrospectionResults.clearClassLoader(Thread.currentThread().getContextClassLoader());
  Introspector.flushCaches();
}
origin: apache/incubator-dubbo

public static ClassGenerator newInstance() {
  return new ClassGenerator(getClassPool(Thread.currentThread().getContextClassLoader()));
}
origin: apache/incubator-dubbo

public static ClassGenerator newInstance() {
  return new ClassGenerator(getClassPool(Thread.currentThread().getContextClassLoader()));
}
origin: spring-projects/spring-framework

public static void setCurrentWebApplicationContext(WebApplicationContext applicationContext) {
  setCurrentWebApplicationContext(Thread.currentThread().getContextClassLoader(), applicationContext);
}
origin: google/guava

public void testGetResource_contextClassLoaderNull() {
 ClassLoader oldContextLoader = Thread.currentThread().getContextClassLoader();
 try {
  Thread.currentThread().setContextClassLoader(null);
  assertNotNull(Resources.getResource("com/google/common/io/testdata/i18n.txt"));
  try {
   Resources.getResource("no such resource");
   fail("Should get IllegalArgumentException");
  } catch (IllegalArgumentException expected) {
  }
 } finally {
  Thread.currentThread().setContextClassLoader(oldContextLoader);
 }
}
java.langThreadgetContextClassLoader

Javadoc

Returns the context ClassLoader for this Thread. The context ClassLoader is provided by the creator of the thread for use by code running in this thread when loading classes and resources. If not #setContextClassLoader, the default is the ClassLoader context of the parent Thread. The context ClassLoader of the primordial thread is typically set to the class loader used to load the application.

If a security manager is present, and the invoker's class loader is not null and is not the same as or an ancestor of the context class loader, then this method invokes the security manager's SecurityManager#checkPermission(java.security.Permission)method with a RuntimePermission("getClassLoader") permission to verify that retrieval of the context class loader is permitted.

Popular methods of Thread

  • currentThread
  • sleep
    Causes the currently executing thread to sleep (temporarily cease execution) for the specified numbe
  • <init>
    Constructs a new Thread with no Runnable object, the given name and belonging to the ThreadGroup pas
  • start
    Causes this thread to begin execution; the Java Virtual Machine calls the run method of this thread
  • interrupt
    Interrupts this thread. Unless the current thread is interrupting itself, which is always permitted,
  • setDaemon
    Marks this thread as either a #isDaemon thread or a user thread. The Java Virtual Machine exits when
  • getName
    Returns this thread's name.
  • join
    Waits at most millis milliseconds plus nanos nanoseconds for this thread to die. This implementatio
  • setContextClassLoader
    Sets the context ClassLoader for this Thread. The context ClassLoader can be set when a thread is cr
  • setName
    Changes the name of this thread to be equal to the argumentname. First the checkAccess method of thi
  • interrupted
    Tests whether the current thread has been interrupted. Theinterrupted status of the thread is cleare
  • getStackTrace
    Returns an array of stack trace elements representing the stack dump of this thread. This method wil
  • interrupted,
  • getStackTrace,
  • getId,
  • isInterrupted,
  • isAlive,
  • setPriority,
  • yield,
  • getThreadGroup,
  • getPriority

Popular in Java

  • Reading from database using SQL prepared statement
  • runOnUiThread (Activity)
  • notifyDataSetChanged (ArrayAdapter)
  • findViewById (Activity)
  • Font (java.awt)
    The Font class represents fonts, which are used to render text in a visible way. A font provides the
  • PrintStream (java.io)
    Fake signature of an existing Java class.
  • Executor (java.util.concurrent)
    An object that executes submitted Runnable tasks. This interface provides a way of decoupling task s
  • BoxLayout (javax.swing)
  • JLabel (javax.swing)
  • DateTimeFormat (org.joda.time.format)
    Factory that creates instances of DateTimeFormatter from patterns and styles. Datetime formatting i
  • Top plugins for Android Studio
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now