Author: rvesse
Date: Fri Apr 26 21:56:02 2013
New Revision: 1476411
URL: http://svn.apache.org/r1476411
Log:
Some changes to make RemoteEndpointDriver more extensible
Modified:
jena/Experimental/jena-jdbc/jena-jdbc-driver-remote/src/main/java/org/apache/jena/jdbc/remote/RemoteEndpointDriver.java
jena/Experimental/jena-jdbc/jena-jdbc-driver-remote/src/main/java/org/apache/jena/jdbc/remote/connections/RemoteEndpointConnection.java
Modified:
jena/Experimental/jena-jdbc/jena-jdbc-driver-remote/src/main/java/org/apache/jena/jdbc/remote/RemoteEndpointDriver.java
URL:
http://svn.apache.org/viewvc/jena/Experimental/jena-jdbc/jena-jdbc-driver-remote/src/main/java/org/apache/jena/jdbc/remote/RemoteEndpointDriver.java?rev=1476411&r1=1476410&r2=1476411&view=diff
==============================================================================
---
jena/Experimental/jena-jdbc/jena-jdbc-driver-remote/src/main/java/org/apache/jena/jdbc/remote/RemoteEndpointDriver.java
(original)
+++
jena/Experimental/jena-jdbc/jena-jdbc-driver-remote/src/main/java/org/apache/jena/jdbc/remote/RemoteEndpointDriver.java
Fri Apr 26 21:56:02 2013
@@ -24,6 +24,7 @@ import java.sql.SQLException;
import java.util.List;
import java.util.Properties;
+import org.apache.jena.jdbc.JdbcCompatibility;
import org.apache.jena.jdbc.JenaDriver;
import org.apache.jena.jdbc.connections.JenaConnection;
import org.apache.jena.jdbc.remote.connections.RemoteEndpointConnection;
@@ -52,7 +53,7 @@ import org.apache.jena.jdbc.remote.conne
* Note that since the {@code &} character is used as a separator for
connection
* URL parameters if you need your endpoint URLs to include these you should
set
* the relevant parameters directly on the {@link Properties} object you pass
to
- * the {@link #connect(String, Properties)} method.
+ * the {@link #connect(String, Properties)} method instead.
* </p>
* <h3>Other Supported Parameters</h3>
* <p>
@@ -134,6 +135,16 @@ public class RemoteEndpointDriver extend
}
/**
+ * Extension point for derived drivers which allows them to provide
different version information and driver prefix
+ * @param majorVersion Major version
+ * @param minorVersion Minor version
+ * @param driverPrefix Driver Prefix
+ */
+ protected RemoteEndpointDriver(int majorVersion, int minorVersion, String
driverPrefix) {
+ super(majorVersion, minorVersion, driverPrefix);
+ }
+
+ /**
* Registers the driver with the JDBC {@link DriverManager}
*
* @throws SQLException
@@ -161,13 +172,55 @@ public class RemoteEndpointDriver extend
// Authentication settings
String user = props.getProperty(PARAM_USERNAME);
- if (user != null && user.trim().length() == 0) user = null;
+ if (user != null && user.trim().length() == 0)
+ user = null;
String password = props.getProperty(PARAM_PASSWORD);
- if (password != null && password.trim().length() == 0) password = null;
+ if (password != null && password.trim().length() == 0)
+ password = null;
// Create connection
+ return openConnection(queryEndpoint, updateEndpoint, defaultGraphs,
namedGraphs, usingGraphs, usingNamedGraphs, user,
+ password, JenaConnection.DEFAULT_HOLDABILITY,
compatibilityLevel);
+ }
+
+ /**
+ * Opens the actual connection
+ * <p>
+ * This extension point allows derived drivers to return an extended
version
+ * of a {@link RemoteEndpointConnection} if they wish or merely to leverage
+ * the method to provide a connection after replacing the
+ * {@link #connect(Properties, int)} method with their own implementation
+ * that uses different connection parameters
+ * </p>
+ *
+ * @param queryEndpoint
+ * SPARQL Query Endpoint
+ * @param updateEndpoint
+ * SPARQL Update Endpoint
+ * @param defaultGraphs
+ * Default Graphs for queries
+ * @param namedGraphs
+ * Named Graphs for queries
+ * @param usingGraphs
+ * Default Graphs for updates
+ * @param usingNamedGraphs
+ * Named Graphs for updates
+ * @param user
+ * User name
+ * @param password
+ * Password
+ * @param holdability
+ * Result Set holdability
+ * @param compatibilityLevel
+ * JDBC compatibility level, see {@link JdbcCompatibility}
+ * @return Remote endpoint connection
+ * @throws SQLException
+ */
+ protected RemoteEndpointConnection openConnection(String queryEndpoint,
String updateEndpoint, List<String> defaultGraphs,
+ List<String> namedGraphs, List<String> usingGraphs, List<String>
usingNamedGraphs, String user, String password,
+ int holdability, int compatibilityLevel) throws SQLException {
return new RemoteEndpointConnection(queryEndpoint, updateEndpoint,
defaultGraphs, namedGraphs, usingGraphs,
- usingNamedGraphs, user, password,
JenaConnection.DEFAULT_HOLDABILITY, compatibilityLevel);
+ usingNamedGraphs, user, password, holdability,
compatibilityLevel);
}
@Override
@@ -184,43 +237,45 @@ public class RemoteEndpointDriver extend
protected DriverPropertyInfo[] getPropertyInfo(Properties connProps,
List<DriverPropertyInfo> baseDriverProps) {
DriverPropertyInfo[] driverProps = new DriverPropertyInfo[8 +
baseDriverProps.size()];
this.copyBaseProperties(driverProps, baseDriverProps, 8);
-
+
// Query Endpoint parameter
driverProps[0] = new DriverPropertyInfo(PARAM_QUERY_ENDPOINT,
connProps.getProperty(PARAM_QUERY_ENDPOINT));
driverProps[0].required =
!connProps.containsKey(PARAM_UPDATE_ENDPOINT);
- driverProps[0].description = "Sets the SPARQL Query endpoint to use
for query operations, if this is specified and " + PARAM_UPDATE_ENDPOINT + " is
not then a read-only connection will be created";
-
+ driverProps[0].description = "Sets the SPARQL Query endpoint to use
for query operations, if this is specified and "
+ + PARAM_UPDATE_ENDPOINT + " is not then a read-only connection
will be created";
+
// Update Endpoint parameter
driverProps[1] = new DriverPropertyInfo(PARAM_UPDATE_ENDPOINT,
connProps.getProperty(PARAM_UPDATE_ENDPOINT));
driverProps[1].required =
!connProps.containsKey(PARAM_UPDATE_ENDPOINT);
- driverProps[1].description = "Sets the SPARQL Update endpoint to use
for update operations, if this is specified and " + PARAM_QUERY_ENDPOINT + " is
not then a write-only connection will be created";
-
+ driverProps[1].description = "Sets the SPARQL Update endpoint to use
for update operations, if this is specified and "
+ + PARAM_QUERY_ENDPOINT + " is not then a write-only connection
will be created";
+
// Default Graph parameter
driverProps[2] = new DriverPropertyInfo(PARAM_DEFAULT_GRAPH_URI, null);
driverProps[2].required = false;
driverProps[2].description = "Sets the URI for a default graph for
queries, may be specified multiple times to specify multiple graphs which
should form the default graph";
-
+
// Named Graph parameter
driverProps[3] = new DriverPropertyInfo(PARAM_NAMED_GRAPH_URI, null);
driverProps[3].required = false;
driverProps[3].description = "Sets the URI for a named graph for
queries, may be specified multiple times to specify multiple named graphs which
should be accessible";
-
+
// Using Graph parameter
driverProps[4] = new DriverPropertyInfo(PARAM_USING_GRAPH_URI, null);
driverProps[4].required = false;
driverProps[4].description = "Sets the URI for a default graph for
updates, may be specified multiple times to specify multiple graphs which
should form the default graph";
-
+
// Using Named Graph parameter
driverProps[5] = new DriverPropertyInfo(PARAM_USING_NAMED_GRAPH_URI,
null);
driverProps[5].required = false;
driverProps[5].description = "Sets the URI for a named graph for
updates, may be specified multiple times to specify multiple named graph which
should be accessible";
-
+
// User Name parameter
driverProps[6] = new DriverPropertyInfo(PARAM_USERNAME,
connProps.getProperty(PARAM_USERNAME));
-
+
// Password parameter
driverProps[7] = new DriverPropertyInfo(PARAM_PASSWORD,
connProps.getProperty(PARAM_PASSWORD));
-
+
return driverProps;
}
}
Modified:
jena/Experimental/jena-jdbc/jena-jdbc-driver-remote/src/main/java/org/apache/jena/jdbc/remote/connections/RemoteEndpointConnection.java
URL:
http://svn.apache.org/viewvc/jena/Experimental/jena-jdbc/jena-jdbc-driver-remote/src/main/java/org/apache/jena/jdbc/remote/connections/RemoteEndpointConnection.java?rev=1476411&r1=1476410&r2=1476411&view=diff
==============================================================================
---
jena/Experimental/jena-jdbc/jena-jdbc-driver-remote/src/main/java/org/apache/jena/jdbc/remote/connections/RemoteEndpointConnection.java
(original)
+++
jena/Experimental/jena-jdbc/jena-jdbc-driver-remote/src/main/java/org/apache/jena/jdbc/remote/connections/RemoteEndpointConnection.java
Fri Apr 26 21:56:02 2013
@@ -50,7 +50,7 @@ public class RemoteEndpointConnection ex
private DatabaseMetaData metadata;
/**
- * Creates a new dataset connection
+ * Creates a new remote connection
*
* @param queryEndpoint
* SPARQL Query Endpoint
@@ -69,7 +69,7 @@ public class RemoteEndpointConnection ex
}
/**
- * Creates a new dataset connection
+ * Creates a new remote connection
*
* @param queryEndpoint
* SPARQL Query Endpoint