com.hp.ucmdb.discovery.library.clients
Class ClientFactory

java.lang.Object
  extended by com.hp.ucmdb.discovery.library.clients.ClientFactory

public class ClientFactory
extends java.lang.Object

ClientFactory is responsible for creating clients of a specific type.
This is an example of ClientFactory usage in creating an SNMP client:


  // Create the factory of type SNMP
  factory = Framework.getClientFactory(ClientsConts.SNMP_PROTOCOL_NAME)

  // Get the credentials IDs of type SNMP that match the IP address parameter
  // for credentialId in factory.getAvailableProtocols('10.11.12.13'):
  // Create the client with a specific credentials Id
  client = factory.createClient(credentialId)
 

The protocol type can be omitted if the protocol attribute ('Protocol') is specified in the pattern parameters or in the destination data attributes:

  factory = Framework.getClientFactory()
 

The client can be created without specifying credential IDs if credentialId is defined in the pattern destination data. By default, the client framework will get this value from the credentialId.

  // Here we assume that the type of client and the credential ID are provided in the destination data.
  client = Framework.getClientFactory().createClient()
 

See Also:
ClientsConsts

Method Summary
 BaseClient createClient()
          Creates a client of the type specified in the credential ID provided in the destination data.
 BaseClient createClient(java.util.Properties props)
          Creates a client of the type specified when this factory was created.
 BaseClient createClient(java.lang.String credentialsId)
          Creates a client of the type specified by the credential ID.
 java.lang.String[] getAvailableProtocols(java.lang.String ipAddress)
          Returns the credentials of the specific protocol type that match the specified IP.
 java.lang.String[] getAvailableProtocols(java.lang.String ipAddress, java.lang.String ipDomain)
          Returns the the IDs of those credentials using this factory's protocol that connect to the specified IP.
 java.lang.String getProtocolProperty(java.lang.String credentialId, java.lang.String propertyName)
          Returns the value of the specified property defined in the protocol.
 java.lang.String getProtocolProperty(java.lang.String credentialId, java.lang.String propertyName, java.lang.String defaultValue)
          Returns the value of the specified property defined in the protocol.
static boolean isKnownProtocol(java.lang.String protocol)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getAvailableProtocols

public java.lang.String[] getAvailableProtocols(java.lang.String ipAddress,
                                                java.lang.String ipDomain)
Returns the the IDs of those credentials using this factory's protocol that connect to the specified IP.

Parameters:
ipAddress - The IP address of the host to execute the client
ipDomain - Not in use
Returns:
The credential IDs for clients to work on the specified IP address

getAvailableProtocols

public java.lang.String[] getAvailableProtocols(java.lang.String ipAddress)
Returns the credentials of the specific protocol type that match the specified IP.

Parameters:
ipAddress - IP address where the client is executed
Returns:
credential IDs for clients to work on the specified IP address

getProtocolProperty

public java.lang.String getProtocolProperty(java.lang.String credentialId,
                                            java.lang.String propertyName)
Returns the value of the specified property defined in the protocol.

Parameters:
credentialId - The credential ID
propertyName - The name of the property
Returns:
The property value, or null if the specified property does not exists
See Also:
getProtocolProperty(String, String, String)

getProtocolProperty

public java.lang.String getProtocolProperty(java.lang.String credentialId,
                                            java.lang.String propertyName,
                                            java.lang.String defaultValue)
Returns the value of the specified property defined in the protocol.

Parameters:
credentialId - The credential ID
propertyName - The name of the property
defaultValue - The default value
Returns:
The property value, or the default value if the specified property does not exists

createClient

public BaseClient createClient()
                        throws java.lang.Exception
Creates a client of the type specified in the credential ID provided in the destination data.

Returns:
A client of the specified type.
Throws:
java.lang.Exception - if failed to connect using these credentials

createClient

public BaseClient createClient(java.lang.String credentialsId)
                        throws java.lang.Exception
Creates a client of the type specified by the credential ID.

Returns:
A client of the specified type
Throws:
java.lang.Exception - if failed to connect with using specified credentials

createClient

public BaseClient createClient(java.util.Properties props)
                        throws java.lang.Exception
Creates a client of the type specified when this factory was created. Properties specified in the props argument override the corresponding credential properties.

Parameters:
props - Properties to overide credential properties
Returns:
A client of the type of this factory
Throws:
java.lang.Exception - if failed to connect with given credentials

isKnownProtocol

public static boolean isKnownProtocol(java.lang.String protocol)


Documentation Feedback
Copyright 2010 Hewlett-Packard Development Company, L.P.