Kohlmeier Christian wrote:
> 
> Hi,
> 
> I havs some questions concerning the <beans>.properties file refered in the
> textual deployment descriptor.
> 
> The jonas example beans show that this files are used to set some database
> configuration.
> I would like to use this file to set some session beans inital information.
> 
> Questions
> 1) Is it possible to use this properties files for other reasons than
> database configuration?
> 2) How do i read this properties inside my bean?
> 3) Is the / At what time is the - properties file read by the EJB-Server?
>     a) Never? Only used at deployment time.
>     b) Once? At beans load time?.
>     c) Every time I read the beans context?
> 
> Christian Kohlmeier
> 
Hi,
As it is explained in the JOnAS Bean Programmer's Guide the "environment
properties"
part of the textual Deployment descriptor reference a file in which are
set properties.
These properties are classified in two categories:
 1.bean properties: the properties specific to the bean itself, i.e.
used by the bean
 implementation only (e.g. the max value of a particular field, ...). 
 2.container properties: properties that are used by the container
and/or 
  EJB platform tools for activities delegated to the platform such as
persistence  
  management (in the case of container-managed persistence). 

The standard way  to read these properties inside a bean is for example:

public class SomeBean implements SessionBean {
  SessionContext ctx;
  java.util.Properties env;

public void setSessionContext(SessionContext sc) {
   ctx = sc;
   env = ctx.getEnvironment();
 }
public someBusinessMethod(...) {
 String fooValue = env.getProperty("foo");
 String barValue = env.getProperty("bar");
}
....

Note this is the standard way for EJB 1.0 and JOnAS 1.6
Now for EJB1.1 specifications and JOnAS 2.0 the standard way is the
following:
in your XML deployment descriptor you must have this sort of thing:
      <env-entry>
        <env-entry-name>foo</env-entry-name>
        <env-entry-type>java.lang.String</env-entry-type>
        <env-entry-value>foovalue</env-entry-value>
      </env-entry>

and in your bean:
        Context initialContext = null;
        initialContext = new InitialContext(); 
        String FooValue = (String)initialContext.lookup("java:comp/env/foo");

I hope it helps,
best regards,
-- 
        Philippe

Philippe Coq  Groupe Bulll/BullSoft/OpenMaster  Phone: (33) 04 76 29 78
49
Bull S.A  - 1 rue de Provence - 38432 Echirolles Cedex France
[EMAIL PROTECTED]  http://www-frec.bull.com
Download our EJBServer at http://www.bullsoft.com/ejb
----
To unsubscribe, send email to [EMAIL PROTECTED] and
include in the body of the message "unsubscribe jonas-users".
For general help, send email to [EMAIL PROTECTED] and
include in the body of the message "help".

Reply via email to