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) 2006-2013 Pentaho 008// All Rights Reserved. 009*/ 010package mondrian.xmla.impl; 011 012import mondrian.server.DynamicContentFinder; 013import mondrian.server.RepositoryContentFinder; 014 015import java.util.HashMap; 016import java.util.Map; 017 018/** 019 * Extends DefaultXmlaServlet to add dynamic datasource loading capability. 020 * 021 * @author Thiyagu Ajit 022 * @author Luc Boudreau 023 */ 024public class DynamicDatasourceXmlaServlet extends MondrianXmlaServlet { 025 private static final long serialVersionUID = 1L; 026 027 /** 028 * A map of datasources definitions to {@link DynamicContentFinder} 029 * instances. 030 */ 031 private final Map<String, DynamicContentFinder> finders = 032 new HashMap<String, DynamicContentFinder>(); 033 034 @Override 035 protected RepositoryContentFinder makeContentFinder(String dataSources) { 036 if (!finders.containsKey(dataSources)) { 037 finders.put(dataSources, new DynamicContentFinder(dataSources)); 038 } 039 return finders.get(dataSources); 040 } 041 @Override 042 public void destroy() { 043 for (DynamicContentFinder finder : finders.values()) { 044 finder.shutdown(); 045 } 046 super.destroy(); 047 } 048} 049 050// End DynamicDatasourceXmlaServlet.java