Reputation: 2820
I am working on a REST API project and using Websphere Application Server 8.5 for the deployment.
There are some String
attributes like COUNTRY_NAME
, COMPANY_NAME
etc, which are same throughout the application.
Currently I have created a Constants
class which is maintaining all the constants using public static final
variables. But some of my team mates on their modules, are adding these constants entries in Websphere environment variables and getting them using System.getProperty()
.
What i am thinking the problem in this System.getProperty()
way is that it makes the app dependent on the Websphere Server, but mine Constants
file is in the application itself, making it standalone, without dependency to server.
But on the other hand, if i want to change the attribute value, i need to create new EAR file of the app & redeploy, while in case of System.getProperty()
change can be done in server, without redeployment.
So which way should i move forward. Using Constants
file or System.getProperty()
.
Upvotes: 2
Views: 379
Reputation: 72854
Storing constants in a dedicated class or interface is not recommended. See What is the best way to implement constants in Java? for a related discussion.
IMO, having the constants configured as resource files is a better approach because it avoids the need to change the code in case constants value need to be changed.
Upvotes: 2