Skip to content

Commit

Permalink
Generate java class containing version information, and use it
Browse files Browse the repository at this point in the history
to populate XMLA driver's version information.


git-svn-id: https://olap4j.svn.sourceforge.net/svnroot/olap4j/trunk@237 c6a108a4-781c-0410-a6c6-c2d559e19af0
  • Loading branch information
julianhyde committed May 12, 2009
1 parent a7031a9 commit 2511d96
Show file tree
Hide file tree
Showing 11 changed files with 202 additions and 31 deletions.
12 changes: 8 additions & 4 deletions build.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,10 @@
# Modify this file to override build settings. It is read by ant's build.xml.
# See also 'test.properties', which contains settings for the regression
# suite.
#
# Uncomment to use yDoc doclet for enhanced javadoc (requires commercial
# license).
#ydoc.home=/usr/local/ydoc-2.2_03-jdk1.5

project.revision=0.9.8-SNAPSHOT
project.revision.major=0
project.revision.minor=9070232
ivy.artifact.id=olap4j
ivy.artifact.group=org.olap4j
impl.title=olap4j
Expand All @@ -26,4 +24,10 @@ javadoc.packagenames=org.olap4j.*

build.dir=build

ivy.repository.publish=http://repo.pentaho.org/artifactory

# Uncomment to use yDoc doclet for enhanced javadoc (requires commercial
# license).
#ydoc.home=/usr/local/ydoc-3.0-jdk1.5

# End build.properties
15 changes: 15 additions & 0 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,21 @@ test.properties.example" />

<target name="version-properties">
<echo message="olap4j ${project.revision}${line.separator}" file="VERSION.txt" />
<echo file="${src.dir}/org/olap4j/driver/xmla/XmlaOlap4jDriverVersion.java">/*
* Project version information. Generated - do not modify.
*/
package org.olap4j.driver.xmla;
/**
* Version information for the XMLA driver. (Generated.)
*/
class XmlaOlap4jDriverVersion {
static final String NAME = "olap4j driver for XML/A";
static final String VERSION = "${project.revision}";
static final int MAJOR_VERSION = ${project.revision.major};
static final int MINOR_VERSION = ${project.revision.minor};
}

// End XmlaOlap4jDriverVersion.java</echo>
</target>

<target name="parser" depends="resolve">
Expand Down
46 changes: 46 additions & 0 deletions src/org/olap4j/driver/xmla/Factory.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,26 +27,72 @@
* @since Jun 14, 2007
*/
interface Factory {
/**
* Creates a connection.
*
* @param driver Driver
* @param proxy Proxy (for submitting requests, via HTTP or otherwise)
* @param url URL of server
* @param info Properties defining the connection
* @return Connection
* @throws SQLException on error
*/
Connection newConnection(
XmlaOlap4jDriver driver,
XmlaOlap4jProxy proxy,
String url,
Properties info) throws SQLException;

/**
* Creates an empty result set.
*
* @param olap4jConnection Connection
* @return Result set
*/
EmptyResultSet newEmptyResultSet(
XmlaOlap4jConnection olap4jConnection);

/**
* Creates a result set with a fixed set of rows.
*
* @param olap4jConnection Connection
* @param headerList Column headers
* @param rowList Row values
* @return Result set
*/
ResultSet newFixedResultSet(
XmlaOlap4jConnection olap4jConnection,
List<String> headerList,
List<List<Object>> rowList);

/**
* Creates a cell set.
*
* @param olap4jStatement Statement
* @return Cell set
* @throws OlapException on error
*/
XmlaOlap4jCellSet newCellSet(
XmlaOlap4jStatement olap4jStatement) throws OlapException;

/**
* Creates a prepared statement.
*
* @param mdx MDX query text
* @param olap4jConnection Connection
* @return Prepared statement
* @throws OlapException on error
*/
XmlaOlap4jPreparedStatement newPreparedStatement(
String mdx,
XmlaOlap4jConnection olap4jConnection) throws OlapException;

/**
* Creates a metadata object.
*
* @param olap4jConnection Connection
* @return Metadata object
*/
XmlaOlap4jDatabaseMetaData newDatabaseMetaData(
XmlaOlap4jConnection olap4jConnection);
}
Expand Down
12 changes: 10 additions & 2 deletions src/org/olap4j/driver/xmla/FactoryJdbc3Impl.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,21 @@
* @since Jun 14, 2007
*/
class FactoryJdbc3Impl implements Factory {
/**
* Creates a FactoryJdbc3Impl.
*/
public FactoryJdbc3Impl() {
}

public Connection newConnection(
XmlaOlap4jDriver driver,
XmlaOlap4jProxy proxy,
String url,
Properties info)
throws SQLException
{
return new FactoryJdbc3Impl.XmlaOlap4jConnectionJdbc3(
proxy, url, info);
driver, proxy, url, info);
}

