com.adventnet.snmp.ui
Class TrapViewer

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.JComponent
                    |
                    +--javax.swing.JPanel
                          |
                          +--com.adventnet.snmp.ui.TrapViewer
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.event.ActionListener, java.util.EventListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, TrapListener, TrapParserListener

public class TrapViewer
extends javax.swing.JPanel
implements TrapParserListener, java.awt.event.ActionListener, TrapListener

This class receives, filters and displays the received traps. Set the port number to listen for traps on the specified port. Also set the parser file name to filter the incoming traps. If the parser file is not specified, default parser file will be created to allow all the traps received on the port.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
Nested classes inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
TrapViewer()
          Constructor for applications
TrapViewer(java.applet.Applet applet)
          Constructor for applets
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent e)
           
 void eventParsed(ParsedTrapEvent e)
          This should be implemented for TrapParserListener.
protected  void finalize()
          This cleans up the connection if no one is using.
 java.lang.String getAuthPassword()
          v3 only get AuthPassword
 int getAuthProtocol()
          v3 only get AuthProtocol
 java.lang.String getCharacterEncoding()
          Gets the Character Encoding being used.
 java.lang.String getCommunity()
          Gets the community string.
 java.lang.String getConfDir()
          Gets the directory where conf files will be saved in.
 java.lang.String getContextID()
          v3 only get the SNMP V3 contextID
 java.lang.String getContextName()
          v3 only get the SNMP V3 Context name
 java.lang.String getFileName()
          Gets the loaded parser file.
 java.lang.String[] getLocalAddresses()
          Gets the local addresses.
 java.lang.String getMibModules()
          Gets the loaded mibs.
 int getPort()
          Gets the listening SNMP port number.
 java.lang.String getPrincipal()
          v3 only get Principal ie userName
 java.lang.String getPrivPassword()
          v3 only get PrivPassword
 int getSnmpVersion()
          v2c and v3 only Gets the SNMP Version.
 void receivedTrap(TrapEvent e)
          This should be implemented for TrapListener.
 void setAuthPassword(java.lang.String password)
          v3 only set AuthPassword
 void setAuthProtocol(int protocol)
          v3 only set AuthProtocol
 void setCharacterEncoding(java.lang.String enc)
          Sets the Character Encoding to be used.
 void setCommunity(java.lang.String community)
          Sets the community string.
 void setConfDir(java.lang.String dir)
          Sets the directory where conf files will be saved in.
 void setContextID(byte[] ctxtID)
          v3 only set the SNMP V3 contextID
 void setContextName(java.lang.String cName)
          v3 only set the SNMP V3 Context name
 void setFileName(java.lang.String fileName)
          Sets the parser file to be used for parsing incoming traps.
 void setLocalAddresses(java.lang.String[] addresses)
          Sets the local addresses to listen on.
 void setMibModules(java.lang.String mibs)
          Set the mibs to be loaded.
 void setPort(int port)
          Sets the local SNMP port number to listen on.
 void setPrincipal(java.lang.String userName)
          v3 only set Principal ie userName
 void setPrivPassword(java.lang.String password)
          v3 only set PrivPassword
 void setSnmpVersion(int version)
          v2c and v3 only Sets the SNMP Version.
 void setTrapAuthEnable(boolean isAuth)
          v3 only Specifies whether received traps should be authenticated.
 void stop()
          Stops all the TrapReceivers listening for traps.
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TrapViewer

public TrapViewer()
Constructor for applications


TrapViewer

public TrapViewer(java.applet.Applet applet)
Constructor for applets

Method Detail

getSnmpVersion

public int getSnmpVersion()
v2c and v3 only Gets the SNMP Version.


setSnmpVersion

public void setSnmpVersion(int version)
v2c and v3 only Sets the SNMP Version.


getLocalAddresses

public java.lang.String[] getLocalAddresses()
Gets the local addresses.


setLocalAddresses

public void setLocalAddresses(java.lang.String[] addresses)
Sets the local addresses to listen on.


setPort

