log.debug("Starting initJNDI");
Configuration c = configuration.subset("jndi");
if (c == null || c.isEmpty())
{
throw new TorqueException(
"JndiDataSourceFactory requires a jndi "
+ "path property to lookup the DataSource in JNDI.");
}
try
{
Hashtable env = new Hashtable();
for (Iterator i = c.getKeys(); i.hasNext(); )
{
String key = (String) i.next();
if (key.equals("path"))
{
path = c.getString(key);
if (log.isDebugEnabled())
{
log.debug("JNDI path: " + path);
}
}
else if (key.equals("ttl"))
{
ttl = c.getLong(key, ttl);
if (log.isDebugEnabled())
{
log.debug("Time between context lookups: " + ttl);
}
}
else
{
String value = c.getString(key);
env.put(key, value);
if (log.isDebugEnabled())
{
log.debug("Set jndi property: " + key + "=" + value);
}
}
}
ctx = new InitialContext(env);
log.debug("Created new InitialContext");
debugCtx(ctx);
}
catch (Exception e)
{
log.error("", e);
throw new TorqueException(e);
}
}