@@ -207,7 +207,21 @@ private DatabaseClientFactory() {
207207 * @return a new client for making database requests
208208 */
209209 static public DatabaseClient newClient (String host , int port ) {
210- return newClient (host , port , null , null , null , null , null );
210+ return newClient (host , port , null , null , null , null , null , null );
211+ }
212+
213+ /**
214+ * Creates a client to access the database by means of a REST server
215+ * without any authentication. Such clients can be convenient for
216+ * experimentation but should not be used in production.
217+ *
218+ * @param host the host with the REST server
219+ * @param port the port for the REST server
220+ * @param database the database to access (default: configured database for the REST server)
221+ * @return a new client for making database requests
222+ */
223+ static public DatabaseClient newClient (String host , int port , String database ) {
224+ return newClient (host , port , database , null , null , null , null , null );
211225 }
212226
213227 /**
@@ -221,7 +235,21 @@ static public DatabaseClient newClient(String host, int port) {
221235 * @return a new client for making database requests
222236 */
223237 static public DatabaseClient newClient (String host , int port , String user , String password , Authentication type ) {
224- return newClient (host , port , user , password , type , null , null );
238+ return newClient (host , port , null , user , password , type , null , null );
239+ }
240+ /**
241+ * Creates a client to access the database by means of a REST server.
242+ *
243+ * @param host the host with the REST server
244+ * @param port the port for the REST server
245+ * @param database the database to access (default: configured database for the REST server)
246+ * @param user the user with read, write, or administrative privileges
247+ * @param password the password for the user
248+ * @param type the type of authentication applied to the request
249+ * @return a new client for making database requests
250+ */
251+ static public DatabaseClient newClient (String host , int port , String database , String user , String password , Authentication type ) {
252+ return newClient (host , port , database , user , password , type , null , null );
225253 }
226254 /**
227255 * Creates a client to access the database by means of a REST server.
@@ -235,7 +263,22 @@ static public DatabaseClient newClient(String host, int port, String user, Strin
235263 * @return a new client for making database requests
236264 */
237265 static public DatabaseClient newClient (String host , int port , String user , String password , Authentication type , SSLContext context ) {
238- return newClient (host , port , user , password , type , context , SSLHostnameVerifier .COMMON );
266+ return newClient (host , port , null , user , password , type , context , SSLHostnameVerifier .COMMON );
267+ }
268+ /**
269+ * Creates a client to access the database by means of a REST server.
270+ *
271+ * @param host the host with the REST server
272+ * @param port the port for the REST server
273+ * @param database the database to access (default: configured database for the REST server)
274+ * @param user the user with read, write, or administrative privileges
275+ * @param password the password for the user
276+ * @param type the type of authentication applied to the request
277+ * @param context the SSL context for authenticating with the server
278+ * @return a new client for making database requests
279+ */
280+ static public DatabaseClient newClient (String host , int port , String database , String user , String password , Authentication type , SSLContext context ) {
281+ return newClient (host , port , database , user , password , type , context , SSLHostnameVerifier .COMMON );
239282 }
240283 /**
241284 * Creates a client to access the database by means of a REST server.
@@ -250,14 +293,32 @@ static public DatabaseClient newClient(String host, int port, String user, Strin
250293 * @return a new client for making database requests
251294 */
252295 static public DatabaseClient newClient (String host , int port , String user , String password , Authentication type , SSLContext context , SSLHostnameVerifier verifier ) {
253- DatabaseClientImpl client = newClientImpl (host , port , user , password , type , context , verifier );
296+ DatabaseClientImpl client = newClientImpl (host , port , null , user , password , type , context , verifier );
297+ client .setHandleRegistry (getHandleRegistry ().copy ());
298+ return client ;
299+ }
300+ /**
301+ * Creates a client to access the database by means of a REST server.
302+ *
303+ * @param host the host with the REST server
304+ * @param port the port for the REST server
305+ * @param database the database to access (default: configured database for the REST server)
306+ * @param user the user with read, write, or administrative privileges
307+ * @param password the password for the user
308+ * @param type the type of authentication applied to the request
309+ * @param context the SSL context for authenticating with the server
310+ * @param verifier a callback for checking hostnames
311+ * @return a new client for making database requests
312+ */
313+ static public DatabaseClient newClient (String host , int port , String database , String user , String password , Authentication type , SSLContext context , SSLHostnameVerifier verifier ) {
314+ DatabaseClientImpl client = newClientImpl (host , port , database , user , password , type , context , verifier );
254315 client .setHandleRegistry (getHandleRegistry ().copy ());
255316 return client ;
256317 }
257- static private DatabaseClientImpl newClientImpl (String host , int port , String user , String password , Authentication type , SSLContext context , SSLHostnameVerifier verifier ) {
318+ static private DatabaseClientImpl newClientImpl (String host , int port , String database , String user , String password , Authentication type , SSLContext context , SSLHostnameVerifier verifier ) {
258319 logger .debug ("Creating new database client for server at " +host +":" +port );
259320 JerseyServices services = new JerseyServices ();
260- services .connect (host , port , user , password , type , context , verifier );
321+ services .connect (host , port , database , user , password , type , context , verifier );
261322
262323 if (clientConfigurator != null ) {
263324 ((HttpClientConfigurator ) clientConfigurator ).configure (
@@ -337,6 +398,7 @@ static public class Bean implements Serializable {
337398
338399 private String host ;
339400 private int port ;
401+ private String database ;
340402 private String user ;
341403 private String password ;
342404 private Authentication authentication ;
@@ -510,7 +572,7 @@ public void registerDefaultHandles() {
510572 * @return a new client for making database requests
511573 */
512574 public DatabaseClient newClient () {
513- DatabaseClientImpl client = newClientImpl (host , port , user , password , authentication , context , verifier );
575+ DatabaseClientImpl client = newClientImpl (host , port , database , user , password , authentication , context , verifier );
514576 client .setHandleRegistry (getHandleRegistry ().copy ());
515577
516578 return client ;
0 commit comments