Skip to content

Commit 5715bcb

Browse files
author
ehennum
committed
clean up on handles and service customization #1111
1 parent f7e2d8c commit 5715bcb

File tree

2 files changed

+27
-5
lines changed
  • marklogic-client-api/src/main/java/com/marklogic/client/impl
  • ml-development-tools/src/main/kotlin/com/marklogic/client/tools/proxy

2 files changed

+27
-5
lines changed

marklogic-client-api/src/main/java/com/marklogic/client/impl/BaseProxy.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,9 @@ public BaseProxy(DatabaseClient db, String endpointDir, JSONWriteHandle serviceD
9393
}
9494
// backward-compatible constructor for 4.x legacy
9595
public BaseProxy(DatabaseClient db, String endpointDir) {
96-
this();
96+
this(db, endpointDir, null);
97+
}
98+
private void init(DatabaseClient db, String endpointDir) {
9799
if (db == null) {
98100
throw new IllegalArgumentException("Cannot connect with null database client");
99101
} else if (db.getDatabase() != null) {

ml-development-tools/src/main/kotlin/com/marklogic/client/tools/proxy/Generator.kt

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,7 @@ class Generator {
330330
${funcImports}
331331
332332
import com.marklogic.client.DatabaseClient;
333+
import com.marklogic.client.io.marker.JSONWriteHandle;
333334
334335
import com.marklogic.client.impl.BaseProxy;
335336
@@ -344,14 +345,33 @@ public interface ${className} {
344345
* client object can be used for any number of requests and in multiple threads.
345346
*
346347
* @param db provides a client for communicating with the database server
347-
* @return an object for session state
348+
* @return an object for executing database operations
348349
*/
349350
static ${className} on(DatabaseClient db) {
351+
return on(db, null);
352+
}
353+
/**
354+
* Creates a ${className} object for executing operations on the database server.
355+
*
356+
* The DatabaseClientFactory class can create the DatabaseClient parameter. A single
357+
* client object can be used for any number of requests and in multiple threads.
358+
*
359+
* The service declaration uses a custom implementation of the same service instead
360+
* of the default implementation of the service by specifying an endpoint directory
361+
* in the modules database with the implementation. A service.json file with the
362+
* declaration can be read with FileHandle or a string serialization of the JSON
363+
* declaration with StringHandle.
364+
*
365+
* @param db provides a client for communicating with the database server
366+
* @param serviceDeclaration substitutes a custom implementation of the service
367+
* @return an object for executing database operations
368+
*/
369+
static ${className} on(DatabaseClient db, JSONWriteHandle serviceDeclaration) {
350370
final class ${className}Impl implements ${className} {
351371
private BaseProxy baseProxy;
352372
353-
private ${className}Impl(DatabaseClient dbClient) {
354-
baseProxy = new BaseProxy(dbClient, "${requestDir}");
373+
private ${className}Impl(DatabaseClient dbClient, JSONWriteHandle servDecl) {
374+
baseProxy = new BaseProxy(dbClient, "${requestDir}", servDecl);
355375
}${
356376
if (!hasSession) ""
357377
else """
@@ -363,7 +383,7 @@ public interface ${className} {
363383
${funcSrc}
364384
}
365385
366-
return new ${className}Impl(db);
386+
return new ${className}Impl(db, serviceDeclaration);
367387
}${
368388
if (!hasSession) ""
369389
else """

0 commit comments

Comments
 (0)