if (connectionPath == null)
{
throw new IllegalArgumentException("The JNDI path cannot be null");
}
XQDataSource ds = null;
try
{
final Context ctx = getInitialContext();
final Object lookup = ctx.lookup(connectionPath);
if (lookup instanceof XQDataSource)
{
ds = (XQDataSource) lookup;
}
else
{
logger.warn(connectionPath + " is not a valid XQDataSource JNDI access");
}
}
catch (Exception e)
{
JndiXQConnectionProvider.logger.error("Failed to access the JDNI-System", e);
}
if (ds != null)
{
if (username == null)
{
return ds.getConnection();
}
return ds.getConnection(username, password);
}
return null;
}