Utility class for binding InstanceManager instances to class loaders.
| 23 | * Utility class for binding {@link InstanceManager} instances to class loaders. |
| 24 | */ |
| 25 | public final class InstanceManagerBindings { |
| 26 | |
| 27 | private static final Map<ClassLoader,InstanceManager> bindings = new ConcurrentHashMap<>(); |
| 28 | |
| 29 | /** |
| 30 | * Constructs a new InstanceManagerBindings. This constructor is private to prevent instantiation. |
| 31 | */ |
| 32 | private InstanceManagerBindings() { |
| 33 | // Hide constructor |
| 34 | } |
| 35 | |
| 36 | /** |
| 37 | * Bind an InstanceManager to the given class loader. |
| 38 | * |
| 39 | * @param classLoader the class loader |
| 40 | * @param instanceManager the instance manager to bind |
| 41 | */ |
| 42 | public static void bind(ClassLoader classLoader, InstanceManager instanceManager) { |
| 43 | bindings.put(classLoader, instanceManager); |
| 44 | } |
| 45 | |
| 46 | /** |
| 47 | * Unbind the InstanceManager associated with the given class loader. |
| 48 | * |
| 49 | * @param classLoader the class loader |
| 50 | */ |
| 51 | public static void unbind(ClassLoader classLoader) { |
| 52 | bindings.remove(classLoader); |
| 53 | } |
| 54 | |
| 55 | /** |
| 56 | * Get the InstanceManager bound to the given class loader. |
| 57 | * |
| 58 | * @param classLoader the class loader |
| 59 | * @return the bound InstanceManager, or {@code null} if none |
| 60 | */ |
| 61 | public static InstanceManager get(ClassLoader classLoader) { |
| 62 | return bindings.get(classLoader); |
| 63 | } |
| 64 | } |
nothing calls this directly
no outgoing calls
no test coverage detected