@@ -687,7 +687,25 @@ static public DatabaseClient newClient(String host, int port, String database) {
687687 * @return a new client for making database requests
688688 */
689689 static public DatabaseClient newClient (String host , int port , SecurityContext securityContext ) {
690- return newClient (host , port , null , securityContext );
690+ return newClient (host , port , null , securityContext , null );
691+ }
692+
693+ /**
694+ * Creates a client to access the database by means of a REST server.
695+ *
696+ * @param host the host with the REST server
697+ * @param port the port for the REST server
698+ * @param securityContext the security context created depending upon the
699+ * authentication type - BasicAuthContext, DigestAuthContext or KerberosAuthContext
700+ * and communication channel type (SSL)
701+ * @param connectionType whether the client connects directly to the MarkLogic host
702+ * or using a gateway such as a load balancer
703+ * @return a new client for making database requests
704+ */
705+ static public DatabaseClient newClient (String host , int port , SecurityContext securityContext ,
706+ DatabaseClient .ConnectionType connectionType )
707+ {
708+ return newClient (host , port , null , securityContext , connectionType );
691709 }
692710
693711 /**
@@ -703,6 +721,27 @@ static public DatabaseClient newClient(String host, int port, SecurityContext se
703721 * @return a new client for making database requests
704722 */
705723 static public DatabaseClient newClient (String host , int port , String database , SecurityContext securityContext ) {
724+ return newClient (host , port , null , securityContext , null );
725+ }
726+
727+ /**
728+ * Creates a client to access the database by means of a REST server.
729+ *
730+ * @param host the host with the REST server
731+ * @param port the port for the REST server
732+ * @param database the database to access (default: configured database for
733+ * the REST server)
734+ * @param securityContext the security context created depending upon the
735+ * authentication type - BasicAuthContext, DigestAuthContext or KerberosAuthContext
736+ * and communication channel type (SSL)
737+ * @param connectionType whether the client connects directly to the MarkLogic host
738+ * or using a gateway such as a load balancer
739+ * @return a new client for making database requests
740+ */
741+ static public DatabaseClient newClient (String host , int port , String database ,
742+ SecurityContext securityContext ,
743+ DatabaseClient .ConnectionType connectionType )
744+ {
706745 String user = null ;
707746 String password = null ;
708747 Authentication type = null ;
@@ -783,7 +822,9 @@ static public DatabaseClient newClient(String host, int port, String database, S
783822 }
784823 }
785824
786- DatabaseClientImpl client = new DatabaseClientImpl (services , host , port , database , securityContext );
825+ DatabaseClientImpl client = new DatabaseClientImpl (
826+ services , host , port , database , securityContext , connectionType
827+ );
787828 client .setHandleRegistry (getHandleRegistry ().copy ());
788829 return client ;
789830 }
@@ -816,7 +857,7 @@ static private SecurityContext makeSecurityContext(String user, String password,
816857 */
817858 @ Deprecated
818859 static public DatabaseClient newClient (String host , int port , String user , String password , Authentication type ) {
819- return newClient (host , port , null , makeSecurityContext (user , password , type , null , null ));
860+ return newClient (host , port , null , makeSecurityContext (user , password , type , null , null ), null );
820861 }
821862 /**
822863 * Creates a client to access the database by means of a REST server.
@@ -832,7 +873,7 @@ static public DatabaseClient newClient(String host, int port, String user, Strin
832873 */
833874 @ Deprecated
834875 static public DatabaseClient newClient (String host , int port , String database , String user , String password , Authentication type ) {
835- return newClient (host , port , database , makeSecurityContext (user , password , type , null , null ));
876+ return newClient (host , port , database , makeSecurityContext (user , password , type , null , null ), null );
836877 }
837878 /**
838879 * Creates a client to access the database by means of a REST server.
@@ -848,7 +889,7 @@ static public DatabaseClient newClient(String host, int port, String database, S
848889 */
849890 @ Deprecated
850891 static public DatabaseClient newClient (String host , int port , String user , String password , Authentication type , SSLContext context ) {
851- return newClient (host , port , null , makeSecurityContext (user , password , type , context , SSLHostnameVerifier .COMMON ));
892+ return newClient (host , port , null , makeSecurityContext (user , password , type , context , SSLHostnameVerifier .COMMON ), null );
852893 }
853894 /**
854895 * Creates a client to access the database by means of a REST server.
@@ -865,7 +906,7 @@ static public DatabaseClient newClient(String host, int port, String user, Strin
865906 */
866907 @ Deprecated
867908 static public DatabaseClient newClient (String host , int port , String database , String user , String password , Authentication type , SSLContext context ) {
868- return newClient (host , port , database , makeSecurityContext (user , password , type , context , SSLHostnameVerifier .COMMON ));
909+ return newClient (host , port , database , makeSecurityContext (user , password , type , context , SSLHostnameVerifier .COMMON ), null );
869910 }
870911 /**
871912 * Creates a client to access the database by means of a REST server.
@@ -882,7 +923,7 @@ static public DatabaseClient newClient(String host, int port, String database, S
882923 */
883924 @ Deprecated
884925 static public DatabaseClient newClient (String host , int port , String user , String password , Authentication type , SSLContext context , SSLHostnameVerifier verifier ) {
885- return newClient (host , port , null , makeSecurityContext (user , password , type , context , verifier ));
926+ return newClient (host , port , null , makeSecurityContext (user , password , type , context , verifier ), null );
886927 }
887928 /**
888929 * Creates a client to access the database by means of a REST server.
@@ -900,7 +941,7 @@ static public DatabaseClient newClient(String host, int port, String user, Strin
900941 */
901942 @ Deprecated
902943 static public DatabaseClient newClient (String host , int port , String database , String user , String password , Authentication type , SSLContext context , SSLHostnameVerifier verifier ) {
903- return newClient (host , port , database , makeSecurityContext (user , password , type , context , verifier ));
944+ return newClient (host , port , database , makeSecurityContext (user , password , type , context , verifier ), null );
904945 }
905946
906947 /**
@@ -978,6 +1019,7 @@ static public class Bean implements Serializable {
9781019 private Authentication authentication ;
9791020 private String externalName ;
9801021 private SecurityContext securityContext ;
1022+ private DatabaseClient .ConnectionType connectionType ;
9811023 private HandleFactoryRegistry handleRegistry =
9821024 HandleFactoryRegistryImpl .newDefault ();
9831025
@@ -1189,6 +1231,24 @@ public SecurityContext getSecurityContext() {
11891231 public void setSecurityContext (SecurityContext securityContext ) {
11901232 this .securityContext = securityContext ;
11911233 }
1234+ /**
1235+ * Identifies whether the client connects directly with a MarkLogic host
1236+ * or by means of a gateway such as a load balancer.
1237+ * @return the connection type
1238+ */
1239+ public DatabaseClient .ConnectionType getConnectionType () {
1240+ return connectionType ;
1241+ }
1242+ /**
1243+ * Specify whether the client connects directly with a MarkLogic host
1244+ * or by means of a gateway such as a load balancer.
1245+ * @param connectionType the connection type
1246+ */
1247+ public void setConnectionType (DatabaseClient .ConnectionType connectionType ) {
1248+ this .connectionType = connectionType ;
1249+ }
1250+
1251+
11921252 /**
11931253 * Returns the registry for associating
11941254 * IO representation classes with handle factories.
@@ -1222,8 +1282,10 @@ public void registerDefaultHandles() {
12221282 * @return a new client for making database requests
12231283 */
12241284 public DatabaseClient newClient () {
1225- DatabaseClientImpl client = (DatabaseClientImpl ) DatabaseClientFactory .newClient (host , port , database ,
1226- makeSecurityContext (user , password , authentication , context , verifier ));
1285+ DatabaseClientImpl client = (DatabaseClientImpl ) DatabaseClientFactory .newClient (
1286+ host , port , database ,
1287+ makeSecurityContext (user , password , authentication , context , verifier ),
1288+ connectionType );
12271289 client .setHandleRegistry (getHandleRegistry ().copy ());
12281290 return client ;
12291291 }
0 commit comments