|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.jboss.jmx.adaptor.snmp.agent.TrapFactorySupport
public class 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.snmp4j.PDUv1 |
generateV1Trap(javax.management.Notification n,
Mapping m,
NotificationWrapper wrapper)
Traslates a Notification to an SNMP V1 trap. |
org.snmp4j.PDU |
generateV2cTrap(javax.management.Notification n,
Mapping m,
NotificationWrapper wrapper)
Traslates a Notification to an SNMP V2c trap. |
org.snmp4j.ScopedPDU |
generateV3Trap(javax.management.Notification n,
Mapping m,
NotificationWrapper wrapper)
Traslates a Notification to an SNMP V3 trap. |
void |
set(Clock clock,
Counter count)
Sets the name of the file containing the notification/trap mappings, the uptime clock and the trap counter |
void |
set(Clock clock,
Counter count,
RequestHandler rh)
|
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(Clock clock,
Counter count)
set in interface TrapFactory
public void set(Clock clock,
Counter count,
RequestHandler rh)
set in interface TrapFactory
public void start()
throws java.lang.Exception
start in interface TrapFactoryjava.lang.Exception
public org.snmp4j.PDUv1 generateV1Trap(javax.management.Notification n,
Mapping m,
NotificationWrapper wrapper)
throws MappingFailedException
generateV1Trap in interface TrapFactoryMappingFailedException
public org.snmp4j.PDU generateV2cTrap(javax.management.Notification n,
Mapping m,
NotificationWrapper wrapper)
throws MappingFailedException
generateV2cTrap in interface TrapFactoryMappingFailedException
public org.snmp4j.ScopedPDU generateV3Trap(javax.management.Notification n,
Mapping m,
NotificationWrapper wrapper)
throws MappingFailedException
generateV3Trap in interface TrapFactoryMappingFailedException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||