com.xensource.xenapi
Class Connection

java.lang.Object
  extended by com.xensource.xenapi.Connection

public class Connection
extends java.lang.Object

Represents a connection to a XenServer. Creating a new instance of this class initialises a new XmlRpcClient that is then used by all method calls: each method call in xenapi takes a Connection as a parameter, composes an XMLRPC method call, and dispatches it on the Connection's client via the dispatch method.


Field Summary
protected  int _connWait
          Connection timeout for xml-rpc calls.
protected  int _replyWait
          Reply timeout for xml-rpc calls.
static java.lang.String BINDINGS_VERSION
          The version of the bindings that this class belongs to.
 
Constructor Summary
Connection(java.lang.String client, java.lang.String username, java.lang.String password)
          Deprecated. Use a constructor that takes a URL as the first parameter instead.
Connection(java.net.URL url)
          Creates a connection to a particular server using a given url.
Connection(java.net.URL url, int replyWait, int connWait)
          Creates a connection to a particular server using a given url.
Connection(java.net.URL url, java.lang.String sessionReference)
          Creates a connection to a particular server using a given url.
Connection(java.net.URL url, java.lang.String sessionReference, int replyWait, int connWait)
          Creates a connection to a particular server using a given url.
 
Method Summary
protected  java.util.Map dispatch(java.lang.String method_call, java.lang.Object[] method_params)
          The (auto-generated parts of) the bindings dispatch XMLRPC calls on this Connection's client through this method.
 void dispose()
          Nothrow guarantee.
protected  void finalize()
           
 APIVersion getAPIVersion()
          Updated when Session.login_with_password() is called.
 org.apache.xmlrpc.client.XmlRpcClientConfigImpl getConfig()
           
 java.lang.String getSessionReference()
           
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BINDINGS_VERSION

public static final java.lang.String BINDINGS_VERSION
The version of the bindings that this class belongs to.

See Also:
Constant Field Values

_replyWait

protected int _replyWait
Reply timeout for xml-rpc calls. The default value is 10 minutes.


_connWait

protected int _connWait
Connection timeout for xml-rpc calls. The default value is 5 seconds.

Constructor Detail

Connection

@Deprecated
public Connection(java.lang.String client,
                             java.lang.String username,
                             java.lang.String password)
           throws java.net.MalformedURLException,
                  org.apache.xmlrpc.XmlRpcException,
                  Types.BadServerResponse,
                  Types.SessionAuthenticationFailed,
                  Types.XenAPIException
Deprecated. Use a constructor that takes a URL as the first parameter instead.

Creates a connection to a particular server using a given username and password. This object can then be passed in to any other API calls. This constructor calls Session.loginWithPassword, passing itself as the first parameter. When this constructor is used, a call to dispose() (also called in the Connection's finalizer) will attempt a Session.logout on this connection.

Throws:
java.net.MalformedURLException
org.apache.xmlrpc.XmlRpcException
Types.BadServerResponse
Types.SessionAuthenticationFailed
Types.XenAPIException

Connection

public Connection(java.net.URL url)
Creates a connection to a particular server using a given url. This object can then be passed in to any other API calls. Note this constructor does NOT call Session.loginWithPassword; the programmer is responsible for calling it, passing the Connection as a parameter. No attempt to connect to the server is made until login is called. When this constructor is used, a call to dispose() will do nothing. The programmer is responsible for manually logging out the Session.


Connection

public Connection(java.net.URL url,
                  int replyWait,
                  int connWait)
Creates a connection to a particular server using a given url. This object can then be passed in to any other API calls. Note this constructor does NOT call Session.loginWithPassword; the programmer is responsible for calling it, passing the Connection as a parameter. No attempt to connect to the server is made until login is called. When this constructor is used, a call to dispose() will do nothing. The programmer is responsible for manually logging out the Session. The parameters replyWait and connWait set timeouts for xml-rpc calls.


Connection

public Connection(java.net.URL url,
                  java.lang.String sessionReference)
Creates a connection to a particular server using a given url. This object can then be passed in to any other API calls. The additional sessionReference parameter must be a reference to a logged-in Session. Any method calls on this Connection will use it. This constructor does not call Session.loginWithPassword, and dispose() on the resulting Connection object does not call Session.logout. The programmer is responsible for ensuring the Session is logged in and out correctly.


Connection

public Connection(java.net.URL url,
                  java.lang.String sessionReference,
                  int replyWait,
                  int connWait)
Creates a connection to a particular server using a given url. This object can then be passed in to any other API calls. The additional sessionReference parameter must be a reference to a logged-in Session. Any method calls on this Connection will use it. This constructor does not call Session.loginWithPassword, and dispose() on the resulting Connection object does not call Session.logout. The programmer is responsible for ensuring the Session is logged in and out correctly. The parameters replyWait and connWait set timeouts for xml-rpc calls.

Method Detail

getAPIVersion

public APIVersion getAPIVersion()
Updated when Session.login_with_password() is called.


finalize

protected void finalize()
                 throws java.lang.Throwable
Overrides:
finalize in class java.lang.Object
Throws:
java.lang.Throwable

dispose

public void dispose()
Nothrow guarantee.


getConfig

public org.apache.xmlrpc.client.XmlRpcClientConfigImpl getConfig()

getSessionReference

public java.lang.String getSessionReference()

dispatch

protected java.util.Map dispatch(java.lang.String method_call,
                                 java.lang.Object[] method_params)
                          throws org.apache.xmlrpc.XmlRpcException,
                                 Types.XenAPIException
The (auto-generated parts of) the bindings dispatch XMLRPC calls on this Connection's client through this method.

Throws:
org.apache.xmlrpc.XmlRpcException
Types.XenAPIException