Pages

Wednesday, April 13, 2011

Using Resource Environment Provider : A replacement for application property files.

Most J2EE Applications and for that matter, any applications uses Property File to provide the properties and attributes to it's app. While this is fine and it works as expected, however, there are instances that you would like to store these properties on your underlying server and manage it from there. Example, in my current company where I work for, (and I believe this is also on majority of MNC's), if you have an application that comes together with a property file and you need to change the property file, Operations will normally require you to do the changes on dev copy and proceed it for re-deployment. Now, in-cases where processes are in-place for you to follow, this needs to go QA regression etc. Depending on schedule, this may take more than a day to implement.

To reduce this, you may use Resource Environment Provider instead of property files to store your properties, and then do a JNDI call to your app server to do get the values. These are possible for Websphere Application Server, Tomcat, etc. You just need to find how to do it in your application server.

The complete tutorial is in this link : http://www.ibm.com/developerworks/websphere/library/techarticles/0611_totapally/0611_totapally.html

What you require :
1. A class that implements ObjectFactory
2. A class that will be used to call get and set values.


1. Create a class library that implements an ObjectFactory. Here's the source code of what I did.





















2. Now create a AppConfig class that is called by the factory.








3. Go to your Websphere Application Server and follow the steps as shown below :






















4. Create a new provider.















5.Click on your provider.

















6. Click on Referenceables and click on New. Add the Factory Class (AppConfigFactory) and the Class (AppConfig) that we've just created.


















7. Click on Apply and Ok. Then go to Resource Environment Entries and create a JNDI.



















8. Choose on your referenceable the AppConfigFactory that we just created. After adding, click on the Custom Properties.






















9. Add the properties you need, and click apply and ok.




10. Add a JSP file on your application such as the code below :

















11. Run your application. You should see your properties viewed. Try changing the properties on the custom properties and restart your application. Once run, you will see the latest changes.

Additional note. If a property in Websphere Application Server has a word password on it, it is automaticaly XORed. I guess this is the default mechanism of Websphere Application Server, to provide atleast a minimum security.

ciao...

16 comments:

  1. Hello, i tried this and it works fine. But when i change the custom properties while my app is running then new properties are not passed to the ObjectFactory (I removed the if(config == null)). Any idea why? I would like to hot-change the properties.
    Best regards, Steffen

    ReplyDelete
  2. Nobody said you could do it on the fly. However, restarting the app is still much faster than re-deploying.

    ReplyDelete
  3. Any idea if this can be achieved in JBoss7 too?

    ReplyDelete
  4. They are the general population to whom you can clarify your ideas, your thoughts and they will give you bona fide input. At some point certain things appears to be anything but difficult to do yet in all actuality it is troublesome so they will control you and fix your things in all actuality if conceivable. convert website to app

    ReplyDelete
  5. Where and who are your potential tenants? Are there businesses and organisations locally with an ever changing workforce, such as hospitals, universities, even TV studios where people are usually employed on short-term contracts?
    zillow ocala fl 34476

    ReplyDelete
  6. Took me time to read all the comments, but I really enjoyed the article. It proved to be Very helpful to me and I am sure to all the commenters here! It’s always nice when you can not only be informed, but also entertained! Assertiveness Training Melbourne

    ReplyDelete
  7. In other instances you may be lucky enough to buy something for less than it is worth and sell it the next day for market value thereby making a profit on the 'turn' or 'flip'. You will normally have to pay Capital Gains Tax on the increase of the property's value when you sell it.Forestry Mulching

    ReplyDelete
  8. I see some amazingly important and kept up to length of your strength searching for in your on the site Roblox APK iOS Download

    ReplyDelete
  9. Hi buddies, it is great written piece entirely defined, continue the good work constantly. Tubemate APK Here Download Latest & Updated File

    ReplyDelete
  10. If you don"t mind proceed with this extraordinary work and I anticipate a greater amount of your magnificent blog entries Tubidy Video APK Download Latest version Free

    ReplyDelete
  11. As a result of the rule change, buying Singapore property has definitely become significantly easier for those purchasing domestically and abroad. martin modern

    ReplyDelete
  12. We now repeat the same lines and calculations for projecting our equity line of credit balances. Once we are done with these two sources, we have completed our financing worksheet.SubZero, Viking Ice Maker Repair Near Me

    ReplyDelete
  13. I have bookmarked your website because this site contains valuable information in it. I am really happy with articles quality and presentation. Thanks a lot for keeping great stuff. I am very much thankful for this site. Costa Del Sol Property For Sale

    ReplyDelete
  14. Thanks for a very interesting blog. What else may I get that kind of info written in such a perfect approach? I’ve a undertaking that I am simply now operating on, and I have been at the look out for such info. Bellevue Property Management

    ReplyDelete
  15. Nice information, valuable and excellent design, as share good stuff with good ideas and concepts, lots of great information and inspiration, both of which I need, thanks to offer such a helpful information here. Property auctions

    ReplyDelete