org.opennms.netmgt.capsd
Class AbstractTcpPlugin

java.lang.Object
  extended by org.opennms.netmgt.capsd.AbstractPlugin
      extended by org.opennms.netmgt.capsd.AbstractTcpPlugin
All Implemented Interfaces:
Plugin
Direct Known Subclasses:
CitrixPlugin, DominoIIOPPlugin, FtpPlugin, HttpPlugin, ImapPlugin

public abstract class AbstractTcpPlugin
extends AbstractPlugin

Implements the basic functionality of a Tcp based servicethat can be discovered by OpenNMS. It extends the AbstractPlugin class and provides methods for creating the sockets and dealing with timeouts and reteries.

Version:
$Id: $
Author:
Matt Brozowski

Constructor Summary
protected AbstractTcpPlugin(String protocol, int defaultTimeout, int defaultRetry)
          Constructor for AbstractTcpPlugin.
protected AbstractTcpPlugin(String protocol, int defaultPort, int defaultTimeout, int defaultRetry)
          Constructor for AbstractTcpPlugin.
 
Method Summary
protected  boolean checkConnection(ConnectionConfig config)
           Test to see if the passed host-port pair is the endpoint for an Citrix server.
protected abstract  boolean checkProtocol(Socket socket, ConnectionConfig config)
          checkProtocol
protected  void closeSocket(Socket socket, ConnectionConfig config)
          closeSocket
protected  ConnectionConfig createConnectionConfig(InetAddress address, int port)
          createConnectionConfig
protected  List<ConnectionConfig> getConnectionConfigList(Map<String,Object> qualifiers, InetAddress address)
          getConnectionConfigList
protected  int getKeyedInteger(Map<String,Object> qualifiers, String key, int defaultVal)
          getKeyedInteger
protected  int[] getKeyedIntegerArray(Map<String,Object> qualifiers, String key, int[] defaultVal)
          getKeyedIntegerArray
 String getPluginName()
          getPluginName
 String getProtocolName()
          Returns the name of the protocol that this plugin checks on the target system for support.
 boolean isProtocolSupported(InetAddress address)
          Returns true if the protocol defined by this plugin is supported.
 boolean isProtocolSupported(InetAddress address, Map<String,Object> qualifiers)
          Returns true if the protocol defined by this plugin is supported.
protected  void populateConnectionConfig(ConnectionConfig config, Map<String,Object> qualifiers)
          populateConnectionConfig
protected  boolean preconnectCheck(ConnectionConfig config)
          preconnectCheck
protected  void saveConfig(Map<String,Object> qualifiers, ConnectionConfig config)
          saveConfig
protected  void saveKeyedInteger(Map<String,Object> qualifiers, String key, int value)
          saveKeyedInteger
 void setPluginName(String pluginName)
          setPluginName
protected  Socket wrapSocket(Socket socket, ConnectionConfig config)
          wrapSocket
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractTcpPlugin

protected AbstractTcpPlugin(String protocol,
                            int defaultTimeout,
                            int defaultRetry)

Constructor for AbstractTcpPlugin.

Parameters:
protocol - a String object.
defaultTimeout - a int.
defaultRetry - a int.

AbstractTcpPlugin

protected AbstractTcpPlugin(String protocol,
                            int defaultPort,
                            int defaultTimeout,
                            int defaultRetry)

Constructor for AbstractTcpPlugin.

Parameters:
protocol - a String object.
defaultPort - a int.
defaultTimeout - a int.
defaultRetry - a int.
Method Detail

checkConnection

protected final boolean checkConnection(ConnectionConfig config)

Test to see if the passed host-port pair is the endpoint for an Citrix server. If there is an Citrix server at that destination then a value of true is returned from the method. Otherwise a false value is returned to the caller.

Parameters:
config - a ConnectionConfig object.
Returns:
True if server supports Citrix on the specified port, false otherwise

closeSocket

protected void closeSocket(Socket socket,
                           ConnectionConfig config)

closeSocket

Parameters:
socket - a Socket object.
config - a ConnectionConfig object.

checkProtocol

protected abstract boolean checkProtocol(Socket socket,
                                         ConnectionConfig config)
                                  throws Exception

checkProtocol

Parameters:
socket - a Socket object.
config - a ConnectionConfig object.
Returns:
a boolean.
Throws:
Exception - if any.

createConnectionConfig

