192. EPMO Open Source Coordination Office Redaction File Detail Report

Produced by Araxis Merge on 9/25/2018 2:13:11 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.

192.1 Files compared

# Location File Last Modified
1 build 3.zip\build 3\MHLTH_YS_137_Source\JavaScript\resources\javaJDF-1.8.0\src\javax\management\monitor GaugeMonitor.java Mon Jan 22 14:46:52 2018 UTC
2 build 3.zip\build 3\MHLTH_YS_137_Source\JavaScript\resources\javaJDF-1.8.0\src\javax\management\monitor GaugeMonitor.java Wed Sep 12 17:20:31 2018 UTC

192.2 Comparison summary

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

192.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

192.4 Active regular expressions

No regular expressions were active.

192.5 Comparison detail

  1   /*
  2    * Copyrig ht (c) 199 9, 2008, 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   package ja vax.manage ment.monit or;
  27  
  28   import sta tic com.su n.jmx.defa ults.JmxPr operties.M ONITOR_LOG GER;
  29   import jav a.util.log ging.Level ;
  30   import jav ax.managem ent.MBeanN otificatio nInfo;
  31   import jav ax.managem ent.Object Name;
  32   import sta tic javax. management .monitor.M onitor.Num ericalType .*;
  33   import sta tic javax. management .monitor.M onitorNoti fication.* ;
  34  
  35   /**
  36    * Defines  a monitor  MBean des igned to o bserve the  values of  a gauge a ttribute.
  37    *
  38    * <P> A g auge monit or observe s an attri bute that  is continu ously
  39    * variabl e with tim e. A gauge  monitor s ends notif ications a s
  40    * follows :
  41    *
  42    * <UL>
  43    *
  44    * <LI> if  the attri bute value  is increa sing and b ecomes equ al to or
  45    * greater  than the  high thres hold value , a {@link
  46    * Monitor Notificati on#THRESHO LD_HIGH_VA LUE_EXCEED ED thresho ld high
  47    * notific ation} is  sent. The  notify hig h flag mus t be set t o
  48    * <CODE>t rue</CODE> .
  49    *
  50    * <BR>Sub sequent cr ossings of  the high  threshold  value do n ot cause
  51    * further  notificat ions unles s the attr ibute valu e becomes  equal to
  52    * or less  than the  low thresh old value. </LI>
  53    *
  54    * <LI> if  the attri bute value  is decrea sing and b ecomes equ al to or
  55    * less th an the low  threshold  value, a  {@link
  56    * Monitor Notificati on#THRESHO LD_LOW_VAL UE_EXCEEDE D threshol d low
  57    * notific ation} is  sent. The  notify low  flag must  be set to
  58    * <CODE>t rue</CODE> .
  59    *
  60    * <BR>Sub sequent cr ossings of  the low t hreshold v alue do no t cause
  61    * further  notificat ions unles s the attr ibute valu e becomes  equal to
  62    * or grea ter than t he high th reshold va lue.</LI>
  63    *
  64    * </UL>
  65    *
  66    * This pr ovides a h ysteresis  mechanism  to avoid r epeated tr iggering
  67    * of noti fications  when the a ttribute v alue makes  small osc illations
  68    * around  the high o r low thre shold valu e.
  69    *
  70    * <P> If  the gauge  difference  mode is u sed, the v alue of th e derived
  71    * gauge i s calculat ed as the  difference  between t he observe d gauge
  72    * values  for two su ccessive o bservation s.
  73    *
  74    * <BR>The  derived g auge value  (V[t]) is  calculate d using th e followin g method:
  75    * <UL>
  76    * <LI>V[t ] = gauge[ t] - gauge [t-GP]</LI >
  77    * </UL>
  78    *
  79    * This im plementati on of the  gauge moni tor requir es the obs erved
  80    * attribu te to be o f the type  integer o r floating -point
  81    * (<CODE> Byte</CODE >, <CODE>I nteger</CO DE>, <CODE >Short</CO DE>,
  82    * <CODE>L ong</CODE> , <CODE>Fl oat</CODE> , <CODE>Do uble</CODE >).
  83    *
  84    *
  85    * @since  1.5
  86    */
  87   public cla ss GaugeMo nitor exte nds Monito r implemen ts GaugeMo nitorMBean  {
  88  
  89       /*
  90        * --- ---------- ---------- ---------- ---------
  91        *  PA CKAGE CLAS SES
  92        * --- ---------- ---------- ---------- ---------
  93        */
  94  
  95       static  class Gau geMonitorO bservedObj ect extend s Observed Object {
  96  
  97           pu blic Gauge MonitorObs ervedObjec t(ObjectNa me observe dObject) {
  98                super(ob servedObje ct);
  99           }
  100  
  101           pu blic final  synchroni zed boolea n getDeriv edGaugeVal id() {
  102                return d erivedGaug eValid;
  103           }
  104           pu blic final  synchroni zed void s etDerivedG augeValid(
  105                                                        b oolean der ivedGaugeV alid) {
  106                this.der ivedGaugeV alid = der ivedGaugeV alid;
  107           }
  108           pu blic final  synchroni zed Numeri calType ge tType() {
  109                return t ype;
  110           }
  111           pu blic final  synchroni zed void s etType(Num ericalType  type) {
  112                this.typ e = type;
  113           }
  114           pu blic final  synchroni zed Number  getPrevio usScanGaug e() {
  115                return p reviousSca nGauge;
  116           }
  117           pu blic final  synchroni zed void s etPrevious ScanGauge(
  118                                                          Number pre viousScanG auge) {
  119                this.pre viousScanG auge = pre viousScanG auge;
  120           }
  121           pu blic final  synchroni zed int ge tStatus()  {
  122                return s tatus;
  123           }
  124           pu blic final  synchroni zed void s etStatus(i nt status)  {
  125                this.sta tus = stat us;
  126           }
  127  
  128           pr ivate bool ean derive dGaugeVali d;
  129           pr ivate Nume ricalType  type;
  130           pr ivate Numb er previou sScanGauge ;
  131           pr ivate int  status;
  132       }
  133  
  134       /*
  135        * --- ---------- ---------- ---------- ---------
  136        *  PR IVATE VARI ABLES
  137        * --- ---------- ---------- ---------- ---------
  138        */
  139  
  140       /**
  141        * Gau ge high th reshold.
  142        *
  143        * <BR >The defau lt value i s a null I nteger obj ect.
  144        */
  145       privat e Number h ighThresho ld = INTEG ER_ZERO;
  146  
  147       /**
  148        * Gau ge low thr eshold.
  149        *
  150        * <BR >The defau lt value i s a null I nteger obj ect.
  151        */
  152       privat e Number l owThreshol d = INTEGE R_ZERO;
  153  
  154       /**
  155        * Fla g indicati ng if the  gauge moni tor notifi es when ex ceeding
  156        * the  high thre shold.
  157        *
  158        * <BR >The defau lt value i s <CODE>fa lse</CODE> .
  159        */
  160       privat e boolean  notifyHigh  = false;
  161  
  162       /**
  163        * Fla g indicati ng if the  gauge moni tor notifi es when ex ceeding
  164        * the  low thres hold.
  165        *
  166        * <BR >The defau lt value i s <CODE>fa lse</CODE> .
  167        */
  168       privat e boolean  notifyLow  = false;
  169  
  170       /**
  171        * Fla g indicati ng if the  gauge diff erence mod e is used.   If the
  172        * gau ge differe nce mode i s used, th e derived  gauge is t he
  173        * dif ference be tween two  consecutiv e observed  values.   Otherwise,
  174        * the  derived g auge is di rectly the  value of  the observ ed
  175        * att ribute.
  176        *
  177        * <BR >The defau lt value i s set to < CODE>false </CODE>.
  178        */
  179       privat e boolean  difference Mode = fal se;
  180  
  181       privat e static f inal Strin g[] types  = {
  182           RU NTIME_ERRO R,
  183           OB SERVED_OBJ ECT_ERROR,
  184           OB SERVED_ATT RIBUTE_ERR OR,
  185           OB SERVED_ATT RIBUTE_TYP E_ERROR,
  186           TH RESHOLD_ER ROR,
  187           TH RESHOLD_HI GH_VALUE_E XCEEDED,
  188           TH RESHOLD_LO W_VALUE_EX CEEDED
  189       };
  190  
  191       privat e static f inal MBean Notificati onInfo[] n otifsInfo  = {
  192           ne w MBeanNot ificationI nfo(
  193                types,
  194                "javax.m anagement. monitor.Mo nitorNotif ication",
  195                "Notific ations sen t by the G augeMonito r MBean")
  196       };
  197  
  198       // Fla gs needed  to impleme nt the hys teresis me chanism.
  199       //
  200       privat e static f inal int R ISING              =  0;
  201       privat e static f inal int F ALLING             =  1;
  202       privat e static f inal int R ISING_OR_F ALLING  =  2;
  203  
  204       /*
  205        * --- ---------- ---------- ---------- ---------
  206        *  CO NSTRUCTORS
  207        * --- ---------- ---------- ---------- ---------
  208        */
  209  
  210       /**
  211        * Def ault const ructor.
  212        */
  213       public  GaugeMoni tor() {
  214       }
  215  
  216       /*
  217        * --- ---------- ---------- ---------- ---------
  218        *  PU BLIC METHO DS
  219        * --- ---------- ---------- ---------- ---------
  220        */
  221  
  222       /**
  223        * Sta rts the ga uge monito r.
  224        */
  225       public  synchroni zed void s tart() {
  226           if  (isActive ()) {
  227                MONITOR_ LOGGER.log p(Level.FI NER, Gauge Monitor.cl ass.getNam e(),
  228                         "start", " the monito r is alrea dy active" );
  229                return;
  230           }
  231           //  Reset val ues.
  232           //
  233           fo r (Observe dObject o  : observed Objects) {
  234                final Ga ugeMonitor ObservedOb ject gmo =
  235                    (Gau geMonitorO bservedObj ect) o;
  236                gmo.setS tatus(RISI NG_OR_FALL ING);
  237                gmo.setP reviousSca nGauge(nul l);
  238           }
  239           do Start();
  240       }
  241  
  242       /**
  243        * Sto ps the gau ge monitor .
  244        */
  245       public  synchroni zed void s top() {
  246           do Stop();
  247       }
  248  
  249       // GET TERS AND S ETTERS
  250       //---- ---------- ------
  251  
  252       /**
  253        * Get s the deri ved gauge  of the spe cified obj ect, if th is object  is
  254        * con tained in  the set of  observed  MBeans, or  <code>nul l</code> o therwise.
  255        *
  256        * @pa ram object  the name  of the MBe an.
  257        *
  258        * @re turn The d erived gau ge of the  specified  object.
  259        *
  260        */
  261       @Overr ide
  262       public  synchroni zed Number  getDerive dGauge(Obj ectName ob ject) {
  263           re turn (Numb er) super. getDerived Gauge(obje ct);
  264       }
  265  
  266       /**
  267        * Get s the deri ved gauge  timestamp  of the spe cified obj ect, if
  268        * thi s object i s containe d in the s et of obse rved MBean s, or
  269        * <co de>0</code > otherwis e.
  270        *
  271        * @pa ram object  the name  of the obj ect whose  derived ga uge
  272        * tim estamp is  to be retu rned.
  273        *
  274        * @re turn The d erived gau ge timesta mp of the  specified  object.
  275        *
  276        */
  277       @Overr ide
  278       public  synchroni zed long g etDerivedG augeTimeSt amp(Object Name objec t) {
  279           re turn super .getDerive dGaugeTime Stamp(obje ct);
  280       }
  281  
  282       /**
  283        * Ret urns the d erived gau ge of the  first obje ct in the  set of
  284        * obs erved MBea ns.
  285        *
  286        * @re turn The d erived gau ge.
  287        *
  288        * @de precated A s of JMX 1 .2, replac ed by
  289        * {@l ink #getDe rivedGauge (ObjectNam e)}
  290        */
  291       @Depre cated
  292       public  synchroni zed Number  getDerive dGauge() {
  293           if  (observed Objects.is Empty()) {
  294                return n ull;
  295           }  else {
  296                return ( Number) ob servedObje cts.get(0) .getDerive dGauge();
  297           }
  298       }
  299  
  300       /**
  301        * Get s the deri ved gauge  timestamp  of the fir st object  in the set
  302        * of  observed M Beans.
  303        *
  304        * @re turn The d erived gau ge timesta mp.
  305        *
  306        * @de precated A s of JMX 1 .2, replac ed by
  307        * {@l ink #getDe rivedGauge TimeStamp( ObjectName )}
  308        */
  309       @Depre cated
  310       public  synchroni zed long g etDerivedG augeTimeSt amp() {
  311           if  (observed Objects.is Empty()) {
  312                return 0 ;
  313           }  else {
  314                return o bservedObj ects.get(0 ).getDeriv edGaugeTim eStamp();
  315           }
  316       }
  317  
  318       /**
  319        * Get s the high  threshold  value com mon to all  observed  MBeans.
  320        *
  321        * @re turn The h igh thresh old value.
  322        *
  323        * @se e #setThre sholds
  324        */
  325       public  synchroni zed Number  getHighTh reshold()  {
  326           re turn highT hreshold;
  327       }
  328  
  329       /**
  330        * Get s the low  threshold  value comm on to all  observed M Beans.
  331        *
  332        * @re turn The l ow thresho ld value.
  333        *
  334        * @se e #setThre sholds
  335        */
  336       public  synchroni zed Number  getLowThr eshold() {
  337           re turn lowTh reshold;
  338       }
  339  
  340       /**
  341        * Set s the high  and the l ow thresho ld values  common to  all
  342        * obs erved MBea ns.
  343        *
  344        * @pa ram highVa lue The hi gh thresho ld value.
  345        * @pa ram lowVal ue The low  threshold  value.
  346        *
  347        * @ex ception Il legalArgum entExcepti on The spe cified hig h/low
  348        * thr eshold is  null or th e low thre shold is g reater tha n the high
  349        * thr eshold or  the high t hreshold a nd the low  threshold  are not
  350        * of  the same t ype.
  351        *
  352        * @se e #getHigh Threshold
  353        * @se e #getLowT hreshold
  354        */
  355       public  synchroni zed void s etThreshol ds(Number  highValue,  Number lo wValue)
  356           th rows Illeg alArgument Exception  {
  357  
  358           if  ((highVal ue == null ) || (lowV alue == nu ll)) {
  359                throw ne w IllegalA rgumentExc eption("Nu ll thresho ld value") ;
  360           }
  361  
  362           if  (highValu e.getClass () != lowV alue.getCl ass()) {
  363                throw ne w IllegalA rgumentExc eption("Di fferent ty pe " +
  364                                                      "th reshold va lues");
  365           }
  366  
  367           if  (isFirstS trictlyGre aterThanLa st(lowValu e, highVal ue,
  368                                                  highVal ue.getClas s().getNam e())) {
  369                throw ne w IllegalA rgumentExc eption("Hi gh thresho ld less th an " +
  370                                                      "lo w threshol d");
  371           }
  372  
  373           if  (highThre shold.equa ls(highVal ue) && low Threshold. equals(low Value))
  374                return;
  375           hi ghThreshol d = highVa lue;
  376           lo wThreshold  = lowValu e;
  377  
  378           //  Reset val ues.
  379           //
  380           in t index =  0;
  381           fo r (Observe dObject o  : observed Objects) {
  382                resetAlr eadyNotifi ed(o, inde x++, THRES HOLD_ERROR _NOTIFIED) ;
  383                final Ga ugeMonitor ObservedOb ject gmo =
  384                    (Gau geMonitorO bservedObj ect) o;
  385                gmo.setS tatus(RISI NG_OR_FALL ING);
  386           }
  387       }
  388  
  389       /**
  390        * Get s the high  notificat ion's on/o ff switch  value comm on to all
  391        * obs erved MBea ns.
  392        *
  393        * @re turn <CODE >true</COD E> if the  gauge moni tor notifi es when
  394        * exc eeding the  high thre shold, <CO DE>false</ CODE> othe rwise.
  395        *
  396        * @se e #setNoti fyHigh
  397        */
  398       public  synchroni zed boolea n getNotif yHigh() {
  399           re turn notif yHigh;
  400       }
  401  
  402       /**
  403        * Set s the high  notificat ion's on/o ff switch  value comm on to all
  404        * obs erved MBea ns.
  405        *
  406        * @pa ram value  The high n otificatio n's on/off  switch va lue.
  407        *
  408        * @se e #getNoti fyHigh
  409        */
  410       public  synchroni zed void s etNotifyHi gh(boolean  value) {
  411           if  (notifyHi gh == valu e)
  412                return;
  413           no tifyHigh =  value;
  414       }
  415  
  416       /**
  417        * Get s the low  notificati on's on/of f switch v alue commo n to all
  418        * obs erved MBea ns.
  419        *
  420        * @re turn <CODE >true</COD E> if the  gauge moni tor notifi es when
  421        * exc eeding the  low thres hold, <COD E>false</C ODE> other wise.
  422        *
  423        * @se e #setNoti fyLow
  424        */
  425       public  synchroni zed boolea n getNotif yLow() {
  426           re turn notif yLow;
  427       }
  428  
  429       /**
  430        * Set s the low  notificati on's on/of f switch v alue commo n to all
  431        * obs erved MBea ns.
  432        *
  433        * @pa ram value  The low no tification 's on/off  switch val ue.
  434        *
  435        * @se e #getNoti fyLow
  436        */
  437       public  synchroni zed void s etNotifyLo w(boolean  value) {
  438           if  (notifyLo w == value )
  439                return;
  440           no tifyLow =  value;
  441       }
  442  
  443       /**
  444        * Get s the diff erence mod e flag val ue common  to all obs erved MBea ns.
  445        *
  446        * @re turn <CODE >true</COD E> if the  difference  mode is u sed,
  447        * <CO DE>false</ CODE> othe rwise.
  448        *
  449        * @se e #setDiff erenceMode
  450        */
  451       public  synchroni zed boolea n getDiffe renceMode( ) {
  452           re turn diffe renceMode;
  453       }
  454  
  455       /**
  456        * Set s the diff erence mod e flag val ue common  to all obs erved MBea ns.
  457        *
  458        * @pa ram value  The differ ence mode  flag value .
  459        *
  460        * @se e #getDiff erenceMode
  461        */
  462       public  synchroni zed void s etDifferen ceMode(boo lean value ) {
  463           if  (differen ceMode ==  value)
  464                return;
  465           di fferenceMo de = value ;
  466  
  467           //  Reset val ues.
  468           //
  469           fo r (Observe dObject o  : observed Objects) {
  470                final Ga ugeMonitor ObservedOb ject gmo =
  471                    (Gau geMonitorO bservedObj ect) o;
  472                gmo.setS tatus(RISI NG_OR_FALL ING);
  473                gmo.setP reviousSca nGauge(nul l);
  474           }
  475       }
  476  
  477      /**
  478        * Ret urns a <CO DE>Notific ationInfo< /CODE> obj ect contai ning the
  479        * nam e of the J ava class  of the not ification  and the no tification
  480        * typ es sent by  the gauge  monitor.
  481        */
  482       @Overr ide
  483       public  MBeanNoti ficationIn fo[] getNo tification Info() {
  484           re turn notif sInfo.clon e();
  485       }
  486  
  487       /*
  488        * --- ---------- ---------- ---------- ---------
  489            PRI D A N E S M   T   ODS
  490        * --- ---------- ---------- ---------- ---------
  491        */
  492  
  493       /**
  494        * Upd ates the d erived gau ge attribu te of the  observed o bject.
  495        *
  496        * @pa ram scanGa uge The va lue of the  observed  attribute.
  497        * @pa ram o The  observed o bject.
  498        * @re turn <CODE >true</COD E> if the  derived ga uge value  is valid,
  499        * <CO DE>false</ CODE> othe rwise.  Th e derived  gauge valu e is
  500        * inv alid when  the differ enceMode f lag is set  to
  501        * <CO DE>true</C ODE> and i t is the f irst notif ication (s o we
  502        * hav en't 2 con secutive v alues to u pdate the  derived ga uge).
  503        */
  504       privat e synchron ized boole an updateD erivedGaug e(
  505           Ob ject scanG auge, Gaug eMonitorOb servedObje ct o) {
  506  
  507           bo olean is_d erived_gau ge_valid;
  508  
  509           //  The gauge  differenc e mode is  used.
  510           //
  511           if  (differen ceMode) {
  512  
  513                // The p revious sc an gauge h as been in itialized.
  514                //
  515                if (o.ge tPreviousS canGauge()  != null)  {
  516                    setD erivedGaug eWithDiffe rence((Num ber)scanGa uge, o);
  517                    is_d erived_gau ge_valid =  true;
  518                }
  519                // The p revious sc an gauge h as not bee n initiali zed.
  520                // We ca nnot updat e the deri ved gauge. ..
  521                //
  522                else {
  523                    is_d erived_gau ge_valid =  false;
  524                }
  525                o.setPre viousScanG auge((Numb er)scanGau ge);
  526           }
  527           //  The gauge  differenc e mode is  not used.
  528           //
  529           el se {
  530                o.setDer ivedGauge( (Number)sc anGauge);
  531                is_deriv ed_gauge_v alid = tru e;
  532           }
  533  
  534           re turn is_de rived_gaug e_valid;
  535       }
  536  
  537       /**
  538        * Upd ates the n otificatio n attribut e of the o bserved ob ject
  539        * and  notifies  the listen ers only o nce if the  notify fl ag
  540        * is  set to <CO DE>true</C ODE>.
  541        * @pa ram o The  observed o bject.
  542        */
  543       privat e synchron ized Monit orNotifica tion updat eNotificat ions(
  544           Ga ugeMonitor ObservedOb ject o) {
  545  
  546           Mo nitorNotif ication n  = null;
  547  
  548           //  Send high  notificat ion if not ifyHigh is  true.
  549           //  Send low  notificati on if noti fyLow is t rue.
  550           //
  551           if  (o.getSta tus() == R ISING_OR_F ALLING) {
  552                if (isFi rstGreater ThanLast(( Number)o.g etDerivedG auge(),
  553                                             h ighThresho ld,
  554                                             o .getType() )) {
  555                    if ( notifyHigh ) {
  556                         n = new Mo nitorNotif ication(
  557                                 TH RESHOLD_HI GH_VALUE_E XCEEDED,
  558                                 th is,
  559                                 0,
  560                                 0,
  561                                 "" ,
  562                                 nu ll,
  563                                 nu ll,
  564                                 nu ll,
  565                                 hi ghThreshol d);
  566                    }
  567                    o.se tStatus(FA LLING);
  568                } else i f (isFirst GreaterTha nLast(lowT hreshold,
  569                                                     (Num ber)o.getD erivedGaug e(),
  570                                                     o.ge tType()))  {
  571                    if ( notifyLow)  {
  572                         n = new Mo nitorNotif ication(
  573                                 TH RESHOLD_LO W_VALUE_EX CEEDED,
  574                                 th is,
  575                                 0,
  576                                 0,
  577                                 "" ,
  578                                 nu ll,
  579                                 nu ll,
  580                                 nu ll,
  581                                 lo wThreshold );
  582                    }
  583                    o.se tStatus(RI SING);
  584                }
  585           }  else {
  586                if (o.ge tStatus()  == RISING)  {
  587                    if ( isFirstGre aterThanLa st((Number )o.getDeri vedGauge() ,
  588                                                  highThr eshold,
  589                                                  o.getTy pe())) {
  590                         if (notify High) {
  591                             n = ne w MonitorN otificatio n(
  592                                      THRESHOL D_HIGH_VAL UE_EXCEEDE D,
  593                                      this,
  594                                      0,
  595                                      0,
  596                                      "",
  597                                      null,
  598                                      null,
  599                                      null,
  600                                      highThre shold);
  601                         }
  602                         o.setStatu s(FALLING) ;
  603                    }
  604                } else i f (o.getSt atus() ==  FALLING) {
  605                    if ( isFirstGre aterThanLa st(lowThre shold,
  606                                                  (Number )o.getDeri vedGauge() ,
  607                                                  o.getTy pe())) {
  608                         if (notify Low) {
  609                             n = ne w MonitorN otificatio n(
  610                                      THRESHOL D_LOW_VALU E_EXCEEDED ,
  611                                      this,
  612                                      0,
  613                                      0,
  614                                      "",
  615                                      null,
  616                                      null,
  617                                      null,
  618                                      lowThres hold);
  619                         }
  620                         o.setStatu s(RISING);
  621                    }
  622                }
  623           }
  624  
  625           re turn n;
  626       }
  627  
  628       /**
  629        * Set s the deri ved gauge  when the d ifferenceM ode flag i s set to
  630        * <CO DE>true</C ODE>.  Bot h integer  and floati ng-point t ypes are
  631        * all owed.
  632        *
  633        * @pa ram scanGa uge The va lue of the  observed  attribute.
  634        * @pa ram o The  observed o bject.
  635        */
  636       privat e synchron ized void  setDerived GaugeWithD ifference(
  637           Nu mber scanG auge, Gaug eMonitorOb servedObje ct o) {
  638           Nu mber prev  = o.getPre viousScanG auge();
  639           Nu mber der;
  640           sw itch (o.ge tType()) {
  641           ca se INTEGER :
  642                der = In teger.valu eOf(((Inte ger)scanGa uge).intVa lue() -
  643                                        ((Inte ger)prev). intValue() );
  644                break;
  645           ca se BYTE:
  646                der = By te.valueOf ((byte)((( Byte)scanG auge).byte Value() -
  647                                            (( Byte)prev) .byteValue ()));
  648                break;
  649           ca se SHORT:
  650                der = Sh ort.valueO f((short)( ((Short)sc anGauge).s hortValue( ) -
  651                                               ((Short)pr ev).shortV alue()));
  652                break;
  653           ca se LONG:
  654                der = Lo ng.valueOf (((Long)sc anGauge).l ongValue()  -
  655                                     ((Long)pr ev).longVa lue());
  656                break;
  657           ca se FLOAT:
  658                der = Fl oat.valueO f(((Float) scanGauge) .floatValu e() -
  659                                      ((Float) prev).floa tValue());
  660                break;
  661           ca se DOUBLE:
  662                der = Do uble.value Of(((Doubl e)scanGaug e).doubleV alue() -
  663                                       ((Doubl e)prev).do ubleValue( ));
  664                break;
  665           de fault:
  666                // Shoul d never oc cur...
  667                MONITOR_ LOGGER.log p(Level.FI NEST, Gaug eMonitor.c lass.getNa me(),
  668                         "setDerive dGaugeWith Difference ",
  669                         "the thres hold type  is invalid ");
  670                return;
  671           }
  672           o. setDerived Gauge(der) ;
  673       }
  674  
  675       /**
  676        * Tes ts if the  first spec ified Numb er is grea ter than o r equal to
  677        * the  last.  Bo th integer  and float ing-point  types are  allowed.
  678        *
  679        * @pa ram greate r The firs t Number t o compare  with the s econd.
  680        * @pa ram less T he second  Number to  compare wi th the fir st.
  681        * @pa ram type T he number  type.
  682        * @re turn <CODE >true</COD E> if the  first spec ified Numb er is
  683        * gre ater than  or equal t o the last , <CODE>fa lse</CODE>
  684        * oth erwise.
  685        */
  686       privat e boolean  isFirstGre aterThanLa st(Number  greater,
  687                                                  Number  less,
  688                                                  Numeric alType typ e) {
  689  
  690           sw itch (type ) {
  691           ca se INTEGER :
  692           ca se BYTE:
  693           ca se SHORT:
  694           ca se LONG:
  695                return ( greater.lo ngValue()  >= less.lo ngValue()) ;
  696           ca se FLOAT:
  697           ca se DOUBLE:
  698                return ( greater.do ubleValue( ) >= less. doubleValu e());
  699           de fault:
  700                // Shoul d never oc cur...
  701                MONITOR_ LOGGER.log p(Level.FI NEST, Gaug eMonitor.c lass.getNa me(),
  702                         "isFirstGr eaterThanL ast",
  703                         "the thres hold type  is invalid ");
  704                return f alse;
  705           }
  706       }
  707  
  708       /**
  709        * Tes ts if the  first spec ified Numb er is stri ctly great er than th e last.
  710        * Bot h integer  and floati ng-point t ypes are a llowed.
  711        *
  712        * @pa ram greate r The firs t Number t o compare  with the s econd.
  713        * @pa ram less T he second  Number to  compare wi th the fir st.
  714        * @pa ram classN ame The nu mber class  name.
  715        * @re turn <CODE >true</COD E> if the  first spec ified Numb er is
  716        * str ictly grea ter than t he last, < CODE>false </CODE> ot herwise.
  717        */
  718       privat e boolean  isFirstStr ictlyGreat erThanLast (Number gr eater,
  719                                                           Number le ss,
  720                                                           String cl assName) {
  721  
  722           if  (classNam e.equals(" java.lang. Integer")  ||
  723                classNam e.equals(" java.lang. Byte") ||
  724                classNam e.equals(" java.lang. Short") ||
  725                classNam e.equals(" java.lang. Long")) {
  726  
  727                return ( greater.lo ngValue()  > less.lon gValue());
  728           }
  729           el se if (cla ssName.equ als("java. lang.Float ") ||
  730                     cla ssName.equ als("java. lang.Doubl e")) {
  731  
  732                return ( greater.do ubleValue( ) > less.d oubleValue ());
  733           }
  734           el se {
  735                // Shoul d never oc cur...
  736                MONITOR_ LOGGER.log p(Level.FI NEST, Gaug eMonitor.c lass.getNa me(),
  737                         "isFirstSt rictlyGrea terThanLas t",
  738                         "the thres hold type  is invalid ");
  739                return f alse;
  740           }
  741       }
  742  
  743       /*
  744        * --- ---------- ---------- ---------- ---------
  745        *  PA CKAGE METH ODS
  746        * --- ---------- ---------- ---------- ---------
  747        */
  748  
  749       /**
  750        * Fac tory metho d for Obse rvedObject  creation.
  751        *
  752        * @si nce 1.6
  753        */
  754       @Overr ide
  755       Observ edObject c reateObser vedObject( ObjectName  object) {
  756           fi nal GaugeM onitorObse rvedObject  gmo =
  757                new Gaug eMonitorOb servedObje ct(object) ;
  758           gm o.setStatu s(RISING_O R_FALLING) ;
  759           gm o.setPrevi ousScanGau ge(null);
  760           re turn gmo;
  761       }
  762  
  763       /**
  764        * Thi s method g lobally se ts the der ived gauge  type for  the given
  765        * "ob ject" and  "attribute " after ch ecking tha t the type  of the
  766        * sup plied obse rved attri bute value  is one of  the value  types
  767        * sup ported by  this monit or.
  768        */
  769       @Overr ide
  770       synchr onized boo lean isCom parableTyp eValid(Obj ectName ob ject,
  771                                                      Str ing attrib ute,
  772                                                      Com parable<?>  value) {
  773           fi nal GaugeM onitorObse rvedObject  o =
  774                (GaugeMo nitorObser vedObject)  getObserv edObject(o bject);
  775           if  (o == nul l)
  776                return f alse;
  777  
  778           //  Check tha t the obse rved attri bute is ei ther of ty pe
  779           //  "Integer"  or "Float ".
  780           //
  781           if  (value in stanceof I nteger) {
  782                o.setTyp e(INTEGER) ;
  783           }  else if (v alue insta nceof Byte ) {
  784                o.setTyp e(BYTE);
  785           }  else if (v alue insta nceof Shor t) {
  786                o.setTyp e(SHORT);
  787           }  else if (v alue insta nceof Long ) {
  788                o.setTyp e(LONG);
  789           }  else if (v alue insta nceof Floa t) {
  790                o.setTyp e(FLOAT);
  791           }  else if (v alue insta nceof Doub le) {
  792                o.setTyp e(DOUBLE);
  793           }  else {
  794                return f alse;
  795           }
  796           re turn true;
  797       }
  798  
  799       @Overr ide
  800       synchr onized Com parable<?>  getDerive dGaugeFrom Comparable (
  801                                                          ObjectName  object,
  802                                                          String att ribute,
  803                                                          Comparable <?> value)  {
  804           fi nal GaugeM onitorObse rvedObject  o =
  805                (GaugeMo nitorObser vedObject)  getObserv edObject(o bject);
  806           if  (o == nul l)
  807                return n ull;
  808  
  809           //  Update th e derived  gauge attr ibutes and  check the
  810           //  validity  of the new  value. Th e derived  gauge valu e
  811           //  is invali d when the  differenc eMode flag  is set to
  812           //  true and  it is the  first noti fication,  i.e. we
  813           //  haven't g ot 2 conse cutive val ues to upd ate the
  814           //  derived g auge.
  815           //
  816           o. setDerived GaugeValid (updateDer ivedGauge( value, o)) ;
  817  
  818           re turn (Comp arable<?>)  o.getDeri vedGauge() ;
  819       }
  820  
  821       @Overr ide
  822       synchr onized voi d onErrorN otificatio n(MonitorN otificatio n notifica tion) {
  823           fi nal GaugeM onitorObse rvedObject  o = (Gaug eMonitorOb servedObje ct)
  824                getObser vedObject( notificati on.getObse rvedObject ());
  825           if  (o == nul l)
  826                return;
  827  
  828           //  Reset val ues.
  829           //
  830           o. setStatus( RISING_OR_ FALLING);
  831           o. setPreviou sScanGauge (null);
  832       }
  833  
  834       @Overr ide
  835       synchr onized Mon itorNotifi cation bui ldAlarmNot ification(
  836                                                      Obj ectName ob ject,
  837                                                      Str ing attrib ute,
  838                                                      Com parable<?>  value) {
  839           fi nal GaugeM onitorObse rvedObject  o =
  840                (GaugeMo nitorObser vedObject)  getObserv edObject(o bject);
  841           if  (o == nul l)
  842                return n ull;
  843  
  844           //  Notify th e listener s if the u pdated der ived
  845           //  gauge val ue is vali d.
  846           //
  847           fi nal Monito rNotificat ion alarm;
  848           if  (o.getDer ivedGaugeV alid())
  849                alarm =  updateNoti fications( o);
  850           el se
  851                alarm =  null;
  852           re turn alarm ;
  853       }
  854  
  855       /**
  856        * Tes ts if the  threshold  high and t hreshold l ow are bot h of the
  857        * sam e type as  the gauge.   Both int eger and f loating-po int types
  858        * are  allowed.
  859        *
  860        * Not e:
  861        *   I f the opti onal lowTh reshold or  highThres hold have  not been
  862        *   i nitialized , their de fault valu e is an In teger obje ct with
  863        *   a  value equ al to zero .
  864        *
  865        * @pa ram object  The obser ved object .
  866        * @pa ram attrib ute The ob served att ribute.
  867        * @pa ram value  The sample  value.
  868        * @re turn <CODE >true</COD E> if type  is the sa me,
  869        * <CO DE>false</ CODE> othe rwise.
  870        */
  871       @Overr ide
  872       synchr onized boo lean isThr esholdType Valid(Obje ctName obj ect,
  873                                                     Stri ng attribu te,
  874                                                     Comp arable<?>  value) {
  875           fi nal GaugeM onitorObse rvedObject  o =
  876                (GaugeMo nitorObser vedObject)  getObserv edObject(o bject);
  877           if  (o == nul l)
  878                return f alse;
  879  
  880           Cl ass<? exte nds Number > c = clas sForType(o .getType() );
  881           re turn (isVa lidForType (highThres hold, c) & &
  882                    isVa lidForType (lowThresh old, c));
  883       }
  884   }