48. EPMO Open Source Coordination Office Redaction File Detail Report

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

48.1 Files compared

# Location File Last Modified
1 IV-eHMP_CIF.zip\IMAG_Source\VISA\Java\CacheImpl\main\src\java\gov\va\med\imaging\storage\cache\impl\jmx AbstractCacheMBean.java Mon Dec 4 21:35:28 2017 UTC
2 IV-eHMP_CIF.zip\IMAG_Source\VISA\Java\CacheImpl\main\src\java\gov\va\med\imaging\storage\cache\impl\jmx AbstractCacheMBean.java Mon Dec 4 21:57:39 2017 UTC

48.2 Comparison summary

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

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

48.4 Active regular expressions

No regular expressions were active.

48.5 Comparison detail

  1   package go v.va.med.i maging.sto rage.cache .impl.jmx;
  2  
  3   import jav a.lang.ref lect.Invoc ationTarge tException ;
  4   import jav a.lang.ref lect.Metho d;
  5   import jav a.text.Dat eFormat;
  6   import jav a.text.Sim pleDateFor mat;
  7   import jav a.util.Ite rator;
  8  
  9   import jav ax.managem ent.*;
  10  
  11   import org .apache.lo gging.log4 j.LogManag er;
  12   import org .apache.lo gging.log4 j.Logger;
  13  
  14   /**
  15    * 
  16    * @author         
BECKEC
  17    *
  18    */
  19   public abs tract clas s Abstract CacheMBean
  20   implements  DynamicMB ean
  21   {
  22           pr ivate Logg er logger  = LogManag er.getLogg er(this.ge tClass());
  23           pr ivate Date Format dat eFormat =  new Simple DateFormat ("ddMMMyyy y hh:mm:ss ");
  24  
  25           /* *
  26            *  If this c onstructor  is used t hen the ma naged obje ct MUST be  set
  27            *  before ca lling anyt hing else  in this cl ass.
  28            *  If possib le it is s afer to us e the Abst ractCacheM Bean(Objec t managedO bject)
  29            *  construct or.
  30            * /
  31           pr otected Ab stractCach eMBean()
  32           {
  33           }
  34  
  35           pu blic abstr act MBeanI nfo getMBe anInfo();
  36  
  37           pr otected Da teFormat g etDateForm at()
  38           {
  39                    retu rn dateFor mat;
  40           }
  41           
  42           /* *
  43            *  
  44            * /
  45           pu blic Objec t getAttri bute(Strin g attribut e) 
  46           th rows Attri buteNotFou ndExceptio n, MBeanEx ception, R eflectionE xception
  47           {
  48                    if(a ttribute = = null)
  49                             throw  new Attrib uteNotFoun dException ("<null> a ttribute n ame not al lowed.");
  50                    
  51                    MBea nAttribute Info attri buteInfo =  getAttrib uteInfo(at tribute);
  52                    
  53                    if(a ttributeIn fo == null )
  54                             throw  new Attrib uteNotFoun dException ("Attribut e '" + att ribute + " ' is not d efined in  '" + this. getClass() .getName()  + "'");
  55                    
  56                    Stri ng getterN ame = crea teGetterNa me(attribu teInfo.get Name(), at tributeInf o.isIs());
  57                    
  58                    retu rn getAttr ibute(gett erName, at tributeInf o.getType( ), this, t his.getCla ss(), attr ibuteInfo. isIs()); 
  59           }
  60  
  61           /* *
  62            *  @param at tributeInf o
  63            *  @param ta rgetInstan ce
  64            *  @param ta rgetClass
  65            *  @throws M BeanExcept ion 
  66            * /
  67           pr ivate Obje ct getAttr ibute(Stri ng getterN ame, Strin g returnCl ass, Objec t targetIn stance, Cl ass target Class, boo lean isIs)  
  68           th rows MBean Exception
  69           {
  70                    Obje ct retValu e = null;
  71                    try
  72                    {
  73                             Method  getterMet hod = targ etClass.ge tMethod( g etterName,  (Class[]) null);
  74                             Object  result =  getterMeth od.invoke( targetInst ance, (Obj ect[])null );
  75                             
  76                             Class  returnType  = Class.f orName(ret urnClass);
  77                             try
  78                             {
  79                                      retValue  = returnT ype.cast(r esult);
  80                             } 
  81                             catch  (ClassCast Exception  e)
  82                             {
  83                                      if(retur nType.equa ls(String. class))
  84                                               retValue =  result.to String();
  85                             }
  86                             
  87                             return  retValue;
  88                    } 
  89                    catc h(Exceptio n e)
  90                    {
  91                             logger .error("In voking att ribute get ter method  '" + gett erName + " ' on class  '" + targ etClass.ge tName() +  "' resulte d in error ", e);
  92                             throw  new MBeanE xception(e );
  93                    }
  94                    
  95           }
  96  
  97           /* *
  98            *  
  99            * /
  100           pu blic Attri buteList g etAttribut es(String[ ] attribut es)
  101           {
  102                    Attr ibuteList  attributeL ist = new  AttributeL ist();
  103                    
  104                    for( String att ribute: at tributes)
  105                    {
  106                             try
  107                             {
  108                                      attribut eList.add( new Attrib ute(attrib ute, getAt tribute(at tribute))) ;
  109                             } 
  110                             catch  (Attribute NotFoundEx ception e)
  111                             {
  112                                      e.printS tackTrace( );
  113                             } 
  114                             catch  (MBeanExce ption e)
  115                             {
  116                                      e.printS tackTrace( );
  117                             } 
  118                             catch  (Reflectio nException  e)
  119                             {
  120                                      e.printS tackTrace( );
  121                             }
  122                    }
  123                    retu rn attribu teList;
  124           }
  125  
  126           //  ========= ========== ========== ========== ========== ========== ========== ========== ========== ==
  127           //  MBean set Attribute( ) Methods
  128           //  ========= ========== ========== ========== ========== ========== ========== ========== ========== ==
  129           /* *
  130            *  
  131            * /
  132           pu blic void  setAttribu te(Attribu te attribu te) 
  133           th rows Attri buteNotFou ndExceptio n, Invalid AttributeV alueExcept ion, MBean Exception,  Reflectio nException
  134           {
  135                    if(a ttribute = = null ||  attribute. getName()  == null)
  136                             throw  new Attrib uteNotFoun dException ("<null> a ttribute n ame not al lowed.");
  137                    
  138                    Stri ng attribu teName = a ttribute.g etName();
  139                    MBea nAttribute Info attri buteInfo =  getAttrib uteInfo(at tributeNam e);
  140                    
  141                    if(a ttributeIn fo == null )
  142                             throw  new Attrib uteNotFoun dException ("Cache at tribute '"  + attribu teName + " ' is not d efined in  '" + this. getClass() .getName()  + "'");
  143                    
  144                    Stri ng setterN ame = crea teSetterNa me(attribu teInfo.get Name());
  145                    logg er.debug(" Setting at tribute '"  + attribu te.getName () + "' to  value '"  + attribut e.getValue () + "'.") ;
  146                    setA ttribute(s etterName,  attribute Info.getTy pe(), attr ibute.getV alue(), th is, this.g etClass()) ;
  147           }
  148  
  149           /* *
  150            *  
  151            *  @param se tterName
  152            *  @param ta rgetInstan ce
  153            *  @param ta rgetClass
  154            *  @throws M BeanExcept ion
  155            * /
  156           pr ivate void  setAttrib ute(String  setterNam e, String  attributeT ypeName, O bject valu e, Object  targetInst ance, Clas s targetCl ass) 
  157           th rows MBean Exception
  158           {
  159                    try
  160                    {
  161                             Class  attributeT ype = Clas s.forName( attributeT ypeName); 
  162                             Method  setterMet hod = targ etClass.ge tMethod( s etterName,  new Class []{attribu teType});
  163                             
  164                             setter Method.inv oke(target Instance,  new Object []{value}) ;
  165                    } 
  166                    catc h(Exceptio n e)
  167                    {
  168                             logger .error("In voking att ribute get ter method  '" + sett erName + " ' on class  '" + targ etClass.ge tName() +  "' resulte d in error ", e);
  169                             throw  new MBeanE xception(e );
  170                    }
  171                    
  172           }
  173           
  174           
  175           /* *
  176            *  
  177            * /
  178           pu blic Attri buteList s etAttribut es(Attribu teList att ributes)
  179           {
  180                    Attr ibuteList  resultingA ttributes  = new Attr ibuteList( );
  181                    for( Iterator i ter = attr ibutes.ite rator(); i ter.hasNex t(); )
  182                    {
  183                             try
  184                             {
  185                                      Attribut e attribut e = (Attri bute)iter. next(); 
  186                                      setAttri bute( attr ibute );
  187                                      resultin gAttribute s.add(attr ibute);
  188                             } 
  189                             catch  (Attribute NotFoundEx ception e)
  190                             {
  191                                      e.printS tackTrace( );
  192                             } 
  193                             catch  (InvalidAt tributeVal ueExceptio n e)
  194                             {
  195                                      e.printS tackTrace( );
  196                             } 
  197                             catch  (MBeanExce ption e)
  198                             {
  199                                      e.printS tackTrace( );
  200                             } 
  201                             catch  (Reflectio nException  e)
  202                             {
  203                                      e.printS tackTrace( );
  204                             }
  205                    }
  206                    retu rn resulti ngAttribut es;
  207           }
  208  
  209           //  ========= ========== ========== ========== ========== ========== ========== ========== ========== ==
  210           //  MBean Ope rations Me thods
  211           //  ========= ========== ========== ========== ========== ========== ========== ========== ========== ==
  212           /* *
  213            *  
  214            * /
  215           pu blic Objec t invoke(S tring acti onName, Ob ject[] par ams, Strin g[] signat ure) 
  216           th rows MBean Exception,  Reflectio nException
  217           {
  218                    MBea nOperation Info opera tionInfo =  getOperat ionInfo(ac tionName,  params);
  219                    if(o perationIn fo != null )
  220                    {
  221                             Class[ ] methodPa rameters =  getParame terTypes(o perationIn fo);
  222                             try
  223                             {
  224                                      Method m ethod = th is.getClas s().getMet hod(operat ionInfo.ge tName(), m ethodParam eters);
  225                                      Object r etVal = me thod.invok e(this, pa rams);
  226                                      
  227                                      return r etVal;
  228                             } 
  229                             catch  (SecurityE xception e )
  230                             {
  231                                      logger.e rror(e);
  232                                      throw ne w Reflecti onExceptio n(e);
  233                             } 
  234                             catch  (NoSuchMet hodExcepti on e)
  235                             {
  236                                      logger.e rror(e);
  237                                      throw ne w Reflecti onExceptio n(e);
  238                             } 
  239                             catch  (IllegalAr gumentExce ption e)
  240                             {
  241                                      logger.e rror(e);
  242                                      throw ne w Reflecti onExceptio n(e);
  243                             } 
  244                             catch  (IllegalAc cessExcept ion e)
  245                             {
  246                                      logger.e rror(e);
  247                                      throw ne w Reflecti onExceptio n(e);
  248                             } 
  249                             catch  (Invocatio nTargetExc eption e)
  250                             {
  251                                      logger.e rror(e);
  252                                      throw ne w Reflecti onExceptio n(e);
  253                             }
  254                    }
  255                    retu rn null;
  256           }
  257  
  258           //  ========= ========== ========== ========== ========== ========== ========== ========== ========== ==
  259           //  Helper Me thods
  260           //  ========= ========== ========== ========== ========== ========== ========== ========== ========== ==
  261           pr ivate Stri ng createG etterName( String att ributeName , boolean  isIs)
  262           {
  263                    if(a ttributeNa me == null  || attrib uteName.le ngth() < 1 )
  264                             return  null;
  265                    
  266                    retu rn (isIs ?  "is" : "g et") + 
  267                                      Characte r.toUpperC ase(attrib uteName.ch arAt(0)) +  
  268                                      attribut eName.subs tring(1);
  269           }
  270           
  271           pr ivate Stri ng createS etterName( String att ributeName )
  272           {
  273                    if(a ttributeNa me == null  || attrib uteName.le ngth() < 1 )
  274                             return  null;
  275                    
  276                    retu rn "set" +  Character .toUpperCa se(attribu teName.cha rAt(0)) +  attributeN ame.substr ing(1);
  277           }
  278           
  279           pr ivate MBea nAttribute Info getAt tributeInf o(String a ttribute)
  280           {
  281                    if(a ttribute = = null)
  282                             return  null;
  283                    
  284                    for( MBeanAttri buteInfo a ttributeIn fo:getMBea nInfo().ge tAttribute s())
  285                    {
  286                             if( at tributeInf o.getName( ).equals(a ttribute)  )
  287                             {
  288                                      logger.d ebug("Requ ested attr ibute '" +  attribute  +"' found  in manage d list.");
  289                                      return a ttributeIn fo;
  290                             }
  291                    }
  292                    
  293                    logg er.debug(" Requested  attribute  '" + attri bute +"' N OT found i n managed  list.");
  294                    retu rn null;
  295           }
  296           
  297           pr ivate MBea nOperation Info getOp erationInf o(String o peration,  Object[] p arameters)
  298           {
  299                    if(o peration = = null)
  300                             return  null;
  301                    
  302                    for( MBeanOpera tionInfo o perationIn fo:getMBea nInfo().ge tOperation s())
  303                    {
  304                             if( op erationInf o.getName( ).equals(o peration)  )
  305                             {
  306                                      MBeanPar ameterInfo [] paramet ersInfo =  operationI nfo.getSig nature();
  307                                      int para metersInde x = 0;
  308                                      for(MBea nParameter Info param eterInfo:  parameters Info)
  309                                      {
  310                                               if( ! para meterInfo. getClass() .isAssigna bleFrom(pa rameters[p arametersI ndex].getC lass()) )
  311                                                       br eak;
  312                                               ++paramete rsIndex;
  313                                      }
  314                                      
  315                                      if(param etersIndex  >= operat ionInfo.ge tSignature ().length  )
  316                                      {
  317                                               logger.deb ug("Reques ted operat ion '" + o peration + "' found i n managed  list.");
  318                                               return ope rationInfo ;
  319                                      }
  320                             }
  321                    }
  322                    
  323                    logg er.debug(" Requested  operation  '" + opera tion +"' N OT found i n managed  list.");
  324                    retu rn null;
  325           }
  326           
  327           /* *
  328            *  Extract t he paramet er types ( classes) f rom an MBe anOperatio nInfo inst ance
  329            *  to use in  finding t he actual  method to  call.
  330            *  
  331            *  @param op erationInf o
  332            *  @return
  333            * /
  334           pr ivate Clas s[] getPar ameterType s(MBeanOpe rationInfo  operation Info)
  335           {
  336                    Clas s[] retVal  = new Cla ss[operati onInfo.get Signature( ).length];
  337                    int  parameterI ndex = 0;
  338                    for( MBeanParam eterInfo p arameter:  operationI nfo.getSig nature() )
  339                             retVal [parameter Index++] =  parameter .getClass( );
  340                    
  341                    retu rn retVal;
  342           }
  343   }