001/*
002// This software is subject to the terms of the Eclipse Public License v1.0
003// Agreement, available at the following URL:
004// http://www.eclipse.org/legal/epl-v10.html.
005// You must accept the terms of that agreement to use this software.
006//
007// Copyright (C) 2009-2009 Pentaho
008// All Rights Reserved.
009*/
010package mondrian.spi.impl;
011
012import mondrian.spi.DataSourceResolver;
013
014import javax.naming.InitialContext;
015import javax.naming.NamingException;
016import javax.sql.DataSource;
017
018/**
019 * Implementation of {@link mondrian.spi.DataSourceResolver} that looks up
020 * a data source using JNDI.
021 *
022 * @author jhyde
023 */
024public class JndiDataSourceResolver implements DataSourceResolver {
025    /**
026     * Public constructor, required for plugin instantiation.
027     */
028    public JndiDataSourceResolver() {
029    }
030
031    public DataSource lookup(String dataSourceName) throws NamingException {
032        return (DataSource) new InitialContext().lookup(dataSourceName);
033    }
034}
035
036// End JndiDataSourceResolver.java