站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > JBoss 4.0.1 sp1 varia API Documentation 英文版文档

TrapFactorySupport (Various API) - JBoss 4.0.1 sp1 varia API Documentation 英文版文档


org.jboss.jmx.adaptor.snmp.agent
Class TrapFactorySupport

java.lang.Object
  extended byorg.jboss.jmx.adaptor.snmp.agent.TrapFactorySupport
All Implemented Interfaces:
TrapFactory

public class TrapFactorySupport
extends Object
implements TrapFactory

TrapFactorySupport takes care of translation of Notifications into SNMP V1 and V2 traps Data Structure Guide It looks complicated but it ain't. The mappings are read into a structure that follows the outline defined in the Notification.xsd. Have a look there and in the example notificationMap.xml and you should get the picture. As an optimization, 2 things are done: 1. The "NotificationType" fields of all the mappings are read, interpreted and compiled as regular expressions. All the instances are placed in an array and made accessible in their compiled form 2. The "wrapperClass" attribute is interpreted as a class name that implements interface NotificationWrapper. An instance of each class is created and similarly placed in an array This results in 2 collections one of regular expressions and one of NotificationWrapper instances. The two collections have exactly the same size as the collection of mappings. Obviously each read mapping has a "1-1" correspondence with exactly 1 compiled regular expression and exactly 1 NotificationWrapper instance. The key for the correspondence is the index: regular expression i corresponds to mapping i that coresponds to NotificationWrapper instance i. The loading of the 2 collections is performed in method startService. Checking for which mapping to apply (implemented in method findMapping) on a notification is simple: traverse the cached regular expressions and attempt to match the notification type against them. The FIRST match short circuits the search and the coresponding mapping index is returned.

Version:
$Revision: 1.3.6.3 $
Author:
Spyros Pollatos, Dimitris Andreadis

Constructor Summary
TrapFactorySupport()
          Create TrapFactorySupport
 
Method Summary
 org.opennms.protocols.snmp.SnmpPduTrap generateV1Trap(javax.management.Notification n)
          Traslates a Notification to an SNMP V1 trap.
 org.opennms.protocols.snmp.SnmpPduPacket generateV2Trap(javax.management.Notification n)
          Traslates a Notification to an SNMP V2 trap.
 void set(String notificationMapResName, Clock clock, Counter count)
          Sets the name of the file containing the notification/trap mappings, the uptime clock and the trap counter
 void start()
          Populates the regular expression and wrapper instance collections.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TrapFactorySupport

public TrapFactorySupport()
Create TrapFactorySupport

Method Detail

set

public void set(String notificationMapResName,
                Clock clock,
                Counter count)
Sets the name of the file containing the notification/trap mappings, the uptime clock and the trap counter

Specified by:
set in interface TrapFactory

start

public void start()
           throws Exception
Populates the regular expression and wrapper instance collections. Note that a failure (e.g. to compile a regular expression or to instantiate a wrapper) generates an error message. Furthermore, the offending expression or class are skipped and the corresponding collection entry is null. It is the user's responsibility to track the reported errors in the logs and act accordingly (i.e. correct them and restart). If not the corresponding mappings are effectively void and will NOT have effect.

Specified by:
start in interface TrapFactory
Throws:
Exception

generateV1Trap

public org.opennms.protocols.snmp.SnmpPduTrap generateV1Trap(javax.management.Notification n)
                                                      throws MappingFailedException
Traslates a Notification to an SNMP V1 trap.

Specified by:
generateV1Trap in interface TrapFactory
Throws:
MappingFailedException

generateV2Trap

public org.opennms.protocols.snmp.SnmpPduPacket generateV2Trap(javax.management.Notification n)
                                                        throws MappingFailedException
Traslates a Notification to an SNMP V2 trap. TODO: how do you get timestamp, generic, and specific stuff in the trap

Specified by:
generateV2Trap in interface TrapFactory
Throws:
MappingFailedException


Copyright © 2002 JBoss Group, LLC. All Rights Reserved.