In Java EE, simple values such as strings, integers, etc. are defined within the component namespace using an env-entry.
E.g.
<env-entry>
<env-entry-name>cfg/xxx</env-entry-name>
<env-entry-type>java.lang.String</env-entry-type>
<env-entry-value>my string</env-entry-value>
</env-entry>
This would then be looked up via :
(String) new InitialContext().lookup("java:comp/env/cfg/xxx");
It is also possible to have the value injected using @Resource :
@Resource(name="cfg/xxx")
private String stringValue;
However, even in this case you still need to also declare the env-entry in the
component's deployment descriptor to provide the actual value, since
hardcoding it defeats the purpose of using the level of indirection provided
by the component environment.
--ken
[Message sent by forum member 'ksak' (ksak)]
http://forums.java.net/jive/thread.jspa?messageID=226951