112. EPMO Open Source Coordination Office Redaction File Detail Report

Produced by Araxis Merge on 12/5/2017 12:06:38 PM Central Standard 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.

112.1 Files compared

# Location File Last Modified
1 IV-eHMP_CIF.zip\IMAG_Source\VISA\Java\CoreValueObjects\main\src\java\gov\va\med\imaging\core\interfaces\router RouterStatisticsAdvice.java Mon Dec 4 21:35:18 2017 UTC
2 IV-eHMP_CIF.zip\IMAG_Source\VISA\Java\CoreValueObjects\main\src\java\gov\va\med\imaging\core\interfaces\router RouterStatisticsAdvice.java Mon Dec 4 21:58:43 2017 UTC

112.2 Comparison summary

Description Between
Files 1 and 2
Text Blocks Lines
Unchanged 3 950
Changed 2 4
Inserted 0 0
Removed 0 0

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

112.4 Active regular expressions

No regular expressions were active.

112.5 Comparison detail

  1   /**
  2    * Package : MAG - Vi stA Imagin g
  3    * WARNING : Per VHA  Directive  2004-038,  this routi ne should  not be mod ified.
  4    * Date Cr eated: Oct  17, 2008
  5    * Site Na me:  Washi ngton OI F ield Offic e, Silver  Spring, MD
  6    * @author         
BECKEC
  7    * @versio n 1.0
  8    *
  9    * ------- ---------- ---------- ---------- ---------- ---------- -------
  10    * Propert y of the U S Governme nt.
  11    * No perm ission to  copy or re distribute  this soft ware is gi ven.
  12    * Use of  unreleased  versions  of this so ftware req uires the  user
  13    * to exec ute a writ ten test a greement w ith the Vi stA Imagin g
  14    * Develop ment Offic e of the D epartment  of Veteran s Affairs,
  15    * telepho ne (301) 7 34-0100.
  16    * 
  17    * The Foo d and Drug  Administr ation clas sifies thi s software  as
  18    * a Class  II medica l device.   As such,  it may not  be change d
  19    * in any  way.  Modi fications  to this so ftware may  result in  an
  20    * adulter ated medic al device  under 21CF R820, the  use of whi ch
  21    * is cons idered to  be a viola tion of US  Federal S tatutes.
  22    * ------- ---------- ---------- ---------- ---------- ---------- -------
  23    */
  24   package go v.va.med.i maging.cor e.interfac es.router;
  25  
  26   import gov .va.med.im aging.core .interface s.Router;
  27  
  28   import jav a.lang.ref lect.Metho d;
  29   import jav a.util.Col lection;
  30   import jav a.util.Has hMap;
  31   import jav a.util.Ite rator;
  32   import jav a.util.Map ;
  33  
  34   import jav ax.managem ent.Attrib ute;
  35   import jav ax.managem ent.Attrib uteList;
  36   import jav ax.managem ent.Attrib uteNotFoun dException ;
  37   import jav ax.managem ent.Dynami cMBean;
  38   import jav ax.managem ent.Invali dAttribute ValueExcep tion;
  39   import jav ax.managem ent.MBeanA ttributeIn fo;
  40   import jav ax.managem ent.MBeanC onstructor Info;
  41   import jav ax.managem ent.MBeanE xception;
  42   import jav ax.managem ent.MBeanI nfo;
  43   import jav ax.managem ent.MBeanN otificatio nInfo;
  44   import jav ax.managem ent.MBeanO perationIn fo;
  45   import jav ax.managem ent.Reflec tionExcept ion;
  46  
  47   import org .apache.lo gging.log4 j.LogManag er;
  48   import org .apache.lo gging.log4 j.Logger;
  49   import org .springfra mework.aop .AfterRetu rningAdvic e;
  50   import org .springfra mework.aop .MethodBef oreAdvice;
  51   import org .springfra mework.aop .ThrowsAdv ice;
  52  
  53   /**
  54    * @author         
BECKEC
  55    *
  56    */
  57   public cla ss RouterS tatisticsA dvice 
  58   implements  MethodBef oreAdvice,  AfterRetu rningAdvic e, ThrowsA dvice, Dyn amicMBean
  59   {
  60           pr ivate Map< String, Ro uterMethod Statistics > methodSt atistics;
  61           pr ivate Logg er logger  = LogManag er.getLogg er(this.ge tClass());
  62  
  63           pu blic Route rStatistic sAdvice()
  64       {
  65                    logg er = LogMa nager.getL ogger(this .getClass( ));
  66                    
  67                    getL ogger().in fo("Regist ering moni tored rout er methods .");
  68                    meth odStatisti cs = new H ashMap<Str ing, Route rMethodSta tistics>() ;
  69                    
  70                    Clas s<Router>  routerInte rfaceClass  = Router. class;
  71                    for( Method met hod : rout erInterfac eClass.get DeclaredMe thods() )
  72                    {
  73                             method Statistics .put(metho d.getName( ), new Rou terMethodS tatistics( ) ); 
  74                    }
  75                    
  76                    getL ogger().in fo("Monito red router  methods r egistered,  registeri ng managed  bean.");
  77           }
  78  
  79           pr otected Lo gger getLo gger()
  80           {
  81                    retu rn logger;
  82           }
  83           
  84           /* *
  85            *  Return an  iterator  of all of  the monito red method  names
  86            *  @return
  87            * /
  88           pu blic Itera tor<String > getMonit oredMethod Names()
  89           {
  90                    retu rn methodS tatistics. keySet().i terator();
  91           }
  92  
  93           /* *
  94            *  Get the m ethod stat istics for  the named , monitore d, method  since the  last
  95            *  reset.
  96            *  
  97            *  @param me thodName
  98            *  @return
  99            * /
  100           pu blic Route rMethodSta tistics ge tMethodSta tistics(St ring metho dName)
  101           {
  102                    retu rn methodS tatistics. get(method Name);
  103           }
  104           
  105           /* *
  106            *  reset the  statistic s for the  names meth od
  107            *  @param me thodName
  108            * /
  109           pu blic void  resetMetho dStatistic s(String m ethodName)
  110           {
  111                    meth odStatisti cs.get(met hodName).r eset();
  112           }
  113           
  114           /* *
  115            *  Reset all  of the me thod stati stics
  116            * /
  117           pu blic void  resetAllMe thodStatis tics()
  118           {
  119                    for( String met hodName :  methodStat istics.key Set())
  120                             method Statistics .get(metho dName).res et();
  121           }
  122           
  123           /* *
  124            *  @see org. springfram ework.aop. MethodBefo reAdvice#b efore(java .lang.refl ect.Method , java.lan g.Object[] , java.lan g.Object)
  125            * /
  126           @O verride
  127           pu blic void  before(Met hod method , Object[]  args, Obj ect target
  128           th rows Throw able
  129           {
  130                    Rout erMethodSt atistics m s = method Statistics .get(metho d.getName( ));
  131                    if(m s != null)
  132                    {
  133                             getLog ger().trac e("Before  calling '"  + method. getName()  + "(" + cr eateArgLog gable(args ) + ").");
  134                             ms.inc rementCall edCount();
  135                    }
  136           }
  137  
  138           /* *
  139            *  @see org. springfram ework.aop. AfterRetur ningAdvice #afterRetu rning(java .lang.Obje ct, java.l ang.reflec t.Method,  java.lang. Object[],  java.lang. Object)
  140            * /
  141           @O verride
  142           pu blic void  afterRetur ning(Objec t result,  Method met hod, Objec t[] args,  Object tar get) 
  143           th rows Throw able
  144           {
  145                    Rout erMethodSt atistics m s = method Statistics .get(metho d.getName( ));
  146                    if(m s != null)
  147                    {
  148                             ms.inc rementSucc essCount() ;
  149                             
  150                             if( !  "void".equ als(method .getReturn Type().toS tring()) & & result = = null )
  151                             {
  152                                      getLogge r().trace( "After ret urning fro m '" + met hod.getNam e() + "("  + createAr gLoggable( args) + 
  153                                                       ")  with null  value.");
  154                                      ms.incre mentNullRe sultCount( );
  155                             }
  156                             else
  157                                      getLogge r().trace( "After ret urning fro m '" + met hod.getNam e() + "("  + createAr gLoggable( args) + 
  158                                                       ") , result i s '" + cre ateResultL oggable(re sult) + "' .");
  159                                      
  160                    }
  161           }
  162  
  163           pu blic void  afterThrow ing(Method  method, O bject[] ar gs, Object  target, T hrowable t hrowable) 
  164           th rows Throw able
  165           {
  166                    Rout erMethodSt atistics m s = method Statistics .get(metho d.getName( ));
  167                    if(m s != null)
  168                    {
  169                             getLog ger().trac e("After r eturning f rom '" + m ethod.getN ame() + "( " + create ArgLoggabl e(args) + 
  170                                      ") with  exception  '" + creat eThrowable Loggable(t hrowable)  + "'.");
  171                             ms.inc rementThro wableCount ();
  172                    }
  173           }
  174  
  175           /* *
  176            *  Format an  array of  Object (pa rameters)  into a Str ing.
  177            *  @param ar gs
  178            *  @return
  179            * /
  180           pr ivate Stri ng createA rgLoggable (Object[]  args)
  181       {
  182                    if(a rgs == nul l || args. length ==  0)
  183                             return  "";
  184                    Stri ngBuffer s b = new St ringBuffer ();
  185                    for( Object arg  : args)
  186                    {
  187                             if(sb. length() >  0)
  188                                      sb.appen d(',');
  189                             sb.app end(arg ==  null ? "< null>" : a rg.getClas s().getNam e());
  190                    }
  191                    
  192                return s b.toString ();
  193       }
  194           
  195           /* *
  196            *  
  197            *  @param re sult
  198            *  @return
  199            * /
  200           pr ivate Stri ng createR esultLogga ble(Object  result)
  201       {
  202                    if(r esult == n ull)
  203                             return  "null";
  204                    
  205                    if(r esult inst anceof Col lection<?> )
  206                             return  "collecti on of " +  ((Collecti on<?>)resu lt).size()  + " entri es";
  207                    if(r esult inst anceof Map <?, ?>)
  208                             return  "map of "  + ((Map<? , ?>)resul t).size()  + " entrie s";
  209                    
  210                    retu rn result. getClass() .getName() ;
  211       }
  212  
  213           /* *
  214            *  NOTE: rec ursive met hod (follo ws getCaus e() chain)
  215            *  @param th rowable
  216            *  @return
  217            * /
  218           pr ivate Stri ng createT hrowableLo ggable(Thr owable thr owable)
  219       {
  220                    if(t hrowable = = null)
  221                             return  "<null (t his should  not happe n!>";
  222                    
  223                    Stri ngBuffer s b = new St ringBuffer ();
  224                    
  225                    sb.a ppend(thro wable.getC lass().get Name());
  226                    sb.a ppend(':') ;
  227                    sb.a ppend(thro wable.getM essage());
  228                    if(t hrowable.g etCause()  != null)
  229                    {
  230                             sb.app end(", cau sed by ");
  231                             sb.app end( creat eThrowable Loggable(t hrowable.g etCause())  );
  232                    }
  233                return s b.toString ();
  234       }
  235           
  236           @O verride
  237           pu blic Strin g toString ()
  238           {
  239                    Stri ngBuffer s b = new St ringBuffer ();
  240                    Stri ng lineBre ak = Syste m.getPrope rty("line. seperator" );
  241                    
  242                    for( String met hodName :  methodStat istics.key Set())
  243                    {
  244                             sb.app end(method Name);
  245                             sb.app end('[');
  246                             sb.app end(method Statistics .get(metho dName).toS tring());
  247                             sb.app end(']');
  248                             sb.app end(lineBr eak);
  249                    }
  250                    
  251                    retu rn sb.toSt ring();
  252           }
  253  
  254           //  ========= ========== ========== ========== ========== ========== ========== ========== ========== =====
  255           //  Dynamic M Bean Imple mentation
  256           //  ========= ========== ========== ========== ========== ========== ========== ========== ========== =====
  257  
  258           /* *
  259            *  Obtain th e value of  a specifi c attribut e of the D ynamic MBe an. 
  260            * /
  261           @O verride
  262       public  Object ge tAttribute (String at tribute) 
  263           th rows Attri buteNotFou ndExceptio n, MBeanEx ception, R eflectionE xception
  264       {
  265                    Stri ng methodN ame = pars eMethodNam e(attribut e);
  266                    Stri ng dataPoi ntName = p arseDataPo int(attrib ute);
  267                    
  268                    if(m ethodName  != null &&  dataPoint Name != nu ll)
  269                    {
  270                             Router MethodStat istics sta ts = this. methodStat istics.get (methodNam e);
  271                             if(sta ts != null )
  272                             {
  273                                      Method g etterMetho d = dataPo intGetterM ethod(data PointName) ;
  274                                      try
  275                    {
  276                             return  getterMet hod.invoke (stats, (O bject[])nu ll);
  277                    } 
  278                                      catch (E xception e )
  279                    {
  280                                               LogManager .getLogger (RouterSta tisticsAdv ice.class) .error("Ex ception '"  + e.getMe ssage() +  "', gettin g '" + att ribute + " '.");
  281                    }
  282                             }
  283                    }
  284                    
  285                return n ull;
  286       }
  287  
  288           /* *
  289            *  Get the v alues of s everal att ributes of  the Dynam ic MBean. 
  290            *  @see java x.manageme nt.Dynamic MBean#getA ttributes( java.lang. String[])
  291            * /
  292           @O verride
  293       public  Attribute List getAt tributes(S tring[] at tributes)
  294       {
  295                    Attr ibuteList  result = n ew Attribu teList();
  296                    
  297                    for( String att ribute : a ttributes)
  298                    try
  299                {
  300                         result.add (new Attri bute(attri bute, getA ttribute(a ttribute)) );
  301                } 
  302                             catch  (Exception  e)
  303                {
  304                                      LogManag er.getLogg er(RouterS tatisticsA dvice.clas s).error(" Exception  '" + e.get Message()  + "', gett ing '" + a ttribute +  "'.");
  305                }
  306                             
  307                    retu rn result;
  308       }
  309  
  310           /* *
  311            *  Allows an  action to  be invoke d on the D ynamic MBe an. 
  312            *  @see java x.manageme nt.Dynamic MBean#invo ke(java.la ng.String,  java.lang .Object[],  java.lang .String[])
  313            * /
  314           @O verride
  315       public  Object in voke(Strin g actionNa me, Object [] params,  String[]  signature)  
  316           th rows MBean Exception,  Reflectio nException
  317       {
  318                    if(" resetAllMe thodStatis tics".equa ls(actionN ame) && (p arams == n ull || par ams.length  == 0) )
  319                             resetA llMethodSt atistics() ;
  320                    
  321                return n ull;
  322       }
  323  
  324           /* *
  325            *  Set the v alue of a  specific a ttribute o f the Dyna mic MBean.  
  326            *  
  327            *  @see java x.manageme nt.Dynamic MBean#setA ttribute(j avax.manag ement.Attr ibute)
  328            * /
  329           @O verride
  330       public  void setA ttribute(A ttribute a ttribute) 
  331           th rows Attri buteNotFou ndExceptio n, Invalid AttributeV alueExcept ion, MBean Exception,  Reflectio nException
  332       {
  333                
  334       }
  335  
  336           /* *
  337            *  Sets the  values of  several at tributes o f the Dyna mic MBean.  
  338            *  @see java x.manageme nt.Dynamic MBean#setA ttributes( javax.mana gement.Att ributeList )
  339            * /
  340           @O verride
  341       public  Attribute List setAt tributes(A ttributeLi st attribu tes)
  342       {
  343                return n ull;
  344       }
  345           
  346           /* *
  347            *  Provides  the expose d attribut es and act ions of th e Dynamic  MBean usin g an MBean Info objec t. 
  348            *  @see java x.manageme nt.Dynamic MBean#getM BeanInfo()
  349            * /
  350           @O verride
  351       public  MBeanInfo  getMBeanI nfo()
  352       {
  353                    MBea nConstruct orInfo[] c onstructor s = null;
  354                    MBea nAttribute Info[] att ributes =  getMBeanAt tributes() ;
  355                    MBea nOperation Info[] ope rations =  getMBeanOp erations() ;
  356                    MBea nNotificat ionInfo[]  notificati ons = null ;
  357                    
  358                    MBea nInfo info  = new MBe anInfo(
  359                                      this.get Class().ge tName(), 
  360                                      "Router  Statistics ", 
  361                                      attribut es, 
  362                                      construc tors, 
  363                                      operatio ns, 
  364                                      notifica tions);
  365                    
  366                return i nfo;
  367       }
  368  
  369           //  this valu e must mat ch the num ber of dat a points e ach method  provides
  370           //  which is  the same a s the numb er of gett ers in the  RouterMet hodStatist ics class
  371           pr ivate stat ic Class<? > routerMe thodStatis ticsClass;
  372           pr ivate stat ic Method[ ] routerMe thodDataPo ints;
  373           
  374           st atic
  375           {
  376                    try
  377                    {
  378                             router MethodStat isticsClas s = Router MethodStat istics.cla ss;
  379                             router MethodData Points = n ew Method[ ]
  380                             {
  381                                      routerMe thodStatis ticsClass. getMethod( "getCalled Count", (C lass<?>[]) null),
  382                                      routerMe thodStatis ticsClass. getMethod( "getSucces sCount", ( Class<?>[] )null),
  383                                      routerMe thodStatis ticsClass. getMethod( "getThrowa bleCount",  (Class<?> [])null),
  384                                      routerMe thodStatis ticsClass. getMethod( "getNullRe sultCount" , (Class<? >[])null),
  385                                      routerMe thodStatis ticsClass. getMethod( "getResetT ime", (Cla ss<?>[])nu ll)
  386                             };
  387                    }
  388                    catc h(Exceptio n x)
  389                    {
  390                             LogMan ager.getLo gger(Route rStatistic sAdvice.cl ass).error ("Exceptio n '" + x.g etMessage( ) + "', in itializing  router st atistics a dvice.");
  391                    }
  392           }
  393           
  394           pr ivate MBea nAttribute Info[] get MBeanAttri butes()
  395       {
  396                    // e ach method  on which  we gather  statistics  provide f ive data p oints;
  397                    // c alls, succ ess, null  results, t hrowable a nd reset t ime
  398                    MBea nAttribute Info[] att ributes =  new MBeanA ttributeIn fo[this.me thodStatis tics.size( ) * router MethodData Points.len gth];
  399                    int  methodInde x = 0;
  400                    for( String met hodName :  this.metho dStatistic s.keySet() )
  401                    {
  402                             int da taPointInd ex = 0;
  403                             for(Me thod dataP ointMethod  : routerM ethodDataP oints)
  404                             {
  405                                      String a ttributeNa me = makeA ttributeNa me(methodN ame, dataP ointMethod .getName() );
  406                                      MBeanAtt ributeInfo  attribute Info = new  MBeanAttr ibuteInfo(
  407                                                       at tributeNam e, 
  408                                                       da taPointMet hod.getRet urnType(). getName(),  
  409                                                       "" , true, fa lse, false );
  410                                      attribut es[(method Index * ro uterMethod DataPoints .length) +  dataPoint Index] = a ttributeIn fo;
  411                                      ++dataPo intIndex;
  412                             }
  413                             ++meth odIndex;
  414                    }
  415                    
  416                return a ttributes;
  417       }
  418  
  419           pr ivate MBea nOperation Info[] get MBeanOpera tions()
  420       {
  421                    Meth od resetMe thod;
  422           tr y
  423           {
  424                    rese tMethod =  this.getCl ass().getM ethod("res etAllMetho dStatistic s", (Class <?>[])null );
  425                    
  426                    retu rn new MBe anOperatio nInfo[]
  427                    {
  428                             new MB eanOperati onInfo("Re set all me thod count ers.", res etMethod)
  429                    };
  430           } 
  431           ca tch (Excep tion e)
  432           {
  433                    LogM anager.get Logger(thi s.getClass ()).error( "Exception  '" + e.ge tMessage()  + "' find ing operat ions.");
  434                    retu rn null;
  435           }
  436       }
  437  
  438           //  ========= ========== ========== ========== ========== ========== ========== ====
  439           //  Helper Me thods to c reate and  parse meth od and dat a points i nto attrib utes
  440           //  ========= ========== ========== ========== ========== ========== ========== ====
  441           pr ivate stat ic final S tring attr ibuteNameD elimiter =  "_";
  442           
  443           pr ivate Stri ng makeAtt ributeName (String me thodName,  String dat aPoint)
  444           {
  445                    retu rn methodN ame.indexO f(attribut eNameDelim iter) >= 0  ? null :
  446                             dataPo int.indexO f(attribut eNameDelim iter) >= 0  ? null :
  447                             method Name + att ributeName Delimiter  + dataPoin t;
  448           }
  449           
  450           pr ivate Stri ng parseMe thodName(S tring attr ibuteName)
  451           {
  452                    Stri ng[] parts  = attribu teName.spl it(attribu teNameDeli miter);
  453                    if(p arts.lengt h == 2)
  454                             return  parts[0];
  455                    
  456                    retu rn null;
  457           }
  458           
  459           pr ivate Stri ng parseDa taPoint(St ring attri buteName)
  460           {
  461                    Stri ng[] parts  = attribu teName.spl it(attribu teNameDeli miter);
  462                    if(p arts.lengt h == 2)
  463                             return  parts[1];
  464                    
  465                    retu rn null;
  466           }
  467           
  468           pr ivate Meth od dataPoi ntGetterMe thod(Strin g dataPoin tName)
  469           {
  470                    if(d ataPointNa me != null )
  471                             for(Me thod metho d : router MethodData Points)
  472                                      if(dataP ointName.e quals(meth od.getName ()))
  473                                               return met hod;
  474                    
  475                    retu rn null;
  476           }
  477   }