2.6.2.1 Java

By using the Oracle VM Manager Web Services Client library in your code, the REST API is almost completely abstracted. The method to query the Manager object as presented in the OvmWsRestClient class is a simple call that constructs a GET request using the Jersey Builder and returns the Manager object:

    public Manager managerGet() throws WsException
    {
        try
        {
            final Builder b = getResourceFromPathElements("Manager", "Manager");

            final Manager manager = b.get(Manager.class);

            return manager;
        }
        catch (final UniformInterfaceException ex)
        {
            throw convertException(ex);
        }
    }

To track the manager status in Java, the API can be queried repeatedly using this managerGet() method to access the Manager object and query the ManagerRunState property value to determine whether or not the Oracle VM Manager instance has RUNNING runtime status. The code should sleep between requests to reduce the number of requests submitted to the Oracle VM Manager instance over a period and to allow time for the instance to properly start up. The following code provides an example of how you might perform the loop required to wait until the ManagerRunState is set to 'RUNNING' in your Java client application:

// Wait for the manager to be in a running state before doing any work
// Refresh the manager object once every second to get the latest run state
final Manager manager = api.managerGet();
while (manager.getManagerRunState() != ManagerRunState.RUNNING){
  try{
    Thread.sleep(1000);
  }
  catch (final InterruptedException e){}
  OvmWsClientTools.refresh(api, manager);
}

Of interest in this loop is the call to OvmWsClientTools.refresh, which is used to refresh the manager object model on each iteration of the loop. This code should be executed immediately after authentication before any other operations are attempted using the SOAP API.