|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.jboss.jmx.adaptor.snmp.agent.TrapFactorySupport
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.
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 |
public TrapFactorySupport()
Method Detail |
public void set(String notificationMapResName, Clock clock, Counter count)
set
in interface TrapFactory
public void start() throws Exception
start
in interface TrapFactory
Exception
public org.opennms.protocols.snmp.SnmpPduTrap generateV1Trap(javax.management.Notification n) throws MappingFailedException
generateV1Trap
in interface TrapFactory
MappingFailedException
public org.opennms.protocols.snmp.SnmpPduPacket generateV2Trap(javax.management.Notification n) throws MappingFailedException
generateV2Trap
in interface TrapFactory
MappingFailedException
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |