[jboss-cvs] JBossAS SVN: r111601 - branches/snmp4j-int/varia/src/main/java/org/jboss/jmx/adaptor/snmp/agent.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Jun 13 16:56:27 EDT 2011


Author: thauser at redhat.com
Date: 2011-06-13 16:56:27 -0400 (Mon, 13 Jun 2011)
New Revision: 111601

Modified:
   branches/snmp4j-int/varia/src/main/java/org/jboss/jmx/adaptor/snmp/agent/SnmpAgentService.java
Log:
adding mib generator to the startup process 

Modified: branches/snmp4j-int/varia/src/main/java/org/jboss/jmx/adaptor/snmp/agent/SnmpAgentService.java
===================================================================
--- branches/snmp4j-int/varia/src/main/java/org/jboss/jmx/adaptor/snmp/agent/SnmpAgentService.java	2011-06-13 20:55:49 UTC (rev 111600)
+++ branches/snmp4j-int/varia/src/main/java/org/jboss/jmx/adaptor/snmp/agent/SnmpAgentService.java	2011-06-13 20:56:27 UTC (rev 111601)
@@ -32,6 +32,8 @@
 import javax.management.ObjectName;
 
 import org.jboss.jmx.adaptor.snmp.config.user.User;
+import org.jboss.jmx.adaptor.snmp.generator.Parser;
+import org.jboss.jmx.adaptor.snmp.generator.Generator;
 import org.jboss.system.ListenerServiceMBeanSupport;
 import org.jboss.xb.binding.MappingObjectModelFactory;
 import org.jboss.xb.binding.Unmarshaller;
@@ -100,6 +102,9 @@
    /** Name of resource file containing get/set mappings */
    private String requestHandlerResName = null;
    
+   /** Path to the output MIB file */
+   private String mibResName = null;
+   
    /** Name of the trap factory class to be utilised */
    private String trapFactoryClassName = null;
 
@@ -161,7 +166,7 @@
    private MessageDispatcherImpl dispatcher;
    
    private Map<String, User> userMap = new HashMap<String, User>();
-   
+
    // Constructors --------------------------------------------------
    
    /**
@@ -652,6 +657,20 @@
 	   this.session.addCommandResponder(responder);
    }
    
+   private void createMib() throws Exception{
+	   // TODO: Make the parser accept a list of InputStreams instead of just one, so that the Deployer can provide
+	   // useful information
+	   InputStream notifications = SecurityActions.getThreadContextClassLoaderResource(this.notificationMapResName);
+	   InputStream attributes = SecurityActions.getThreadContextClassLoaderResource(this.requestHandlerResName);
+	  
+	   Parser parser = new Parser(attributes, notifications);
+	   parser.parse();
+	   Generator generator = new Generator(mibResName, parser.getMaList(), parser.getMbList(), parser.getNmList());
+	   generator.writeFile();
+
+	   }
+   
+   
    /*
     * Read the users from the users.xml and add them to the usm
     */
@@ -695,9 +714,7 @@
     	  this.userMap.put(user.getSecurityName(), user);
       }
    }
-   
-   //TODO: for v3 support we need to have this Snmp object have a USM (user security model) associated with it
-   // as well as the appropriate MP. 
+
    // the new Snmp(TransportMapping) constructor already initializes a MessageDispatcherImpl with all MP's associated. 
    /**
     * Start the embedded agent 
@@ -711,6 +728,7 @@
 	  initTransportMapping();
       initSession();
       addUsmUsers();
+      createMib();
      
       session.listen();
    }
@@ -726,6 +744,7 @@
       else
          return InetAddress.getByName(host);
    }
+
 	/**
 	 * @param usersResName the usersResName to set
 	 */
@@ -789,4 +808,23 @@
 		return transportMappings;
 	}
 
+	@Override
+	public void sendSNMPNotification(String type, Map<String, Object> userData) {
+		Notification n = new Notification(type, this, getNextNotificationSequenceNumber());
+		n.setUserData(userData);
+		try {
+			this.trapEmitter.send(n);           
+	    } catch (Exception e) {
+	         log.error("Problem occured while Sending trap", e);
+	    }   		
+	}
+
+public String getMibResName(){
+		return this.mibResName;
+	}
+	
+	public void setMibResName(String mibResName){
+		this.mibResName = mibResName;
+	}
+	
 }



More information about the jboss-cvs-commits mailing list