WIDAR Classes

ca.nrc.widar.mccc.crm
Class CrmComm

java.lang.Object
  extended by ca.nrc.widar.mccc.crm.CrmComm

public class CrmComm
extends java.lang.Object

WIDAR/EVLA - CRM: CrmComm Class

The CRM HTTP Comm(unications).

A class which contains communication utility methods for the CRM.

Copyright: National Research Council of Canada and Associated Universities Inc., 2010, 2011, 2012

Since:
1.0
Author:
Dave Del Rizzo (Dave.DelRizzo@nrc.gc.ca)
 

Nested Class Summary
static class CrmComm.SmallDataReadyListener
          A utilitiy sub-class used as a bare bones DataReadyListener for the methods within the CrmComm class.
 
Field Summary
static java.lang.String CLASSNAME
           
static CrmComm.SmallDataReadyListener drl
           
static int SERVER_DEFAULT_TIMEOUT
           
 
Constructor Summary
CrmComm()
          A class containing a collection of static XML communication methods intended to facilitate communication between the CRM and WIDAR hardware components.
 
Method Summary
static java.net.InetAddress getLocalInetAddress()
          Returns the InetAddress for the local host (CRM)
static void sendGet(java.net.InetAddress host, int port, java.lang.String context, java.lang.String command, DataReadyListener drl)
          a sendGet convenience method, allowing the caller to not require specifying the timeout value and defaulting to the SERVER_DEFAULT_TIMEOUT
static void sendGet(java.net.InetAddress host, int port, java.lang.String context, java.lang.String command, DataReadyListener drl, int timeout)
          Sends the supplied message String as an asynchronous server 'GET' query to the specified server.
static void sendPost(java.net.InetAddress host, int port, java.lang.String context, java.lang.String message, DataReadyListener drl)
          a sendPost convenience method, allowing the caller to not require specifying the timeout value and defaulting to the SERVER_DEFAULT_TIMEOUT
static void sendPost(java.net.InetAddress host, int port, java.lang.String context, java.lang.String message, DataReadyListener drl, int timeout)
          Sends the supplied message String as an asynchronous server 'POST' query to the specified server.
static java.lang.String verifyCmibHost(java.lang.String hostName)
          Supplied with a String hostname, this method attempts to verify the existence of a CMIB hostname by sending a generic SUPERVISOR XML request.
static java.net.InetAddress verifyHost(java.lang.String hostName)
          Supplied with a String hostname, this method attempts to verify the existence of the hostname via the 'isReachable' test with a 5 second timeout.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CLASSNAME

public static final java.lang.String CLASSNAME
See Also:
Constant Field Values

SERVER_DEFAULT_TIMEOUT

public static final int SERVER_DEFAULT_TIMEOUT
See Also:
Constant Field Values

drl

public static CrmComm.SmallDataReadyListener drl
Constructor Detail

CrmComm

public CrmComm()
A class containing a collection of static XML communication methods intended to facilitate communication between the CRM and WIDAR hardware components. This class is not meant to be instantiated.

Method Detail

verifyCmibHost

public static java.lang.String verifyCmibHost(java.lang.String hostName)
Supplied with a String hostname, this method attempts to verify the existence of a CMIB hostname by sending a generic SUPERVISOR XML request. The response to such a request contains in the parent tag, an indication as to the type of CMIB that is being queried, and that string - the name of the XML tag - is what is returned. This method is used primarily to distinguish between a Baseline Board and Station Board CMIB.

Parameters:
hostName - A String representation of the CMIB host name to be tested
Returns:
A String, the content of which is the XML tag used by the queried CMIB. This String is used to distinguish between 'baselineBoard' and 'stationBoard' CMIBs.

verifyHost

public static java.net.InetAddress verifyHost(java.lang.String hostName)
Supplied with a String hostname, this method attempts to verify the existence of the hostname via the 'isReachable' test with a 5 second timeout. If the hostname provided is not reachable, then null is returned, otherwise, the InetAddress object associated with the hostname is returned.

Parameters:
hostName - A String representation of the host name to be tested
Returns:
An InetAddress object for the provided hostname, or null if it is not reachable

getLocalInetAddress

public static java.net.InetAddress getLocalInetAddress()
Returns the InetAddress for the local host (CRM)

Returns:
An InetAddress object describing the local host (CRM)

sendGet

public static void sendGet(java.net.InetAddress host,
                           int port,
                           java.lang.String context,
                           java.lang.String command,
                           DataReadyListener drl)
a sendGet convenience method, allowing the caller to not require specifying the timeout value and defaulting to the SERVER_DEFAULT_TIMEOUT

Parameters:
host - The InetAddress of the target host
port - The integer port number of the target host
context - The String context for the target host HTTP server
command - The String command to be sent
drl - A reference to the DataReadyListener of the sender in order to properly direct the reply

sendGet

public static void sendGet(java.net.InetAddress host,
                           int port,
                           java.lang.String context,
                           java.lang.String command,
                           DataReadyListener drl,
                           int timeout)
Sends the supplied message String as an asynchronous server 'GET' query to the specified server. The caller also supplies the DataReadyListener and a timeout value (ms).

Parameters:
host - The InetAddress of the target host
port - The integer port number of the target host
context - The String context for the target host HTTP server
command - The String command to be sent
drl - A reference to the DataReadyListener of the sender in order to properly direct the reply
timeout - The int number of milliseconds to wait for a reply

sendPost

public static void sendPost(java.net.InetAddress host,
                            int port,
                            java.lang.String context,
                            java.lang.String message,
                            DataReadyListener drl)
a sendPost convenience method, allowing the caller to not require specifying the timeout value and defaulting to the SERVER_DEFAULT_TIMEOUT

Parameters:
host - The InetAddress of the target host
port - The integer port number of the target host
context - The String context for the target host HTTP server
message - The String message to be sent
drl - A reference to the DataReadyListener of the sender in order to properly direct the reply

sendPost

public static void sendPost(java.net.InetAddress host,
                            int port,
                            java.lang.String context,
                            java.lang.String message,
                            DataReadyListener drl,
                            int timeout)
Sends the supplied message String as an asynchronous server 'POST' query to the specified server. The caller also supplies the DataReadyListener and a timeout value (ms).

Parameters:
host - The InetAddress of the target host
port - The integer port number of the target host
context - The String context for the target host HTTP server
message - The String body of the message to be sent
drl - A reference to the DataReadyListener of the sender in order to properly direct the reply
timeout - The int number of milliseconds to wait for a reply

NRAO/DRAO

National Radio Astronomy Observatory