com.cisco.ipphone.sdk
Class IPAddressProvider

java.lang.Object
  extended by com.cisco.ipphone.sdk.IPAddressProvider
All Implemented Interfaces:
IPAddressProviderIF

public class IPAddressProvider
extends java.lang.Object
implements IPAddressProviderIF

The IPAddressProvider class provides a simple Java "wrapper" around the Cisco CallManager DeviceListX API. This implementation of the IPAddressProviderIF interface caches IP address information and automatically refreshes the information at the specified interval. The initial loading of IP addresses from the DeviceListX API is performed by the calling thread of the IPAddressProvider constructor - this ensures that the provider is ready for requests as soon as the constructor method returns. Subsequent updates are handled automatically by the IPAddressProvider class using a Timer thread. The refresh logic is designed so that the calling thread will always return immediately - it will never block while waiting for the device list to be updated (except for the initial load as stated above).
Note: Any IPAddressProvider objects which point to the same CallManager server, share the same IP address information, and that information will only be refreshed at the specified interval regardless of the number of IPAddressProvider objects created and the frequency of their use.
The implementation only reports the IP addresses of devices which are in the REGISTERED state.

See Also:
IPAddressProviderIF

Field Summary
static int DEFAULT_INTERVAL
           
 
Constructor Summary
IPAddressProvider(java.lang.String callManager, java.lang.String callManagerUserId, java.lang.String callManagerPassword)
          Equivalent to calling: IPAddressProvider(callManager, callManagerUserId, callManagerPassword, false, IPAddressProvider.DEFAULT_INTERVAL);
IPAddressProvider(java.lang.String callManager, java.lang.String callManagerUserId, java.lang.String callManagerPassword, boolean useHttps)
          Equivalent to calling: IPAddressProvider(callManager, callManagerUserId, callManagerPassword, useHttps, IPAddressProvider.DEFAULT_INTERVAL);
IPAddressProvider(java.lang.String callManager, java.lang.String callManagerUserId, java.lang.String callManagerPassword, boolean useHttps, int refreshInterval)
          Creates a new IPAddressProvider and immediately loads the IP address table
 
Method Summary
 java.util.HashMap getAllIPAddresses()
          This method retrieves all of the current active IP addresses of devices.
 java.lang.String getDeviceType(Phone phone)
          Returns the device type of the specified phone
 java.lang.String getIPAddress(Phone phone)
          This method retrieves the current active IP address of the specified Phone.
 java.lang.String[] getIPAddresses(Phone[] phones)
          This method retrieves the current active IP addresses of the specified Phones.
 Phone getPhone(java.lang.String ipAddress)
          This method does the inverse of the other methods - it accepts an IP address as a parameter and searches for the Phone currently using that address.
static void main(java.lang.String[] args)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_INTERVAL

public static final int DEFAULT_INTERVAL
See Also:
Constant Field Values
Constructor Detail

IPAddressProvider

public IPAddressProvider(java.lang.String callManager,
                         java.lang.String callManagerUserId,
                         java.lang.String callManagerPassword)
Equivalent to calling: IPAddressProvider(callManager, callManagerUserId, callManagerPassword, false, IPAddressProvider.DEFAULT_INTERVAL);

Parameters:
callManager - String
callManagerUserId - String
callManagerPassword - String

IPAddressProvider

public IPAddressProvider(java.lang.String callManager,
                         java.lang.String callManagerUserId,
                         java.lang.String callManagerPassword,
                         boolean useHttps)
Equivalent to calling: IPAddressProvider(callManager, callManagerUserId, callManagerPassword, useHttps, IPAddressProvider.DEFAULT_INTERVAL);

Parameters:
callManager - String
callManagerUserId - String
callManagerPassword - String
useHttps - boolean

IPAddressProvider

public IPAddressProvider(java.lang.String callManager,
                         java.lang.String callManagerUserId,
                         java.lang.String callManagerPassword,
                         boolean useHttps,
                         int refreshInterval)
Creates a new IPAddressProvider and immediately loads the IP address table

Parameters:
callManager - String Hostname or IP address of the CallManager server hosting the DeviceListX API
callManagerUserId - String The UserId used to authenticate to the CallManager for CCMAdmin access
callManagerPassword - String The password of the above UserId
useHttps - boolean If 'true' then https is used rather than http (Note: https is required for CallManager 4.1)
refreshInterval - int Interval in seconds to refresh the IP address data
Method Detail

getPhone

public Phone getPhone(java.lang.String ipAddress)
This method does the inverse of the other methods - it accepts an IP address as a parameter and searches for the Phone currently using that address.

Specified by:
getPhone in interface IPAddressProviderIF
Parameters:
ipAddress - a String containing the current IP address of the requested Phone
Returns:
the Phone currently using the specified IP address or null if the address could not be found

getIPAddress

public java.lang.String getIPAddress(Phone phone)
This method retrieves the current active IP address of the specified Phone.

Specified by:
getIPAddress in interface IPAddressProviderIF
Parameters:
phone - the Phone for which an IP address is requested
Returns:
a String containing the IP address of the Phone in dotted-decimal format. If the Phone is not found, null will be returned.

getIPAddresses

public java.lang.String[] getIPAddresses(Phone[] phones)
This method retrieves the current active IP addresses of the specified Phones.

Specified by:
getIPAddresses in interface IPAddressProviderIF
Parameters:
phones - an Array of Phones for which IP addresses are requested
Returns:
an Array of Strings containing the IP addresses of the requested Phones in dotted-decimal format. The returned array will always be the same length as the phones[] supplied as an argument. For any phones not found, the corresponding array element will contain null.

getAllIPAddresses

public java.util.HashMap getAllIPAddresses()
This method retrieves all of the current active IP addresses of devices.

Specified by:
getAllIPAddresses in interface IPAddressProviderIF
Returns:
a HashMap which contains all of the deviceNames (the HashMap keys) and their IP addresses (the HashMap values)

getDeviceType

public java.lang.String getDeviceType(Phone phone)
Returns the device type of the specified phone

Parameters:
phone - Phone
Returns:
String device type, or null if phone is unknown

main

public static void main(java.lang.String[] args)