简体   繁体   中英

How to update the value of Websphere Resource Environment Provider custom properties using java code?

We are using custom properties defined in Websphere using a Resource Environment provider that was setup using the instructions on

http://www.ibm.com/developerworks/websphere/library/techarticles/0611_totapally/0611_totapally.html

We have succeeded in setting up the custom properties and reading those in Java code (servlet).

The custom properties include properties that need to be updated on runtime. So we are looking for a way to update the values of some of these custom properties in Java code (servlet). Is there any way we can achieve this?

Also, we noticed that a server restart is required to reflect the updated values in the application. Is there someway we can propagate the changes without server restart?

I do not recommend this. Your application will need to have administrative access to the server, and in my opinion, application's modifying their own server's configurations are fragile. You would be better off using an in-memory solution (for example, a singleton POJO or singleton EJB).

If you really want to do this:

  1. You need to use AdminClientFactory to obtain AdminClient, then create a ConfigServiceProxy to find the relevant configuration object and modify it's attributes. These steps will be very similar (but more verbose) to what you would do in wsadmin. In my opinion, the best code example of using ConfigServiceProxy is for configuring JDBC .

  2. Ultimately, your resource environment provider configuration is stored in a resources.xml configuration file in the profile's config directory. There is a reload method on the DataSourceCfgHelper MBean (somewhat awkwardly placed) that you can use to dynamically reload the resources.xml files (the resources.xml files are incidentally reloaded automatically between application restarts). The "configuring JDBC" link above also has an example of invoking this reload method.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM