com.cri.xcat.api
Interface IResponseHandler

All Known Implementing Classes:
DefaultResponseHandler, NonBlockingHandler

public interface IResponseHandler

This interface is used for handling an xCAT response (from the xCAT daemon). The methods included in this interface allow a class that would like to handle an xCAT response the necessarily functionality needed to handle either the XML response or the error that occurred while attempting the communication.

Author:
Scott Brown

Method Summary
 void handleError(java.lang.Exception e)
          This method is called when an error has occurred while attempting to submit a request (send a command) to the xCAT daemon.
 void handleXmlResponse(java.io.InputStream inputStream)
          This method takes the InputStream from the SSL socket connection and parses it.
 

Method Detail

handleError

void handleError(java.lang.Exception e)
This method is called when an error has occurred while attempting to submit a request (send a command) to the xCAT daemon. It can be called at any time during the communication process, even while the client is handling the XML response from the server.

Parameters:
e - The error that occurred.

handleXmlResponse

void handleXmlResponse(java.io.InputStream inputStream)
This method takes the InputStream from the SSL socket connection and parses it. The InputStream is the response from xcatd after a request is made to the daemon.

The response is in a XML format with the root XML tag of xcatresponse. According to the xCAT documentation, a valid XML response can be in various formats. There are 3 specifically mentioned in the documentation that are listed below:

 1.     <xcatresponse>
       <data>...</data>
       <data>...</data>
                   ...
       <data>...</data>
      </xcatresponse>
 

In this format, there can be multiple data tags.

 2.     <xcatresponse>
         <data>
        <desc>desc1</desc>
        <contents>contents1</contents>
       </data>
       <data>
        <desc>desc2</desc>
        <contents>contents2</contents>
       </data>
      </xcatresponse>
 

NOTE: In this format, only the data array can have more than one element. All other arrays are assumed to be a single element.

 3.     <xcatresponse>
       <node>
        <name>node1</name>
          <data>
         <desc>node 1 desc</desc>
         <contents>node 1 contents</contents>
        </data>
       </node>
       <node>
        <name>node2</name>
          <data>
         <desc>node 2 desc</desc>
         <contents>node 2 contents</contents>
        </data>
       </node>
      </xcatresponse>
 

NOTE: Only the node array can have more than one element. All other arrays are assumed to be a single element.

The response from xcatd may also contain an error. The error will be specified in the XML response and in which case the client should recognize this error and respond accordingly. NOTE: The handleError method is not automatically called when xcatd responds with valid XML containing an error message. This is up to the client.

Parameters:
inputStream - the input stream from the xCAT daemon to this client.