Win a copy of Modern JavaScript for the Impatient this week in the Server-Side JavaScript and NodeJS forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

5 bean client steps

 
Ranch Hand
Posts: 187
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
On p55 of HFEJB K&B it shows 5 steps to use a bean.
The book also says that if the client is another bean the code will be slightly different.

How?

Will someone advise me on whether I am correct or not:--

[ October 01, 2004: Message edited by: Swamy Nathan ]
 
Cowgirl and Author
Posts: 1589
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think this is almost right...

One thing I'd specify is that if the servlet client is a part of the same J2EE App Server, than the servlet and the bean clients will be identical, and what you refer to as SimpleClient (like our standalone plain old Java app) should really be called "A non-J2EE client", which could mean a standalone Swing GUI, or a servlet.

So, the two issues that you've specified are correct;

1) How do you get the InitialContext?
2) What do you code in the lookup String?

So, here we go:

1) InitialContext:

For J2EE clients (which could mean another bean, a servlet running in the servlet Container of the same J2EE server, or even a "J2EE application client", you can ask for the default InitialContext. The Contianer *knows* it's own JNDI context.

But for NON-J2EE clients, of course, you must specify *somehow* the location and class type of the driver for that server. You can do this in several ways: invoking InitialContext() overridden constructor that takes a Properties object; invoking the no-arg constructor and assuming that it will find the jndi.properties file that has the correct info, or specifying command-line arguments that set those properties. This is really dependent on your app server.


2) For the lookup String, NON-J2EE clients must specify the JNDI name configured on deployment of the app. J2EE clients will use the java:com/env lookup, because that allows them to use a coded name that can (in the DD) be mapped to something else later.

Does that help? We should make a table like you've done and put it on our web page... or add to the next edition of the book. It's a great idea!
cheers,
Kathy
 
Swamy Nathan
Ranch Hand
Posts: 187
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there any easier way to post tabular info here?
 
Swamy Nathan
Ranch Hand
Posts: 187
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there any easier way to post tabular info here?
 
Consider Paul's rocket mass heater.
    Bookmark Topic Watch Topic
  • New Topic