/** * Opens a scope without any parent. * If a scope by this {@code name} already exists, it is returned. * Otherwise a new scope is created. * * @param name the name of the scope to open. * @param shouldCheckMultipleRootScopes whether or not to check that the return scope * is not introducing a second tree in TP forest of scopes. */ private static Scope openScope(Object name, boolean shouldCheckMultipleRootScopes) { if (name == null) { throw new IllegalArgumentException("null scope names are not allowed."); } Scope scope = MAP_KEY_TO_SCOPE.get(name); if (scope != null) { return scope; } scope = new ScopeImpl(name); Scope previous = MAP_KEY_TO_SCOPE.putIfAbsent(name, scope); if (previous != null) { //if there was already a scope by this name, we return it scope = previous; } else if (shouldCheckMultipleRootScopes) { ConfigurationHolder.configuration.checkMultipleRootScopes(scope); } return scope; }
/** * Opens a scope without any parent. * If a scope by this {@code name} already exists, it is returned. * Otherwise a new scope is created. * * @param name the name of the scope to open. * @param shouldCheckMultipleRootScopes whether or not to check that the return scope * is not introducing a second tree in TP forest of scopes. */ private static Scope openScope(Object name, boolean shouldCheckMultipleRootScopes) { if (name == null) { throw new IllegalArgumentException("null scope names are not allowed."); } Scope scope = MAP_KEY_TO_SCOPE.get(name); if (scope != null) { return scope; } scope = new ScopeImpl(name); Scope previous = MAP_KEY_TO_SCOPE.putIfAbsent(name, scope); if (previous != null) { //if there was already a scope by this name, we return it scope = previous; } else if (shouldCheckMultipleRootScopes) { ConfigurationHolder.configuration.checkMultipleRootScopes(scope); } return scope; }