public void setPort(int port)
             throws SnmpException
Sets the local SNMP port number to listen on. It is set in the trap field.

Throws:
java.lang.Throwable - if the port set is <= 0
SnmpException

getPort

public int getPort()
Gets the listening SNMP port number.


setCommunity

public void setCommunity(java.lang.String community)
Sets the community string.


getCommunity

public java.lang.String getCommunity()
Gets the community string.


setCharacterEncoding

public void setCharacterEncoding(java.lang.String enc)
Sets the Character Encoding to be used. The encoding specified will be used internally to convert String <--> byte[]. The default value is ISO8859_1.

Parameters:
enc - The name of a character encoding. All the string encoding will be done base on this encoding.

getCharacterEncoding

public java.lang.String getCharacterEncoding()
Gets the Character Encoding being used. This encoding scheme will be used internally to convert String <--> byte[]. The default value is ISO8859_1.

Returns:
enc The character encoding used.

getContextName

public java.lang.String getContextName()
v3 only get the SNMP V3 Context name


setContextName

public void setContextName(java.lang.String cName)
v3 only set the SNMP V3 Context name


getContextID

public java.lang.String getContextID()
v3 only get the SNMP V3 contextID


setContextID

public void setContextID(byte[] ctxtID)
v3 only set the SNMP V3 contextID


getPrincipal

public java.lang.String getPrincipal()
v3 only get Principal ie userName


setPrincipal

public void setPrincipal(java.lang.String userName)
v3 only set Principal ie userName


getAuthProtocol

public int getAuthProtocol()
v3 only get AuthProtocol


setAuthProtocol

public void setAuthProtocol(int protocol)
v3 only set AuthProtocol


getAuthPassword

public java.lang.String getAuthPassword()
v3 only get AuthPassword


setAuthPassword

public void setAuthPassword(java.lang.String password)
v3 only set AuthPassword


getPrivPassword

public java.lang.String getPrivPassword()
v3 only get PrivPassword


setPrivPassword

public void setPrivPassword(java.lang.String password)
v3 only set PrivPassword


setMibModules

public void setMibModules(java.lang.String mibs)
Set the mibs to be loaded.


getMibModules

public java.lang.String getMibModules()
Gets the loaded mibs.


setFileName

public void setFileName(java.lang.String fileName)
Sets the parser file to be used for parsing incoming traps. It should be .parser file


getFileName

public java.lang.String getFileName()
Gets the loaded parser file.


receivedTrap

public void receivedTrap(TrapEvent e)
This should be implemented for TrapListener. The TrapParserBean gets TrapEvent and parses it and generates a ParsedTrapEvent if it matches the Criteria in the Trap parser file.

Specified by:
receivedTrap in interface TrapListener

eventParsed

public void eventParsed(ParsedTrapEvent e)
This should be implemented for TrapParserListener. The TrapBrowser gets ParsedTrapEvent and displays it in the TrapBrowser table.

Specified by:
eventParsed in interface TrapParserListener

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent e)
Specified by:
actionPerformed in interface java.awt.event.ActionListener

stop

public void stop()
Stops all the TrapReceivers listening for traps.


finalize

protected void finalize()
                 throws java.lang.Throwable
This cleans up the connection if no one is using.

Overrides:
finalize in class java.lang.Object
Throws:
java.lang.Throwable - in case of finalization errors

setTrapAuthEnable

public void setTrapAuthEnable(boolean isAuth)
v3 only Specifies whether received traps should be authenticated. Default value is false.

Parameters:
isAuth - Set this to true if traps should be authenticated. False otherwise.

setConfDir

public void setConfDir(java.lang.String dir)
Sets the directory where conf files will be saved in. The default is the current working directory.

Since:
WebNMS SNMP API 4 SP7 ( Release 4.0.7 )

getConfDir

public java.lang.String getConfDir()
Gets the directory where conf files will be saved in.

Since:
WebNMS SNMP API 4 SP7 ( Release 4.0.7 )


Copyright (c)ZOHO Corp. 1996-2012