zan-mateusz commented on code in PR #1425:
URL: https://github.com/apache/brooklyn-server/pull/1425#discussion_r2716807974


##########
camp/camp-brooklyn/src/main/java/org/apache/brooklyn/camp/brooklyn/spi/creation/CampResolver.java:
##########
@@ -262,35 +262,16 @@ static void fixScopeRootAtRoot(ManagementContext mgmt, 
EntitySpec<?> node) {
     }
 
     private static void fixScopeRoot(ManagementContext mgmt, Object value, 
Consumer<Object> updater) {
-        java.util.function.Function<String,String> fixString = v -> 
"$brooklyn:self()" + Strings.removeFromStart((String)v, 
"$brooklyn:scopeRoot()");
-        // TODO better approach to replacing scopeRoot
-        // we could replace within maps and strings, and inside DSL; currently 
only supported at root of config or flags
-        // but that's hard, we'd need to rebuild those maps and strings, which 
might be inside objects;
-        // and we'd need to replace references to scopeRoot inside a DSL, eg 
formatString;
-        // better would be to collect the DSL items we just created, and 
convert those if they belong to the now-root node (possibly promoted);
-        // it is a rare edge case however, so for now we use this poor-man's 
logic which captures the most common case --
-        // see DslYamlTest.testDslScopeRootEdgeCases
-        if (value instanceof BrooklynDslDeferredSupplier) {
-            if (value.toString().startsWith("$brooklyn:scopeRoot()")) {
-                updater.accept(DslUtils.parseBrooklynDsl(mgmt, 
fixString.apply(value.toString())));
-                return;
-            }
-        }
-
-        // don't think blocks below here ever get used...
-        if (value instanceof String) {
-            if (((String)value).startsWith("$brooklyn:scopeRoot()")) {
-                updater.accept( fixString.apply((String)value) );
-            }
-            return;
-        }
-
-        if (value instanceof DslComponent) {
-            // superseded by above - no longer used
-            if ( ((DslComponent)value).getScope() == Scope.SCOPE_ROOT ) {
-                updater.accept( 
DslComponent.newInstanceChangingScope(Scope.THIS, (DslComponent) value, 
fixString) );
+        Object v2 = DslCopyHelpers.visitRecursively(value, 
BrooklynDslDeferredSupplier.class,

Review Comment:
   the indentation here appears slightly off, but not a big deal



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to