# Interface ContextBind

All Known Subinterfaces:
  `Context`

All Known Implementing Classes:
  `FailedContext, ReplicatedContext, StandardContext`

public interface ContextBind
Defines methods for binding and unbinding the current thread's context class loader to a web application class loader.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `ClassLoader`
  `bind(boolean usePrivilegedAction, ClassLoader originalClassLoader)`
  Deprecated.
  Unused.
  `ClassLoader`
  `bind(ClassLoader originalClassLoader)`
  Change the current thread context class loader to the web application class loader.
  `void`
  `unbind(boolean usePrivilegedAction, ClassLoader originalClassLoader)`
  Deprecated.
  Unused.
  `void`
  `unbind(ClassLoader originalClassLoader)`
  Restore the current thread context class loader to the original class loader in used before `bind(boolean, ClassLoader)` was called.

- ## Method Details

  - ### bind

    ClassLoader bind(ClassLoader originalClassLoader)
    Change the current thread context class loader to the web application class loader. If no web application class loader is defined, or if the current thread is already using the web application class loader then no change will be made. If the class loader is changed and a `ThreadBindingListener` is configured then `ThreadBindingListener.bind()` will be called after the change has been made.
    Parameters:
      `originalClassLoader` - The current class loader if known to save this method having to look it up
    Returns:
      If the class loader has been changed by the method it will return the thread context class loader in use when the method was called. If no change was made then this method returns null.

  - ### unbind

    void unbind(ClassLoader originalClassLoader)
    Restore the current thread context class loader to the original class loader in used before `bind(boolean, ClassLoader)` was called. If no original class loader is passed to this method then no change will be made. If the class loader is changed and a `ThreadBindingListener` is configured then `ThreadBindingListener.unbind()` will be called before the change is made.
    Parameters:
      `originalClassLoader` - The class loader to restore as the thread context class loader

  - ### bind

    @Deprecated ClassLoader bind(boolean usePrivilegedAction, ClassLoader originalClassLoader)
    Deprecated.
    Unused. Will be removed in Tomcat 12 onwards.
    Change the current thread context class loader to the web application class loader. If no web application class loader is defined, or if the current thread is already using the web application class loader then no change will be made. If the class loader is changed and a `ThreadBindingListener` is configured then `ThreadBindingListener.bind()` will be called after the change has been made.
    Parameters:
      `usePrivilegedAction` - Unused
      `originalClassLoader` - The current class loader if known to save this method having to look it up
    Returns:
      If the class loader has been changed by the method it will return the thread context class loader in use when the method was called. If no change was made then this method returns null.

  - ### unbind

    @Deprecated void unbind(boolean usePrivilegedAction, ClassLoader originalClassLoader)
    Deprecated.
    Unused. Will be removed in Tomcat 12 onwards.
    Restore the current thread context class loader to the original class loader in used before `bind(boolean, ClassLoader)` was called. If no original class loader is passed to this method then no change will be made. If the class loader is changed and a `ThreadBindingListener` is configured then `ThreadBindingListener.unbind()` will be called before the change is made.
    Parameters:
      `usePrivilegedAction` - Unused
      `originalClassLoader` - The class loader to restore as the thread context class loader