users@glassfish.java.net

Re: Custom properties in a ejb archive

From: <glassfish_at_javadesktop.org>
Date: Wed, 05 Dec 2007 06:42:13 PST

You can use <env-entry> in ejb-jar.xml, and inject or look up the value in implementation classes:

<?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>xxx</description>
        <env-entry-name>username</env-entry-name>
        <env-entry-type>java.lang.String</env-entry-type>
        <env-entry-value>xxx</env-entry-value>
      </env-entry>

@Stateless
public FooBean implements Foo {
@Resource(name="username")
private String username;

You can also look up by the env-entry name:
context.lookup("java:comp/env/username");

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

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