[jboss-cvs] JBossAS SVN: r111596 - 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:51:52 EDT 2011
Author: thauser at redhat.com
Date: 2011-06-13 16:51:52 -0400 (Mon, 13 Jun 2011)
New Revision: 111596
Added:
branches/snmp4j-int/varia/src/main/java/org/jboss/jmx/adaptor/snmp/agent/BindEntry.java
Log:
Factor this class out so others can use it, notably the TrapEmitter / TrapFactory classes
Added: branches/snmp4j-int/varia/src/main/java/org/jboss/jmx/adaptor/snmp/agent/BindEntry.java
===================================================================
--- branches/snmp4j-int/varia/src/main/java/org/jboss/jmx/adaptor/snmp/agent/BindEntry.java (rev 0)
+++ branches/snmp4j-int/varia/src/main/java/org/jboss/jmx/adaptor/snmp/agent/BindEntry.java 2011-06-13 20:51:52 UTC (rev 111596)
@@ -0,0 +1,128 @@
+/*
+ * 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.agent;
+
+import javax.management.Attribute;
+import javax.management.ObjectName;
+import org.snmp4j.smi.OID;
+//import org.jboss.logging.Logger;
+ /**
+ * An entry containing the mapping between oid and mbean/attribute
+ *
+ * @author <a href="mailto:pilhuhn at user.sf.net>">Heiko W. Rupp</a>
+ */
+ public class BindEntry implements Comparable {
+ private final OID oid;
+
+ private ObjectName mbean;
+ private Attribute attr;
+ private String mName;
+ private String aName;
+ private boolean isReadWrite = false;
+
+ /**
+ * Constructs a new BindEntry.
+ * @param coid The SNMP-oid, this entry will use.
+ * @param mbName The name of an MBean with attribute to query
+ * @param attrName The name of the attribute to query
+ */
+ public BindEntry(final String oidString, final String mbName, final String attrName) {
+ this.oid = new OID(oidString);
+ this.mName = mbName;
+ this.aName = attrName;
+ try
+ {
+ mbean = new ObjectName(mbName);
+ attr = new Attribute(attrName, null);
+
+ }
+ catch (Exception e)
+ {
+ // log.warn(e.toString());
+ // mName = "-unset-";
+ // aName = "-unset-";
+ }
+ }
+
+ /**
+ * A string representation of this BindEntry
+ */
+ public String toString() {
+ StringBuffer buf = new StringBuffer();
+ buf.append("[oid=");
+ buf.append(oid).append(", mbean=");
+ buf.append(mName).append(", attr=");
+ buf.append(aName).append(", rw=");
+ buf.append(isReadWrite).append("]");
+
+ return buf.toString();
+ }
+
+ public Attribute getAttr() {
+ return attr;
+ }
+
+ public ObjectName getMbean()
+ {
+ return mbean;
+ }
+
+ public OID getOid()
+ {
+ return oid;
+ }
+
+ public boolean isReadWrite(){
+ return this.isReadWrite;
+ }
+
+ public void setReadWrite(boolean rw){
+ this.isReadWrite = rw;
+ }
+
+
+ /**
+ * Compare two BindEntries. Ordering is defined at oid-level.
+ *
+ * @param other
+ * The BindEntry to compare to.
+ * @return 0 on equals, 1 if this is bigger than other
+ */
+ public int compareTo(Object other)
+ {
+ if (other == null)
+ throw new NullPointerException("Can't compare to NULL");
+
+ if (!(other instanceof BindEntry))
+ throw new ClassCastException("Parameter is no BindEntry");
+
+ // trivial case
+ if (this.equals(other))
+ return 0;
+
+ BindEntry obe = (BindEntry) other;
+
+ int res =oid.compareTo(obe.getOid());
+ return res;
+ }
+
+ }
\ No newline at end of file
More information about the jboss-cvs-commits
mailing list