• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Using JNDI to store and retrieve properties

 
Ranch Hand
Posts: 188
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I want to be able to look up various string values using JNDI in a MessageListener class. For example I want to be able to store the database username and password, a queue name, queue owner, port number, etc. I am already doing this in some EJBs since I can specify the JNDI entries using <env-entry>, but I don't know how I would specify JNDI entries for a class which isn't an EJB, since I won't be declaring environment entries for the class in an ejb-jar.xml file. How is this done ? Should I be using JNDI for lookups of String values, or is there another approach which is better for this sort of thing ? Essentially I want to have a place outside of the Java sources where I can modify variable values (properties ?) at deploy time, and have these read into my code using JNDI lookups (or some other mechanism if more appropriate). It doesn't appear that this can be done for non-EJB classes in either ejb-jar.xml or jboss.xml.

Thanks in advance for any suggestions.


-James
 
Ranch Hand
Posts: 1258
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For a client application, you're right--there's no easy way for you to create "deployment" settings, which are then loaded into some JNDI context before your "main" function is invoked. You can, however, bind your objects in JNDI yourself. You can explore the JNDI javadocs to see if it meets with your approval.
 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The optional env-entry element in web.xml declares an environment entry for an application, visible by web components. It can be useful?

F.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic