Skip to content
This repository was archived by the owner on Feb 19, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions java/lib/com/xensource/xenapi/Connection.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ public class Connection

private APIVersion apiVersion;

protected int _wait = 600;

/**
* Updated when Session.login_with_password() is called.
*/
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
{
Expand Down
10 changes: 10 additions & 0 deletions java/lib/com/xensource/xenapi/XenAPIObject.java
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
}