This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JNDI and reference objects  RSS feed

 
Jeff Gaer
Ranch Hand
Posts: 103
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to be able to share an object that implements the Map interface between several web apps running on the same server without incurring the overhead of serializing and de-serializing the state them or the risk of having multiple concurrent versions of the same object. Its my understanding that you can't count on the session being the same between different web applicaionts running on the same servier applications ( is that true?).The documentation for JNDI suggests that it is possible to avoid serialization by binding to a reference using javax.naming.Reference. But when I look at the Sun JNDI tutorial sample code it looks to me like it is still serializing the contents of the object and just calling it a reference. The ObjectFactory just calls the constructor with the result of getContent for the addr, which happends to be the only parameter to the constructor and the only state in the object. How would this work for a Map? I think I am looking more for a capablity to get an objectHandle. Is there any ability to do this? A better approach?

Code from the sun tutorial follows
//COnstructor
public Fruit(String f) {/
fruit = f;
}
// Construct the ref addr ,
new StringRefAddr("fruit", fruit),
public Object getObjectInstance(Object obj, Name name, Context ctx,
Hashtable env) throws Exception {
if (obj instanceof Reference) {
Reference ref = (Reference)obj;
if (ref.getClassName().equals(Fruit.class.getClassName())) {
RefAddr addr = ref.get("fruit");
if (addr != null) {
return new Fruit((String)addr.getContent());
}
}
}
return null;
}
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!