[jboss-cvs] JBossAS SVN: r109462 - branches/snmp4j-integration-1.11.1/varia/src/main/java/org/jboss/jmx/adaptor/snmp/agent.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Nov 24 15:52:46 EST 2010
Author: thauser at redhat.com
Date: 2010-11-24 15:52:45 -0500 (Wed, 24 Nov 2010)
New Revision: 109462
Modified:
branches/snmp4j-integration-1.11.1/varia/src/main/java/org/jboss/jmx/adaptor/snmp/agent/RequestHandlerImpl.java
Log:
refactor variable type casting to a single method.
Modified: branches/snmp4j-integration-1.11.1/varia/src/main/java/org/jboss/jmx/adaptor/snmp/agent/RequestHandlerImpl.java
===================================================================
--- branches/snmp4j-integration-1.11.1/varia/src/main/java/org/jboss/jmx/adaptor/snmp/agent/RequestHandlerImpl.java 2010-11-24 20:52:14 UTC (rev 109461)
+++ branches/snmp4j-integration-1.11.1/varia/src/main/java/org/jboss/jmx/adaptor/snmp/agent/RequestHandlerImpl.java 2010-11-24 20:52:45 UTC (rev 109462)
@@ -342,6 +342,11 @@
var = setValueFor(oid,newVal);
}
catch (ReadOnlyException e){log.debug("ReadOnlyException in RequestHandlerImpl");}
+
+ if (var != null){
+ log.debug("set operation failed to set attribute, returned non-null result");
+ response = null;
+ }
//null on success. change this;
// newVB.setVariable(var);
response.add(newVB);
@@ -679,6 +684,41 @@
// return ssy;
// }
+ /**
+ * Get a proper type of variable based on an input variable from a
+ * VariableBinding.
+ * @param val the value to be converted
+ * @return an Object created with the proper type. null if failure
+ */
+ private Object convertValue(final Variable val){
+ Object result = null;
+ if (val instanceof OctetString)
+ {
+ result = val.toString();
+ }
+ else if (val instanceof Integer32)
+ {
+ result = new Integer(((Integer32)val).getValue());
+ }
+ else if (val instanceof Counter32)
+ {
+ result = new Long(((Counter32)val).getValue());
+ }
+ else if (val instanceof Counter64)
+ {
+ result = new Long(((Counter64)val).getValue());
+ }
+ else{
+ result = null;
+ }
+ return result;
+
+ }
+
+
+
+
+
// /**
// * Set a jmx attribute
// * @param oid The oid to set. This is translated into a mbean / attribute pair
@@ -711,25 +751,28 @@
try
{
- Object val = null;
- if (newVal instanceof OctetString)
- {
+ // Object val = null;
+ Object val = convertValue(newVal);
+ /* if (newVal instanceof OctetString)
+ {
val = newVal.toString();
}
else if (newVal instanceof Integer32)
- {
+ {
val = new Integer(((Integer32)newVal).getValue());
}
else if (newVal instanceof Counter32)
- {
+ {
val = new Long(((Counter32)newVal).getValue());
}
else if (newVal instanceof Counter64)
{
val = new Long(((Counter64)newVal).getValue());
- }
+ }*/
// TODO do more mumbo jumbo for type casting / changing
+
+
if (val != null)
{
Attribute at = new Attribute(be.attr.getName(), val);
More information about the jboss-cvs-commits
mailing list