Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Why use InitialContext()  RSS feed

 
Ravi Singh
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you construct an Initial Context using the no argument InitialContext() constructer, how does the initial context 'know' which naming service to connect to?

Does it connect to the localhost?
 
Anthony Watson
Ranch Hand
Posts: 327
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you construct an InitialContext with the no argument constructor, you will get a reference to the local container's initial context. Using the no argument constructor can limit flexibility. It is better to put the initial context arguments in a central location, such as a deployment descriptor, so that your code will not need to be changed if you wish to use a different initial context later. Another way to centralize the retrieval of an initial context is to use the Service Locator pattern.
[ September 13, 2004: Message edited by: Anthony Watson ]
 
Kunaal A Trehan
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You normally use InitialContext ctx =new InitialContext() when you are already inside the container's envoirnment
eg. Calling Entity beans from the Session Facade Bean

So in that case you look for the default context.
So you donot need to pass the configuration parameters.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!