• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

When to use jndi ?

 
Ranch Hand
Posts: 159
Eclipse IDE C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,
I have a question about the use of jndi.
Is it made only to e.g. lookup of beans , can we compare it to the windows registry ? ->as in : its there, it works but its not good programmoing to go and use it extensively.
or
is it frequently used as a place to store "global" objects in memory ?
I'm actually looking for a solution to cach data in a way that it has the same benefits of a entity bean (everyone can access the same data) but I don't want to make it persistent.
Our first solution was to put it in an entity bean as non persistent data, but then when the bean passivates, you lose your non persistent data
What can a person put in jndi and is still good programming ?
thnx
 
Ranch Hand
Posts: 1873
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Mark,

is it frequently used as a place to store "global" objects in memory ?

NO. JNDI is a "directory service" its not a "cache" maintaining service for objects.
So I guess your dilema of whether to use JNDI for caching gets resolved.
Regards
Maulin
 
Mark Uppeteer
Ranch Hand
Posts: 159
Eclipse IDE C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Maulin,
So...can we use it for anything ? if so, can you give an example ?
or is it just to put and search our beans in ?
 
Maulin Vasavada
Ranch Hand
Posts: 1873
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Mark,
Well, it can be used to store anything but that anything is restricted to what "directory services" defines
Google on directory server/services and see what they usually do. They usually store information about resources within an organization like Users, Printers etc in a central place.
What you seem to refer is "caching of objects". If you mean you want to cache number of objects via JNDI (storing it in directory service), that can't be done. We should not get confused between totally different concepts here.
I guess googling on "naming and directory" service or Sun's JNDI tutorial would help you identify what I am babbling....
Thanks
Maulin
 
Mark Uppeteer
Ranch Hand
Posts: 159
Eclipse IDE C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thnx for your reply Maulin,
I read a bit about naming and directory services, its sort of a phonebook with name and an object reference 'lines' in it right ?
So in this example...
// Create the object to be bound
Fruit fruit = new Fruit("lemon");
// Perform the bind
ctx.rebind("favorite", fruit);
If fruit goes out of scope, will it be deleted ? or will it stay to exist because jndi still points to it ?
My guess is it will be deleted and your reference will be invalid.
Or am I still missing the ball completely wrong..
 
Maulin Vasavada
Ranch Hand
Posts: 1873
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yup. you have got it
Regards
Maulin
 
Mark Uppeteer
Ranch Hand
Posts: 159
Eclipse IDE C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Or am I still missing the ball completely wrong..


thats an interesting sentence :roll:
But then, is there a way (or a solution/pattern) to have an entity bean with none persistent data (for speed reasons) that everyone can access and that doesn't lose its data on passivation ? something like a stateful session bean with multiple users ?
grtz
Mark
 
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
You can bind a instance of a class(POJO-Plain Old Java Object) to the JNDI context and the client will be able to lookup the same instance from JNDI.

hope this helps.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic