modifying properties-service.xml - java

I have a question related to the properties-service.xml. There is a value inside this file that needs to be updated every once in a while programmatically. So I have the following questions about this operation which I wasn't able to find some details about them:
Is there a way to update properties-service.xml programatically other than parsing it and changing the value? If parsing is the only way, is there an available method of retrieving the location of the used properties file?
Can we reload the properties-service.xml after the update without restarting jboss or do I need to set the property manually?
Any help is appreciated.
Thanks,
Sami

To get location of the properties file - acquire System property "jboss.server.home.dir" and suffix "/deploy/properties-service.xml" to it.
Once you save your changes to properties files, JBoss will hot-deploy it as it scans for changes every 5 seconds. If it doesn't hot deploy check value of attribute "ScanEnabled" in /conf/jboss-service.xml to confirm that hot deploy is enabled

Related

Reinitialization of spring bean during runtime?

I have a problem ."This is just a configuration which I would like to manage during runtime. I don't want to redeploy whole app to update configuration".I am reading some values from the property files.How can i acheive this?
There are lots of possible solutions, depending on the exact need (and this like possibility to reload these properties on demand etc.).
The simplest one seems to be this one:
Create a bean that internally has a cache defined (like Guava Cache)
Set certain TTL for the cache contents (this will cause your properties to be reloaded every TTL seconds)
Provide a way to populate the cache
Optionally provide a way to force refresh of cache contents
As for the last point I cannot give you a way to do this because I know nothing of your project, but there are at least few good options here depending on the project you are working on.
Assuming your file is not part of deployable (WAR/EAR/JAR), you can watch for directory changes and identify whether your file has changed (refer Can I watch for single file change with WatchService (not the whole directory)?). Once you notice the file has changed, you can execute your logic.

How to add jvm custom propertis in bulk in Websphere

Our application is deployed in websphere and uses lots of custom jvm properties.
Right now we are adding the properties one by one through admin console.
This is a pain during development phase.
Because every day after syncing their code, each and every developer needs to find out if a new property has been added/renamed and do those changes in their own console. Else the application wont start.
It also takes a lot of application setup time, while deploying to various testing environments.
Could you help me identify the place where websphere stores these custom properties? We are thinking of writing a code to update that file (?) directly instead of adding one by one through admin console.
Please help.
P.S:- We are not allowed to use jython in our local :(
In the server.xml configuration for that given server, located somewhere like
Dmgr/config/cells/cellName/nodes/nodeName/servers/server1/server.xml
You can inspect the <processDefinitions> element and add a "systemProperties" stanza like:
<systemProperties xmi:id="Property_1460665921900" name="someName" value="someValue" required="false"/>
DO THIS AT YOUR OWN RISK. The "Property_1112223334445" part is fragile, and you need to make sure it has a unique 13-digit number at the end.
Or, you can modify the "genericJvmArguments" tag in the same file, using a format more like -DsomeName=someValue
Finally, if you do have jacl scripting access, there is an article on updating using scripting here.

How to get the current state i.e. ChangeSet/UUID/version-number of a project/file by using RTC Java APIs 5.2

How to get the current state i.e. ChangeSet/UUID/version-number of a project/file by using RTC Java APIs 5.2 (residing on Jazz server) along with its contents.
Suppose I load a particular file into my local sandbox, then I deleted
that file from my local workspace/sandbox, And other developer
checked-in the changes into the same file, so How to get that file
previous contents ignoring the latest state updated by someone else???
Thanks in advance!!!
If you reload your local sandbox (based on your repo workspace), you would recover that file (without any further modification)
You would get the other developer work only if you accepted incomming change sets into your repository workspace.
If you didn't accept anything, simply reloading would be enough.
(as illustrated in this thread, using ILoadOperation)

prefs.xml(java.utils.prefs.Preference) automatically refrsh by Glassfish

In my current application we are using Glassfish to deploy my ear file and We read the user specific values from different places and store it into java.util.prefs.Preference to user it latter. We also have options to change the java.util.prefs.Preference externally. Now the questions are:
a) Recently I found, whenever I am starting my application in Glassfish, Glassfish creating a prefs.xml file containing all the preference I set under /.java/.userPrefs/. But no where I have written code to store the same in this location. So, is that Glassfish's default behavior to store the preferences in this location? or is there any settings?
b) Now if the answer is yes for the question a. Then I am changing the prefernce value in the prefs.xml but after that if I am fetching the values from java.util.Preference, I am getting the old values only not the new value. Why java not refreshing the values? or prefs.xml is only for import/Export prefernces?
c) Whenever I am changing my Preference value externally, its not refreshing the value in prefs.xml. Is that a one time process of server restart?
Any help on the questing would be very much helpful to me.
a) Recently I found, whenever I am starting my application in Glassfish, Glassfish creating a prefs.xml file containing all the preference I set under /.java/.userPrefs/. But no where I have written code to store the same in this location. So, is that Glassfish's default behavior to store the preferences in this location? or is there any settings?
Answer: Glass fish do it automatically. It fetch the preference and then store into the same.
b) Now if the answer is yes for the question a. Then I am changing the prefernce value in the prefs.xml but after that if I am fetching the values from java.util.Preference, I am getting the old values only not the new value. Why java not refreshing the values? or prefs.xml is only for import/Export prefernces?
Ans: Only for import and export.
c) Whenever I am changing my Preference value externally, its not refreshing the value in prefs.xml. Is that a one time process of server restart?
Ans: prefs.xml only used as a back up copy. If you update the through java.util.Preference then also it will not be reflected in prefs.xml. Fir better understanding, change value in prefs.xml then restart server. You will find glassfish replaces your values with the value set through java code.

Java Deployment, Config File Changes

I have a java project deployed on the server.
Now I want to make some changes in "project/WebContent/WEB-INF/configuration.propertys".
My question is do I need to make changes in my local machine and redeploy or can I just make some changes in server's directory? As I can see the configuration.propertys file in server directory I doubt that I can make direct changes to that file and will it be effect to the deployed project
Thanks and Regards.
yup , you dont need to go round the complete cycle again, just update the properties file in server directory installed applications and restart your application.
I would suggest creating a DynamicMBean object to reload the properties file dynamically and it would not require a server restart. I think this is one of the best production quality solution.
It depends on how this properties file is used. If the configuration data is cached in the internal structures, then you have to initiate reinitialization of these structures in order to make the changes effective.
However, in some containers, you will just trigger automatic re-deployment of the application if you change the resources. But this is totally environment-specific.

Categories