Override Java properties from packages

I am using several packages that are configured using config properties like org.apache.ws.security.crypto. Usually one config file is enough, but now I need to override one or more properties when used by code that is called from a specific instance of an object. I'm far from being a java expert (but I mean too many years of programming experience to mention), so any particular fidelity for a solution would be appreciated.

+2


source to share


2 answers


The Java property store is a single global map of name values. There is no general support for overriding properties based on "who" (object, package, etc.) Refers to a property.



+1


source


The answer will depend on the specific package you are using and what property you want to change. The properties file can be read once at startup and is no longer available for access. If this is what the code does, then there is nothing you can do about it without changing the code. Other packages give you the ability to change properties or provide other configuration options that allow you to set values ​​without using a properties file. Individual subscribers would have to make sure to change properties as needed.

You also need to worry about threading issues (even if you are running on an application server that abstracts them). If properties are stored as a static variable, then changing it for one caller can change it for all callers.



Anyway, I would suggest talking about the specific class and property you care about here and see if anyone knows how to handle property change on a per user basis.

0


source







All Articles