Rui Gil <[EMAIL PROTECTED]> writes:
>
>I'm getting a deprecation in the following method
>"EJBContext.getEnvironment()"
>Does anyone know the new mechanism to get an EJBean environment, 
>because it's seems that is not a method anymore...
>
>Thanx,
>
>Rui Gil

In EJB 1.1, to lookup a bean's configured environment, use the following
code in your bean:

javax.naming.Context initCtx = new javax.naming.InitialContext();
javax.naming.Context myEnv = (Context) initCtx.lookup("java:comp/env");

Note, the Context returned is SPECIFIC to that bean, and is also PRIVATE
to that bean - see the EJB 1.1 specs for more details.

Then access individual properties for this bean using code like:

String myProp = (String) myEnv.lookup( "myProp" );
Integer myNum = (Integer) myEnv.lookup( "aNumProperty" );

[This requires the server to support the EJB 1.1 XML Deployment
Descriptor format, and for corresponding entries in the bean's
deployment descriptor - again, see the EJB 1.1 specs for more details
about <env-entry> elements.]

Of course, there are relatively few EJB servers that currently do
support the 1.1 specs, and JOnAS is still using the EJB 1.0 way of doing
things I'm afraid.

HTH.

- Jorgen

------------------------------------------------------------
| Software Technologies  ----:----  http://www.SwTech.com/ |
| ----------->  One-stop Developer Reference  <----------- |
| Technical reference for professional software developers |
------------------------------------------------------------

Reply via email to