@@ -58,7 +58,15 @@ public class Connection
5858
5959 private APIVersion apiVersion ;
6060
61- protected int _wait = 600 ;
61+ /**
62+ * Reply timeout for xml-rpc calls. The default value is 10 minutes.
63+ */
64+ protected int _replyWait = 600 ;
65+
66+ /**
67+ * Connection timeout for xml-rpc calls. The default value is 5 seconds.
68+ */
69+ protected int _connWait = 5 ;
6270
6371 /**
6472 * Updated when Session.login_with_password() is called.
@@ -135,7 +143,7 @@ public Connection(String client, String username, String password) throws java.n
135143 }
136144
137145 /**
138- * Creates a connection to a particular server using a given username and password . This object can then be passed
146+ * Creates a connection to a particular server using a given url . This object can then be passed
139147 * in to any other API calls.
140148 *
141149 * Note this constructor does NOT call Session.loginWithPassword; the programmer is responsible for calling it,
@@ -149,16 +157,29 @@ public Connection(URL url)
149157 deprecatedConstructorUsed = false ;
150158 this .client = getClientFromURL (url );
151159 }
152-
153- public Connection (URL url , int wait )
154- {
155- this (url );
156- _wait = wait ;
160+
161+ /**
162+ * Creates a connection to a particular server using a given url. This object can then be passed
163+ * in to any other API calls.
164+ *
165+ * Note this constructor does NOT call Session.loginWithPassword; the programmer is responsible for calling it,
166+ * passing the Connection as a parameter. No attempt to connect to the server is made until login is called.
167+ *
168+ * When this constructor is used, a call to dispose() will do nothing. The programmer is responsible for manually
169+ * logging out the Session.
170+ *
171+ * The parameters replyWait and connWait set timeouts for xml-rpc calls.
172+ */
173+ public Connection (URL url , int replyWait , int connWait )
174+ {
175+ this (url );
176+ _replyWait = replyWait ;
177+ _connWait = connWait ;
157178 }
158-
179+
159180
160181 /**
161- * Creates a connection to a particular server using a given username and password . This object can then be passed
182+ * Creates a connection to a particular server using a given url . This object can then be passed
162183 * in to any other API calls.
163184 *
164185 * The additional sessionReference parameter must be a reference to a logged-in Session. Any method calls on this
@@ -174,6 +195,24 @@ public Connection(URL url, String sessionReference)
174195 this .sessionReference = sessionReference ;
175196 }
176197
198+ /**
199+ * Creates a connection to a particular server using a given url. This object can then be passed
200+ * in to any other API calls.
201+ *
202+ * The additional sessionReference parameter must be a reference to a logged-in Session. Any method calls on this
203+ * Connection will use it. This constructor does not call Session.loginWithPassword, and dispose() on the resulting
204+ * Connection object does not call Session.logout. The programmer is responsible for ensuring the Session is logged
205+ * in and out correctly.
206+ *
207+ * The parameters replyWait and connWait set timeouts for xml-rpc calls.
208+ */
209+ public Connection (URL url , String sessionReference , int replyWait , int connWait )
210+ {
211+ this (url , sessionReference );
212+ _replyWait = replyWait ;
213+ _connWait = connWait ;
214+ }
215+
177216 protected void finalize () throws Throwable
178217 {
179218 dispose ();
@@ -259,14 +298,14 @@ private static String loginWithPassword(XmlRpcClient client, String username, St
259298
260299 public XmlRpcClientConfigImpl getConfig ()
261300 {
262- return config ;
301+ return config ;
263302 }
264303 private XmlRpcClient getClientFromURL (URL url )
265304 {
266305 config .setTimeZone (TimeZone .getTimeZone ("UTC" ));
267306 config .setServerURL (url );
268- config .setReplyTimeout (_wait * 1000 );
269- config .setConnectionTimeout (5000 );
307+ config .setReplyTimeout (_replyWait * 1000 );
308+ config .setConnectionTimeout (_connWait * 1000 );
270309 XmlRpcClient client = new XmlRpcClient ();
271310 client .setConfig (config );
272311 return client ;
@@ -330,7 +369,7 @@ else if (method_call.equals("session.logout"))
330369 new Connection (new URL (client_url .getProtocol (),
331370 (String )error [1 ],
332371 client_url .getPort (),
333- client_url .getFile ()), _wait );
372+ client_url .getFile ()), _replyWait , _connWait );
334373 tmp_conn .sessionReference = sessionReference ;
335374 try
336375 {
0 commit comments