Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MONDRIAN Oops, missed a file. olap4j.jar is now tagged revision 0.9.4…
…-svn0059 and built against JDK1.5 (previously 1.6). [git-p4: depot-paths = "//open/mondrian/": change = 10417]
- Loading branch information
1 parent
81b79f8
commit 9632926
Showing
2 changed files
with
87 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
/* | ||
// This software is subject to the terms of the Common Public License | ||
// Agreement, available at the following URL: | ||
// http://www.opensource.org/licenses/cpl.html. | ||
// Copyright (C) 2008-2008 Julian Hyde | ||
// All Rights Reserved. | ||
// You must accept the terms of that agreement to use this software. | ||
*/ | ||
package mondrian.olap4j; | ||
|
||
import org.xml.sax.SAXException; | ||
import org.olap4j.driver.xmla.XmlaOlap4jDriver; | ||
|
||
import javax.servlet.ServletException; | ||
import java.util.concurrent.*; | ||
import java.util.*; | ||
import java.net.URL; | ||
import java.io.IOException; | ||
|
||
import mondrian.tui.XmlaSupport; | ||
|
||
/** | ||
* Proxy which implements XMLA requests by talking to mondrian | ||
* in-process. This is more convenient to debug than an inter-process | ||
* request using HTTP. | ||
* | ||
* @version $Id$ | ||
* @author jhyde | ||
*/ | ||
public class MondrianInprocProxy | ||
implements XmlaOlap4jDriver.Proxy | ||
{ | ||
private final Map<String, String> catalogNameUrls; | ||
private final String urlString; | ||
|
||
/** | ||
* Creates and initializes a MondrianInprocProxy. | ||
* | ||
* @param catalogNameUrls Collection of catalog names and the URL where | ||
* their catalog is to be found. For testing purposes, this should contain | ||
* a catalog called "FoodMart". | ||
* | ||
* @param urlString JDBC connect string; must begin with "jdbc:mondrian:" | ||
*/ | ||
public MondrianInprocProxy( | ||
Map<String, String> catalogNameUrls, | ||
String urlString) | ||
{ | ||
this.catalogNameUrls = catalogNameUrls; | ||
if (!urlString.startsWith("jdbc:mondrian:")) { | ||
throw new IllegalArgumentException(); | ||
} | ||
this.urlString = urlString.substring("jdbc:mondrian:".length()); | ||
} | ||
|
||
// Use single-threaded executor for ease of debugging. | ||
private static final ExecutorService singleThreadExecutor = | ||
Executors.newSingleThreadExecutor(); | ||
|
||
public byte[] get(URL url, String request) throws IOException { | ||
try { | ||
return XmlaSupport.processSoapXmla( | ||
request, urlString, catalogNameUrls, null); | ||
} catch (ServletException e) { | ||
throw new RuntimeException( | ||
"Error while reading '" + url + "'", e); | ||
} catch (SAXException e) { | ||
throw new RuntimeException( | ||
"Error while reading '" + url + "'", e); | ||
} | ||
} | ||
|
||
public Future<byte[]> submit( | ||
final URL url, | ||
final String request) | ||
{ | ||
return singleThreadExecutor.submit( | ||
new Callable<byte[] >() { | ||
public byte[] call() throws Exception { | ||
return get(url, request); | ||
} | ||
} | ||
); | ||
} | ||
} | ||
|
||
// End MondrianInprocProxy.java |