gtully commented on a change in pull request #3867:
URL: https://github.com/apache/activemq-artemis/pull/3867#discussion_r763007942
##########
File path:
artemis-server/src/main/java/org/apache/activemq/artemis/core/server/balancing/policies/PolicyFactoryResolver.java
##########
@@ -56,19 +59,15 @@ private void loadPolicyFactories() {
PolicyFactory.class, BrokerBalancer.class.getClassLoader());
for (PolicyFactory policyFactory : serviceLoader) {
- registerPolicyFactory(policyFactory);
+
policyFactories.put(keyFromClassName(policyFactory.getClass().getName()),
policyFactory);
}
}
- public void registerPolicyFactory(PolicyFactory policyFactory) {
- for (String policyName : policyFactory.getSupportedPolicies()) {
- policyFactories.put(policyName, policyFactory);
- }
+ public void registerPolicyFactory(String name, PolicyFactory policyFactory)
{
+ policyFactories.put(name, policyFactory);
}
- public void unregisterPolicyFactory(PolicyFactory policyFactory) {
- for (String policyName : policyFactory.getSupportedPolicies()) {
- policyFactories.remove(policyName, policyFactory);
- }
+ String keyFromClassName(String name) {
+ return name.substring(0, name.indexOf("PolicyFactory"));
Review comment:
I think it makes sense to use part of the newly provided class to
provide a name to identify the feature. That class wil have to implement a
specific interface so it will already be tied to a class. But in this case, the
name gives the actual intent of the class. I don't see need for any indirection.
--
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]