Interface Environment

All Superinterfaces:
Attributes

public interface Environment extends Attributes
A named runtime environment containing a ClassLoader and Attributes.
  • Field Details

    • LOG

      static final org.slf4j.Logger LOG
  • Method Details

    • getAll

      static Collection<Environment> getAll()
      Gets all existing environments.
      Returns:
      the environments
    • removeAll

      static void removeAll()
      Removes all the environments.
    • get

      static Environment get(String name)
      Gets the environment with the given name.
      Parameters:
      name - the environment name
      Returns:
      the environment, or null if no environment with such name exists
    • ensure

      static Environment ensure(String name, Class<?> classToLoad) throws IllegalStateException
      Gets the environment with the given name, creating it with the default classloader if necessary.
      Parameters:
      name - the environment name
      classToLoad - A class to either: use to create the environment with its classloader; or to check the environments can load the passed class.
      Returns:
      the environment
      Throws:
      IllegalArgumentException - if an environment with the given name but a different classloader already exists
      IllegalStateException
    • create

      static Environment create(String name, ClassLoader classLoader) throws IllegalStateException
      Creates an environment with the given name and classloader.
      Parameters:
      name - the environment name
      classLoader - the environment classloader
      Returns:
      the environment
      Throws:
      IllegalStateException - if an environment with the given name already exists
    • getName

      String getName()
      Returns:
      The case-insensitive name of the environment.
    • getClassLoader

      ClassLoader getClassLoader()
      Returns:
      The ClassLoader for the environment or if none set, then the ClassLoader that loaded the environment implementation.
    • run

      default void run(Runnable runnable)
      Run a Runnable in the environment, i.e. with current Thread.getContextClassLoader() set to getClassLoader().
      Parameters:
      runnable - The Runnable to run in the environment.