What is the java "Context" class used for?
<p>I'm checking a java webpage code, actually a Liferay portlet's based website.</p>

<p>I was checking the server-side .java files, and in a DAO pattern file, seeing how the programmer dealt with the DB connections. I'm used to Java SE, where you normally get a Connection object calling to the <code>DriverManager</code> class, but here, things are pretty different:</p>

<pre><code>initContext = new InitialContext();
envContext = (Context) initContext.lookup("java:/comp/env");
ds = (DataSource) envContext.lookup("jdbc/SSMoracle");
conn = ds.getConnection();  
</code></pre>

<p>Doing this, the object <code>conn</code> gets a proper connection to the DB, and it works perfectly. I've never seen how it works though, especially the <code>Context</code> class. </p>

<p>What does this class do, and why is it used instead of using a class that calls <code>DriverManager</code> to get the proper connection? I would love to know!</p>