Github user ahgittin commented on a diff in the pull request:

    https://github.com/apache/incubator-brooklyn/pull/1112#discussion_r47896697
  
    --- Diff: 
core/src/main/java/org/apache/brooklyn/core/mgmt/internal/DeferredBrooklynProperties.java
 ---
    @@ -0,0 +1,370 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one
    + * or more contributor license agreements.  See the NOTICE file
    + * distributed with this work for additional information
    + * regarding copyright ownership.  The ASF licenses this file
    + * to you under the Apache License, Version 2.0 (the
    + * "License"); you may not use this file except in compliance
    + * with the License.  You may obtain a copy of the License at
    + *
    + *     http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing,
    + * software distributed under the License is distributed on an
    + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    + * KIND, either express or implied.  See the License for the
    + * specific language governing permissions and limitations
    + * under the License.
    + */
    +package org.apache.brooklyn.core.mgmt.internal;
    +
    +import static com.google.common.base.Preconditions.checkNotNull;
    +
    +import java.io.File;
    +import java.io.InputStream;
    +import java.net.URL;
    +import java.util.Collection;
    +import java.util.Map;
    +import java.util.Set;
    +import java.util.concurrent.ExecutionException;
    +
    +import org.apache.brooklyn.api.mgmt.ExecutionContext;
    +import org.apache.brooklyn.config.ConfigKey;
    +import org.apache.brooklyn.config.ConfigKey.HasConfigKey;
    +import org.apache.brooklyn.core.internal.BrooklynProperties;
    +import org.apache.brooklyn.util.core.config.ConfigBag;
    +import org.apache.brooklyn.util.core.flags.TypeCoercions;
    +import org.apache.brooklyn.util.core.task.DeferredSupplier;
    +import org.apache.brooklyn.util.core.task.Tasks;
    +import org.apache.brooklyn.util.exceptions.Exceptions;
    +import org.apache.brooklyn.util.guava.Maybe;
    +import org.slf4j.Logger;
    +import org.slf4j.LoggerFactory;
    +
    +import com.google.common.base.Predicate;
    +import com.google.common.collect.Maps;
    +
    +/**
    + * Delegates to another {@link BrooklynProperties} implementation, but 
intercepts all calls to get.
    + * The results are transformed: if they are in the external-config format 
then they are 
    + * automatically converted to {@link DeferredSupplier}.
    + * 
    + * The external-config format is that same as that for camp-yaml 
blueprints (i.e. 
    + * {@code $brooklyn:external("myprovider", "mykey")}.
    + */
    +public class DeferredBrooklynProperties implements BrooklynProperties {
    +
    +    private static final Logger LOG = 
LoggerFactory.getLogger(DeferredBrooklynProperties.class);
    +
    +    private static final String EXTERNAL_CONFIG_PREFIX = 
"$brooklyn:external";
    +    
    +    private final BrooklynProperties delegate;
    +    private final ManagementContextInternal mgmt;
    +
    +    public DeferredBrooklynProperties(BrooklynProperties delegate, 
ManagementContextInternal mgmt) {
    +        this.delegate = checkNotNull(delegate, "delegate");
    +        this.mgmt = checkNotNull(mgmt, "mgmt");
    +    }
    +    
    +    private Object transform(ConfigKey<?> key, Object value) {
    +        if (value instanceof CharSequence) {
    +            String raw = value.toString();
    +            if (raw.startsWith(EXTERNAL_CONFIG_PREFIX)) {
    +                CampYamlParser parser = 
mgmt.getConfig().getConfig(CampYamlParser.YAML_PARSER_KEY);
    --- End diff --
    
    why not `startsWith("$brooklyn:)` ?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to