Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Accessing files from EJB

 
John Lindwall
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'd like to have some property files available from an EJB. The EJB spec says not to access files using java.io from an EJB. Um ... OK.
What are some practical solutions to this issue?
I dislike user getResource() because (being classpath-based) it opens the door to configuration errors. "Oh you mean we're loading foo.properties from the classpath? I didn't realize that and added my own foo.properties to the classpath and it was loaded instead of the expected one". I like something more explicit.
 
Lilac Ezer
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think the preferred solution is to declare your properties in the EJB deployment descriptors in <env-entry> elements.
I think if you called getResource or used the Preferences API in jdk1.4, that is still 'cheating' because I/O calls may still take place, even if you are not calling a file directly.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic