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

    https://github.com/apache/brooklyn-server/pull/285#discussion_r76570589
  
    --- Diff: 
core/src/main/java/org/apache/brooklyn/core/location/AbstractLocation.java ---
    @@ -718,6 +719,35 @@ public boolean removeChild(Location child) {
             return removed;
         }
     
    +    public void init() {
    +        super.init();
    +        loadExtension();
    +    }
    +
    +    public void rebind() {
    +        super.rebind();
    +        loadExtension();
    +    }
    +
    +    private void loadExtension() {
    +        try {
    +            Map<String, String> extensions = 
getConfig(LocationConfigKeys.EXTENSIONS);
    +            if (extensions != null) {
    +                for (Map.Entry<String, String> extension: 
extensions.entrySet()) {
    +                    Class<?> extensionClassType =  new 
ClassLoaderUtils(this, getManagementContext()).loadClass(extension.getKey());
    +
    +                    if (!hasExtension(extensionClassType)) {
    +                        Object extensionClass = new ClassLoaderUtils(this, 
getManagementContext()).loadClass(extension.getValue()).newInstance();
    +                        addExtension((Class)extensionClassType, 
extensionClass);
    +                    }
    +                }
    +            }
    +        } catch (Exception e) {
    +            LOG.error("Location extension can not be loaded {}", e);
    --- End diff --
    
    Minor: this will call `LOG.error(String msg, Throwable t)` so the `{}` has 
no effect. That might be what we want, to ensure the stacktrace definitely gets 
logged (depending what happens to the propagated exception).
    
    If we do want just the exception's toString, would need to change it to 
something like:
    
        LOG.error("Location extension can not be loaded (rethrowing): {}", new 
Object[] {e});


---
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 [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to