public EmptyResultSet newEmptyResultSet(
Expand Down Expand Up @@ -106,12 +113,13 @@ public EmptyResultSetJdbc3(

private class XmlaOlap4jConnectionJdbc3 extends XmlaOlap4jConnection {
public XmlaOlap4jConnectionJdbc3(
XmlaOlap4jDriver driver,
XmlaOlap4jProxy proxy,
String url,
Properties info)
throws SQLException
{
super(FactoryJdbc3Impl.this, proxy, url, info);
super(FactoryJdbc3Impl.this, driver, proxy, url, info);
}
}

Expand Down
49 changes: 46 additions & 3 deletions src/org/olap4j/driver/xmla/FactoryJdbc4Impl.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// This software is subject to the terms of the Eclipse Public License v1.0
// Agreement, available at the following URL:
// http://www.eclipse.org/legal/epl-v10.html.
// Copyright (C) 2007-2008 Julian Hyde
// Copyright (C) 2007-2009 Julian Hyde
// All Rights Reserved.
// You must accept the terms of that agreement to use this software.
*/
Expand All @@ -24,14 +24,21 @@
* @since Jun 14, 2007
*/
class FactoryJdbc4Impl implements Factory {
/**
* Creates a FactoryJdbc4Impl.
*/
public FactoryJdbc4Impl() {
}

public Connection newConnection(
XmlaOlap4jDriver driver,
XmlaOlap4jProxy proxy,
String url,
Properties info)
throws SQLException
{
return new XmlaOlap4jConnectionJdbc4(
this, proxy, url, info);
this, driver, proxy, url, info);
}

public EmptyResultSet newEmptyResultSet(
Expand Down Expand Up @@ -73,6 +80,13 @@ public XmlaOlap4jDatabaseMetaData newDatabaseMetaData(
// Inner classes

private static class EmptyResultSetJdbc4 extends EmptyResultSet {
/**
* Creates a EmptyResultSetJdbc4.
*
* @param olap4jConnection Connection
* @param headerList Column names
* @param rowList List of row values
*/
EmptyResultSetJdbc4(
XmlaOlap4jConnection olap4jConnection,
List<String> headerList,
Expand Down Expand Up @@ -330,13 +344,24 @@ private static class XmlaOlap4jConnectionJdbc4
extends XmlaOlap4jConnection
implements OlapConnection
{
/**
* Creates a XmlaOlap4jConnectionJdbc4.
*
* @param factory Factory
* @param driver Driver
* @param proxy Proxy
* @param url URL
* @param info Extra properties
* @throws SQLException on error
*/
public XmlaOlap4jConnectionJdbc4(
Factory factory,
XmlaOlap4jDriver driver,
XmlaOlap4jProxy proxy,
String url,
Properties info) throws SQLException
{
super(factory, proxy, url, info);
super(factory, driver, proxy, url, info);
}

public OlapStatement createStatement() {
Expand Down Expand Up @@ -399,6 +424,12 @@ public Struct createStruct(
}

private static class XmlaOlap4jCellSetJdbc4 extends XmlaOlap4jCellSet {
/**
* Creates an XmlaOlap4jCellSetJdbc4.
*
* @param olap4jStatement Statement
* @throws OlapException on error
*/
XmlaOlap4jCellSetJdbc4(
XmlaOlap4jStatement olap4jStatement)
throws OlapException
Expand Down Expand Up @@ -645,6 +676,13 @@ public void updateNClob(
private static class XmlaOlap4jPreparedStatementJdbc4
extends XmlaOlap4jPreparedStatement
{
/**
* Creates a XmlaOlap4jPreparedStatementJdbc4.
*
* @param olap4jConnection Connection
* @param mdx MDX query text
* @throws OlapException on error
*/
XmlaOlap4jPreparedStatementJdbc4(
XmlaOlap4jConnection olap4jConnection,
String mdx) throws OlapException
Expand Down Expand Up @@ -752,6 +790,11 @@ public void setNClob(
private static class XmlaOlap4jDatabaseMetaDataJdbc4
extends XmlaOlap4jDatabaseMetaData
{
/**
* Creates an XmlaOlap4jDatabaseMetaDataJdbc4.
*
* @param olap4jConnection Connection
*/
XmlaOlap4jDatabaseMetaDataJdbc4(
XmlaOlap4jConnection olap4jConnection)
{
Expand Down
5 changes: 5 additions & 0 deletions src/org/olap4j/driver/xmla/XmlaOlap4jConnection.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ abstract class XmlaOlap4jConnection implements OlapConnection {

private static final String CONNECT_STRING_PREFIX = "jdbc:xmla:";

final XmlaOlap4jDriver driver;

final Factory factory;

final XmlaOlap4jProxy proxy;
Expand Down Expand Up @@ -120,19 +122,22 @@ abstract class XmlaOlap4jConnection implements OlapConnection {
* @pre acceptsURL(url)
*
* @param factory Factory
* @param driver Driver
* @param proxy Proxy object which receives XML requests
* @param url Connect-string URL
* @param info Additional properties
* @throws java.sql.SQLException if there is an error
*/
XmlaOlap4jConnection(
Factory factory,
XmlaOlap4jDriver driver,
XmlaOlap4jProxy proxy,
String url,
Properties info)
throws SQLException
{
this.factory = factory;
this.driver = driver;
this.proxy = proxy;
if (!acceptsURL(url)) {
// This is not a URL we can handle.
Expand Down
8 changes: 4 additions & 4 deletions src/org/olap4j/driver/xmla/XmlaOlap4jDatabaseMetaData.java
Original file line number Diff line number Diff line change
Expand Up @@ -219,19 +219,19 @@ public String getDatabaseProductVersion() throws SQLException {
}

public String getDriverName() throws SQLException {
return XmlaOlap4jDriver.NAME;
return olap4jConnection.driver.getName();
}

public String getDriverVersion() throws SQLException {
return XmlaOlap4jDriver.VERSION;
return olap4jConnection.driver.getVersion();
}

public int getDriverMajorVersion() {
return XmlaOlap4jDriver.MAJOR_VERSION;
return olap4jConnection.driver.getMajorVersion();
}

public int getDriverMinorVersion() {
return XmlaOlap4jDriver.MINOR_VERSION;
return olap4jConnection.driver.getMinorVersion();
}

public boolean usesLocalFiles() throws SQLException {
Expand Down
34 changes: 25 additions & 9 deletions src/org/olap4j/driver/xmla/XmlaOlap4jDriver.java
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,7 @@
* @since May 22, 2007
*/
public class XmlaOlap4jDriver implements Driver {
public static final String NAME = "olap4j driver for XML/A";
public static final String VERSION = "0.9.5";
public static final int MAJOR_VERSION = 0;
public static final int MINOR_VERSION = 905;

private final Factory factory;

/**
Expand Down Expand Up @@ -141,7 +138,10 @@ protected XmlaOlap4jDriver() {
}

/**
* Registers this driver.
* Registers an instance of XmlaOlap4jDriver.
*
* <p>Called implicitly on class load, and implements the traditional
* 'Class.forName' way of registering JDBC drivers.
*
* @throws SQLException on error
*/
Expand All @@ -163,7 +163,7 @@ public Connection connect(String url, Properties info) throws SQLException {
XmlaOlap4jProxy proxy = createProxy(map);

// returns a connection object to the java API
return factory.newConnection(proxy, url, info);
return factory.newConnection(this, proxy, url, info);
}

public boolean acceptsURL(String url) throws SQLException {
Expand All @@ -187,12 +187,28 @@ public DriverPropertyInfo[] getPropertyInfo(
return list.toArray(new DriverPropertyInfo[list.size()]);
}

/**
* Returns the driver name. Not in the JDBC API.
* @return Driver name
*/
String getName() {
return XmlaOlap4jDriverVersion.NAME;
}

/**
* Returns the driver version. Not in the JDBC API.
* @return Driver version
*/
public String getVersion() {
return XmlaOlap4jDriverVersion.VERSION;
}

public int getMajorVersion() {
return MAJOR_VERSION;
return XmlaOlap4jDriverVersion.MAJOR_VERSION;
}

public int getMinorVersion() {
return MINOR_VERSION;
return XmlaOlap4jDriverVersion.MINOR_VERSION;
}

public boolean jdbcCompliant() {
Expand All @@ -216,7 +232,7 @@ protected XmlaOlap4jProxy createProxy(Map<String, String> map) {
return proxy;
}
}
return new XmlaOlap4jHttpProxy();
return new XmlaOlap4jHttpProxy(this);
}

/**
Expand Down
Loading

0 comments on commit 2511d96

Please sign in to comment.