Hmmm... I do not believe you really want to use property files in
EJB. I believe that property files require the java.io package which
an enterprise bean must not use. Check the Bean Provider's
responsibilities in Chapter 24 "Runtime Environment" in the EJB 2.0
spec.
EJB 2,0 provides a facility called Environment Entries that allow a
bean to lookup info at runtime using a JNDI lookup. I guess the EJB
designers were trying to find something that is both cross platform
and secure. Check out Chapter 20 Enterprise bean's environment in the
EJB 2.0 spec.
In your deployment descriptor
<entity>
....
<env-entry>
<description>Description provides facility for developer to
communicate intent to deployer</description>
<env-entry-name>pie</env-entry-name>
<env-entry-type>java.lang.Double</env-entry-type>
<env-entry-value>3.14</env-entry-value>
</env-entry>
<env-entry>
<description>Another place to provide info concerning deploy
time constant to bean deployer</description>
<env-entry-name>name</env-enty-name>
<env-entry-type>java.lang.String</env-entry-type>
<env-entry-value>Thermond</env-entry-value>
</env-entry>
...
In your bean,
....
import javax.ejb.*;
import javax.naming.*;
...
public void myBusinessMethod()
{
InitialContext ic = new InitialContext();
Double value = (Double) ic.lookup("java:comp/env/pie");
double pie = value.doubleValue();
String name = (String) ic.lookup("java:comp/env/name");
...
Your bean can access its JNDI environment in setSession/EntityContext
(), ejbCreate(), ejbRemove() ejbActivate(), ejbPassivate(), and
business methods. So I guess I should say that the JNDI environment
is accessible from every method of your session or entity bean but
the constructor.
I am assumed that you want just simple deployment time constants and
not something that should be a environment reference or a connection
factory.
If you want to do something similar with servlets and JSPs use <init-
param> or <context-param> in the web.xml. Feel free to ask about
them. I did not include them since this is mostly an EJB forum.
Good Luck
Thermond Adams
--- In weblogic-workbook@yahoogroups.com, "tramosde" <tramosde@y...>
wrote:
> I have the property file for my applications with some special
> definitions.
> How do I tell webLogic where the property file is????
>
> Thanks!!!