protected ConnectionConfig createConnectionConfig(InetAddress address,
                                                  int port)

createConnectionConfig

Parameters:
address - a InetAddress object.
port - a int.
Returns:
a ConnectionConfig object.

getConnectionConfigList

protected List<ConnectionConfig> getConnectionConfigList(Map<String,Object> qualifiers,
                                                         InetAddress address)

getConnectionConfigList

Parameters:
qualifiers - a Map object.
address - a InetAddress object.
Returns:
a List object.

getKeyedInteger

protected final int getKeyedInteger(Map<String,Object> qualifiers,
                                    String key,
                                    int defaultVal)

getKeyedInteger

Parameters:
qualifiers - a Map object.
key - a String object.
defaultVal - a int.
Returns:
a int.

getKeyedIntegerArray

protected final int[] getKeyedIntegerArray(Map<String,Object> qualifiers,
                                           String key,
                                           int[] defaultVal)

getKeyedIntegerArray

Parameters:
qualifiers - a Map object.
key - a String object.
defaultVal - an array of int.
Returns:
an array of int.

getPluginName

public final String getPluginName()

getPluginName

Returns:
Returns the pluginName.

getProtocolName

public final String getProtocolName()
Returns the name of the protocol that this plugin checks on the target system for support.

Specified by:
getProtocolName in interface Plugin
Specified by:
getProtocolName in class AbstractPlugin
Returns:
The protocol name for this plugin.

isProtocolSupported

public final boolean isProtocolSupported(InetAddress address)
Returns true if the protocol defined by this plugin is supported. If the protocol is not supported then a false value is returned to the caller. Returns true if the protocol defined by this plugin is supported. If the protocol is not supported then a false value is returned to the caller. Returns true if the protocol defined by this plugin is supported. If the protocol is not supported then a false value is returned to the caller.

Specified by:
isProtocolSupported in interface Plugin
Specified by:
isProtocolSupported in class AbstractPlugin
Parameters:
address - The address to check for support.
Returns:
True if the protocol is supported by the address.

isProtocolSupported

public final boolean isProtocolSupported(InetAddress address,
                                         Map<String,Object> qualifiers)
Returns true if the protocol defined by this plugin is supported. If the protocol is not supported then a false value is returned to the caller. The qualifier map passed to the method is used by the plugin to return additional information by key-name. These key-value pairs can be added to service events if needed. Returns true if the protocol defined by this plugin is supported. If the protocol is not supported then a false value is returned to the caller. The qualifier map passed to the method is used by the plugin to return additional information by key-name. These key-value pairs can be added to service events if needed. Returns true if the protocol defined by this plugin is supported. If the protocol is not supported then a false value is returned to the caller. The qualifier map passed to the method is used by the plugin to return additional information by key-name. These key-value pairs can be added to service events if needed.

Specified by:
isProtocolSupported in interface Plugin
Specified by:
isProtocolSupported in class AbstractPlugin
Parameters:
address - The address to check for support.
qualifiers - The map where qualification are set by the plugin.
Returns:
True if the protocol is supported by the address.

populateConnectionConfig

protected void populateConnectionConfig(ConnectionConfig config,
                                        Map<String,Object> qualifiers)

populateConnectionConfig

Parameters:
config - a ConnectionConfig object.
qualifiers - a Map object.

preconnectCheck

protected boolean preconnectCheck(ConnectionConfig config)

preconnectCheck

Parameters:
config - a ConnectionConfig object.
Returns:
a boolean.

saveConfig

protected void saveConfig(Map<String,Object> qualifiers,
                          ConnectionConfig config)

saveConfig

Parameters:
qualifiers - a Map object.
config - a ConnectionConfig object.

saveKeyedInteger

protected final void saveKeyedInteger(Map<String,Object> qualifiers,
                                      String key,
                                      int value)

saveKeyedInteger

Parameters:
qualifiers - a Map object.
key - a String object.
value - a int.

setPluginName

public final void setPluginName(String pluginName)

setPluginName

Parameters:
pluginName - The pluginName to set.

wrapSocket

protected Socket wrapSocket(Socket socket,
                            ConnectionConfig config)
                     throws Exception

wrapSocket

Parameters:
socket - a Socket object.
config - a ConnectionConfig object.
Returns:
a Socket object.
Throws:
Exception - if any.


Copyright © 2011. All Rights Reserved.