/** * Removes all nodes of {@code scope} using DFS. We don't lock here. * * @param scope the parent scope of which all children will recursively be removed * from the map. We don't do anything else to the children nodes are they will be * garbage collected soon. We just cut a whole sub-graph in the references graph of the JVM * normally. */ private static void removeScopeAndChildrenFromMap(ScopeNode scope) { MAP_KEY_TO_SCOPE.remove(scope.getName()); scope.close(); for (ScopeNode childScope : scope.childrenScopes.values()) { removeScopeAndChildrenFromMap(childScope); } }
@Test public void testReset_shouldClearBoundAnnotations_andFlagTheScopeAsOpen() throws Exception { //GIVEN ScopeNode scope = new ScopeImpl("root"); scope.bindScopeAnnotation(CustomScope.class); scope.close(); //WHEN scope.reset(); //THEN assertThat(scope.isBoundToScopeAnnotation(CustomScope.class), is(false)); assertThat(scope.isOpen, is(true)); }
/** * Removes all nodes of {@code scope} using DFS. We don't lock here. * * @param scope the parent scope of which all children will recursively be removed * from the map. We don't do anything else to the children nodes are they will be * garbage collected soon. We just cut a whole sub-graph in the references graph of the JVM * normally. */ private static void removeScopeAndChildrenFromMap(ScopeNode scope) { MAP_KEY_TO_SCOPE.remove(scope.getName()); scope.close(); for (ScopeNode childScope : scope.childrenScopes.values()) { removeScopeAndChildrenFromMap(childScope); } }