Elffuss BraidHub

kikocis/java-driver public

Expose the driver version through the API (JAVA-532).
Changesetf3b7ffe9920874f05696a397ebf0c0488aed9f8128c274fa71b1a0309084cce9
Authorolim7t <omichallat+github@gmail.com> · 2014-11-04 12:01 +01:00
Committerolim7t <omichallat+github@gmail.com> · 2014-11-04 14:55 +01:00
Parents6124b21eb26d

Browse the files at this changeset

4 files changed

modified driver-core/CHANGELOG.rst +2 −0
@@ -3,8 +3,10 @@
33
44 2.0.8:
55 ------
6+
67 - [bug] Fix token awareness for case-sensitive keyspaces and tables (JAVA-526)
78 - [bug] Check maximum number of values passed to SimpleStatement (JAVA-515)
9+- [improvement] Expose the driver version through the API (JAVA-532)
810
911
1012 2.0.7:
modified driver-core/pom.xml +9 −0
@@ -91,6 +91,15 @@
9191
9292 </dependencies>
9393
94+ <build>
95+ <resources>
96+ <resource>
97+ <directory>src/main/resources</directory>
98+ <filtering>true</filtering>
99+ </resource>
100+ </resources>
101+ </build>
102+
94103 <profiles>
95104 <profile>
96105 <id>default</id>
modified driver-core/src/main/java/com/datastax/driver/core/Cluster.java +14 −0
@@ -69,6 +69,8 @@
6969 private static final int NON_BLOCKING_EXECUTOR_SIZE = SystemProperties.getInt("com.datastax.driver.NON_BLOCKING_EXECUTOR_SIZE",
7070 Runtime.getRuntime().availableProcessors());
7171
72+ private static final ResourceBundle driverProperties = ResourceBundle.getBundle("com.datastax.driver.core.Driver");
73+
7274 // Some per-JVM number that allows to generate unique cluster names when
7375 // multiple Cluster instance are created in the same JVM.
7476 private static final AtomicInteger CLUSTER_ID = new AtomicInteger(0);
@@ -187,6 +189,18 @@
187189 return new Cluster.Builder();
188190 }
189191
192+ /**
193+ * Returns the current version of the driver.
194+ * <p>
195+ * This is intended for products that wrap or extend the driver, as a way to check
196+ * compatibility if end-users override the driver version in their application.
197+ *
198+ * @return the version.
199+ */
200+ public static String getDriverVersion() {
201+ return driverProperties.getString("driver.version");
202+ }
203+
190204 /**
191205 * Creates a new session on this cluster but does not initialize it.
192206 * <p>
added driver-core/src/main/resources/com/datastax/driver/core/Driver.properties +1 −0
@@ -0,0 +1,1 @@
1+driver.version=${project.version}
No newline at the end of the file