> 1> Does this "testpropname" gets attached to a JNDI
> tree??

I think it really depends on the server as to how they do it... in JBoss,
the java:comp context is bound, and that then, based on the thread thats
calling it, will return the appropriate subcontexts

> 2> From what u say it seems this java:comp/env - is
> something very specific to EJB - is that a good design
> to keem something so specific in JNDI.

absolutely... whilst there's no reason you couldn't use java:comp/env in
your own application completely independent from EJB (although you would
have to do some things that the EJB server does for you - like binding),
java:comp/env is effectively an EJB thing.

> 3> I do a new IntialContext() and then access those
> props from within the ejb - I do not pass any
> specifics of the EJB to the InitalContext object - how
> does it know which ejbs env its accessing??

again - up to the container... JBoss holds its context information in the
thread.  I'm guessing most (all?) servers do this.

> 4> To me it seems the correct design would have been
> to get those env from the EJBContext and not from
> InitialContext.

and expose a Map or something?  yes... possible, but they chose JNDI (o:

> 5> i still do not understand how this is technically
> possible - In a JNDI tree the key name has to be
> unique - so how is it possible to attach 2
> "testpropname" for 2 EJBs in the same tree??

ok, suppose I have a class:

public class Foo
{
  public int bar;
}

now, you can just do something like:

  Foo f = new Foo();
  f.bar = 4;
  System.out.println(f.bar);

and you _know_ that bar is 4.  But, suppose I do this:

public class Foo
{
  private int bar;
  public void setBar(int b) { this.bar = b; }
  public int getBar() { return bar; }
}

and then

  Foo f = new Foo();
  f.setBar(4);
  System.out.println(f.getBar());

now, because you can see all the code, you know whats going on, but imagine
I was to rewrite getBar() to something like:

  public int getBar()
  {
    // which thread is calling me?  if its thread A, return 5, else return
6....
    return (currentthread == A) ? 5 : 6;
  }

of course thats pseudo code, but thats effectively what happens...

hth
dim



>
> TIA
> Anamitra
> --- Dmitri Colebatch <[EMAIL PROTECTED]> wrote:
> > Hi,
> >
> > in short:  each EJB has its 'own' java:comp/env
> > context.  So, two ejbs will see different things in
> > their java:comp/env contexts
> > (unless you've set them up to be the same).  Also,
> > you wont then (ordinarily) be able to do lookups in
> > java:comp/env from outside
> > ejb code.
> >
> > cheesr
> > dim
> >
> >
> > ----- Original Message -----
> > From: "Anamitra Bhattacharyya"
> > <[EMAIL PROTECTED]>
> > To: <[EMAIL PROTECTED]>
> > Sent: Friday, May 03, 2002 12:32 PM
> > Subject: java:comp/env dilemma
> >
> >
> > > Hi
> > > This is very basic question - but pls help me
> > > understand this JNDI/EJB stuff. We add environ
> > entries
> > > to our ejb and that gets attached to the JNDI tree
> > by
> > > the name java:comp/env/tespropname. Now if I have
> > > another EJB with the same property "testpropname"-
> > the
> > > container will take care that they are separate -
> > > though I access them from either of the EJBs using
> > > ctx.lookup("java:com/env/testpropname")!!!
> > > The spec says:
> > >
> > > An environment entry is scoped to the enterprise
> > bean
> > > whose declaration contains the env-entry element.
> > > This means that the environment entry is
> > inaccessible
> > > from other enterprise beans at runtime, and
> > > that other enterprise beans may define env-entry
> > > elements with the same env-entry-name without
> > > causing a name conflict.
> > >
> > > Can anyone explain this "scoping" concept - I
> > looked
> > > through the JNDI apis and didnt find anything
> > which
> > > the container can use to acheive this ejb based
> > > "scoping".
> > > TIA
> > > Anamitra
> > >
> > > __________________________________________________
> > > Do You Yahoo!?
> > > Yahoo! Health - your guide to health and wellness
> > > http://health.yahoo.com
> > >
> > >
> >
>
===========================================================================
> > > To unsubscribe, send email to
> > [EMAIL PROTECTED] and include in the body
> > > of the message "signoff EJB-INTEREST".  For
> > general help, send email to
> > > [EMAIL PROTECTED] and include in the body of
> > the message "help".
> > >
> >
>
>
> __________________________________________________
> Do You Yahoo!?
> Yahoo! Health - your guide to health and wellness
> http://health.yahoo.com
>
>
===========================================================================
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the
body
> of the message "signoff EJB-INTEREST".  For general help, send email to
> [EMAIL PROTECTED] and include in the body of the message "help".
>

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to