GitHub user GabrielBrascher opened a pull request:
https://github.com/apache/cloudstack/pull/1263
Removed unused code from com.cloud.api.ApiServer
**Removed â\_â from variables names**: private variables with â\_â
at the beginning is common in C++ but not in Java.
**Removed unused methods from ApiServer:**
- com.cloud.api.ApiServer.setPluggableServices(List\<PluggableService\>):
this method can be removed and replaced by the annotation @Inject in the
variable pluggableServices;
- com.cloud.api.ApiServer.getPluggableServices(): unused method;
- com.cloud.api.ApiServer.setApiAccessCheckers(List\<APIChecker\>): can be
replaced by the @Inject in the variable apiAccessCheckers;
- com.cloud.api.ApiServer.getApiAccessCheckers(): unused method.
**Methods and variables access level reviewed:**
- com.cloud.api.ApiServer.handleAsyncJobPublishEvent(String, String
,Object): this method was private but the annotation @MessageHandler requests
public methods, as can be seen in
org.apache.cloudstack.framework.messagebus.MessageDispatcher.buildHandlerMethodCache(Class\<?\>),
which searches methods with the @MessageHandler annotation and changes
it to be accessible (âsetAccessible(true)â). Thus, there is no reason
for handleAsyncJobPublishEvent be a private method and lead some other dev to
wrong conclusions about the use of the method;
- Global variables and methods called just by this class (ApiServer) were
changed to private.
**Changed variables and methods from static to non-static (if possible):**
as some variables/methods are used just by one object of this class,
instantiated by Spring, they were changed to non-static.
With that, calls from com.cloud.api.ApiServlet.ApiServlet() that used
static methods from ApiServer, were changed from ApiServer.\<staticMethodName\>
to \_apiServer.\<methodName\> that refers to the
org.apache.cloudstack.api.ApiServerService interface. Thus, methods
com.cloud.api.ApiServer.getJSONContentType() and
com.cloud.api.ApiServer.isSecureSessionCookieEnabled() had to be added in the
interface (org.apache.cloudstack.api.ApiServerService, interface implemented by
class ApiServer).
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/rafaelweingartner/cloudstack
lrg-cs-hackday-018
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/cloudstack/pull/1263.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 #1263
----
commit b8b09e7abf9c318d774d5dadd3663e2d79107f21
Author: gabrascher <[email protected]>
Date: 2015-12-20T11:38:04Z
Removed unused code from com.cloud.api.ApiServer
Removed â_â from variables names, private variables with â_â at the
beginning is common in C++ but not in Java.
Removed unused methods from ApiServer:
- com.cloud.api.ApiServer.setPluggableServices(List<PluggableService>):
This method can be removed and replaced by the annotation @Inject in the
variable pluggableServices (before _pluggableServices.
- com.cloud.api.ApiServer.getPluggableServices(): Unused method.
- com.cloud.api.ApiServer.setApiAccessCheckers(List<APIChecker>): Can be
replaced by the @Inject in the variable apiAccessCheckers (before
_apiAccessCheckers).
- com.cloud.api.ApiServer.getApiAccessCheckers(): Unused method.
Methods and variables access level reviewed:
- com.cloud.api.ApiServer.handleAsyncJobPublishEvent(String, String,
Object): This method was private but the annotation @MessageHandler
requests public methods, as can be seen in
org.apache.cloudstack.framework.messagebus.MessageDispatcher.buildHandlerMethodCache(Class<?>),
which searches methods with the @MessageHandler annotation and changes
it to be accessible (âsetAccessible(true)â). Thus, there is no reason
for handleAsyncJobPublishEvent be a private method and lead some other
dev to wrong conclusions about the use of the method.
- Global variables and methods called just by this class (ApiServer)
were changed to private.
Changed variables and methods from static to non-static (if possible):
As some variables/methods are used just by one object of this class,
instantiated by Spring, they were changed to non-static.
With that, calls from com.cloud.api.ApiServlet.ApiServlet() that used
static methods from ApiServer, were changed from
ApiServer.<staticMethodName> to _apiServer.<methodName> that refers to
the org.apache.cloudstack.api.ApiServerService interface. Thus, methods
com.cloud.api.ApiServer.getJSONContentType() and
com.cloud.api.ApiServer.isSecureSessionCookieEnabled() had to be added
in the interface (org.apache.cloudstack.api.ApiServerService, interface
implemented by class ApiServer).
----
---
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.
---