196. EPMO Open Source Coordination Office Redaction File Detail Report

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

196.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\timer Timer.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\timer Timer.java Wed Sep 12 17:21:15 2018 UTC

196.2 Comparison summary

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

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

196.4 Active regular expressions

No regular expressions were active.

196.5 Comparison detail

  1   /*
  2    * Copyrig ht (c) 199 9, 2012, 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.timer ;
  27  
  28   import sta tic com.su n.jmx.defa ults.JmxPr operties.T IMER_LOGGE R;
  29   import jav a.util.Arr ayList;
  30   import jav a.util.Dat e;
  31   import jav a.util.Has hMap;
  32   import jav a.util.Map ;
  33   import jav a.util.Set ;
  34   import jav a.util.Tre eSet;
  35   import jav a.util.Vec tor;
  36   import jav a.util.log ging.Level ;
  37  
  38   // jmx imp orts
  39   //
  40   import jav ax.managem ent.Instan ceNotFound Exception;
  41   import jav ax.managem ent.MBeanN otificatio nInfo;
  42   import jav ax.managem ent.MBeanR egistratio n;
  43   import jav ax.managem ent.MBeanS erver;
  44   import jav ax.managem ent.Notifi cationBroa dcasterSup port;
  45   import jav ax.managem ent.Object Name;
  46  
  47   /**
  48    *
  49    * Provide s the impl ementation  of the ti mer MBean.
  50    * The tim er MBean s ends out a n alarm at  a specifi ed time
  51    * that wa kes up all  the liste ners regis tered to r eceive tim er notific ations.
  52    * <P>
  53    *
  54    * This cl ass manage s a list o f dated ti mer notifi cations.
  55    * A metho d allows u sers to ad d/remove a s many not ifications  as requir ed.
  56    * When a  timer noti fication i s emitted  by the tim er and bec omes obsol ete,
  57    * it is a utomatical ly removed  from the  list of ti mer notifi cations.
  58    * <BR>Add itional ti mer notifi cations ca n be added  into regu larly repe ating noti fications.
  59    * <P>
  60    *
  61    * Note:
  62    * <OL>
  63    * <LI>Whe n sending  timer noti fications,  the timer  updates t he notific ation sequ ence numbe r
  64    * irrespe ctive of t he notific ation type .
  65    * <LI>The  timer ser vice relie s on the s ystem date  of the ho st where t he <CODE>T imer</CODE > class is  loaded.
  66    * Listene rs may rec eive untim ely notifi cations
  67    * if thei r host has  a differe nt system  date.
  68    * To avoi d such pro blems, syn chronize t he system  date of al l host mac hines wher e timing i s needed.
  69    * <LI>The  default b ehavior fo r periodic  notificat ions is <i >fixed-del ay executi on</i>, as
  70    *     spe cified in  {@link jav a.util.Tim er}. In or der to use  <i>fixed- rate execu tion</i>,  use the
  71    *     ove rloaded {@ link #addN otificatio n(String,  String, Ob ject, Date , long, lo ng, boolea n)} method .
  72    * <LI>Not ification  listeners  are potent ially all  executed i n the same
  73    * thread.   Therefor e, they sh ould execu te rapidly  to avoid  holding up
  74    * other l isteners o r perturbi ng the reg ularity of  fixed-del ay
  75    * executi ons.  See  {@link Not ificationB roadcaster Support}.
  76    * </OL>
  77    *
  78    * @since  1.5
  79    */
  80   public cla ss Timer e xtends Not ificationB roadcaster Support
  81           im plements T imerMBean,  MBeanRegi stration {
  82  
  83  
  84       /*
  85        * --- ---------- ---------- ---------- ---------
  86        *  PU BLIC VARIA BLES
  87        * --- ---------- ---------- ---------- ---------
  88        */
  89  
  90       /**
  91        * Num ber of mil liseconds  in one sec ond.
  92        * Use ful consta nt for the  <CODE>add Notificati on</CODE>  method.
  93        */
  94       public  static fi nal long O NE_SECOND  = 1000;
  95  
  96       /**
  97        * Num ber of mil liseconds  in one min ute.
  98        * Use ful consta nt for the  <CODE>add Notificati on</CODE>  method.
  99        */
  100       public  static fi nal long O NE_MINUTE  = 60*ONE_S ECOND;
  101  
  102       /**
  103        * Num ber of mil liseconds  in one hou r.
  104        * Use ful consta nt for the  <CODE>add Notificati on</CODE>  method.
  105        */
  106       public  static fi nal long O NE_HOUR    = 60*ONE_M INUTE;
  107  
  108       /**
  109        * Num ber of mil liseconds  in one day .
  110        * Use ful consta nt for the  <CODE>add Notificati on</CODE>  method.
  111        */
  112       public  static fi nal long O NE_DAY     = 24*ONE_H OUR;
  113  
  114       /**
  115        * Num ber of mil liseconds  in one wee k.
  116        * Use ful consta nt for the  <CODE>add Notificati on</CODE>  method.
  117        */
  118       public  static fi nal long O NE_WEEK    = 7*ONE_DA Y;
  119  
  120       /*
  121        * --- ---------- ---------- ---------- ---------
  122        *  PR IVATE VARI ABLES
  123        * --- ---------- ---------- ---------- ---------
  124        */
  125  
  126       /**
  127        * Tab le contain ing all th e timer no tification s of this  timer,
  128        * wit h the asso ciated dat e, period  and number  of occurr ences.
  129        */
  130       final  private Ma p<Integer, Object[]>  timerTable  =
  131           ne w HashMap< >();
  132  
  133       /**
  134        * Pas t notifica tions send ing on/off  flag valu e.
  135        * Thi s attribut e is used  to specify  if the ti mer has to  send past  notificat ions after  start.
  136        * <BR >The defau lt value i s set to < CODE>false </CODE>.
  137        */
  138       privat e boolean  sendPastNo tification s = false;
  139  
  140       /**
  141        * Tim er state.
  142        * The  default v alue is se t to <CODE >false</CO DE>.
  143        */
  144       privat e transien t boolean  isActive =  false;
  145  
  146       /**
  147        * Tim er sequenc e number.
  148        * The  default v alue is se t to 0.
  149        */
  150       privat e transien t long seq uenceNumbe r = 0;
  151  
  152       // Fla gs needed  to keep th e indexes  of the obj ects in th e array.
  153       //
  154       privat e static f inal int T IMER_NOTIF _INDEX      = 0;
  155       privat e static f inal int T IMER_DATE_ INDEX       = 1;
  156       privat e static f inal int T IMER_PERIO D_INDEX     = 2;
  157       privat e static f inal int T IMER_NB_OC CUR_INDEX   = 3;
  158       privat e static f inal int A LARM_CLOCK _INDEX      = 4;
  159       privat e static f inal int F IXED_RATE_ INDEX       = 5;
  160  
  161       /**
  162        * The  notificat ion counte r ID.
  163        * Use d to keep  the max ke y value in serted int o the time r table.
  164        */
  165       volati le private  int count erID = 0;
  166  
  167       privat e java.uti l.Timer ti mer;
  168  
  169       /*
  170        * --- ---------- ---------- ---------- ---------
  171        *  CO NSTRUCTORS
  172        * --- ---------- ---------- ---------- ---------
  173        */
  174  
  175       /**
  176        * Def ault const ructor.
  177        */
  178       public  Timer() {
  179       }
  180  
  181       /*
  182        * --- ---------- ---------- ---------- ---------
  183        *  PU BLIC METHO DS
  184        * --- ---------- ---------- ---------- ---------
  185        */
  186  
  187       /**
  188        * All ows the ti mer MBean  to perform  any opera tions it n eeds befor e being re gistered
  189        * in  the MBean  server.
  190        * <P>
  191        * Not  used in t his contex t.
  192        *
  193        * @pa ram server  The MBean  server in  which the  timer MBe an will be  registere d.
  194        * @pa ram name T he object  name of th e timer MB ean.
  195        *
  196        * @re turn The n ame of the  timer MBe an registe red.
  197        *
  198        * @ex ception ja va.lang.Ex ception
  199        */
  200       public  ObjectNam e preRegis ter(MBeanS erver serv er, Object Name name)
  201           th rows java. lang.Excep tion {
  202           re turn name;
  203       }
  204  
  205       /**
  206        * All ows the ti mer MBean  to perform  any opera tions need ed after h aving been
  207        * reg istered in  the MBean  server or  after the  registrat ion has fa iled.
  208        * <P>
  209        * Not  used in t his contex t.
  210        */
  211       public  void post Register ( Boolean re gistration Done) {
  212       }
  213  
  214       /**
  215        * All ows the ti mer MBean  to perform  any opera tions it n eeds befor e being un registered
  216        * by  the MBean  server.
  217        * <P>
  218        * Sto ps the tim er.
  219        *
  220        * @ex ception ja va.lang.Ex ception
  221        */
  222       public  void preD eregister( ) throws j ava.lang.E xception {
  223  
  224           TI MER_LOGGER .logp(Leve l.FINER, T imer.class .getName() ,
  225                    "pre Deregister ", "stop t he timer") ;
  226  
  227           //  Stop the  timer.
  228           //
  229           st op();
  230       }
  231  
  232       /**
  233        * All ows the ti mer MBean  to perform  any opera tions need ed after h aving been
  234        * unr egistered  by the MBe an server.
  235        * <P>
  236        * Not  used in t his contex t.
  237        */
  238       public  void post Deregister () {
  239       }
  240  
  241       /*
  242        * Thi s override s the meth od in Noti ficationBr oadcasterS upport.
  243        * Ret urn the MB eanNotific ationInfo[ ] array fo r this MBe an.
  244        * The  returned  array has  one elemen t to indic ate that t he MBean
  245        * can  emit Time rNotificat ion.  The  array of t ype string s
  246        * ass ociated wi th this en try is a s napshot of  the curre nt types
  247        * tha t were giv en to addN otificatio n.
  248        */
  249       public  synchroni zed MBeanN otificatio nInfo[] ge tNotificat ionInfo()  {
  250           Se t<String>  notifTypes  = new Tre eSet<Strin g>();
  251           fo r (Object[ ] entry :  timerTable .values())  {
  252                TimerNot ification  notif = (T imerNotifi cation)
  253                    entr y[TIMER_NO TIF_INDEX] ;
  254                notifTyp es.add(not if.getType ());
  255           }
  256           St ring[] not ifTypesArr ay =
  257                notifTyp es.toArray (new Strin g[0]);
  258           re turn new M BeanNotifi cationInfo [] {
  259                new MBea nNotificat ionInfo(no tifTypesAr ray,
  260                                            Ti merNotific ation.clas s.getName( ),
  261                                            "N otificatio n sent by  Timer MBea n")
  262           };
  263       }
  264  
  265       /**
  266        * Sta rts the ti mer.
  267        * <P>
  268        * If  there is o ne or more  timer not ifications  before th e time in  the list o f notifica tions, the  notificat ion
  269        * is  sent accor ding to th e <CODE>se ndPastNoti fications< /CODE> fla g and then , updated
  270        * acc ording to  its period  and remai ning numbe r of occur rences.
  271        * If  the timer  notificati on date re mains earl ier than t he current  date, thi s notifica tion is ju st removed
  272        * fro m the list  of notifi cations.
  273        */
  274       public  synchroni zed void s tart() {
  275  
  276           TI MER_LOGGER .logp(Leve l.FINER, T imer.class .getName() ,
  277                    "sta rt", "star ting the t imer");
  278  
  279           //  Start the  TimerAlar mClock.
  280           //
  281           if  (isActive  == false)  {
  282  
  283                timer =  new java.u til.Timer( );
  284  
  285                TimerAla rmClock al armClock;
  286                Date dat e;
  287  
  288                Date cur rentDate =  new Date( );
  289  
  290                // Send  or not pas t notifica tions depe nding on t he flag.
  291                // Updat e the date  and the n umber of o ccurrences  of past n otificatio ns
  292                // to ma ke them la ter than t he current  date.
  293                //
  294                sendPast Notificati ons(curren tDate, sen dPastNotif ications);
  295  
  296                // Updat e and star t all the  TimerAlarm Clocks.
  297                // Here,  all the n otificatio ns in the  timer tabl e are late r than the  current d ate.
  298                //
  299                for (Obj ect[] obj  : timerTab le.values( )) {
  300  
  301                    // R etrieve th e date not ification  and the Ti merAlarmCl ock.
  302                    //
  303                    date  = (Date)o bj[TIMER_D ATE_INDEX] ;
  304  
  305                    // U pdate all  the TimerA larmClock  timeouts a nd start t hem.
  306                    //
  307                    bool ean fixedR ate = ((Bo olean)obj[ FIXED_RATE _INDEX]).b ooleanValu e();
  308                    if ( fixedRate)
  309                    {
  310                      al armClock =  new Timer AlarmClock (this, dat e);
  311                      ob j[ALARM_CL OCK_INDEX]  = (Object )alarmCloc k;
  312                      ti mer.schedu le(alarmCl ock, alarm Clock.next );
  313                    }
  314                    else
  315                    {
  316                      al armClock =  new Timer AlarmClock (this, (da te.getTime () - curre ntDate.get Time()));
  317                      ob j[ALARM_CL OCK_INDEX]  = (Object )alarmCloc k;
  318                      ti mer.schedu le(alarmCl ock, alarm Clock.time out);
  319                    }
  320                }
  321  
  322                // Set t he state t o ON.
  323                //
  324                isActive  = true;
  325  
  326                TIMER_LO GGER.logp( Level.FINE R, Timer.c lass.getNa me(),
  327                         "start", " timer star ted");
  328           }  else {
  329                TIMER_LO GGER.logp( Level.FINE R, Timer.c lass.getNa me(),
  330                         "start", " the timer  is already  activated ");
  331           }
  332       }
  333  
  334       /**
  335        * Sto ps the tim er.
  336        */
  337       public  synchroni zed void s top() {
  338  
  339           TI MER_LOGGER .logp(Leve l.FINER, T imer.class .getName() ,
  340                    "sto p", "stopp ing the ti mer");
  341  
  342           //  Stop the  TimerAlarm Clock.
  343           //
  344           if  (isActive  == true)  {
  345  
  346                for (Obj ect[] obj  : timerTab le.values( )) {
  347  
  348                    // S top all th e TimerAla rmClock.
  349                    //
  350                    Time rAlarmCloc k alarmClo ck = (Time rAlarmCloc k)obj[ALAR M_CLOCK_IN DEX];
  351                    if ( alarmClock  != null)  {
  352   //                       alarmCl ock.interr upt();
  353   //                       try {
  354   //                           //  Wait until  the threa d die.
  355   //                           //
  356   //                           ala rmClock.jo in();
  357   //                       } catch  (Interrup tedExcepti on ex) {
  358   //                           //  Ignore...
  359   //                       }
  360   //                       // Remo ve the ref erence on  the TimerA larmClock.
  361   //                       //
  362  
  363                         alarmClock .cancel();
  364                    }
  365                }
  366  
  367                timer.ca ncel();
  368  
  369                // Set t he state t o OFF.
  370                //
  371                isActive  = false;
  372  
  373                TIMER_LO GGER.logp( Level.FINE R, Timer.c lass.getNa me(),
  374                         "stop", "t imer stopp ed");
  375           }  else {
  376                TIMER_LO GGER.logp( Level.FINE R, Timer.c lass.getNa me(),
  377                         "stop", "t he timer i s already  deactivate d");
  378           }
  379       }
  380  
  381       /**
  382        * Cre ates a new  timer not ification  with the s pecified < CODE>type< /CODE>, <C ODE>messag e</CODE>
  383        * and  <CODE>use rData</COD E> and ins erts it in to the lis t of notif ications w ith a give n date,
  384        * per iod and nu mber of oc currences.
  385        * <P>
  386        * If  the timer  notificati on to be i nserted ha s a date t hat is bef ore the cu rrent date ,
  387        * the  method be haves as i f the spec ified date  were the  current da te. <BR>
  388        * For  once-off  notificati ons, the n otificatio n is deliv ered immed iately. <B R>
  389        * For  periodic  notificati ons, the f irst notif ication is  delivered  immediate ly and the
  390        * sub sequent on es are spa ced as spe cified by  the period  parameter .
  391        * <P>
  392        * Not e that onc e the time r notifica tion has b een added  into the l ist of not ifications ,
  393        * its  associate d date, pe riod and n umber of o ccurrences  cannot be  updated.
  394        * <P>
  395        * In  the case o f a period ic notific ation, the  value of  parameter  <i>fixedRa te</i> is  used to
  396        * spe cify the e xecution s cheme, as  specified  in {@link  java.util. Timer}.
  397        *
  398        * @pa ram type T he timer n otificatio n type.
  399        * @pa ram messag e The time r notifica tion detai led messag e.
  400        * @pa ram userDa ta The tim er notific ation user  data obje ct.
  401        * @pa ram date T he date wh en the not ification  occurs.
  402        * @pa ram period  The perio d of the t imer notif ication (i n millisec onds).
  403        * @pa ram nbOccu rences The  total num ber the ti mer notifi cation wil l be emitt ed.
  404        * @pa ram fixedR ate If <co de>true</c ode> and i f the noti fication i s periodic , the noti fication
  405        *                    is sch eduled wit h a <i>fix ed-rate</i > executio n scheme.  If
  406        *                    <code> false</cod e> and if  the notifi cation is  periodic,  the notifi cation
  407        *                    is sch eduled wit h a <i>fix ed-delay</ i> executi on scheme.  Ignored i f the
  408        *                    notifi cation is  not period ic.
  409        *
  410        * @re turn The i dentifier  of the new  created t imer notif ication.
  411        *
  412        * @ex ception ja va.lang.Il legalArgum entExcepti on The dat e is {@cod e null} or
  413        * the  period or  the numbe r of occur rences is  negative.
  414        *
  415        * @se e #addNoti fication(S tring, Str ing, Objec t, Date, l ong, long)
  416        */
  417   // NPCTE f ix for bug Id 4464388 , esc 0,   MR, to be  added afte r modifica tion of jm x spec
  418   //  public  synchroni zed Intege r addNotif ication(St ring type,  String me ssage, Ser ializable  userData,
  419   //                                                     Date date,  long peri od, long n bOccurence s)
  420   // end of  NPCTE fix  for bugId  4464388
  421  
  422       public  synchroni zed Intege r addNotif ication(St ring type,  String me ssage, Obj ect userDa ta,
  423                                                       Da te date, l ong period , long nbO ccurences,  boolean f ixedRate)
  424           th rows java. lang.Illeg alArgument Exception  {
  425  
  426           if  (date ==  null) {
  427                throw ne w java.lan g.IllegalA rgumentExc eption("Ti mer notifi cation dat e cannot b e null.");
  428           }
  429  
  430           //  Check tha t all the  timer noti fication a ttributes  are valid.
  431           //
  432  
  433           //  Invalid t imer perio d value ex ception:
  434           //  Check tha t the peri od and the  nbOccuren ces are PO SITIVE VAL UES.
  435           //
  436           if  ((period  < 0) || (n bOccurence s < 0)) {
  437                throw ne w java.lan g.IllegalA rgumentExc eption("Ne gative val ues for th e periodic ity");
  438           }
  439  
  440           Da te current Date = new  Date();
  441  
  442           //  Update th e date if  it is befo re the cur rent date.
  443           //
  444           if  (currentD ate.after( date)) {
  445  
  446                date.set Time(curre ntDate.get Time());
  447                if (TIME R_LOGGER.i sLoggable( Level.FINE R)) {
  448                    TIME R_LOGGER.l ogp(Level. FINER, Tim er.class.g etName(),
  449                             "addNo tification ",
  450                             "updat e timer no tification  to add wi th:" +
  451                             "\n\tN otificatio n date = "  + date);
  452                }
  453           }
  454  
  455           //  Create an d add the  timer noti fication i nto the ti mer table.
  456           //
  457           In teger noti fID = Inte ger.valueO f(++counte rID);
  458  
  459           //  The seque nceNumber  and the ti meStamp at tributes a re updated
  460           //  when the  notificati on is emit ted by the  timer.
  461           //
  462           Ti merNotific ation noti f = new Ti merNotific ation(type , this, 0,  0, messag e, notifID );
  463           no tif.setUse rData(user Data);
  464  
  465           Ob ject[] obj  = new Obj ect[6];
  466  
  467           Ti merAlarmCl ock alarmC lock;
  468           if  (fixedRat e)
  469           {
  470              alarmClock  = new Tim erAlarmClo ck(this, d ate);
  471           }
  472           el se
  473           {
  474              alarmClock  = new Tim erAlarmClo ck(this, ( date.getTi me() - cur rentDate.g etTime())) ;
  475           }
  476  
  477           //  Fix bug 0 0417.B
  478           //  The date  registered  into the  timer is a  clone fro m the date  parameter .
  479           //
  480           Da te d = new  Date(date .getTime() );
  481  
  482           ob j[TIMER_NO TIF_INDEX]  = (Object )notif;
  483           ob j[TIMER_DA TE_INDEX]  = (Object) d;
  484           ob j[TIMER_PE RIOD_INDEX ] = (Objec t) period;
  485           ob j[TIMER_NB _OCCUR_IND EX] = (Obj ect) nbOcc urences;
  486           ob j[ALARM_CL OCK_INDEX]  = (Object )alarmCloc k;
  487           ob j[FIXED_RA TE_INDEX]  = Boolean. valueOf(fi xedRate);
  488  
  489           if  (TIMER_LO GGER.isLog gable(Leve l.FINER))  {
  490                StringBu ilder strb  = new Str ingBuilder ()
  491                .append( "adding ti mer notifi cation:\n\ t")
  492                .append( "Notificat ion source  = ")
  493                .append( notif.getS ource())
  494                .append( "\n\tNotif ication ty pe = ")
  495                .append( notif.getT ype())
  496                .append( "\n\tNotif ication ID  = ")
  497                .append( notifID)
  498                .append( "\n\tNotif ication da te = ")
  499                .append( d)
  500                .append( "\n\tNotif ication pe riod = ")
  501                .append( period)
  502                .append( "\n\tNotif ication nb  of occurr ences = ")
  503                .append( nbOccurenc es)
  504                .append( "\n\tNotif ication ex ecutes at  fixed rate  = ")
  505                .append( fixedRate) ;
  506                TIMER_LO GGER.logp( Level.FINE R, Timer.c lass.getNa me(),
  507                         "addNotifi cation", s trb.toStri ng());
  508           }
  509  
  510           ti merTable.p ut(notifID , obj);
  511  
  512           //  Update an d start th e TimerAla rmClock.
  513           //
  514           if  (isActive  == true)  {
  515              if (fixedR ate)
  516              {
  517                timer.sc hedule(ala rmClock, a larmClock. next);
  518              }
  519              else
  520              {
  521                timer.sc hedule(ala rmClock, a larmClock. timeout);
  522              }
  523           }
  524  
  525           TI MER_LOGGER .logp(Leve l.FINER, T imer.class .getName() ,
  526                    "add Notificati on", "time r notifica tion added ");
  527           re turn notif ID;
  528       }
  529  
  530       /**
  531        * Cre ates a new  timer not ification  with the s pecified < CODE>type< /CODE>, <C ODE>messag e</CODE>
  532        * and  <CODE>use rData</COD E> and ins erts it in to the lis t of notif ications w ith a give n date,
  533        * per iod and nu mber of oc currences.
  534        * <P>
  535        * If  the timer  notificati on to be i nserted ha s a date t hat is bef ore the cu rrent date ,
  536        * the  method be haves as i f the spec ified date  were the  current da te. <BR>
  537        * For  once-off  notificati ons, the n otificatio n is deliv ered immed iately. <B R>
  538        * For  periodic  notificati ons, the f irst notif ication is  delivered  immediate ly and the
  539        * sub sequent on es are spa ced as spe cified by  the period  parameter .
  540        * <P>
  541        * Not e that onc e the time r notifica tion has b een added  into the l ist of not ifications ,
  542        * its  associate d date, pe riod and n umber of o ccurrences  cannot be  updated.
  543        * <P>
  544        * In  the case o f a period ic notific ation, use s a <i>fix ed-delay</ i> executi on scheme,  as specif ied in
  545        * {@l ink java.u til.Timer} . In order  to use a  <i>fixed-r ate</i> ex ecution sc heme, use
  546        * {@l ink #addNo tification (String, S tring, Obj ect, Date,  long, lon g, boolean )} instead .
  547        *
  548        * @pa ram type T he timer n otificatio n type.
  549        * @pa ram messag e The time r notifica tion detai led messag e.
  550        * @pa ram userDa ta The tim er notific ation user  data obje ct.
  551        * @pa ram date T he date wh en the not ification  occurs.
  552        * @pa ram period  The perio d of the t imer notif ication (i n millisec onds).
  553        * @pa ram nbOccu rences The  total num ber the ti mer notifi cation wil l be emitt ed.
  554        *
  555        * @re turn The i dentifier  of the new  created t imer notif ication.
  556        *
  557        * @ex ception ja va.lang.Il legalArgum entExcepti on The dat e is {@cod e null} or
  558        * the  period or  the numbe r of occur rences is  negative.
  559        *
  560        * @se e #addNoti fication(S tring, Str ing, Objec t, Date, l ong, long,  boolean)
  561        */
  562   // NPCTE f ix for bug Id 4464388 , esc 0,   MR , to be  added aft er modific ation of j mx spec
  563   //  public  synchroni zed Intege r addNotif ication(St ring type,  String me ssage, Ser ializable  userData,
  564   //                                                  Da te date, l ong period )
  565   // end of  NPCTE fix  for bugId  4464388 */
  566  
  567       public  synchroni zed Intege r addNotif ication(St ring type,  String me ssage, Obj ect userDa ta,
  568                                                       Da te date, l ong period , long nbO ccurences)
  569           th rows java. lang.Illeg alArgument Exception  {
  570  
  571         retu rn addNoti fication(t ype, messa ge, userDa ta, date,  period, nb Occurences , false);
  572       }
  573  
  574       /**
  575        * Cre ates a new  timer not ification  with the s pecified < CODE>type< /CODE>, <C ODE>messag e</CODE>
  576        * and  <CODE>use rData</COD E> and ins erts it in to the lis t of notif ications w ith a give n date
  577        * and  period an d a null n umber of o ccurrences .
  578        * <P>
  579        * The  timer not ification  will repea t continuo usly using  the timer  period us ing a <i>f ixed-delay </i>
  580        * exe cution sch eme, as sp ecified in  {@link ja va.util.Ti mer}. In o rder to us e a <i>fix ed-rate</i >
  581        * exe cution sch eme, use { @link #add Notificati on(String,  String, O bject, Dat e, long, l ong,
  582        * boo lean)} ins tead.
  583        * <P>
  584        * If  the timer  notificati on to be i nserted ha s a date t hat is bef ore the cu rrent date ,
  585        * the  method be haves as i f the spec ified date  were the  current da te. The
  586        * fir st notific ation is d elivered i mmediately  and the s ubsequent  ones are
  587        * spa ced as spe cified by  the period  parameter .
  588        *
  589        * @pa ram type T he timer n otificatio n type.
  590        * @pa ram messag e The time r notifica tion detai led messag e.
  591        * @pa ram userDa ta The tim er notific ation user  data obje ct.
  592        * @pa ram date T he date wh en the not ification  occurs.
  593        * @pa ram period  The perio d of the t imer notif ication (i n millisec onds).
  594        *
  595        * @re turn The i dentifier  of the new  created t imer notif ication.
  596        *
  597        * @ex ception ja va.lang.Il legalArgum entExcepti on The dat e is {@cod e null} or
  598        * the  period is  negative.
  599        */
  600   // NPCTE f ix for bug Id 4464388 , esc 0,   MR , to be  added aft er modific ation of j mx spec
  601   //  public  synchroni zed Intege r addNotif ication(St ring type,  String me ssage, Ser ializable  userData,
  602   //                                                  Da te date, l ong period )
  603   // end of  NPCTE fix  for bugId  4464388 */
  604  
  605       public  synchroni zed Intege r addNotif ication(St ring type,  String me ssage, Obj ect userDa ta,
  606                                                       Da te date, l ong period )
  607           th rows java. lang.Illeg alArgument Exception  {
  608  
  609           re turn (addN otificatio n(type, me ssage, use rData, dat e, period,  0));
  610       }
  611  
  612       /**
  613        * Cre ates a new  timer not ification  with the s pecified < CODE>type< /CODE>, <C ODE>messag e</CODE>
  614        * and  <CODE>use rData</COD E> and ins erts it in to the lis t of notif ications w ith a give n date
  615        * and  a null pe riod and n umber of o ccurrences .
  616        * <P>
  617        * The  timer not ification  will be ha ndled once  at the sp ecified da te.
  618        * <P>
  619        * If  the timer  notificati on to be i nserted ha s a date t hat is bef ore the cu rrent date ,
  620        * the  method be haves as i f the spec ified date  were the  current da te and the
  621        * not ification  is deliver ed immedia tely.
  622        *
  623        * @pa ram type T he timer n otificatio n type.
  624        * @pa ram messag e The time r notifica tion detai led messag e.
  625        * @pa ram userDa ta The tim er notific ation user  data obje ct.
  626        * @pa ram date T he date wh en the not ification  occurs.
  627        *
  628        * @re turn The i dentifier  of the new  created t imer notif ication.
  629        *
  630        * @ex ception ja va.lang.Il legalArgum entExcepti on The dat e is {@cod e null}.
  631        */
  632   // NPCTE f ix for bug Id 4464388 , esc 0,   MR, to be  added afte r modifica tion of jm x spec
  633   //  public  synchroni zed Intege r addNotif ication(St ring type,  String me ssage, Ser ializable  userData,  Date date)
  634   //      th rows java. lang.Illeg alArgument Exception  {
  635   // end of  NPCTE fix  for bugId  4464388
  636  
  637       public  synchroni zed Intege r addNotif ication(St ring type,  String me ssage, Obj ect userDa ta, Date d ate)
  638           th rows java. lang.Illeg alArgument Exception  {
  639  
  640  
  641           re turn (addN otificatio n(type, me ssage, use rData, dat e, 0, 0));
  642       }
  643  
  644       /**
  645        * Rem oves the t imer notif ication co rrespondin g to the s pecified i dentifier  from the l ist of not ifications .
  646        *
  647        * @pa ram id The  timer not ification  identifier .
  648        *
  649        * @ex ception In stanceNotF oundExcept ion The sp ecified id entifier d oes not co rrespond t o any time r notifica tion
  650        * in  the list o f notifica tions of t his timer  MBean.
  651        */
  652       public  synchroni zed void r emoveNotif ication(In teger id)  throws Ins tanceNotFo undExcepti on {
  653  
  654           //  Check tha t the noti fication t o remove i s effectiv ely in the  timer tab le.
  655           //
  656           if  (timerTab le.contain sKey(id) = = false) {
  657                throw ne w Instance NotFoundEx ception("T imer notif ication to  remove no t in the l ist of not ifications ");
  658           }
  659  
  660           //  Stop the  TimerAlarm Clock.
  661           //
  662           Ob ject[] obj  = timerTa ble.get(id );
  663           Ti merAlarmCl ock alarmC lock = (Ti merAlarmCl ock)obj[AL ARM_CLOCK_ INDEX];
  664           if  (alarmClo ck != null ) {
  665   //              alarm Clock.inte rrupt();
  666   //              try {
  667   //                  / / Wait unt il the thr ead die.
  668   //                  / /
  669   //                  a larmClock. join();
  670   //              } cat ch (Interr uptedExcep tion e) {
  671   //                  / / Ignore.. .
  672   //              }
  673   //              // Re move the r eference o n the Time rAlarmCloc k.
  674   //              //
  675                alarmClo ck.cancel( );
  676           }
  677  
  678           //  Remove th e timer no tification  from the  timer tabl e.
  679           //
  680           if  (TIMER_LO GGER.isLog gable(Leve l.FINER))  {
  681                StringBu ilder strb  = new Str ingBuilder ()
  682                .append( "removing  timer noti fication:" )
  683                .append( "\n\tNotif ication so urce = ")
  684                .append( ((TimerNot ification) obj[TIMER_ NOTIF_INDE X]).getSou rce())
  685                .append( "\n\tNotif ication ty pe = ")
  686                .append( ((TimerNot ification) obj[TIMER_ NOTIF_INDE X]).getTyp e())
  687                .append( "\n\tNotif ication ID  = ")
  688                .append( ((TimerNot ification) obj[TIMER_ NOTIF_INDE X]).getNot ificationI D())
  689                .append( "\n\tNotif ication da te = ")
  690                .append( obj[TIMER_ DATE_INDEX ])
  691                .append( "\n\tNotif ication pe riod = ")
  692                .append( obj[TIMER_ PERIOD_IND EX])
  693                .append( "\n\tNotif ication nb  of occurr ences = ")
  694                .append( obj[TIMER_ NB_OCCUR_I NDEX])
  695                .append( "\n\tNotif ication ex ecutes at  fixed rate  = ")
  696                .append( obj[FIXED_ RATE_INDEX ]);
  697                TIMER_LO GGER.logp( Level.FINE R, Timer.c lass.getNa me(),
  698                         "removeNot ification" , strb.toS tring());
  699           }
  700  
  701           ti merTable.r emove(id);
  702  
  703           TI MER_LOGGER .logp(Leve l.FINER, T imer.class .getName() ,
  704                    "rem oveNotific ation", "t imer notif ication re moved");
  705       }
  706  
  707       /**
  708        * Rem oves all t he timer n otificatio ns corresp onding to  the specif ied type f rom the li st of noti fications.
  709        *
  710        * @pa ram type T he timer n otificatio n type.
  711        *
  712        * @ex ception In stanceNotF oundExcept ion The sp ecified ty pe does no t correspo nd to any  timer noti fication
  713        * in  the list o f notifica tions of t his timer  MBean.
  714        */
  715       public  synchroni zed void r emoveNotif ications(S tring type ) throws I nstanceNot FoundExcep tion {
  716  
  717           Ve ctor<Integ er> v = ge tNotificat ionIDs(typ e);
  718  
  719           if  (v.isEmpt y())
  720                throw ne w Instance NotFoundEx ception("T imer notif ications t o remove n ot in the  list of no tification s");
  721  
  722           fo r (Integer  i : v)
  723                removeNo tification (i);
  724       }
  725  
  726       /**
  727        * Rem oves all t he timer n otificatio ns from th e list of  notificati ons
  728        * and  resets th e counter  used to up date the t imer notif ication id entifiers.
  729        */
  730       public  synchroni zed void r emoveAllNo tification s() {
  731  
  732           Ti merAlarmCl ock alarmC lock;
  733  
  734           fo r (Object[ ] obj : ti merTable.v alues()) {
  735  
  736                // Stop  the TimerA larmClock.
  737                //
  738                alarmClo ck = (Time rAlarmCloc k)obj[ALAR M_CLOCK_IN DEX];
  739   //              if (a larmClock  != null) {
  740   //                  a larmClock. interrupt( );
  741   //                  t ry {
  742   //                       // Wait  until the  thread di e.
  743   //                       //
  744   //                       alarmCl ock.join() ;
  745   //                  }  catch (In terruptedE xception e x) {
  746   //                       // Igno re...
  747   //                  }
  748                      //  Remove th e referenc e on the T imerAlarmC lock.
  749                      //
  750   //              }
  751                alarmClo ck.cancel( );
  752           }
  753  
  754           //  Remove al l the time r notifica tions from  the timer  table.
  755           TI MER_LOGGER .logp(Leve l.FINER, T imer.class .getName() ,
  756                    "rem oveAllNoti fications" , "removin g all time r notifica tions");
  757  
  758           ti merTable.c lear();
  759  
  760           TI MER_LOGGER .logp(Leve l.FINER, T imer.class .getName() ,
  761                    "rem oveAllNoti fications" , "all tim er notific ations rem oved");
  762           //  Reset the  counterID .
  763           //
  764           co unterID =  0;
  765  
  766           TI MER_LOGGER .logp(Leve l.FINER, T imer.class .getName() ,
  767                    "rem oveAllNoti fications" , "timer n otificatio n counter  ID reset") ;
  768       }
  769  
  770       // GET TERS AND S ETTERS
  771       //---- ---------- ------
  772  
  773       /**
  774        * Get s the numb er of time r notifica tions regi stered int o the list  of notifi cations.
  775        *
  776        * @re turn The n umber of t imer notif ications.
  777        */
  778       public  synchroni zed int ge tNbNotific ations() {
  779           re turn timer Table.size ();
  780       }
  781  
  782       /**
  783        * Get s all time r notifica tion ident ifiers reg istered in to the lis t of notif ications.
  784        *
  785        * @re turn A vec tor of <CO DE>Integer </CODE> ob jects cont aining all  the timer  notificat ion identi fiers.
  786        * <BR >The vecto r is empty  if there  is no time r notifica tion regis tered for  this timer  MBean.
  787        */
  788       public  synchroni zed Vector <Integer>  getAllNoti ficationID s() {
  789           re turn new V ector<Inte ger>(timer Table.keyS et());
  790       }
  791  
  792       /**
  793        * Get s all the  identifier s of timer  notificat ions corre sponding t o the spec ified type .
  794        *
  795        * @pa ram type T he timer n otificatio n type.
  796        *
  797        * @re turn A vec tor of <CO DE>Integer </CODE> ob jects cont aining all  the ident ifiers of
  798        * tim er notific ations wit h the spec ified <COD E>type</CO DE>.
  799        * <BR >The vecto r is empty  if there  is no time r notifica tions regi stered for  this time r MBean
  800        * wit h the spec ified <COD E>type</CO DE>.
  801        */
  802       public  synchroni zed Vector <Integer>  getNotific ationIDs(S tring type ) {
  803  
  804           St ring s;
  805  
  806           Ve ctor<Integ er> v = ne w Vector<I nteger>();
  807  
  808           fo r (Map.Ent ry<Integer ,Object[]>  entry : t imerTable. entrySet() ) {
  809                Object[]  obj = ent ry.getValu e();
  810                s = ((Ti merNotific ation)obj[ TIMER_NOTI F_INDEX]). getType();
  811                if ((typ e == null)  ? s == nu ll : type. equals(s))
  812                    v.ad dElement(e ntry.getKe y());
  813           }
  814           re turn v;
  815       }
  816       // 508 9997: retu rn is Vect or<Integer > not Vect or<TimerNo tification >
  817  
  818       /**
  819        * Get s the time r notifica tion type  correspond ing to the  specified  identifie r.
  820        *
  821        * @pa ram id The  timer not ification  identifier .
  822        *
  823        * @re turn The t imer notif ication ty pe or null  if the id entifier i s not mapp ed to any
  824        * tim er notific ation regi stered for  this time r MBean.
  825        */
  826       public  synchroni zed String  getNotifi cationType (Integer i d) {
  827  
  828           Ob ject[] obj  = timerTa ble.get(id );
  829           if  (obj != n ull) {
  830                return (  ((TimerNo tification )obj[TIMER _NOTIF_IND EX]).getTy pe() );
  831           }
  832           re turn null;
  833       }
  834  
  835       /**
  836        * Get s the time r notifica tion detai led messag e correspo nding to t he specifi ed identif ier.
  837        *
  838        * @pa ram id The  timer not ification  identifier .
  839        *
  840        * @re turn The t imer notif ication de tailed mes sage or nu ll if the  identifier  is not ma pped to an y
  841        * tim er notific ation regi stered for  this time r MBean.
  842        */
  843       public  synchroni zed String  getNotifi cationMess age(Intege r id) {
  844  
  845           Ob ject[] obj  = timerTa ble.get(id );
  846           if  (obj != n ull) {
  847                return (  ((TimerNo tification )obj[TIMER _NOTIF_IND EX]).getMe ssage() );
  848           }
  849           re turn null;
  850       }
  851  
  852       /**
  853        * Get s the time r notifica tion user  data objec t correspo nding to t he specifi ed identif ier.
  854        *
  855        * @pa ram id The  timer not ification  identifier .
  856        *
  857        * @re turn The t imer notif ication us er data ob ject or nu ll if the  identifier  is not ma pped to an y
  858        * tim er notific ation regi stered for  this time r MBean.
  859        */
  860       // NPC TE fix for  bugId 446 4388, esc  0, MR, 03  sept 2001,  to be add ed after m odificatio n of jmx s pec
  861       //publ ic Seriali zable getN otificatio nUserData( Integer id ) {
  862       // end  of NPCTE  fix for bu gId 446438 8
  863  
  864       public  synchroni zed Object  getNotifi cationUser Data(Integ er id) {
  865           Ob ject[] obj  = timerTa ble.get(id );
  866           if  (obj != n ull) {
  867                return (  ((TimerNo tification )obj[TIMER _NOTIF_IND EX]).getUs erData() ) ;
  868           }
  869           re turn null;
  870       }
  871  
  872       /**
  873        * Get s a copy o f the date  associate d to a tim er notific ation.
  874        *
  875        * @pa ram id The  timer not ification  identifier .
  876        *
  877        * @re turn A cop y of the d ate or nul l if the i dentifier  is not map ped to any
  878        * tim er notific ation regi stered for  this time r MBean.
  879        */
  880       public  synchroni zed Date g etDate(Int eger id) {
  881  
  882           Ob ject[] obj  = timerTa ble.get(id );
  883           if  (obj != n ull) {
  884                Date dat e = (Date) obj[TIMER_ DATE_INDEX ];
  885                return ( new Date(d ate.getTim e()));
  886           }
  887           re turn null;
  888       }
  889  
  890       /**
  891        * Get s a copy o f the peri od (in mil liseconds)  associate d to a tim er notific ation.
  892        *
  893        * @pa ram id The  timer not ification  identifier .
  894        *
  895        * @re turn A cop y of the p eriod or n ull if the  identifie r is not m apped to a ny
  896        * tim er notific ation regi stered for  this time r MBean.
  897        */
  898       public  synchroni zed Long g etPeriod(I nteger id)  {
  899  
  900           Ob ject[] obj  = timerTa ble.get(id );
  901           if  (obj != n ull) {
  902                return ( Long)obj[T IMER_PERIO D_INDEX];
  903           }
  904           re turn null;
  905       }
  906  
  907       /**
  908        * Get s a copy o f the rema ining numb er of occu rrences as sociated t o a timer  notificati on.
  909        *
  910        * @pa ram id The  timer not ification  identifier .
  911        *
  912        * @re turn A cop y of the r emaining n umber of o ccurrences  or null i f the iden tifier is  not mapped  to any
  913        * tim er notific ation regi stered for  this time r MBean.
  914        */
  915       public  synchroni zed Long g etNbOccure nces(Integ er id) {
  916  
  917           Ob ject[] obj  = timerTa ble.get(id );
  918           if  (obj != n ull) {
  919                return ( Long)obj[T IMER_NB_OC CUR_INDEX] ;
  920           }
  921           re turn null;
  922       }
  923  
  924       /**
  925        * Get s a copy o f the flag  indicatin g whether  a periodic  notificat ion is
  926        * exe cuted at < i>fixed-de lay</i> or  at <i>fix ed-rate</i >.
  927        *
  928        * @pa ram id The  timer not ification  identifier .
  929        *
  930        * @re turn A cop y of the f lag indica ting wheth er a perio dic notifi cation is
  931        *          execu ted at <i> fixed-dela y</i> or a t <i>fixed -rate</i>.
  932        */
  933       public  synchroni zed Boolea n getFixed Rate(Integ er id) {
  934  
  935         Obje ct[] obj =  timerTabl e.get(id);
  936         if ( obj != nul l) {
  937           Bo olean fixe dRate = (B oolean)obj [FIXED_RAT E_INDEX];
  938           re turn (Bool ean.valueO f(fixedRat e.booleanV alue()));
  939         }
  940         retu rn null;
  941       }
  942  
  943       /**
  944        * Get s the flag  indicatin g whether  or not the  timer sen ds past no tification s.
  945        * <BR >The defau lt value o f the past  notificat ions sendi ng on/off  flag is <C ODE>false< /CODE>.
  946        *
  947        * @re turn The p ast notifi cations se nding on/o ff flag va lue.
  948        *
  949        * @se e #setSend PastNotifi cations
  950        */
  951       public  boolean g etSendPast Notificati ons() {
  952           re turn sendP astNotific ations;
  953       }
  954  
  955       /**
  956        * Set s the flag  indicatin g whether  the timer  sends past  notificat ions or no t.
  957        * <BR >The defau lt value o f the past  notificat ions sendi ng on/off  flag is <C ODE>false< /CODE>.
  958        *
  959        * @pa ram value  The past n otificatio ns sending  on/off fl ag value.
  960        *
  961        * @se e #getSend PastNotifi cations
  962        */
  963       public  void setS endPastNot ifications (boolean v alue) {
  964           se ndPastNoti fications  = value;
  965       }
  966  
  967       /**
  968        * Tes ts whether  the timer  MBean is  active.
  969        * A t imer MBean  is marked  active wh en the {@l ink #start  start} me thod is ca lled.
  970        * It  becomes in active whe n the {@li nk #stop s top} metho d is calle d.
  971        * <BR >The defau lt value o f the acti ve on/off  flag is <C ODE>false< /CODE>.
  972        *
  973        * @re turn <CODE >true</COD E> if the  timer MBea n is activ e, <CODE>f alse</CODE > otherwis e.
  974        */
  975       public  boolean i sActive()  {
  976           re turn isAct ive;
  977       }
  978  
  979       /**
  980        * Tes ts whether  the list  of timer n otificatio ns is empt y.
  981        *
  982        * @re turn <CODE >true</COD E> if the  list of ti mer notifi cations is  empty, <C ODE>false< /CODE> oth erwise.
  983        */
  984       public  synchroni zed boolea n isEmpty( ) {
  985           re turn (time rTable.isE mpty());
  986       }
  987  
  988       /*
  989        * --- ---------- ---------- ---------- ---------
  990            PRI D A N E S M   T   ODS
  991        * --- ---------- ---------- ---------- ---------
  992        */
  993  
  994       /**
  995        * Sen ds or not  past notif ications d epending o n the spec ified flag .
  996        *
  997        * @pa ram curren tDate The  current da te.
  998        * @pa ram curren tFlag The  flag indic ating if p ast notifi cations mu st be sent  or not.
  999        */
  1000       privat e synchron ized void  sendPastNo tification s(Date cur rentDate,  boolean cu rrentFlag)  {
  1001  
  1002           Ti merNotific ation noti f;
  1003           In teger noti fID;
  1004           Da te date;
  1005  
  1006           Ar rayList<Ob ject[]> va lues =
  1007                new Arra yList<Obje ct[]>(time rTable.val ues());
  1008  
  1009           fo r (Object[ ] obj : va lues) {
  1010  
  1011                // Retri eve the ti mer notifi cation and  the date  notificati on.
  1012                //
  1013                notif =  (TimerNoti fication)o bj[TIMER_N OTIF_INDEX ];
  1014                notifID  = notif.ge tNotificat ionID();
  1015                date = ( Date)obj[T IMER_DATE_ INDEX];
  1016  
  1017                // Updat e the time r notifica tion while :
  1018                //  - th e timer no tification  date is e arlier tha n the curr ent date
  1019                //  - th e timer no tification  has not b een remove d from the  timer tab le.
  1020                //
  1021                while (  (currentDa te.after(d ate)) && ( timerTable .containsK ey(notifID )) ) {
  1022  
  1023                    if ( currentFla g == true)  {
  1024                         if (TIMER_ LOGGER.isL oggable(Le vel.FINER) ) {
  1025                             String Builder st rb = new S tringBuild er()
  1026                             .appen d("sending  past time r notifica tion:")
  1027                             .appen d("\n\tNot ification  source = " )
  1028                             .appen d(notif.ge tSource())
  1029                             .appen d("\n\tNot ification  type = ")
  1030                             .appen d(notif.ge tType())
  1031                             .appen d("\n\tNot ification  ID = ")
  1032                             .appen d(notif.ge tNotificat ionID())
  1033                             .appen d("\n\tNot ification  date = ")
  1034                             .appen d(date)
  1035                             .appen d("\n\tNot ification  period = " )
  1036                             .appen d(obj[TIME R_PERIOD_I NDEX])
  1037                             .appen d("\n\tNot ification  nb of occu rrences =  ")
  1038                             .appen d(obj[TIME R_NB_OCCUR _INDEX])
  1039                             .appen d("\n\tNot ification  executes a t fixed ra te = ")
  1040                             .appen d(obj[FIXE D_RATE_IND EX]);
  1041                             TIMER_ LOGGER.log p(Level.FI NER, Timer .class.get Name(),
  1042                                      "sendPas tNotificat ions", str b.toString ());
  1043                         }
  1044                         sendNotifi cation(dat e, notif);
  1045  
  1046                         TIMER_LOGG ER.logp(Le vel.FINER,  Timer.cla ss.getName (),
  1047                                 "s endPastNot ifications ", "past t imer notif ication se nt");
  1048                    }
  1049  
  1050                    // U pdate the  date and t he number  of occurre nces of th e timer no tification .
  1051                    //
  1052                    upda teTimerTab le(notif.g etNotifica tionID());
  1053                }
  1054           }
  1055       }
  1056  
  1057       /**
  1058        * If  the timer  notificati on is not  periodic,  it is remo ved from t he list of  notificat ions.
  1059        * <P>
  1060        * If  the timer  period of  the timer  notificati on has a n on null pe riodicity,
  1061        * the  date of t he timer n otificatio n is updat ed by addi ng the per iodicity.
  1062        * The  associate d TimerAla rmClock is  updated b y setting  its timeou t to the p eriod valu e.
  1063        * <P>
  1064        * If  the timer  period has  a defined  number of  occurrenc es, the ti mer
  1065        * not ification  is updated  if the nu mber of oc currences  has not ye t been rea ched.
  1066        * Oth erwise it  is removed  from the  list of no tification s.
  1067        *
  1068        * @pa ram notifI D The time r notifica tion ident ifier to u pdate.
  1069        */
  1070       privat e synchron ized void  updateTime rTable(Int eger notif ID) {
  1071  
  1072           //  Retrieve  the timer  notificati on and the  TimerAlar mClock.
  1073           //
  1074           Ob ject[] obj  = timerTa ble.get(no tifID);
  1075           Da te date =  (Date)obj[ TIMER_DATE _INDEX];
  1076           Lo ng period  = (Long)ob j[TIMER_PE RIOD_INDEX ];
  1077           Lo ng nbOccur ences = (L ong)obj[TI MER_NB_OCC UR_INDEX];
  1078           Bo olean fixe dRate = (B oolean)obj [FIXED_RAT E_INDEX];
  1079           Ti merAlarmCl ock alarmC lock = (Ti merAlarmCl ock)obj[AL ARM_CLOCK_ INDEX];
  1080  
  1081           if  (period.l ongValue()  != 0) {
  1082  
  1083                // Updat e the date  and the n umber of o ccurrences  of the ti mer notifi cation
  1084                // and t he TimerAl armClock t ime out.
  1085                // NOTES  :
  1086                //   nbO ccurences  = 0 notifi es an infi nite perio dicity.
  1087                //   nbO ccurences  = 1 notifi es a finit e periodic ity that h as reached  its end.
  1088                //   nbO ccurences  > 1 notifi es a finit e periodic ity that h as not yet  reached i ts end.
  1089                //
  1090                if ((nbO ccurences. longValue( ) == 0) ||  (nbOccure nces.longV alue() > 1 )) {
  1091  
  1092                    date .setTime(d ate.getTim e() + peri od.longVal ue());
  1093                    obj[ TIMER_NB_O CCUR_INDEX ] = Long.v alueOf(jav a.lang.Mat h.max(0L,  (nbOccuren ces.longVa lue() - 1) ));
  1094                    nbOc curences =  (Long)obj [TIMER_NB_ OCCUR_INDE X];
  1095  
  1096                    if ( isActive = = true) {
  1097                      if  (fixedRat e.booleanV alue())
  1098                      {
  1099                         alarmClock  = new Tim erAlarmClo ck(this, d ate);
  1100                         obj[ALARM_ CLOCK_INDE X] = (Obje ct)alarmCl ock;
  1101                         timer.sche dule(alarm Clock, ala rmClock.ne xt);
  1102                      }
  1103                      el se
  1104                      {
  1105                         alarmClock  = new Tim erAlarmClo ck(this, p eriod.long Value());
  1106                         obj[ALARM_ CLOCK_INDE X] = (Obje ct)alarmCl ock;
  1107                         timer.sche dule(alarm Clock, ala rmClock.ti meout);
  1108                      }
  1109                    }
  1110                    if ( TIMER_LOGG ER.isLogga ble(Level. FINER)) {
  1111                         TimerNotif ication no tif = (Tim erNotifica tion)obj[T IMER_NOTIF _INDEX];
  1112                         StringBuil der strb =  new Strin gBuilder()
  1113                         .append("u pdate time r notifica tion with: ")
  1114                         .append("\ n\tNotific ation sour ce = ")
  1115                         .append(no tif.getSou rce())
  1116                         .append("\ n\tNotific ation type  = ")
  1117                         .append(no tif.getTyp e())
  1118                         .append("\ n\tNotific ation ID =  ")
  1119                         .append(no tifID)
  1120                         .append("\ n\tNotific ation date  = ")
  1121                         .append(da te)
  1122                         .append("\ n\tNotific ation peri od = ")
  1123                         .append(pe riod)
  1124                         .append("\ n\tNotific ation nb o f occurren ces = ")
  1125                         .append(nb Occurences )
  1126                         .append("\ n\tNotific ation exec utes at fi xed rate =  ")
  1127                         .append(fi xedRate);
  1128                         TIMER_LOGG ER.logp(Le vel.FINER,  Timer.cla ss.getName (),
  1129                                 "u pdateTimer Table", st rb.toStrin g());
  1130                    }
  1131                }
  1132                else {
  1133                    if ( alarmClock  != null)  {
  1134   //                       alarmCl ock.interr upt();
  1135   //                       try {
  1136   //                           //  Wait until  the threa d die.
  1137   //                           //
  1138   //                           ala rmClock.jo in();
  1139   //                       } catch  (Interrup tedExcepti on e) {
  1140   //                           //  Ignore...
  1141   //                       }
  1142                         alarmClock .cancel();
  1143                    }
  1144                    time rTable.rem ove(notifI D);
  1145                }
  1146           }
  1147           el se {
  1148                if (alar mClock !=  null) {
  1149   //                  a larmClock. interrupt( );
  1150   //                  t ry {
  1151   //                       // Wait  until the  thread di e.
  1152   //                       //
  1153   //                       alarmCl ock.join() ;
  1154   //                  }  catch (In terruptedE xception e ) {
  1155   //                       // Igno re...
  1156   //                  }
  1157  
  1158                       a larmClock. cancel();
  1159                }
  1160                timerTab le.remove( notifID);
  1161           }
  1162       }
  1163  
  1164       /*
  1165        * --- ---------- ---------- ---------- ---------
  1166        *  PA CKAGE METH ODS
  1167        * --- ---------- ---------- ---------- ---------
  1168        */
  1169  
  1170       /**
  1171        * Thi s method i s called b y the time r each tim e
  1172        * the  TimerAlar mClock has  exceeded  its timeou t.
  1173        *
  1174        * @pa ram notifi cation The  TimerAlar mClock not ification.
  1175        */
  1176       @Suppr essWarning s("depreca tion")
  1177       void n otifyAlarm Clock(Time rAlarmCloc kNotificat ion notifi cation) {
  1178  
  1179           Ti merNotific ation time rNotificat ion = null ;
  1180           Da te timerDa te = null;
  1181  
  1182           //  Retrieve  the timer  notificati on associa ted to the  alarm-clo ck.
  1183           //
  1184           Ti merAlarmCl ock alarmC lock = (Ti merAlarmCl ock)notifi cation.get Source();
  1185  
  1186           sy nchronized (Timer.thi s) {
  1187                for (Obj ect[] obj  : timerTab le.values( )) {
  1188                    if ( obj[ALARM_ CLOCK_INDE X] == alar mClock) {
  1189                         timerNotif ication =  (TimerNoti fication)o bj[TIMER_N OTIF_INDEX ];
  1190                         timerDate  = (Date)ob j[TIMER_DA TE_INDEX];
  1191                         break;
  1192                    }
  1193                }
  1194           }
  1195  
  1196           //  Notify th e timer.
  1197           //
  1198           se ndNotifica tion(timer Date, time rNotificat ion);
  1199  
  1200           //  Update th e notifica tion and t he TimerAl armClock t imeout.
  1201           //
  1202           up dateTimerT able(timer Notificati on.getNoti ficationID ());
  1203       }
  1204  
  1205       /**
  1206        * Thi s method i s used by  the timer  MBean to u pdate and  send a tim er
  1207        * not ification  to all the  listeners  registere d for this  kind of n otificatio n.
  1208        *
  1209        * @pa ram timeSt amp The no tification  emission  date.
  1210        * @pa ram notifi cation The  timer not ification  to send.
  1211        */
  1212       void s endNotific ation(Date  timeStamp , TimerNot ification  notificati on) {
  1213  
  1214           if  (TIMER_LO GGER.isLog gable(Leve l.FINER))  {
  1215                StringBu ilder strb  = new Str ingBuilder ()
  1216                .append( "sending t imer notif ication:")
  1217                .append( "\n\tNotif ication so urce = ")
  1218                .append( notificati on.getSour ce())
  1219                .append( "\n\tNotif ication ty pe = ")
  1220                .append( notificati on.getType ())
  1221                .append( "\n\tNotif ication ID  = ")
  1222                .append( notificati on.getNoti ficationID ())
  1223                .append( "\n\tNotif ication da te = ")
  1224                .append( timeStamp) ;
  1225                TIMER_LO GGER.logp( Level.FINE R, Timer.c lass.getNa me(),
  1226                         "sendNotif ication",  strb.toStr ing());
  1227           }
  1228           lo ng curSeqN umber;
  1229           sy nchronized (this) {
  1230                sequence Number = s equenceNum ber + 1;
  1231                curSeqNu mber = seq uenceNumbe r;
  1232           }
  1233           sy nchronized  (notifica tion) {
  1234                notifica tion.setTi meStamp(ti meStamp.ge tTime());
  1235                notifica tion.setSe quenceNumb er(curSeqN umber);
  1236                this.sen dNotificat ion((Timer Notificati on)notific ation.clon eTimerNoti fication() );
  1237           }
  1238  
  1239           TI MER_LOGGER .logp(Leve l.FINER, T imer.class .getName() ,
  1240                    "sen dNotificat ion", "tim er notific ation sent ");
  1241       }
  1242   }