/** * Clears all scopes. Useful for testing and not getting any leak... */ public static void reset() { for (Object name : Collections.list(MAP_KEY_TO_SCOPE.keys())) { closeScope(name); } ConfigurationHolder.configuration.onScopeForestReset(); ScopeImpl.resetUnBoundProviders(); }
/** * Detach a scope from its parent, this will trigger the garbage collection of this scope and it's * sub-scopes * if they are not referenced outside of Toothpick. * * @param name the name of the scope to close. */ public static void closeScope(Object name) { //we remove the scope first, so that other threads don't see it, and see the next snapshot of the tree ScopeNode scope = (ScopeNode) MAP_KEY_TO_SCOPE.remove(name); if (scope != null) { ScopeNode parentScope = scope.getParentScope(); if (parentScope != null) { parentScope.removeChild(scope); } else { ConfigurationHolder.configuration.onScopeForestReset(); } removeScopeAndChildrenFromMap(scope); } }
/** * Clears all scopes. Useful for testing and not getting any leak... */ public static void reset() { for (Object name : Collections.list(MAP_KEY_TO_SCOPE.keys())) { closeScope(name); } ConfigurationHolder.configuration.onScopeForestReset(); ScopeImpl.resetUnBoundProviders(); }
/** * Detach a scope from its parent, this will trigger the garbage collection of this scope and it's * sub-scopes * if they are not referenced outside of Toothpick. * * @param name the name of the scope to close. */ public static void closeScope(Object name) { //we remove the scope first, so that other threads don't see it, and see the next snapshot of the tree ScopeNode scope = (ScopeNode) MAP_KEY_TO_SCOPE.remove(name); if (scope != null) { ScopeNode parentScope = scope.getParentScope(); if (parentScope != null) { parentScope.removeChild(scope); } else { ConfigurationHolder.configuration.onScopeForestReset(); } removeScopeAndChildrenFromMap(scope); } }