users@glassfish.java.net

Re: ejb3 modules: configuration best-practises?

From: <glassfish_at_javadesktop.org>
Date: Mon, 28 Jan 2008 07:15:46 PST

Hi Kristian,

The standard way in JavaEE is to use env-entry for configuration data. This applies to all JavaEE component types including EJB, web, connector. 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>
        <description>regular env-entry</description>
        <env-entry-name>username</env-entry-name>
        <env-entry-type>java.lang.String</env-entry-type>
        <env-entry-value>abc</env-entry-value>
      </env-entry>
      <env-entry>
        <env-entry-name>othername</env-entry-name>
        <env-entry-type>java.lang.String</env-entry-type>
        <env-entry-value>other value</env-entry-value>
      </env-entry>

You can then look them up with JNDI or inject them to EJB 3 bean class, servlet, filters, interceptors, listener classes, etc.

-cheng
[Message sent by forum member 'cf126330' (cf126330)]

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