*/
private DataSource findDataSource(final Context initialContext, final String connectionPath) throws SQLException
{
final Configuration config = ClassicEngineBoot.getInstance().getGlobalConfig();
final LFUMap map = getDataSourceCache();
final boolean cacheEnabled = "true".equals(config.getConfigProperty
("org.pentaho.reporting.engine.classic.extensions.datasources.mondrian.CacheJndiDataSources"));
if (cacheEnabled)
{
synchronized (map)
{
final DataSource o1 = (DataSource) map.get(connectionPath);
if (o1 != null)
{
return o1;
}
}
}
try
{
final Object o = initialContext.lookup(connectionPath);
if (o instanceof DataSource)
{
if (cacheEnabled)
{
synchronized (map)
{
map.put(connectionPath, o);
}
}
return (DataSource) o;
}
}
catch (NamingException e)
{
// ignored ..
}
final Iterator keys = config.findPropertyKeys
("org.pentaho.reporting.engine.classic.core.modules.misc.datafactory.jndi-prefix.");
while (keys.hasNext())
{
final String key = (String) keys.next();
final String prefix = config.getConfigProperty(key);
try
{
final Object o = initialContext.lookup(prefix + connectionPath);
if (o instanceof DataSource)
{
if (cacheEnabled)
{
synchronized (map)
{
map.put(connectionPath, o);
}
}
return (DataSource) o;
}
}