[jboss-cvs] JBossAS SVN: r111479 - branches/snmp4j-int/varia/src/main/java/org/jboss/jmx/adaptor/snmp/config/attribute.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon May 30 10:20:09 EDT 2011
Author: thauser at redhat.com
Date: 2011-05-30 10:20:09 -0400 (Mon, 30 May 2011)
New Revision: 111479
Added:
branches/snmp4j-int/varia/src/main/java/org/jboss/jmx/adaptor/snmp/config/attribute/MIBGenerator.java
Log:
start MIBGenerator work
Added: branches/snmp4j-int/varia/src/main/java/org/jboss/jmx/adaptor/snmp/config/attribute/MIBGenerator.java
===================================================================
--- branches/snmp4j-int/varia/src/main/java/org/jboss/jmx/adaptor/snmp/config/attribute/MIBGenerator.java (rev 0)
+++ branches/snmp4j-int/varia/src/main/java/org/jboss/jmx/adaptor/snmp/config/attribute/MIBGenerator.java 2011-05-30 14:20:09 UTC (rev 111479)
@@ -0,0 +1,114 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.jmx.adaptor.snmp.config.attribute;
+
+import java.util.ArrayList;
+
+
+/**
+* The goal of this class is to be able to, from information gathered from attributes.xml(s),
+* generate an MIB that is able to be loaded by external managers.
+*
+* @author <a href="mailto:tom.hauser at gmail.com">Tom Hauser</a>
+**/
+
+public class MIBGenerator {
+
+ String mibResName; // the name of the output MIB file
+ ArrayList<MappedAttribute>(1) maList; // a list of all mapped attributes algamated from all attributes.xml
+
+
+ //mutators
+ public String getMibResName(){
+ return this.mibResName;
+ }
+
+ public void setMibRedName(String mrn){
+ this.mibResName = mrn;
+ }
+ //adds a given attribute to the list, so that the generated MIB will contain it.
+ public void addAttribute(MappedAttribute ma){
+ maList.add(ma);
+ }
+
+ //we're done gathering attributes. write the MIB.
+ public void writeMib(){
+
+ }
+
+ public void writeHeader(){
+ new PrintWriter(new BufferedWriter(new FileWriter("mibRedName")));
+ PrintWriter.
+ }
+
+ public void writeImports(){
+
+ }
+
+
+
+
+ /* Internal Classes ----- */
+
+ private class MIBElement{
+ private String name;
+ private String syntax;
+ private String maxAccess;
+ private String status;
+ private String description;
+ private String objectId;
+
+ //need to modify the information saved in mapped attribute maybe.
+ //or just make a new class to hold this info in, instead of an internal one.
+ //we need to get the information out of the MappedAttribute and format it
+ //correctly for use in an MIB.
+ MIBElement(MappedAttribute ma){
+ this.name = ma.getName().substring(ma.lastIndexOf('='), ma.length());
+ this.syntax = "STRING"; // definitely need a better way to find this out.
+
+ if (ma.isReadWrite()) // since we only have "rw" and "ro", this needs expansion.
+ maxAccess = "read-write";
+ else
+ maxAccess = "read-only";
+
+ this.status = "mandatory"; // again, need expansions to attributes.xml to account for this
+ this.description = "TEST"; // see above.
+ this.objectId = ma.getOid(); // this will contain the full numerical OID.
+
+ }
+
+ public String toString(){
+ return this.name + " OBJECT-TYPE\n"
+ + "\tSYNTAX "+ syntax +"\n"
+ + "\tACCESS "+ maxAccess +"\n"
+ + "\tSTATUS "+ status +"\n"
+ + "\tDESCRIPTION "+ "\n\t\t"
+ + description + "\n"
+ + "::= { "+ checkOIDReplacement +" "
+ + objectId + " }"+"\n";
+ }
+
+
+
+}
+
+}
\ No newline at end of file
More information about the jboss-cvs-commits
mailing list