diff --git a/java/lib/com/xensource/xenapi/Connection.java b/java/lib/com/xensource/xenapi/Connection.java index 0ee56cc..ed8c97d 100644 --- a/java/lib/com/xensource/xenapi/Connection.java +++ b/java/lib/com/xensource/xenapi/Connection.java @@ -58,6 +58,8 @@ public class Connection private APIVersion apiVersion; + protected int _wait = 600; + /** * Updated when Session.login_with_password() is called. */ @@ -145,9 +147,15 @@ public Connection(String client, String username, String password) throws java.n public Connection(URL url) { deprecatedConstructorUsed = false; - this.client = getClientFromURL(url); } + + public Connection(URL url, int wait) + { + this(url); + _wait = wait; + } + /** * Creates a connection to a particular server using a given username and password. This object can then be passed @@ -257,6 +265,8 @@ private XmlRpcClient getClientFromURL(URL url) { config.setTimeZone(TimeZone.getTimeZone("UTC")); config.setServerURL(url); + config.setReplyTimeout(_wait * 1000); + config.setConnectionTimeout(5000); XmlRpcClient client = new XmlRpcClient(); client.setConfig(config); return client; @@ -320,7 +330,7 @@ else if (method_call.equals("session.logout")) new Connection(new URL(client_url.getProtocol(), (String)error[1], client_url.getPort(), - client_url.getFile())); + client_url.getFile()), _wait); tmp_conn.sessionReference = sessionReference; try { diff --git a/java/lib/com/xensource/xenapi/XenAPIObject.java b/java/lib/com/xensource/xenapi/XenAPIObject.java index 815a874..39db25c 100644 --- a/java/lib/com/xensource/xenapi/XenAPIObject.java +++ b/java/lib/com/xensource/xenapi/XenAPIObject.java @@ -33,4 +33,14 @@ public abstract class XenAPIObject { public abstract String toWireString(); + + /** + * When XAPI returns a null, it actually gets changed into an + * object that contains the string "OpaqueRef:NULL". This is a + * convenience method to check if a XenAPIObject is in fact + * null in XAPI's eyes. + **/ + public boolean isNull() { + return toWireString().contains("OpaqueRef:NULL"); + } }