O'Reilly logo

J2EE™ and Beyond: Design, Develop, and Deploy World-Class Java™ Software by Art Taylor

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The DirectoryService Class: The getContext Method

The getContext method with no arguments is used to retrieve the base context or the InitialContext for the naming service. As shown in the next listing, the overloaded version of that method accepts a string parameter and firsts tests to see whether or not the instance member for the InitialContext has been set; if it has, there is no attempt to create it. But if it has not been set, then the getContext method is called to retrieve the InitialContext. This is cast as an InitialContext in this example, but the true type of the reference is an InitialDirContext a subclass of InitialContext (and the reason the cast works).

The next step is to call the InitialContext lookup method to retrieve the ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required