users@glassfish.java.net

making env-entry available to helper classes

From: <glassfish_at_javadesktop.org>
Date: Mon, 19 Mar 2007 07:04:31 PST

Hi,

I'm building an EJB3 Stateless SessionBean that uses some helper classes (like a Logger or a Configurator); I have defined an entry in the ejb-jar.xml:
        <session>
            <ejb-name>SessionStoreBean</ejb-name>
            <mapped-name>ejb/SessionStore</mapped-name>
            <ejb-class>org.limbs.broker.session.SessionStoreBean</ejb-class>
            <env-entry>
                <env-entry-name>dbType</env-entry-name>
                <env-entry-type>java.lang.String</env-entry-type>
                <env-entry-value>MySQL</env-entry-value>
            </env-entry>
        </session>

If I use the @Resource annotation in by Session Bean class:
    @Resource(name="dbType") private String dbType = "Oracle";

then the value is properly overwritten with the one defined in the ejb-jar.xml.

However, if I do the same in a helper class, the value is not overwritten.

Is there a way to get the value from the ejb-jar.xml injected into the helper classes as well?

Thanks for your help

Jean-Noel Colin
[Message sent by forum member 'jncolin' (jncolin)]

http://forums.java.net/jive/thread.jspa?messageID=208725