[GitHub] brooklyn-server pull request #625: Updates BasicExternalConfigSupplierRegist...

2017-04-11 Thread asfgit
Github user asfgit closed the pull request at:

https://github.com/apache/brooklyn-server/pull/625


---
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.
---


[GitHub] brooklyn-server pull request #625: Updates BasicExternalConfigSupplierRegist...

2017-04-11 Thread nakomis
Github user nakomis commented on a diff in the pull request:

https://github.com/apache/brooklyn-server/pull/625#discussion_r110842541
  
--- Diff: 
core/src/main/java/org/apache/brooklyn/core/mgmt/internal/BasicExternalConfigSupplierRegistry.java
 ---
@@ -103,12 +103,13 @@ private void 
updateFromBrooklynProperties(ManagementContext mgmt) {
 BrooklynProperties config = 
ConfigUtils.filterForPrefixAndStrip(externalProviderProperties, key + ".");
 
 try {
-Maybe configSupplier = 
Reflections.invokeConstructorFromArgs(classloader, 
ExternalConfigSupplier.class, providerClassname, mgmt, name, config);
+Class supplierClass = 
(Class)new ClassLoaderUtils(this, 
mgmt).loadClass(providerClassname);
+Maybe configSupplier = 
Reflections.invokeConstructorFromArgs(supplierClass, mgmt, name, config);
 if (!configSupplier.isPresent()) {
--- End diff --

`supplierClass` is passed to `Reflections.invokeConstructorFromArgs` so it 
needs to be loaded first


---
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.
---


[GitHub] brooklyn-server pull request #625: Updates BasicExternalConfigSupplierRegist...

2017-04-10 Thread neykov
Github user neykov commented on a diff in the pull request:

https://github.com/apache/brooklyn-server/pull/625#discussion_r110697978
  
--- Diff: 
utils/common/src/main/java/org/apache/brooklyn/util/javalang/Reflections.java 
---
@@ -204,6 +209,7 @@ public Object loadInstance(String classname) throws 
ReflectionNotFoundException,
 }
 
 /** does not look through ancestors of outer class */
+/** @deprecated since 0.11.0, use {@link 
org.apache.brooklyn.util.core.ClassLoaderUtils} in a combination with {@link 
#invokeConstructorFromArgs(Class, Object...)} instead */
--- End diff --

`Reflections` is in `utils-common`, while `ClassLoaderUtils` is in `core`. 
Could move the string based methods to another utility class into `core`.  If 
the caller is going to be constructing the `ClassLoaderUtils` there's not much 
to gain from it though.


---
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.
---


[GitHub] brooklyn-server pull request #625: Updates BasicExternalConfigSupplierRegist...

2017-04-10 Thread aledsage
Github user aledsage commented on a diff in the pull request:

https://github.com/apache/brooklyn-server/pull/625#discussion_r110695847
  
--- Diff: 
utils/common/src/main/java/org/apache/brooklyn/util/javalang/Reflections.java 
---
@@ -204,6 +209,7 @@ public Object loadInstance(String classname) throws 
ReflectionNotFoundException,
 }
 
 /** does not look through ancestors of outer class */
+/** @deprecated since 0.11.0, use {@link 
org.apache.brooklyn.util.core.ClassLoaderUtils} in a combination with {@link 
#invokeConstructorFromArgs(Class, Object...)} instead */
--- End diff --

Alternatively we could allow `Reflections to be constructed with a 
`ClassLoaderUtils`, and deprecate the method that creates it with a 
`ClassLoader`. We'd also deprecate the static methods that take a `ClassLoader`?


---
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.
---


[GitHub] brooklyn-server pull request #625: Updates BasicExternalConfigSupplierRegist...

2017-04-10 Thread aledsage
Github user aledsage commented on a diff in the pull request:

https://github.com/apache/brooklyn-server/pull/625#discussion_r110694398
  
--- Diff: 
utils/common/dependencies/osgi/entities/src/main/java/org/apache/brooklyn/test/osgi/UnprefixedDummyExternalConfigSupplier.java
 ---
@@ -0,0 +1,33 @@
+/*
+ * 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 com.example.brooklyn.test.osgi;
+
+import org.apache.brooklyn.core.config.external.ExternalConfigSupplier;
+
+public class DummyExternalConfigSupplier implements ExternalConfigSupplier 
{
--- End diff --

This classname doesn't match its filename.


---
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.
---


[GitHub] brooklyn-server pull request #625: Updates BasicExternalConfigSupplierRegist...

2017-04-10 Thread aledsage
Github user aledsage commented on a diff in the pull request:

https://github.com/apache/brooklyn-server/pull/625#discussion_r110694031
  
--- Diff: 
core/src/main/java/org/apache/brooklyn/core/mgmt/internal/BasicExternalConfigSupplierRegistry.java
 ---
@@ -103,12 +103,13 @@ private void 
updateFromBrooklynProperties(ManagementContext mgmt) {
 BrooklynProperties config = 
ConfigUtils.filterForPrefixAndStrip(externalProviderProperties, key + ".");
 
 try {
-Maybe configSupplier = 
Reflections.invokeConstructorFromArgs(classloader, 
ExternalConfigSupplier.class, providerClassname, mgmt, name, config);
+Class supplierClass = 
(Class)new ClassLoaderUtils(this, 
mgmt).loadClass(providerClassname);
+Maybe configSupplier = 
Reflections.invokeConstructorFromArgs(supplierClass, mgmt, name, config);
 if (!configSupplier.isPresent()) {
--- End diff --

I think we should only try to load `supplierClass` if `configSupplier` is 
absent (i.e. move that line to inside the if below.


---
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.
---


[GitHub] brooklyn-server pull request #625: Updates BasicExternalConfigSupplierRegist...

2017-04-10 Thread aledsage
Github user aledsage commented on a diff in the pull request:

https://github.com/apache/brooklyn-server/pull/625#discussion_r110694368
  
--- Diff: 
utils/common/dependencies/osgi/com-example-entities/src/main/java/com/example/brooklyn/test/osgi/PrefixedDummyExternalConfigSupplier.java
 ---
@@ -0,0 +1,33 @@
+/*
+ * 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 com.example.brooklyn.test.osgi;
+
+import org.apache.brooklyn.core.config.external.ExternalConfigSupplier;
+
+public class DummyExternalConfigSupplier implements ExternalConfigSupplier 
{
--- End diff --

This classname doesn't match its filename.


---
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.
---


[GitHub] brooklyn-server pull request #625: Updates BasicExternalConfigSupplierRegist...

2017-04-10 Thread neykov
Github user neykov commented on a diff in the pull request:

https://github.com/apache/brooklyn-server/pull/625#discussion_r110666451
  
--- Diff: 
utils/common/src/main/java/org/apache/brooklyn/util/javalang/Reflections.java 
---
@@ -204,6 +209,7 @@ public Object loadInstance(String classname) throws 
ReflectionNotFoundException,
 }
 
 /** does not look through ancestors of outer class */
+/** @deprecated since 0.11.0, use {@link 
org.apache.brooklyn.util.core.ClassLoaderUtils} in a combination with {@link 
#invokeConstructorFromArgs(Class, Object...)} instead */
--- End diff --

Can you deprecate the corresponding `invokeConstructorFromArgs`  methods as 
well.


---
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.
---


[GitHub] brooklyn-server pull request #625: Updates BasicExternalConfigSupplierRegist...

2017-04-10 Thread neykov
Github user neykov commented on a diff in the pull request:

https://github.com/apache/brooklyn-server/pull/625#discussion_r110665785
  
--- Diff: 
core/src/main/java/org/apache/brooklyn/core/mgmt/internal/BasicExternalConfigSupplierRegistry.java
 ---
@@ -103,12 +103,13 @@ private void 
updateFromBrooklynProperties(ManagementContext mgmt) {
 BrooklynProperties config = 
ConfigUtils.filterForPrefixAndStrip(externalProviderProperties, key + ".");
 
 try {
-Maybe configSupplier = 
Reflections.invokeConstructorFromArgs(classloader, 
ExternalConfigSupplier.class, providerClassname, mgmt, name, config);
+Class supplierClass = 
(Class)new ClassLoaderUtils(this, 
mgmt).loadClass(providerClassname);
+Maybe configSupplier = 
Reflections.invokeConstructorFromArgs(supplierClass, new Object[] {mgmt, name, 
config});
 if (!configSupplier.isPresent()) {
-configSupplier = 
Reflections.invokeConstructorFromArgs(classloader, 
ExternalConfigSupplier.class, providerClassname, mgmt, name, 
config.asMapWithStringKeys());
+configSupplier = 
Reflections.invokeConstructorFromArgs(supplierClass, new Object[] {mgmt, name, 
config.asMapWithStringKeys()});
--- End diff --

No need to create the array, you can simplify to: 
```
Reflections.invokeConstructorFromArgs(supplierClass, mgmt, name, 
config.asMapWithStringKeys());
```


---
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.
---


[GitHub] brooklyn-server pull request #625: Updates BasicExternalConfigSupplierRegist...

2017-04-10 Thread nakomis
GitHub user nakomis opened a pull request:

https://github.com/apache/brooklyn-server/pull/625

Updates BasicExternalConfigSupplierRegistry to use ClassLoaderUtils



You can merge this pull request into a Git repository by running:

$ git pull https://github.com/nakomis/brooklyn-server 
reflections-external-supplier

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/brooklyn-server/pull/625.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #625


commit 9409b5bd9446e040ac574b736c8edf8e994a9ba4
Author: Martin Harris 
Date:   2017-04-10T14:01:01Z

Updates BasicExternalConfigSupplierRegistry to use ClassLoaderUtils




---
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.
---