Save This Page
Home » JBoss-5.1.0 » org.jboss.jmx.adaptor.snmp » agent » [javadoc | source]
org.jboss.jmx.adaptor.snmp.agent
public class: TrapFactorySupport [javadoc | source]
java.lang.Object
   org.jboss.jmx.adaptor.snmp.agent.TrapFactorySupport

All Implemented Interfaces:
    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.
Constructor:
 public TrapFactorySupport() 
Method from org.jboss.jmx.adaptor.snmp.agent.TrapFactorySupport Summary:
generateV1Trap,   generateV2Trap,   set,   start
Methods from java.lang.Object:
clone,   equals,   finalize,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from org.jboss.jmx.adaptor.snmp.agent.TrapFactorySupport Detail:
 public SnmpPduTrap generateV1Trap(Notification n) throws MappingFailedException 
    Traslates a Notification to an SNMP V1 trap. *
 public SnmpPduPacket generateV2Trap(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
 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
 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.