users@glassfish.java.net

Re: Design Suggestions Properties/Resources

From: Cheng Fang <Cheng.Fang_at_Sun.COM>
Date: Fri, 19 Oct 2007 10:09:19 -0400

glassfish_at_javadesktop.org wrote:
> Thanks for the advice!
>
> But since I don't have a web.xml and I want my resource to be available to all session beans in which config file can I then add the <env-entry>.
You have to have ejb-jar.xml where <env-entry> is declared for /*every*/
EJB. If your beans are already annotated, this ejb-jar.xml can be very
simple. For example,

<?xml version="1.0" encoding="UTF-8"?>
<ejb-jar xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="3.0"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd">
    <enterprise-beans>
        <session>
            <ejb-name>FooBean</ejb-name>
            <env-entry>
                <env-entry-name>myChar</env-entry-name>
                <env-entry-type>java.lang.Character</env-entry-type>
                <env-entry-value>1</env-entry-value>
            </env-entry>
        </session>
       
        <session>
            <ejb-name>BarBean</ejb-name>
            <env-entry>
                <env-entry-name>myChar</env-entry-name>
                <env-entry-type>java.lang.Character</env-entry-type>
                <env-entry-value>2</env-entry-value>
            </env-entry>
        </session>
    </enterprise-beans>
</ejb-jar>

> Do I have to add it to the config file of my ear-file perhaps?
> [Message sent by forum member 'woel' (woel)]
>
>
<env-entry> is not available at application (EAR) level. I'd suggest
not to use any custom prop files to store these config data, since it is
tedious and error-prone to retrieve while we already have a JavaEE
standard way to do that.
> http://forums.java.net/jive/thread.jspa?messageID=241216
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>
>