@@ -207,7 +207,21 @@ private DatabaseClientFactory() {
207
207
* @return a new client for making database requests
208
208
*/
209
209
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 );
211
225
}
212
226
213
227
/**
@@ -221,7 +235,21 @@ static public DatabaseClient newClient(String host, int port) {
221
235
* @return a new client for making database requests
222
236
*/
223
237
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 );
225
253
}
226
254
/**
227
255
* 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
235
263
* @return a new client for making database requests
236
264
*/
237
265
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 );
239
282
}
240
283
/**
241
284
* 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
250
293
* @return a new client for making database requests
251
294
*/
252
295
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 );
254
315
client .setHandleRegistry (getHandleRegistry ().copy ());
255
316
return client ;
256
317
}
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 ) {
258
319
logger .debug ("Creating new database client for server at " +host +":" +port );
259
320
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 );
261
322
262
323
if (clientConfigurator != null ) {
263
324
((HttpClientConfigurator ) clientConfigurator ).configure (
@@ -337,6 +398,7 @@ static public class Bean implements Serializable {
337
398
338
399
private String host ;
339
400
private int port ;
401
+ private String database ;
340
402
private String user ;
341
403
private String password ;
342
404
private Authentication authentication ;
@@ -510,7 +572,7 @@ public void registerDefaultHandles() {
510
572
* @return a new client for making database requests
511
573
*/
512
574
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 );
514
576
client .setHandleRegistry (getHandleRegistry ().copy ());
515
577
516
578
return client ;
0 commit comments