@@ -330,6 +330,7 @@ class Generator {
330330${funcImports}
331331
332332import com.marklogic.client.DatabaseClient;
333+ import com.marklogic.client.io.marker.JSONWriteHandle;
333334
334335import 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