110. EPMO Open Source Coordination Office Redaction File Detail Report

Produced by Araxis Merge on 9/25/2018 2:13:03 PM Central Daylight Time. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.

110.1 Files compared

# Location File Last Modified
1 build 3.zip\build 3\MHLTH_YS_137_Source\JavaScript\resources\javaJDF-1.8.0\src\com\sun\jmx\snmp\agent SnmpMibAgent.java Mon Jan 22 14:46:50 2018 UTC
2 build 3.zip\build 3\MHLTH_YS_137_Source\JavaScript\resources\javaJDF-1.8.0\src\com\sun\jmx\snmp\agent SnmpMibAgent.java Wed Sep 12 16:26:54 2018 UTC

110.2 Comparison summary

Description Between
Files 1 and 2
Text Blocks Lines
Unchanged 2 1534
Changed 1 2
Inserted 0 0
Removed 0 0

110.3 Comparison options

Whitespace
Character case Differences in character case are significant
Line endings Differences in line endings (CR and LF characters) are ignored
CR/LF characters Not shown in the comparison detail

110.4 Active regular expressions

No regular expressions were active.

110.5 Comparison detail

  1   /*
  2    * Copyrig ht (c) 199 8, 2013, O racle and/ or its aff iliates. A ll rights  reserved.
  3    * DO NOT  ALTER OR R EMOVE COPY RIGHT NOTI CES OR THI S FILE HEA DER.
  4    *
  5    * This co de is free  software;  you can r edistribut e it and/o r modify i t
  6    * under t he terms o f the GNU  General Pu blic Licen se version  2 only, a s
  7    * publish ed by the  Free Softw are Founda tion.  Ora cle design ates this
  8    * particu lar file a s subject  to the "Cl asspath" e xception a s provided
  9    * by Orac le in the  LICENSE fi le that ac companied  this code.
  10    *
  11    * This co de is dist ributed in  the hope  that it wi ll be usef ul, but WI THOUT
  12    * ANY WAR RANTY; wit hout even  the implie d warranty  of MERCHA NTABILITY  or
  13    * FITNESS  FOR A PAR TICULAR PU RPOSE.  Se e the GNU  General Pu blic Licen se
  14    * version  2 for mor e details  (a copy is  included  in the LIC ENSE file  that
  15    * accompa nied this  code).
  16    *
  17    * You sho uld have r eceived a  copy of th e GNU Gene ral Public  License v ersion
  18    * 2 along  with this  work; if  not, write  to the Fr ee Softwar e Foundati on,
  19    * Inc., 5 1 Franklin  St, Fifth  Floor, Bo ston, MA 0 2110-1301  USA.
  20    *
  21    * Please  contact Or acle, 500  Oracle Par kway, Redw ood Shores , CA 94065  USA
  22    * or visi t www.orac le.com if  you need a dditional  informatio n or have  any
  23    * questio ns.
  24    */
  25  
  26  
  27   package co m.sun.jmx. snmp.agent ;
  28  
  29  
  30  
  31   // java im ports
  32   //
  33   import jav a.io.Seria lizable;
  34   import jav a.util.Vec tor;
  35   import jav a.util.Enu meration;
  36  
  37   // jmx imp orts
  38   //
  39   import jav ax.managem ent.MBeanS erver;
  40   import jav ax.managem ent.MBeanR egistratio n;
  41   import jav ax.managem ent.Object Name;
  42   import jav ax.managem ent.Instan ceNotFound Exception;
  43   import jav ax.managem ent.Servic eNotFoundE xception;
  44   import jav ax.managem ent.Reflec tionExcept ion;
  45   import jav ax.managem ent.MBeanE xception;
  46   import com .sun.jmx.s nmp.SnmpVa rBind;
  47   import com .sun.jmx.s nmp.SnmpDe finitions;
  48   import com .sun.jmx.s nmp.SnmpSt atusExcept ion;
  49   import com .sun.jmx.s nmp.SnmpPd u;
  50   import com .sun.jmx.s nmp.SnmpOi d;
  51   import com .sun.jmx.s nmp.SnmpEn gine;
  52  
  53   /**
  54    * Abstrac t class fo r represen ting an SN MP agent.
  55    *
  56    * The cla ss is used  by the SN MP protoco l adaptor  as the ent ry point i n
  57    * the SNM P agent to  query.
  58    *
  59    * <p><b>T his API is  a Sun Mic rosystems  internal A PI  and is  subject
  60    * to chan ge without  notice.</ b></p>
  61    */
  62  
  63   public abs tract clas s SnmpMibA gent
  64       implem ents SnmpM ibAgentMBe an, MBeanR egistratio n, Seriali zable {
  65  
  66       /**
  67        * Def ault const ructor.
  68        */
  69       public  SnmpMibAg ent() {
  70       }
  71  
  72       // --- ---------- ---------- ---------- ---------- ---------- ---------- ------
  73       // PUB LIC METHOD S
  74       //---- ---------- ---------- ---------- ---------- ---------- ---------- ------
  75  
  76       /**
  77        * Ini tializes t he MIB (wi th no regi stration o f the MBea ns into th e
  78        * MBe an server) .
  79        *
  80        * @ex ception Il legalAcces sException  The MIB c an not be  initialize d.
  81        */
  82       public  abstract  void init( ) throws I llegalAcce ssExceptio n;
  83  
  84       /**
  85        * Ini tializes t he MIB but  each sing le MBean r epresentin g the MIB
  86        * is  inserted i nto the MB ean server .
  87        *
  88        * @pa ram server  The MBean  server to  register  the servic e with.
  89        * @pa ram name T he object  name.
  90        *
  91        * @re turn The n ame of the  SNMP MIB  registered .
  92        *
  93        * @ex ception ja va.lang.Ex ception
  94        */
  95       @Overr ide
  96       public  abstract  ObjectName  preRegist er(MBeanSe rver serve r,
  97                                                  ObjectN ame name)
  98           th rows java. lang.Excep tion;
  99  
  100       /**
  101        * Not  used in t his contex t.
  102        */
  103       @Overr ide
  104       public  void post Register ( Boolean re gistration Done) {
  105       }
  106  
  107       /**
  108        * Not  used in t his contex t.
  109        */
  110       @Overr ide
  111       public  void preD eregister( ) throws j ava.lang.E xception {
  112       }
  113  
  114       /**
  115        * Not  used in t his contex t.
  116        */
  117       @Overr ide
  118       public  void post Deregister () {
  119       }
  120  
  121       /**
  122        * Pro cesses a < CODE>get</ CODE> oper ation.
  123        * Thi s method m ust update  the SnmpV arBinds co ntained in  the
  124        * <va r>{@link S nmpMibRequ est} req</ var> param eter.
  125        *
  126        * @pa ram req Th e SnmpMibR equest obj ect holdin g the list  of variab le to
  127        *             be  retrieved . This lis t is compo sed of
  128        *             <C ODE>SnmpVa rBind</COD E> objects .
  129        *
  130        * @ex ception Sn mpStatusEx ception An  error occ urred duri ng the ope ration.
  131        */
  132       @Overr ide
  133       public  abstract  void get(S nmpMibRequ est req)
  134           th rows SnmpS tatusExcep tion;
  135  
  136       /**
  137        * Pro cesses a < CODE>getNe xt</CODE>  operation.
  138        * Thi s method m ust update  the SnmpV arBinds co ntained in  the
  139        * <va r>{@link S nmpMibRequ est} req</ var> param eter.
  140        *
  141        * @pa ram req Th e SnmpMibR equest obj ect holdin g the list  of
  142        *             OI Ds from wh ich the ne xt variabl es should  be retriev ed.
  143        *             Th is list is  composed  of <CODE>S nmpVarBind </CODE> ob jects.
  144        *
  145        * @ex ception Sn mpStatusEx ception An  error occ urred duri ng the ope ration.
  146        */
  147       @Overr ide
  148       public  abstract  void getNe xt(SnmpMib Request re q)
  149           th rows SnmpS tatusExcep tion;
  150  
  151       /**
  152        * Pro cesses a < CODE>getBu lk</CODE>  operation.
  153        * Thi s method m ust update  the SnmpV arBinds co ntained in  the
  154        * <va r>{@link S nmpMibRequ est} req</ var> param eter.
  155        *
  156        * @pa ram req Th e SnmpMibR equest obj ect holdin g the list  of variab le to
  157        *             be  retrieved . This lis t is compo sed of
  158        *             <C ODE>SnmpVa rBind</COD E> objects .
  159        *
  160        * @pa ram nonRep eat The nu mber of va riables, s tarting wi th the fir st
  161        *     variable i n the vari able-bindi ngs, for w hich a sin gle
  162        *     lexicograp hic succes sor is req uested.
  163        *
  164        * @pa ram maxRep eat The nu mber of le xicographi c successo rs request ed
  165        *     for each o f the last  R variabl es. R is t he number  of variabl es
  166        *     following  the first  <CODE>nonR epeat</COD E> variabl es for whi ch
  167        *     multiple l exicograph ic success ors are re quested.
  168        *
  169        * @ex ception Sn mpStatusEx ception An  error occ urred duri ng the ope ration.
  170        */
  171       @Overr ide
  172       public  abstract  void getBu lk(SnmpMib Request re q, int non Repeat,
  173                                       int max Repeat)
  174           th rows SnmpS tatusExcep tion;
  175  
  176       /**
  177        * Pro cesses a < CODE>set</ CODE> oper ation.
  178        * Thi s method m ust update  the SnmpV arBinds co ntained in  the
  179        * <va r>{@link S nmpMibRequ est} req</ var> param eter.
  180        * Thi s method i s called d uring the  second pha se of the  SET two-ph ase
  181        * com mit.
  182        *
  183        * @pa ram req Th e SnmpMibR equest obj ect holdin g the list  of variab le to
  184        *             be  set. This  list is c omposed of
  185        *             <C ODE>SnmpVa rBind</COD E> objects .
  186        *
  187        * @ex ception Sn mpStatusEx ception An  error occ urred duri ng the ope ration.
  188        *             Th rowing an  exception  in this me thod will  break the
  189        *             at omicity of  the SET o peration.  Care must  be taken s o that
  190        *             th e exceptio n is throw n in the { @link #che ck(SnmpMib Request)}
  191        *             me thod inste ad.
  192        */
  193       @Overr ide
  194       public  abstract  void set(S nmpMibRequ est req)
  195           th rows SnmpS tatusExcep tion;
  196  
  197  
  198       /**
  199        * Che cks if a < CODE>set</ CODE> oper ation can  be perform ed.
  200        * If  the operat ion can no t be perfo rmed, the  method sho uld throw  an
  201        * <CO DE>SnmpSta tusExcepti on</CODE>.
  202        * Thi s method i s called d uring the  first phas e of the S ET two-pha se
  203        * com mit.
  204        *
  205        * @pa ram req Th e SnmpMibR equest obj ect holdin g the list  of variab le to
  206        *             be  set. This  list is c omposed of
  207        *             <C ODE>SnmpVa rBind</COD E> objects .
  208        *
  209        * @ex ception Sn mpStatusEx ception Th e <CODE>se t</CODE> o peration
  210        *     cannot be  performed.
  211        */
  212       @Overr ide
  213       public  abstract  void check (SnmpMibRe quest req)
  214           th rows SnmpS tatusExcep tion;
  215  
  216       /**
  217        * Get s the root  object id entifier o f the MIB.
  218        * <P> The root o bject iden tifier is  the object  identifie r uniquely
  219        * ide ntifying t he MIB.
  220        *
  221        * @re turn The r oot object  identifie r.
  222        */
  223       public  abstract  long[] get RootOid();
  224  
  225       // --- ---------- ---------- ---------- ---------- ---------- ---------- ------
  226       // GET TERS AND S ETTERS
  227       // --- ---------- ---------- ---------- ---------- ---------- ---------- ------
  228  
  229       /**
  230        * Get s the refe rence to t he MBean s erver in w hich the S NMP MIB is
  231        * reg istered.
  232        *
  233        * @re turn The M Bean serve r or null  if the MIB  is not re gistered i n any
  234        *      MBean ser ver.
  235        */
  236       @Overr ide
  237       public  MBeanServ er getMBea nServer()  {
  238           re turn serve r;
  239       }
  240  
  241       /**
  242        * Get s the refe rence to t he SNMP pr otocol ada ptor to wh ich the MI B is
  243        * bou nd.
  244        *
  245        * @re turn The S NMP MIB ha ndler.
  246        */
  247       @Overr ide
  248       public  SnmpMibHa ndler getS nmpAdaptor () {
  249           re turn adapt or;
  250       }
  251  
  252       /**
  253        * Set s the refe rence to t he SNMP pr otocol ada ptor throu gh which t he MIB
  254        * wil l be SNMP  accessible  and add t his new MI B in the S NMP MIB ha ndler.
  255        *
  256        * @pa ram stack  The SNMP M IB handler .
  257        */
  258       @Overr ide
  259       public  void setS nmpAdaptor (SnmpMibHa ndler stac k) {
  260           if  (adaptor  != null) {
  261                adaptor. removeMib( this);
  262           }
  263           ad aptor = st ack;
  264           if  (adaptor  != null) {
  265                adaptor. addMib(thi s);
  266           }
  267       }
  268  
  269        /**
  270        * Set s the refe rence to t he SNMP pr otocol ada ptor throu gh which t he MIB
  271        * wil l be SNMP  accessible  and add t his new MI B in the S NMP MIB ha ndler.
  272        * Thi s method i s to be ca lled to se t a specif ic agent t o a specif ic OID. Th is can be  useful whe n dealing  with MIB o verlapping .
  273        * Som e OID can  be impleme nted in mo re than on e MIB. In  this case,  the OID n earest the  agent wil l be used  on SNMP op erations.
  274        * @pa ram stack  The SNMP M IB handler .
  275        * @pa ram oids T he set of  OIDs this  agent impl ements.
  276        *
  277        * @si nce 1.5
  278        */
  279       @Overr ide
  280       public  void setS nmpAdaptor (SnmpMibHa ndler stac k, SnmpOid [] oids) {
  281           if  (adaptor  != null) {
  282                adaptor. removeMib( this);
  283           }
  284           ad aptor = st ack;
  285           if  (adaptor  != null) {
  286                adaptor. addMib(thi s, oids);
  287           }
  288       }
  289  
  290       /**
  291        * Set s the refe rence to t he SNMP pr otocol ada ptor throu gh which t he MIB
  292        * wil l be SNMP  accessible  and adds  this new M IB in the  SNMP MIB h andler.
  293        * Add s a new co ntextualiz ed MIB in  the SNMP M IB handler .
  294        *
  295        * @pa ram stack  The SNMP M IB handler .
  296        * @pa ram contex tName The  MIB contex t name. If  null is p assed, wil l be regis tered in t he default  context.
  297        *
  298        * @ex ception Il legalArgum entExcepti on If the  parameter  is null.
  299        *
  300        * @si nce 1.5
  301        */
  302       @Overr ide
  303       public  void setS nmpAdaptor (SnmpMibHa ndler stac k, String  contextNam e) {
  304           if  (adaptor  != null) {
  305                adaptor. removeMib( this, cont extName);
  306           }
  307           ad aptor = st ack;
  308           if  (adaptor  != null) {
  309                adaptor. addMib(thi s, context Name);
  310           }
  311       }
  312       /**
  313        * Set s the refe rence to t he SNMP pr otocol ada ptor throu gh which t he MIB
  314        * wil l be SNMP  accessible  and adds  this new M IB in the  SNMP MIB h andler.
  315        * Add s a new co ntextualiz ed MIB in  the SNMP M IB handler .
  316        *
  317        * @pa ram stack  The SNMP M IB handler .
  318        * @pa ram contex tName The  MIB contex t name. If  null is p assed, wil l be regis tered in t he default  context.
  319        * @pa ram oids T he set of  OIDs this  agent impl ements.
  320        * @ex ception Il legalArgum entExcepti on If the  parameter  is null.
  321        *
  322        * @si nce 1.5
  323        */
  324       @Overr ide
  325       public  void setS nmpAdaptor (SnmpMibHa ndler stac k,
  326                                     String co ntextName,
  327                                     SnmpOid[]  oids) {
  328           if  (adaptor  != null) {
  329                adaptor. removeMib( this, cont extName);
  330           }
  331           ad aptor = st ack;
  332           if  (adaptor  != null) {
  333                adaptor. addMib(thi s, context Name, oids );
  334           }
  335       }
  336  
  337       /**
  338        * Get s the obje ct name of  the SNMP  protocol a daptor to  which the  MIB
  339        * is  bound.
  340        *
  341        * @re turn The n ame of the  SNMP prot ocol adapt or.
  342        */
  343       @Overr ide
  344       public  ObjectNam e getSnmpA daptorName () {
  345           re turn adapt orName;
  346       }
  347  
  348       /**
  349        * Set s the refe rence to t he SNMP pr otocol ada ptor throu gh which t he MIB
  350        * wil l be SNMP  accessible  and add t his new MI B in the S NMP MIB ha ndler
  351        * ass ociated to  the speci fied <CODE >name</COD E>.
  352        *
  353        * @pa ram name T he name of  the SNMP  protocol a daptor.
  354        *
  355        * @ex ception In stanceNotF oundExcept ion The SN MP protoco l adaptor  does
  356        *      not exist  in the MB ean server .
  357        *
  358        * @ex ception Se rviceNotFo undExcepti on This SN MP MIB is  not regist ered
  359        *      in the MB ean server  or the re quested se rvice is n ot support ed.
  360        */
  361       @Overr ide
  362       public  void setS nmpAdaptor Name(Objec tName name )
  363           th rows Insta nceNotFoun dException , ServiceN otFoundExc eption {
  364  
  365           if  (server = = null) {
  366                throw ne w ServiceN otFoundExc eption(mib Name + " i s not regi stered in  the MBean  server");
  367           }
  368           //  First rem ove the re ference on  the old a daptor ser ver.
  369           //
  370           if  (adaptor  != null) {
  371                adaptor. removeMib( this);
  372           }
  373  
  374           //  Then upda te the ref erence to  the new ad aptor serv er.
  375           //
  376           Ob ject[] par ams = {thi s};
  377           St ring[] sig nature = { "com.sun.j mx.snmp.ag ent.SnmpMi bAgent"};
  378           tr y {
  379                adaptor  = (SnmpMib Handler)(s erver.invo ke(name, " addMib", p arams,
  380                                                             signatu re));
  381           }  catch (Ins tanceNotFo undExcepti on e) {
  382                throw ne w Instance NotFoundEx ception(na me.toStrin g());
  383           }  catch (Ref lectionExc eption e)  {
  384                throw ne w ServiceN otFoundExc eption(nam e.toString ());
  385           }  catch (MBe anExceptio n e) {
  386                // Shoul d never oc cur...
  387           }
  388  
  389           ad aptorName  = name;
  390       }
  391       /**
  392        * Set s the refe rence to t he SNMP pr otocol ada ptor throu gh which t he MIB
  393        * wil l be SNMP  accessible  and add t his new MI B in the S NMP MIB ha ndler
  394        * ass ociated to  the speci fied <CODE >name</COD E>.
  395        * Thi s method i s to be ca lled to se t a specif ic agent t o a specif ic OID. Th is can be  useful whe n dealing  with MIB o verlapping .
  396        * Som e OID can  be impleme nted in mo re than on e MIB. In  this case,  the OID n earer agen t will be  used on SN MP operati ons.
  397        * @pa ram name T he name of  the SNMP  protocol a daptor.
  398        * @pa ram oids T he set of  OIDs this  agent impl ements.
  399        * @ex ception In stanceNotF oundExcept ion The SN MP protoco l adaptor  does
  400        *      not exist  in the MB ean server .
  401        *
  402        * @ex ception Se rviceNotFo undExcepti on This SN MP MIB is  not regist ered
  403        *      in the MB ean server  or the re quested se rvice is n ot support ed.
  404        *
  405        * @si nce 1.5
  406        */
  407       @Overr ide
  408       public  void setS nmpAdaptor Name(Objec tName name , SnmpOid[ ] oids)
  409           th rows Insta nceNotFoun dException , ServiceN otFoundExc eption {
  410  
  411           if  (server = = null) {
  412                throw ne w ServiceN otFoundExc eption(mib Name + " i s not regi stered in  the MBean  server");
  413           }
  414           //  First rem ove the re ference on  the old a daptor ser ver.
  415           //
  416           if  (adaptor  != null) {
  417                adaptor. removeMib( this);
  418           }
  419  
  420           //  Then upda te the ref erence to  the new ad aptor serv er.
  421           //
  422           Ob ject[] par ams = {thi s, oids};
  423           St ring[] sig nature = { "com.sun.j mx.snmp.ag ent.SnmpMi bAgent",
  424           oi ds.getClas s().getNam e()};
  425           tr y {
  426                adaptor  = (SnmpMib Handler)(s erver.invo ke(name, " addMib", p arams,
  427                                                             signatu re));
  428           }  catch (Ins tanceNotFo undExcepti on e) {
  429                throw ne w Instance NotFoundEx ception(na me.toStrin g());
  430           }  catch (Ref lectionExc eption e)  {
  431                throw ne w ServiceN otFoundExc eption(nam e.toString ());
  432           }  catch (MBe anExceptio n e) {
  433                // Shoul d never oc cur...
  434           }
  435  
  436           ad aptorName  = name;
  437       }
  438       /**
  439        * Set s the refe rence to t he SNMP pr otocol ada ptor throu gh which t he MIB
  440        * wil l be SNMP  accessible  and add t his new MI B in the S NMP MIB ha ndler
  441        * ass ociated to  the speci fied <CODE >name</COD E>.
  442        *
  443        * @pa ram name T he name of  the SNMP  protocol a daptor.
  444        * @pa ram contex tName The  MIB contex t name. If  null is p assed, wil l be regis tered in t he default  context.
  445        * @ex ception In stanceNotF oundExcept ion The SN MP protoco l adaptor  does
  446        *      not exist  in the MB ean server .
  447        *
  448        * @ex ception Se rviceNotFo undExcepti on This SN MP MIB is  not regist ered
  449        *      in the MB ean server  or the re quested se rvice is n ot support ed.
  450        *
  451        * @si nce 1.5
  452        */
  453       @Overr ide
  454       public  void setS nmpAdaptor Name(Objec tName name , String c ontextName )
  455           th rows Insta nceNotFoun dException , ServiceN otFoundExc eption {
  456  
  457           if  (server = = null) {
  458                throw ne w ServiceN otFoundExc eption(mib Name + " i s not regi stered in  the MBean  server");
  459           }
  460  
  461           //  First rem ove the re ference on  the old a daptor ser ver.
  462           //
  463           if  (adaptor  != null) {
  464                adaptor. removeMib( this, cont extName);
  465           }
  466  
  467           //  Then upda te the ref erence to  the new ad aptor serv er.
  468           //
  469           Ob ject[] par ams = {thi s, context Name};
  470           St ring[] sig nature = { "com.sun.j mx.snmp.ag ent.SnmpMi bAgent", " java.lang. String"};
  471           tr y {
  472                adaptor  = (SnmpMib Handler)(s erver.invo ke(name, " addMib", p arams,
  473                                                             signatu re));
  474           }  catch (Ins tanceNotFo undExcepti on e) {
  475                throw ne w Instance NotFoundEx ception(na me.toStrin g());
  476           }  catch (Ref lectionExc eption e)  {
  477                throw ne w ServiceN otFoundExc eption(nam e.toString ());
  478           }  catch (MBe anExceptio n e) {
  479                // Shoul d never oc cur...
  480           }
  481  
  482           ad aptorName  = name;
  483       }
  484  
  485       /**
  486        * Set s the refe rence to t he SNMP pr otocol ada ptor throu gh which t he MIB
  487        * wil l be SNMP  accessible  and add t his new MI B in the S NMP MIB ha ndler
  488        * ass ociated to  the speci fied <CODE >name</COD E>.
  489        *
  490        * @pa ram name T he name of  the SNMP  protocol a daptor.
  491        * @pa ram contex tName The  MIB contex t name. If  null is p assed, wil l be regis tered in t he default  context.
  492        * @pa ram oids T he set of  OIDs this  agent impl ements.
  493        * @ex ception In stanceNotF oundExcept ion The SN MP protoco l adaptor  does
  494        *      not exist  in the MB ean server .
  495        *
  496        * @ex ception Se rviceNotFo undExcepti on This SN MP MIB is  not regist ered
  497        *      in the MB ean server  or the re quested se rvice is n ot support ed.
  498        *
  499        * @si nce 1.5
  500        */
  501       @Overr ide
  502       public  void setS nmpAdaptor Name(Objec tName name ,
  503                                         Strin g contextN ame, SnmpO id[] oids)
  504           th rows Insta nceNotFoun dException , ServiceN otFoundExc eption {
  505  
  506           if  (server = = null) {
  507                throw ne w ServiceN otFoundExc eption(mib Name + " i s not regi stered in  the MBean  server");
  508           }
  509  
  510           //  First rem ove the re ference on  the old a daptor ser ver.
  511           //
  512           if  (adaptor  != null) {
  513                adaptor. removeMib( this, cont extName);
  514           }
  515  
  516           //  Then upda te the ref erence to  the new ad aptor serv er.
  517           //
  518           Ob ject[] par ams = {thi s, context Name, oids };
  519           St ring[] sig nature = { "com.sun.j mx.snmp.ag ent.SnmpMi bAgent", " java.lang. String", o ids.getCla ss().getNa me()};
  520           tr y {
  521                adaptor  = (SnmpMib Handler)(s erver.invo ke(name, " addMib", p arams,
  522                                                             signatu re));
  523           }  catch (Ins tanceNotFo undExcepti on e) {
  524                throw ne w Instance NotFoundEx ception(na me.toStrin g());
  525           }  catch (Ref lectionExc eption e)  {
  526                throw ne w ServiceN otFoundExc eption(nam e.toString ());
  527           }  catch (MBe anExceptio n e) {
  528                // Shoul d never oc cur...
  529           }
  530  
  531           ad aptorName  = name;
  532       }
  533  
  534       /**
  535        * Ind icates whe ther or no t the MIB  module is  bound to a  SNMP prot ocol
  536        * ada ptor.
  537        * As  a reminder , only bou nd MIBs ca n be acces sed throug h SNMP pro tocol
  538        * ada ptor.
  539        *
  540        * @re turn <CODE >true</COD E> if the  MIB module  is bound,
  541        *          <CODE >false</CO DE> otherw ise.
  542        */
  543       @Overr ide
  544       public  boolean g etBindingS tate() {
  545           if  (adaptor  == null)
  546                return f alse;
  547           el se
  548                return t rue;
  549       }
  550  
  551       /**
  552        * Get s the MIB  name.
  553        *
  554        * @re turn The M IB name.
  555        */
  556       @Overr ide
  557       public  String ge tMibName()  {
  558           re turn mibNa me;
  559       }
  560  
  561       /**
  562        * Thi s is a fac tory metho d for crea ting new S nmpMibRequ est object s.
  563        * @pa ram reqPdu  The recei ved PDU.
  564        * @pa ram vblist    The vec tor of Snm pVarBind o bjects in  which the
  565        *         MIB co ncerned by  this requ est is inv olved.
  566        * @pa ram versio n  The pro tocol vers ion of the  SNMP requ est.
  567        * @pa ram userDa ta User al located co ntextual d ata.
  568        *
  569        * @re turn A new  SnmpMibRe quest obje ct.
  570        *
  571        * @si nce 1.5
  572        **/
  573       public  static Sn mpMibReque st newMibR equest(Snm pPdu reqPd u,
  574                                                      Vec tor<SnmpVa rBind> vbl ist,
  575                                                      int  version,
  576                                                      Obj ect userDa ta)
  577       {
  578           re turn new S nmpMibRequ estImpl(nu ll,
  579                                            re qPdu,
  580                                            vb list,
  581                                            ve rsion,
  582                                            us erData,
  583                                            nu ll,
  584                                            Sn mpDefiniti ons.noAuth NoPriv,
  585                                            ge tSecurityM odel(versi on),
  586                                            nu ll,null);
  587       }
  588       /**
  589        * Thi s is a fac tory metho d for crea ting new S nmpMibRequ est object s.
  590        * @pa ram engine  The local  engine.
  591        * @pa ram reqPdu  The recei ved pdu.
  592        * @pa ram vblist  The vecto r of SnmpV arBind obj ects in wh ich the
  593        *         MIB co ncerned by  this requ est is inv olved.
  594        * @pa ram versio n The prot ocol versi on of the  SNMP reque st.
  595        * @pa ram userDa ta User al located co ntextual d ata.
  596        *
  597        * @re turn A new  SnmpMibRe quest obje ct.
  598        *
  599        * @si nce 1.5
  600        **/
  601       public  static Sn mpMibReque st newMibR equest(Snm pEngine en gine,
  602                                                      Snm pPdu reqPd u,
  603                                                      Vec tor<SnmpVa rBind> vbl ist,
  604                                                      int  version,
  605                                                      Obj ect userDa ta,
  606                                                      Str ing princi pal,
  607                                                      int  securityL evel,
  608                                                      int  securityM odel,
  609                                                      byt e[] contex tName,
  610                                                      byt e[] access ContextNam e) {
  611           re turn new S nmpMibRequ estImpl(en gine,
  612                                            re qPdu,
  613                                            vb list,
  614                                            ve rsion,
  615                                            us erData,
  616                                            pr incipal,
  617                                            se curityLeve l,
  618                                            se curityMode l,
  619                                            co ntextName,
  620                                            ac cessContex tName);
  621       }
  622       // --- ---------- ---------- ---------- ---------- ---------- ---------- ------
  623       // PAC KAGE METHO DS
  624       // --- ---------- ---------- ---------- ---------- ---------- ---------- ------
  625  
  626       /**
  627        * Pro cesses a < CODE>getBu lk</CODE>  operation  using call  to
  628        * <CO DE>getNext </CODE>.
  629        * The  method im plements t he <CODE>g etBulk</CO DE> operat ion by cal ling
  630        * app ropriately  the <CODE >getNext</ CODE> meth od.
  631        *
  632        * @pa ram req Th e SnmpMibR equest con taining th e variable  list to b e
  633        *         retrie ved.
  634        *
  635        * @pa ram nonRep eat The nu mber of va riables, s tarting wi th the fir st
  636        *     variable i n the vari able-bindi ngs, for w hich a sin gle lexico graphic
  637        *     successor  is request ed.
  638        *
  639        * @pa ram maxRep eat The nu mber of le xicographi c successo rs
  640        *     requested  for each o f the last  R variabl es. R is t he number  of
  641        *     variables  following  the first  nonRepeat  variables  for which
  642        *     multiple l exicograph ic success ors are re quested.
  643        *
  644        * @re turn The v ariable li st contain ing return ed values.
  645        *
  646        * @ex ception Sn mpStatusEx ception An  error occ urred duri ng the ope ration.
  647        */
  648       void g etBulkWith GetNext(Sn mpMibReque st req, in t nonRepea t, int max Repeat)
  649           th rows SnmpS tatusExcep tion {
  650           fi nal Vector <SnmpVarBi nd> list =  req.getSu bList();
  651  
  652           //  RFC 1905,  Section 4 .2.3, p14
  653           fi nal int L  = list.siz e() ;
  654           fi nal int N  = Math.max (Math.min( nonRepeat,  L), 0) ;
  655           fi nal int M  = Math.max (maxRepeat , 0) ;
  656           fi nal int R  = L - N ;
  657  
  658           //  Let's bui ld the var BindList f or the res ponse pdu
  659           //
  660           //  int error Status = S nmpDefinit ions.snmpR spNoError  ;
  661           //  int error Index = 0  ;
  662           if  (L != 0)  {
  663  
  664                // Non-r epeaters a nd first r ow of repe aters
  665                //
  666                getNext( req);
  667  
  668                // Now t he remaini ng repeate rs
  669                //
  670                Vector<S nmpVarBind > repeater s= splitFr om(list, N );
  671                SnmpMibR equestImpl  repeatedR eq =
  672                    new  SnmpMibReq uestImpl(r eq.getEngi ne(),
  673                                             r eq.getPdu( ),
  674                                             r epeaters,
  675                                             S nmpDefinit ions.snmpV ersionTwo,
  676                                             r eq.getUser Data(),
  677                                             r eq.getPrin cipal(),
  678                                             r eq.getSecu rityLevel( ),
  679                                             r eq.getSecu rityModel( ),
  680                                             r eq.getCont extName(),
  681                                             r eq.getAcce ssContextN ame());
  682                for (int  i = 2 ; i  <= M ; i+ +) {
  683                    getN ext(repeat edReq);
  684                    conc atVector(r eq, repeat ers);
  685                }
  686           }
  687       }
  688  
  689  
  690       // --- ---------- ---------- ---------- ---------- ---------- ---------- ------
  691         // PRI D A N E S M   T   ODS
  692       // --- ---------- ---------- ---------- ---------- ---------- ---------- ------
  693  
  694       /**
  695        * Thi s method c reates a n ew Vector  which does  not conta in the fir st
  696        * ele ment up to  the speci fied limit .
  697        *
  698        * @pa ram origin al The ori ginal vect or.
  699        * @pa ram limit  The limit.
  700        */
  701       privat e Vector<S nmpVarBind > splitFro m(Vector<S nmpVarBind > original , int limi t) {
  702  
  703           in t max= ori ginal.size ();
  704           Ve ctor<SnmpV arBind> re sult= new  Vector<>(m ax - limit );
  705           in t i= limit ;
  706  
  707           //  Ok the lo op looks a  bit stran ge. But in  order to  improve th e
  708           //  perf, we  try to avo id referen ce to the  limit vari able from
  709           //  within th e loop ...
  710           //
  711           fo r(Enumerat ion<SnmpVa rBind> e=  original.e lements();  e.hasMore Elements() ; --i) {
  712                SnmpVarB ind var= e .nextEleme nt();
  713                if (i >0 )
  714                    cont inue;
  715                result.a ddElement( new SnmpVa rBind(var. oid, var.v alue));
  716           }
  717           re turn resul t;
  718       }
  719  
  720       privat e void con catVector( SnmpMibReq uest req,  Vector<Snm pVarBind>  source) {
  721           fo r(Enumerat ion<SnmpVa rBind> e=  source.ele ments(); e .hasMoreEl ements();  ) {
  722                SnmpVarB ind var= e .nextEleme nt();
  723                // We ne ed to dupl icate the  SnmpVarBin d otherwis e it is go ing
  724                // to be  overloade d by the n ext get Ne xt ...
  725                req.addV arBind(new  SnmpVarBi nd(var.oid , var.valu e));
  726           }
  727       }
  728  
  729       privat e static i nt getSecu rityModel( int versio n) {
  730           sw itch(versi on) {
  731           ca se SnmpDef initions.s nmpVersion One:
  732                return S nmpDefinit ions.snmpV 1SecurityM odel;
  733           de fault:
  734                return S nmpDefinit ions.snmpV 2SecurityM odel;
  735           }
  736       }
  737  
  738       // --- ---------- ---------- ---------- ---------- ---------- ---------- ------
  739       // PRO TECTED VAR IABLES
  740       // --- ---------- ---------- ---------- ---------- ---------- ---------- ------
  741  
  742       /**
  743        * The  object na me of the  MIB.
  744        * @se rial
  745        */
  746       protec ted String  mibName;
  747  
  748       /**
  749        * The  reference  to the MB ean server .
  750        * @se rial
  751        */
  752       protec ted MBeanS erver serv er;
  753  
  754       // --- ---------- ---------- ---------- ---------- ---------- ---------- ------
  755       // PRI VATE VARIA BLES
  756       // --- ---------- ---------- ---------- ---------- ---------- ---------- ------
  757  
  758       /**
  759        * The  object na me of the  SNMP proto col adapto r.
  760        * @se rial
  761        */
  762       privat e ObjectNa me adaptor Name;
  763  
  764       /**
  765        * The  reference  to the SN MP stack.
  766        */
  767       privat e transien t SnmpMibH andler ada ptor;
  768   }