GitHub user pedro-martins reopened a pull request:
https://github.com/apache/cloudstack/pull/714
Changed variable s_logger to non-static and fixed its name in
âcom.cloud.utils.component.ComponentLifecycleBaseâ and its subclasses
Hi guys,
We have noticed that every single class that is a subclass of
âComponentLifecycleBaseâ instantiate their on âloggerâ manually and
uses a nonstandard name. We fixed that by changing the variable in
âComponentLifecycleBaseâ to protected and non-static and instantiated it
using the method âgetClassâ from Object class. Therefore, we can reduce the
code in a few hundred lines and use a more intuitive name for the logger
variable.
During that process we found a static method that used the âs_loggerâ
variable in classes:
com.cloud.network.element.VirtualRouterElement
org.apache.cloudstack.network.element.InternalLoadBalancerElement
To fix that we had to create a new class
âcom.cloud.network.element.HAProxyLBRuleâ, instantiate it with @Componente
and inject into the aforementioned classes.
The class that we create is âcom.cloud.network.element.HAProxyLBRuleâ
and has the following methods:
com.cloud.network.element.HAProxyLBRule.containsOnlyNumbers(String, String)
com.cloud.network.element.HAProxyLBRule.validateHAProxyLBRule(LoadBalancingRule)
Sadly we could not write test cases to it; hence we did not fully
understand those methods. However, if anyone out there understands it, we would
appreciate some code to be added to it.
As minor this change may seem; we believe that it enhances a little bit the
ACS code by using standard name to logger variable.
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/rafaelweingartner/cloudstack
master-lrg-cs-hackday-003
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/cloudstack/pull/714.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 #714
----
commit ddcd1ed3e53dd3fff6e557e4a4b13eb2f03e62df
Author: pedro-martins <[email protected]>
Date: 2015-08-19T14:02:37Z
Changed variable s_logger to non-static and fixed its name in
âcom.cloud.utils.component.ComponentLifecycleBaseâ and its subclasses
We have noticed that every single class that is a subclass of
âComponentLifecycleBaseâ instantiate their on âloggerâ manually and
uses a nonstandard name. We fixed that by changing the variable in
âComponentLifecycleBaseâ to protected and non-static and instantiated it
using the method âgetClassâ from Object class. Therefore, we can reduce the
code in a few hundred lines and use a more intuitive name for the logger
variable.
During that process we found a static method that used the âs_loggerâ
variable in classes:
com.cloud.network.element.VirtualRouterElement
org.apache.cloudstack.network.element.InternalLoadBalancerElement
To fix that we had to create a new class
âcom.cloud.network.element.HAProxyLBRuleâ, instantiate it with @Componente
and inject into the aforementioned classes.
The class that we create is âcom.cloud.network.element.HAProxyLBRuleâ
and has the following methods:
com.cloud.network.element.HAProxyLBRule.containsOnlyNumbers(String, String)
com.cloud.network.element.HAProxyLBRule.validateHAProxyLBRule(LoadBalancingRule)
test
test2
----
---
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.
---