brooklyn-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aledsage <...@git.apache.org>
Subject [GitHub] incubator-brooklyn pull request: Add type coercion from Map to Pro...
Date Mon, 18 Aug 2014 13:23:43 GMT
Github user aledsage commented on a diff in the pull request:

    https://github.com/apache/incubator-brooklyn/pull/123#discussion_r16352171
  
    --- Diff: software/webapp/src/main/java/brooklyn/entity/proxy/ProxySslConfig.java ---
    @@ -19,11 +19,48 @@
     package brooklyn.entity.proxy;
     
     import java.io.Serializable;
    +import java.util.Map;
    +import java.util.concurrent.atomic.AtomicBoolean;
     
    +import brooklyn.util.flags.TypeCoercions;
    +
    +import com.google.common.base.Function;
     import com.google.common.base.Objects;
     
     public class ProxySslConfig implements Serializable {
     
    +    private static AtomicBoolean initialized = new AtomicBoolean(false);
    +
    +    /** Setup type coercion. */
    +    @SuppressWarnings("rawtypes")
    +    public static void init() {
    +        if (initialized.getAndSet(true)) return;
    +
    +        TypeCoercions.registerAdapter(Map.class, ProxySslConfig.class, new Function<Map,
ProxySslConfig>() {
    +            @Override
    +            public ProxySslConfig apply(final Map input) {
    +                ProxySslConfig sslConfig = new ProxySslConfig();
    +                sslConfig.certificateSourceUrl = (String) input.get("certificateSourceUrl");
    +                sslConfig.keySourceUrl = (String) input.get("keySourceUrl");
    +                sslConfig.certificateDestination = (String) input.get("certificateDestination");
    +                sslConfig.keyDestination = (String) input.get("keyDestination");
    +                Object targetIsSsl = input.get("targetIsSsl");
    +                if (targetIsSsl != null) {
    +                    sslConfig.targetIsSsl = TypeCoercions.coerce(targetIsSsl, Boolean.TYPE);
    +                }
    +                Object reuseSessions = input.get("reuseSessions");
    +                if (reuseSessions != null) {
    +                    sslConfig.reuseSessions = TypeCoercions.coerce(reuseSessions, Boolean.TYPE);
    +                }
    +                return sslConfig;
    +            }
    +        });
    +    }
    +
    +    static {
    --- End diff --
    
    What will have caused ProxySslConfig class to be loaded, for this static `init()` to be
called?


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message