Kaj Bjurman wrote:
> Hi all,
>
> Is there a way to put a global property in a deployment descriptor? (So it
> can be used from JNDI by several EJBs).
>
If your properties are read-only, you could just write a stateless session bean
which holds these shared properties in its environment. This bean could have
these methods (where map is a HashMap):
public Object getProperty(String name, Object defaultValue) {
Object o = null;
o = map.get(name);
if (o == null) {
try {
o = env.lookup(name);
if (o == null) {
o = defaultValue;
}
else {
map.put(name, o);
}
}
catch (NamingException e) {
o = defaultValue;
}
}
return o;
}
public Object getProperty(String name) {
return getProperty(name, null);
}
In your other beans, instead of getting the property from the java:comp/env
context, you would call this session bean.
JB.
<snipped>
--
Jean-Baptiste Nizet
[EMAIL PROTECTED]
R&D Engineer, S1 Belgium
Kleine Kloosterstraat, 23
B-1932 Sint-Stevens Woluwe
+32 2 200 45 42
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".