This week's giveaway is in the Spring forum.
We're giving away four copies of Learn Spring Security (video course) and have Eugen Paraschiv on-line!
See this thread for details.
Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

application-wide "env-entry" ??

 
Terence Doyle
Ranch Hand
Posts: 328
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I'm creating a J2ee application using various EJB's and at least one WAR, all inside one single EAR file.
This app. is to be intalled at different clients. I'd like to be able to specify different properties ( server used, remote host addresses, etc.) in some part of the EAR that will be available using
(String)context.lookup("java:comp/env/" + name );
I have been able to customize individual EJB's using the <env-entry> tag in its DD but what about the being able to customize the whole application??
I'm been scouring docs and the net and I can't see any specific application.wide examples.
Many thanks for your help.

Terry Doyle
 
Dave Landers
Ranch Hand
Posts: 401
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is, IMHO, one of the big weaknesses of J2EE. EJB and WebApps have lots of neat ways to do configuration (ejb-rev, env-entry, etc) but there is nothing at the application level.
There are lots of options, but if you want to stick with the spec, one thing you could do is to make a session bean that contains all the application-wide env-entry settings. Call something like getProperty(key) on that bean to retrieve the single env-entry from anywhere in the app. Not exactly pretty, but it works.
Blatant Advertisement:
Come to my Techniques for Building J2EE Applications talk at this year's Colorado Software Summit where we will discuss this and several other similar issues
 
Terence Doyle
Ranch Hand
Posts: 328
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Dave,
We've already got it working by placing the properties in one EJB DD and the WAR DD but I'm just not happy with that.
Too many chances of the application assembly getting more complicated than it should be.
You're the only one that answered - and with a confirmation of my worst fears - so I guess there's just nothing doing. If ANYONE has a way to do this please let me know, if not let's complain to SUN :-)
Suggestion to Sun for the next version of application.xml DTD .... How about allowing <env-entry> elements there that are placed in an application-wide jndi context ( java:comp/app for example )

Terry
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic