jdk/src/share/classes/com/sun/jmx/snmp/agent/SnmpGenericObjectServer.java
changeset 14677 1607f4cfc506
parent 5506 202f599c92aa
child 23010 6dadb192ad81
equal deleted inserted replaced
14675:17224d0282f1 14677:1607f4cfc506
    26 package com.sun.jmx.snmp.agent;
    26 package com.sun.jmx.snmp.agent;
    27 
    27 
    28 
    28 
    29 // java imports
    29 // java imports
    30 //
    30 //
    31 import java.util.Vector;
       
    32 import java.util.Enumeration;
    31 import java.util.Enumeration;
    33 import java.util.Iterator;
    32 import java.util.Iterator;
    34 
    33 
    35 // jmx imports
    34 // jmx imports
    36 //
    35 //
   147         final String[]      nameList = new String[size];
   146         final String[]      nameList = new String[size];
   148         final SnmpVarBind[] varList  = new SnmpVarBind[size];
   147         final SnmpVarBind[] varList  = new SnmpVarBind[size];
   149         final long[]        idList   = new long[size];
   148         final long[]        idList   = new long[size];
   150         int   i = 0;
   149         int   i = 0;
   151 
   150 
   152         for (Enumeration e=req.getElements(); e.hasMoreElements();) {
   151         for (Enumeration<SnmpVarBind> e=req.getElements(); e.hasMoreElements();) {
   153             final SnmpVarBind var= (SnmpVarBind) e.nextElement();
   152             final SnmpVarBind var= e.nextElement();
   154             try {
   153             try {
   155                 final long id = var.oid.getOidArc(depth);
   154                 final long id = var.oid.getOidArc(depth);
   156                 nameList[i]   = meta.getAttributeName(id);
   155                 nameList[i]   = meta.getAttributeName(id);
   157                 varList[i]    = var;
   156                 varList[i]    = var;
   158                 idList[i]     = id;
   157                 idList[i]     = id;
   188         } catch (Exception x) {
   187         } catch (Exception x) {
   189             result = new AttributeList();
   188             result = new AttributeList();
   190         }
   189         }
   191 
   190 
   192 
   191 
   193         final Iterator it = result.iterator();
   192         final Iterator<?> it = result.iterator();
   194 
   193 
   195         for (int j=0; j < i; j++) {
   194         for (int j=0; j < i; j++) {
   196             if (!it.hasNext()) {
   195             if (!it.hasNext()) {
   197                 //java.lang.System.out.println(name + "variable[" + j +
   196                 //java.lang.System.out.println(name + "variable[" + j +
   198                 //                           "] absent");
   197                 //                           "] absent");
   310         final String[]      nameList = new String[size];
   309         final String[]      nameList = new String[size];
   311         final SnmpVarBind[] varList  = new SnmpVarBind[size];
   310         final SnmpVarBind[] varList  = new SnmpVarBind[size];
   312         final long[]        idList   = new long[size];
   311         final long[]        idList   = new long[size];
   313         int   i = 0;
   312         int   i = 0;
   314 
   313 
   315         for (Enumeration e=req.getElements(); e.hasMoreElements();) {
   314         for (Enumeration<SnmpVarBind> e=req.getElements(); e.hasMoreElements();) {
   316             final SnmpVarBind var= (SnmpVarBind) e.nextElement();
   315             final SnmpVarBind var= e.nextElement();
   317             try {
   316             try {
   318                 final long id = var.oid.getOidArc(depth);
   317                 final long id = var.oid.getOidArc(depth);
   319                 final String attname = meta.getAttributeName(id);
   318                 final String attname = meta.getAttributeName(id);
   320                 final Object attvalue=
   319                 final Object attvalue=
   321                     meta.buildAttributeValue(id,var.value);
   320                     meta.buildAttributeValue(id,var.value);
   328             } catch(SnmpStatusException x) {
   327             } catch(SnmpStatusException x) {
   329                 req.registerSetException(var,x);
   328                 req.registerSetException(var,x);
   330             }
   329             }
   331         }
   330         }
   332 
   331 
   333         AttributeList result = null;
   332         AttributeList result;
   334         int errorCode = SnmpStatusException.noAccess;
   333         int errorCode = SnmpStatusException.noAccess;
   335 
   334 
   336         try {
   335         try {
   337             result = server.setAttributes(name,attList);
   336             result = server.setAttributes(name,attList);
   338         } catch (InstanceNotFoundException f) {
   337         } catch (InstanceNotFoundException f) {
   343             result = new AttributeList();
   342             result = new AttributeList();
   344         } catch (Exception x) {
   343         } catch (Exception x) {
   345             result = new AttributeList();
   344             result = new AttributeList();
   346         }
   345         }
   347 
   346 
   348         final Iterator it = result.iterator();
   347         final Iterator<?> it = result.iterator();
   349 
   348 
   350         for (int j=0; j < i; j++) {
   349         for (int j=0; j < i; j++) {
   351             if (!it.hasNext()) {
   350             if (!it.hasNext()) {
   352                 final SnmpStatusException x =
   351                 final SnmpStatusException x =
   353                     new SnmpStatusException(errorCode);
   352                     new SnmpStatusException(errorCode);
   467                       SnmpMibSubRequest req, int depth)
   466                       SnmpMibSubRequest req, int depth)
   468         throws SnmpStatusException {
   467         throws SnmpStatusException {
   469 
   468 
   470         final Object data = req.getUserData();
   469         final Object data = req.getUserData();
   471 
   470 
   472         for (Enumeration e=req.getElements(); e.hasMoreElements();) {
   471         for (Enumeration<SnmpVarBind> e=req.getElements(); e.hasMoreElements();) {
   473             final SnmpVarBind var= (SnmpVarBind) e.nextElement();
   472             final SnmpVarBind var= e.nextElement();
   474             try {
   473             try {
   475                 final long id = var.oid.getOidArc(depth);
   474                 final long id = var.oid.getOidArc(depth);
   476                 // call meta.check() here, and meta.check will call check()
   475                 // call meta.check() here, and meta.check will call check()
   477                 check(meta,name,var.value,id,data);
   476                 check(meta,name,var.value,id,data);
   478             } catch(SnmpStatusException x) {
   477             } catch(SnmpStatusException x) {