246. EPMO Open Source Coordination Office Redaction File Detail Report

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

246.1 Files compared

# Location File Last Modified
1 IV-eHMP_CIF.zip\IMAG_Source\VISA\Java\ImagingCacheImpl\main\src\java\gov\va\med\imaging\storage\cache\impl CacheManagerImpl.java Mon Dec 4 21:35:30 2017 UTC
2 IV-eHMP_CIF.zip\IMAG_Source\VISA\Java\ImagingCacheImpl\main\src\java\gov\va\med\imaging\storage\cache\impl CacheManagerImpl.java Mon Dec 4 22:01:31 2017 UTC

246.2 Comparison summary

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

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

246.4 Active regular expressions

No regular expressions were active.

246.5 Comparison detail

  1   package go v.va.med.i maging.sto rage.cache .impl;
  2  
  3   import gov .va.med.im aging.stor age.cache. *;
  4   import gov .va.med.im aging.stor age.cache. exceptions .CacheExce ption;
  5   import gov .va.med.im aging.stor age.cache. exceptions .CacheInit ialization Exception;
  6   import gov .va.med.im aging.stor age.cache. exceptions .CacheStat eException ;
  7   import gov .va.med.im aging.stor age.cache. impl.evict ion.Evicti onStrategy Factory;
  8   import gov .va.med.im aging.stor age.cache. impl.files ystem.File SystemCach e;
  9   import gov .va.med.im aging.stor age.cache. impl.jmx.A bstractCac heMBean;
  10   import gov .va.med.im aging.stor age.cache. memento.Ev ictionStra tegyMement o;
  11   import gov .va.med.se rver.Serve rLifecycle Event;
  12   import gov .va.med.se rver.Serve rLifecycle Listener;
  13  
  14   import jav a.io.File;
  15   import jav a.io.FileN otFoundExc eption;
  16   import jav a.io.IOExc eption;
  17   import jav a.io.Input Stream;
  18   import jav a.lang.man agement.Ma nagementFa ctory;
  19   import jav a.net.URI;
  20   import jav a.net.URIS yntaxExcep tion;
  21   import jav a.util.Arr ayList;
  22   import jav a.util.Lis t;
  23  
  24   import jav ax.managem ent.*;
  25   import jav ax.managem ent.openmb ean.*;
  26  
  27   import org .apache.lo gging.log4 j.LogManag er;
  28   import org .apache.lo gging.log4 j.Logger;
  29  
  30   /**
  31    * Cache i nstances m ust be cre ated throu gh this cl ass, not d irectly.  
  32    * This cl ass is the  interface  for the c ache lifec ycle and a lso for th e manageme nt and mon itoring of  the 
  33    * lifecyc le and par ameter per sistence m ethods of  a Cache in stance.
  34    * 
  35    * This cl ass also i s responsi ble for st oring and  loading th e FileSyst emCache st ate and fo r
  36    * restori ng the sta te of the  cache when  it is rec reated.
  37    * 
  38    * The Cac heManagerI mpl single ton may ma nage a num ber of cac he instanc es, each i dentified
  39    * by name .  This cl ass (Cache Factory) u ses the na me as iden tified in  the resour ce
  40    * declara tion as th e cache na me it need s from Cac heManagerI mpl.
  41    * 
  42    * The Cac heManagerI mpl manage s the life cycle and  the config uration of  the Cache
  43    * regardl ess of whe ther an MB eanServer  is availab le.  The C acheManage rImpl must  be
  44    * instant iated and  it must be  used for  Cache conf iguration,  not direc t
  45    * Cache a ccess.
  46    * 
  47    * @author         
BECKEC
  48    *
  49    */
  50   public cla ss CacheMa nagerImpl
  51   extends Ab stractCach eMBean
  52   implements  ServerLif ecycleList ener, Cach eStructure ChangeList ener, Cach eManager
  53   {
  54           pr ivate stat ic CacheMa nagerImpl  singleton;                // the  single in stance of  this class
  55           
  56           pr ivate Logg er logger  = LogManag er.getLogg er(this.ge tClass());
  57           pr ivate bool ean server Running =  false;                             // we ma y delay st arting the  managed c aches so w e set this  when we g et the sta rt
  58           pr ivate Know nCacheList  knownCach es;                                         // A list  of all the  caches th at this ma nager know s about, t his class  keeps the
  59                                                                                                                              // confi gurations  in the con fig direct ory consis tent with  the transi ent
  60                                                                                                                              // list  of caches.
  61           
  62           pu blic stati c final St ring defau ltConfigur ationDirec toryName =  "/vix";
  63           pu blic stati c final St ring cache Configurat ionSubdire ctoryName  = "cache-c onfig";
  64           
  65           pr ivate Cach e activeCa che;               //  used in i nteractive  managemen t, not use d in norma l operatio n
  66           
  67           /* *
  68            *  This clas s is a sin gleton bec ause the c ache insta nces may b e shared a cross mult iple web a pps 
  69            *  but each  cache must  behave wi th synchro nicity wit h respect  to its nam e as the p rimary key .
  70            *    
  71            *  @return
  72            *  @throws M BeanExcept ion
  73            *  @throws C acheExcept ion 
  74            * /
  75           pu blic stati c synchron ized Cache ManagerImp l getSingl eton() 
  76           th rows MBean Exception,  CacheExce ption
  77           {
  78                    if(s ingleton = = null)
  79                             single ton = new  CacheManag erImpl();
  80                    
  81                    retu rn singlet on;
  82           }
  83  
  84           /* *
  85            *  @throws M BeanExcept ion 
  86            *  @throws C acheInitia lizationEx ception 
  87            *  
  88            *
  89            * /
  90           pr ivate Cach eManagerIm pl() 
  91           th rows Cache Exception,  MBeanExce ption 
  92           {
  93                    know nCaches =  new KnownC acheList(g etConfigur ationDirec tory());
  94                    
  95                    regi sterCacheM anagerMBea n();             // r egister ou rselves as  an MBean
  96                    // r egister th e known ca ches so th at they ar e manageab le
  97                    for( Cache cach e : knownC aches)
  98                             regist erCacheMBe ans(cache) ;
  99           }
  100           
  101           /*  (non-Java doc)
  102            *  @see gov. va.med.ima ging.stora ge.cache.i mpl.ICache Manager#ge tKnownCach es()
  103            * /
  104           pu blic Known CacheList  getKnownCa ches()
  105           {
  106                    retu rn this.kn ownCaches;
  107           }
  108           
  109           pu blic Cache  getActive Cache()
  110           {
  111                    retu rn activeC ache;
  112           }
  113           
  114           pu blic void  setActiveC ache(Cache  activeCac he)
  115           {
  116                    this .activeCac he = activ eCache;
  117           }
  118  
  119  
  120           pu blic Cache  createCac he(String  name, URI  locationUr i) 
  121           th rows MBean Exception,  CacheExce ption, URI SyntaxExce ption, IOE xception
  122           {
  123                    retu rn createC ache(name,  locationU ri, (Strin g)null);
  124           }
  125           
  126           /*  (non-Java doc)
  127            *  @see gov. va.med.ima ging.stora ge.cache.i mpl.ICache Manager#cr eateCache( java.lang. String, ja va.net.URI , java.lan g.String)
  128            * /
  129           pu blic Cache  createCac he(String  name, URI  locationUr i, String  prototypeN ame) 
  130           th rows MBean Exception,  CacheExce ption, URI SyntaxExce ption, IOE xception
  131           {
  132                    Cach e cache =  getKnownCa ches().cre ate(name,  locationUr i, prototy peName);
  133                    
  134                    // r egister th e newly cr eated cach e so that  it is mana geable
  135                    regi sterCacheM Beans(cach e);
  136                    
  137                    retu rn cache;
  138           }
  139  
  140           pu blic Cache  createCac he(String  name, URI  locationUr i, InputSt ream proto type) 
  141           th rows MBean Exception,  CacheExce ption, URI SyntaxExce ption, IOE xception
  142           {
  143                    Cach e cache =  getKnownCa ches().cre ate(name,  locationUr i, prototy pe);
  144                    
  145                    // r egister th e newly cr eated cach e so that  it is mana geable
  146                    regi sterCacheM Beans(cach e);
  147                    
  148                    retu rn cache;
  149           }
  150  
  151           /*  (non-Java doc)
  152            *  @see gov. va.med.ima ging.stora ge.cache.i mpl.ICache Manager#ge tCache(jav a.lang.Str ing)
  153            * /
  154           pu blic Cache  getCache( String cac heName) 
  155           th rows FileN otFoundExc eption, IO Exception,  MBeanExce ption, Cac heExceptio n
  156           {
  157                    Cach e cache =  knownCache s.get(cach eName);
  158                    retu rn cache;
  159           }
  160           
  161           //  ========= ========== ========== ========== ========== ========== ========== ========== ========== === 
  162           //  Basic Cac he managem ent method s made ava ilable her e so that  tests can  get a runn ing cache
  163           //  ========= ========== ========== ========== ========== ========== ========== ========== ========== ===
  164           /*  (non-Java doc)
  165            *  @see gov. va.med.ima ging.stora ge.cache.i mpl.filesy stem.Cache Manager#in itialize()
  166            * /
  167           /*  (non-Java doc)
  168            *  @see gov. va.med.ima ging.stora ge.cache.i mpl.ICache Manager#in itialize(g ov.va.med. imaging.st orage.cach e.Cache)
  169            * /
  170           pu blic Strin g initiali ze(Cache c ache)
  171           {
  172                    try
  173                    {
  174                             if(! c ache.isIni tialized() )
  175                             {
  176                                      cache.se tInitializ ed(Boolean .TRUE);
  177                                      if(serve rRunning)
  178                                               cache.cach eLifecycle Event(Cach eLifecycle Event.STAR T);
  179                             }
  180                             else
  181                                      return " Cache was  already in itialized" ;
  182                    } 
  183                    catc h (CacheEx ception cX )
  184                    {
  185                             logger .error("Er ror initia lizing cac he.", cX);
  186                             return  cX.getMes sage();
  187                    }
  188                    retu rn "Cache  Initialize d";
  189           }
  190           
  191           /*  (non-Java doc)
  192            *  @see gov. va.med.ima ging.stora ge.cache.i mpl.filesy stem.Cache Manager#en able()
  193            * /
  194           /*  (non-Java doc)
  195            *  @see gov. va.med.ima ging.stora ge.cache.i mpl.ICache Manager#en able(gov.v a.med.imag ing.storag e.cache.Ca che)
  196            * /
  197           pu blic Strin g enable(C ache cache )
  198           {
  199                    try
  200                    {
  201                             cache. setEnabled (Boolean.T RUE);
  202                    } 
  203                    catc h (CacheEx ception cX )
  204                    {
  205                             logger .error("Er ror enabli ng cache ' " + cache. getName()  + "'.", cX );
  206                             return  cX.getMes sage();
  207                    }
  208                    retu rn "Cache  Enabled";
  209           }
  210  
  211           /*  (non-Java doc)
  212            *  @see gov. va.med.ima ging.stora ge.cache.i mpl.filesy stem.Cache Manager#di sable()
  213            * /
  214           /*  (non-Java doc)
  215            *  @see gov. va.med.ima ging.stora ge.cache.i mpl.ICache Manager#di sable(gov. va.med.ima ging.stora ge.cache.C ache)
  216            * /
  217           pu blic Strin g disable( Cache cach e)
  218           {
  219                    try
  220                    {
  221                             cache. setEnabled (Boolean.F ALSE);
  222                    } 
  223                    catc h (CacheEx ception cX )
  224                    {
  225                             logger .error("Er ror disabl ing cache  '" + cache .getName()  + "'.", c X);
  226                             return  cX.getMes sage();
  227                    }
  228                    retu rn "Cache  Enabled";
  229           }
  230  
  231           /*  (non-Java doc)
  232            *  @see gov. va.med.ima ging.stora ge.cache.i mpl.ICache Manager#st ore(gov.va .med.imagi ng.storage .cache.Cac he)
  233            * /
  234           pu blic void  store(Cach e cache) 
  235           th rows IOExc eption
  236           {
  237                    getK nownCaches ().store(c ache);
  238           }
  239  
  240           /*  (non-Java doc)
  241            *  @see gov. va.med.ima ging.stora ge.cache.i mpl.ICache Manager#st oreAll()
  242            * /
  243           pu blic void  storeAll()  
  244           th rows IOExc eption
  245           {
  246                    getK nownCaches ().storeAl l();
  247           }
  248           
  249           /*  (non-Java doc)
  250            *  @see gov. va.med.ima ging.stora ge.cache.i mpl.ICache Manager#de lete(gov.v a.med.imag ing.storag e.cache.Ca che)
  251            * /
  252           pu blic void  delete(Cac he cache)
  253           {
  254                    // d isable the  cache to  stop new r equests
  255                    disa ble(cache) ;
  256                    unre gisterCach eMBeans(ca che);
  257                    
  258                    Stri ng cacheNa me = cache .getName() ;
  259                    cach e = null;             // drop th e referenc e
  260                    getK nownCaches ().remove( cacheName) ;
  261           }
  262           
  263           /*  (non-Java doc)
  264            *  @see gov. va.med.ima ging.stora ge.cache.i mpl.ICache Manager#cr eateEvicti onStrategy (gov.va.me d.imaging. storage.ca che.Cache,  gov.va.me d.imaging. storage.ca che.mement o.Eviction StrategyMe mento)
  265            * /
  266           pu blic Evict ionStrateg y createEv ictionStra tegy(Cache  cache, Ev ictionStra tegyMement o memento)
  267           th rows Cache Exception
  268           {
  269                    if(  getKnownCa ches().isK nownCache( cache) )
  270                    {
  271                             Evicti onStrategy Factory fa ctory = Ev ictionStra tegyFactor y.getSingl eton();
  272                             Evicti onTimer ti mer = cach e.getEvict ionTimer() ;
  273                             Evicti onStrategy  strategy  = factory. createEvic tionStrate gy(memento , timer);
  274                             
  275                             if(str ategy != n ull)
  276                                      cache.ad dEvictionS trategy(st rategy);
  277                             
  278                             try
  279                             {
  280                                      register EvictionSt rategyMBea n(cache, s trategy);
  281                             } 
  282                             catch  (Exception  x)
  283                             {
  284                                      logger.w arn(x);
  285                             }
  286                             
  287                             return  strategy;
  288                    }
  289                    
  290                    retu rn null;
  291           }
  292           
  293           /*  (non-Java doc)
  294            *  @see gov. va.med.ima ging.stora ge.cache.i mpl.ICache Manager#cr eateRegion (gov.va.me d.imaging. storage.ca che.Cache,  java.lang .String, j ava.lang.S tring[])
  295            * /
  296           pu blic Regio n createRe gion(Cache  cache, St ring regio nName, Str ing[] evic tionStrate gyNames)
  297           th rows Cache Exception
  298           {
  299                    if(g etKnownCac hes().isKn ownCache(c ache) )
  300                    {
  301                             Region  region =  cache.crea teRegion(r egionName,  evictionS trategyNam es);
  302                             
  303                             cache. addRegion( region);
  304                             
  305                             try
  306                             {
  307                                      register RegionMBea n(cache, r egion);
  308                             } 
  309                             catch  (Exception  x)
  310                             {
  311                                      logger.w arn(x);
  312                             }
  313                             
  314                             return  region;
  315                    }
  316                    
  317                    retu rn null;
  318           }
  319           
  320           //  ========= ========== ========== ========== ========== ========== ========== ========== ========== ========== ========== ========== =
  321           //  
  322           //  ========= ========== ========== ========== ========== ========== ========== ========== ========== ========== ========== ========== =
  323           
  324           pr ivate fina l static S tring cach eManagerMB eanObjectN ame = "Vis taImaging. ViX:type=C acheManage rImpl,name =CacheMana gerImpl";
  325           pr ivate fina l static S tring cach eMBeanObje ctNamePref ix = "Vist aImaging.V iX:type=Ca che,name=" ;
  326           pr ivate fina l static S tring byte ChannelMBe anObjectNa mePrefix =  "VistaIma ging.ViX:t ype=CacheB yteChannel Factory,na me=";
  327           pr ivate fina l static S tring evic tionStrate gyMBeanObj ectNamePre fix = "Vis taImaging. ViX:type=C acheEvicti onStrategy ,name=";
  328           pr ivate fina l static S tring regi onMBeanObj ectNamePre fix = "Vis taImaging. ViX:type=C acheRegion ,name=";
  329           
  330           pr ivate Stri ng createC acheMBeanO bjectName( Cache cach e)
  331           {r eturn cach eMBeanObje ctNamePref ix + cache .getName() ; }
  332           
  333           pr ivate Stri ng createB yteChannel MBeanObjec tName(Cach e cache)
  334           {r eturn byte ChannelMBe anObjectNa mePrefix +  cache.get Name(); }
  335           
  336           pr ivate Stri ng createR egionMBean ObjectName (Cache cac he, Region  region)
  337           {r eturn regi onMBeanObj ectNamePre fix + cach e.getName( ) + "." +  region.get Name(); }
  338           
  339           pr ivate Stri ng createE victionStr ategyMBean ObjectName (Cache cac he, Evicti onStrategy  evictionS trategy)
  340           {r eturn evic tionStrate gyMBeanObj ectNamePre fix + cach e.getName( ) + "." +  evictionSt rategy.get Name(); }
  341           
  342           /* *
  343            *  Register  the cache  manager
  344            *  
  345            *  @param ca cheName
  346            * /
  347           pu blic void  registerCa cheManager MBean()
  348           {
  349                    MBea nServer mb s = Manage mentFactor y.getPlatf ormMBeanSe rver();
  350                    if(m bs != null )
  351                    {
  352                             try
  353                             {
  354                                      mbs.regi sterMBean( this, new  ObjectName (cacheMana gerMBeanOb jectName)) ;
  355                             } 
  356                             catch  (Exception  x)
  357                             {
  358                                      logger.w arn("Unabl e to regis ter Cache  with JMX,  management  and monit oring will  not be av ailable",  x);
  359                             }
  360                    }
  361           }
  362           
  363           pr ivate void  registerC acheMBeans (Cache cac he)
  364           {
  365                    MBea nServer mb s = Manage mentFactor y.getPlatf ormMBeanSe rver();
  366                    
  367                    if(m bs != null )
  368                    {
  369                             try
  370                             {
  371                                      if( cach e instance of Dynamic MBean)
  372                                      {
  373                                               String cac heMBeanNam e = create CacheMBean ObjectName (cache);
  374                                               logger.inf o("Registe ring cache  '" + cach eMBeanName  + "'.");
  375                                              
  376                                               mbs.regist erMBean(ca che, new O bjectName( cacheMBean Name));
  377                                      }
  378                                      
  379                                      logger.i nfo("Regis tering " +  cache.get EvictionSt rategies() .size() +  " eviction  strategie s for cach e '" + cac he.getName () + "'.") ;
  380                                      for(Evic tionStrate gy evictio nStrategy:  cache.get EvictionSt rategies() )
  381                                               registerEv ictionStra tegyMBean( cache, evi ctionStrat egy);
  382                    
  383                                      logger.i nfo("Regis tering " +  cache.get Regions(). size() + "  regions f or cache ' " + cache. getName()  + "'.");
  384                                      for(Regi on region  : cache.ge tRegions() )
  385                                               registerRe gionMBean( cache, reg ion);
  386                    
  387                                      if( cach e.getInsta nceByteCha nnelFactor y() instan ceof Dynam icMBean)
  388                                      {
  389                                               String byt eChannelMB eanName =  createByte ChannelMBe anObjectNa me(cache);
  390                                               logger.inf o("Registe ring byte  channel '"  + byteCha nnelMBeanN ame + "'." );
  391                                              
  392                                               mbs.regist erMBean(ca che.getIns tanceByteC hannelFact ory(), new  ObjectNam e(byteChan nelMBeanNa me));
  393                                      }
  394                             }
  395                             catch  (Exception  x)
  396                             {
  397                                      logger.w arn("Unabl e to regis ter Cache  with JMX,  management  and monit oring will  not be av ailable",  x);
  398                             }
  399                    }
  400           }
  401           
  402           pr ivate void  registerE victionStr ategyMBean (Cache cac he, Evicti onStrategy  evictionS trategy) 
  403           th rows Insta nceAlready ExistsExce ption, MBe anRegistra tionExcept ion, NotCo mpliantMBe anExceptio n, Malform edObjectNa meExceptio n, NullPoi nterExcept ion
  404           {
  405                    MBea nServer mb s = Manage mentFactor y.getPlatf ormMBeanSe rver();
  406                    
  407                    if(m bs != null )
  408                    {
  409                             String  evictionS trategyObj ectName =  createEvic tionStrate gyMBeanObj ectName(ca che, evict ionStrateg y);
  410                             logger .info("Reg istering e viction st rategy '"  + eviction StrategyOb jectName +  "'.");
  411                             mbs.re gisterMBea n( evictio nStrategy,  new Objec tName(evic tionStrate gyObjectNa me) );
  412                    }
  413           }
  414           
  415           pr ivate void  registerR egionMBean (Cache cac he, Region  region) 
  416           th rows Insta nceAlready ExistsExce ption, MBe anRegistra tionExcept ion, NotCo mpliantMBe anExceptio n, Malform edObjectNa meExceptio n, NullPoi nterExcept ion
  417           {
  418                    MBea nServer mb s = Manage mentFactor y.getPlatf ormMBeanSe rver();
  419                    
  420                    if(  mbs != nul l )
  421                    {
  422                             String  regionObj ectName =  createRegi onMBeanObj ectName(ca che, regio n);
  423                             logger .info("Reg istering r egion '" +  regionObj ectName +  "'.");
  424                             
  425                             mbs.re gisterMBea n( region,  new Objec tName(regi onObjectNa me) );
  426                    }
  427           }
  428           
  429           pr ivate void  unregiste rCacheMBea ns(Cache c ache)
  430           {
  431                    MBea nServer mb s = Manage mentFactor y.getPlatf ormMBeanSe rver();
  432                    
  433                    if(m bs != null )
  434                    {
  435                             try
  436                             {
  437                                      if( cach e instance of Dynamic MBean)
  438                                      {
  439                                               String cac heMBeanNam e = create CacheMBean ObjectName (cache);
  440                                               try{mbs.un registerMB ean(new Ob jectName(c acheMBeanN ame));}
  441                                               catch(Inst anceNotFou ndExceptio n infX){lo gger.warn( infX);}                 // if th e MBean is  not regis tered then  don't wor ry 'bout i t
  442                                      }
  443                                      for(Evic tionStrate gy evictio nStrategy:  cache.get EvictionSt rategies() )
  444                                               try{unregi sterEvicti onStrategy MBean(cach e, evictio nStrategy) ;}
  445                                               catch(Inst anceNotFou ndExceptio n infX){lo gger.warn( infX);}                 // if th e MBean is  not regis tered then  don't wor ry 'bout i t
  446                    
  447                                      for(Regi on region  : cache.ge tRegions() )
  448                                               try{unregi sterRegion MBean(cach e, region) ;}
  449                                               catch(Inst anceNotFou ndExceptio n infX){lo gger.warn( infX);}                 // if th e MBean is  not regis tered then  don't wor ry 'bout i t
  450                    
  451                                      if( cach e.getInsta nceByteCha nnelFactor y() instan ceof Dynam icMBean)
  452                                      {
  453                                               String byt eChannelOb jectName =  createByt eChannelMB eanObjectN ame(cache) ;
  454                                               try{mbs.un registerMB ean(new Ob jectName(b yteChannel ObjectName ));}
  455                                               catch(Inst anceNotFou ndExceptio n infX){lo gger.warn( infX);}                 // if th e MBean is  not regis tered then  don't wor ry 'bout i t
  456                                      }
  457                             }
  458                             catch  (Exception  x)
  459                             {
  460                                      logger.w arn("Unabl e to unreg ister Cach e with JMX , manageme nt and mon itoring fo r new inst ances may  not be ava ilable", x );
  461                             }
  462                    }
  463           }
  464           pr ivate void  unregiste rEvictionS trategyMBe an(Cache c ache, Evic tionStrate gy evictio nStrategy)  
  465           th rows Insta nceAlready ExistsExce ption, MBe anRegistra tionExcept ion, NotCo mpliantMBe anExceptio n, Malform edObjectNa meExceptio n, NullPoi nterExcept ion, Insta nceNotFoun dException
  466           {
  467                    MBea nServer mb s = Manage mentFactor y.getPlatf ormMBeanSe rver();
  468                    
  469                    if(m bs != null  && evicti onStrategy  instanceo f DynamicM Bean)
  470                    {
  471                             String  evictionS trategyObj ectName =  createEvic tionStrate gyMBeanObj ectName(ca che, evict ionStrateg y);
  472                             logger .info("Unr egistering  eviction  strategy ' " + evicti onStrategy ObjectName  + "'.");
  473                             
  474                             mbs.un registerMB ean( new O bjectName( evictionSt rategyObje ctName) );
  475                    }
  476           }
  477           
  478           pr ivate void  unregiste rRegionMBe an(Cache c ache, Regi on region)  
  479           th rows Insta nceAlready ExistsExce ption, MBe anRegistra tionExcept ion, NotCo mpliantMBe anExceptio n, Malform edObjectNa meExceptio n, NullPoi nterExcept ion, Insta nceNotFoun dException
  480           {
  481                    MBea nServer mb s = Manage mentFactor y.getPlatf ormMBeanSe rver();
  482                    
  483                    if(  mbs != nul l && regio n instance of Dynamic MBean)
  484                    {
  485                             String  regionObj ectName =  createRegi onMBeanObj ectName(ca che, regio n);
  486                             logger .info("Unr egistering  region '"  + regionO bjectName  + "'.");
  487                             
  488                             mbs.un registerMB ean( new O bjectName( regionObje ctName) );
  489                    }
  490           }
  491           
  492           //  ========= ========== ========== ========== ========== ========== ========== ========== ========== === 
  493           //  CacheLife cycleListe ner Implem entation
  494           //  These are  messages  from the a pp server,  abstracte d by a pla tform spec ific class
  495           //  to our se mantics
  496           //  ========= ========== ========== ========== ========== ========== ========== ========== ========== ===
  497           
  498           
  499           /* *
  500        * @se e gov.va.m ed.server. ServerLife cycleListe ner#server LifecycleE vent(gov.v a.med.serv er.ServerL ifecycleEv ent)
  501        * Tra nslate the  server li fecycle me ssages to  the cache  lifecycle  messages,  removing t he depende ncy
  502        * tha t the cach e even be  in a serve r environm ent.
  503        * Thi s replaces  the Cache LifecycleE vent handl ing in V-O ne.
  504        */
  505       @Overr ide
  506       public  void serv erLifecycl eEvent(Ser verLifecyc leEvent ev ent)
  507       {
  508                    bool ean previo usServerRu nning = se rverRunnin g;
  509                    
  510                    Cach eLifecycle Event cach eLifecycle Event = nu ll;
  511                    
  512                    if(e vent.getEv entType(). equals(Ser verLifecyc leEvent.Ev entType.ST ART))
  513                    {
  514                             server Running =  true;
  515                             cacheL ifecycleEv ent = Cach eLifecycle Event.STAR T;
  516                    }
  517                    if(e vent.getEv entType(). equals(Ser verLifecyc leEvent.Ev entType.ST OP))
  518                    {
  519                             server Running =  false;
  520                             cacheL ifecycleEv ent = Cach eLifecycle Event.STOP ;
  521                    }
  522                    
  523                    // i f this rep resents an  actual se rver runni ng state c hange then  pass
  524                    // i t on to th e cache in stances
  525                    if(p reviousSer verRunning  != server Running)
  526                    {
  527                             for( C ache cache  : getKnow nCaches()  )
  528                                      // if th e cache is  initializ ed, pass t his on to  the cache
  529                                      if(cache .isInitial ized())
  530                                      {
  531                                               try
  532                                               {
  533                                                       ca che.cacheL ifecycleEv ent(cacheL ifecycleEv ent);
  534                                              
  535                                               catch (Cac heStateExc eption x)
  536                                               {
  537                                                       lo gger.error (x);
  538                                               }
  539                                      }
  540                    }
  541       }
  542  
  543           //  ========= ========== ========== ========== ========== ========== ========== ========== ========== === 
  544           //  DynamicMB ean Implem entation
  545           //  ========= ========== ========== ========== ========== ========== ========== ========== ========== ===
  546           pu blic MBean Info getMB eanInfo() 
  547           {
  548                    try
  549                    {
  550                             // the  MBeanInfo  must be r egenerated  because t he state o f some
  551                             // ope rations ma y change
  552                             return  createMBe anInfo();
  553                    } 
  554                    catc h (OpenDat aException  x)
  555                    {
  556                             logger .error(x);
  557                             return  null;
  558                    }
  559           }
  560           
  561           pr ivate Open MBeanInfoS upport cre ateMBeanIn fo() 
  562           th rows OpenD ataExcepti on
  563           {
  564           re turn new O penMBeanIn foSupport(
  565                             FileSy stemCache. class.getN ame(), 
  566                             "Cache  Managemen t (initial izing, ena bling, sto ring)", 
  567                             create MBeanAttri buteInfo()
  568                             create MBeanConst ructorInfo (), 
  569                                      createMB eanOperati onInfo(), 
  570                                      createMB eanNotific ationInfo( )
  571                             );
  572           }
  573  
  574           /* *
  575            *  
  576            *  @param ca che
  577            *  @throws O penDataExc eption 
  578            * /
  579           pr ivate Open MBeanAttri buteInfo[]  createMBe anAttribut eInfo() 
  580           th rows OpenD ataExcepti on
  581           {
  582                    List <OpenMBean AttributeI nfo> attri butes = ne w ArrayLis t<OpenMBea nAttribute Info>();
  583  
  584                    attr ibutes.add (
  585                             new Op enMBeanAtt ributeInfo Support("k nownCacheN ames", "A  comma sepe rated list  of known  cache name s", Simple Type.STRIN G, true, f alse, fals e)
  586                    );
  587                    
  588                    retu rn attribu tes.toArra y(new Open MBeanAttri buteInfo[a ttributes. size()]);
  589           }
  590  
  591           pr ivate Open MBeanConst ructorInfo [] createM BeanConstr uctorInfo( )
  592           {
  593           re turn new O penMBeanCo nstructorI nfoSupport []
  594           {
  595                             
  596           };
  597           }
  598           
  599           pr ivate MBea nNotificat ionInfo[]  createMBea nNotificat ionInfo()
  600           {
  601                    retu rn new MBe anNotifica tionInfo[]
  602                    {
  603                                      
  604                    };
  605           }
  606  
  607           pr ivate fina l static S tring init ializePref ix = "init ialize-";
  608           pr ivate fina l static S tring enab lePrefix =  "enable-" ;
  609           pr ivate fina l static S tring disa blePrefix  = "disable -";
  610           pr ivate fina l static S tring stor eOperation  = "store" ;
  611           pr ivate fina l static S tring stor eAllOperat ion = "sto reAll";
  612           pr ivate fina l static S tring crea teOperatio n = "creat eCache";
  613           
  614           /* *
  615            *  The opera tions are  pulled fro m the core  cache and  the membe r regions.
  616            *  @param ca che 
  617            *
  618            * /
  619           pr ivate Open MBeanOpera tionInfo[]  createMBe anOperatio nInfo()
  620           {
  621                    List <OpenMBean OperationI nfo> opera tions = ne w ArrayLis t<OpenMBea nOperation Info>();
  622                    
  623                    for( Cache cach e : getKno wnCaches() )
  624                    {
  625                             if(cac he != null  && !cache .isInitial ized())
  626                                      operatio ns.add(
  627                                      new Open MBeanOpera tionInfoSu pport(init ializePref ix + cache .getName()
  628                                                       "I nitialize  the cache  (root dire ctory must  be set fi rst) \n" +
  629                                                       "T his action  is ignore d if the c ache is in itialized. \n" + 
  630                                                       "I f the cach e has been  started w ith a vali d configur ation stat e availabl e \n" +
  631                                                       "i t will sta rt in an i nitialized  state.  C hanges to  configurat ion will t hen requir e a restar t of the s erver.", 
  632                                                       ne w OpenMBea nParameter Info[]{}, 
  633                                                       Si mpleType.V OID, MBean OperationI nfo.ACTION )
  634                             );
  635           
  636                             if(cac he != null  && cache. isInitiali zed() && ! cache.isEn abled() )
  637                                      operatio ns.add(
  638                                      new Open MBeanOpera tionInfoSu pport(enab lePrefix +  cache.get Name(), 
  639                                                       "E nable the  cache (cac he must be  initializ ed)", 
  640                                                       ne w OpenMBea nParameter Info[]{}, 
  641                                                       Si mpleType.V OID, MBean OperationI nfo.ACTION )
  642                             );
  643                             
  644                             else i f(cache !=  null && c ache.isEna bled())
  645                                      operatio ns.add(
  646                                      new Open MBeanOpera tionInfoSu pport(disa blePrefix  + cache.ge tName(), 
  647                                                       "D isable the  cache (ca che must b e initiali zed and en abled)", 
  648                                                       ne w OpenMBea nParameter Info[]{}, 
  649                                                       Si mpleType.V OID, MBean OperationI nfo.ACTION )
  650                             );
  651                    }
  652                    
  653                    oper ations.add (
  654                             new Op enMBeanOpe rationInfo Support(st oreOperati on, 
  655                                               "Store the  named cac he configu ration to  persistent  storage",  
  656                                               new OpenMB eanParamet erInfo[]{n ew OpenMBe anParamete rInfoSuppo rt("name",  "the bnam e of the c ache to sa ve configu ration of" , SimpleTy pe.STRING) }, 
  657                                               SimpleType .VOID, MBe anOperatio nInfo.ACTI ON)
  658                    );
  659                    
  660                    oper ations.add (
  661                             new Op enMBeanOpe rationInfo Support(st oreAllOper ation, 
  662                                               "Store all  current c ache confi guration t o persiste nt storage ", 
  663                                               new OpenMB eanParamet erInfo[]{}
  664                                               SimpleType .VOID, MBe anOperatio nInfo.ACTI ON)
  665                    );
  666                    
  667                    oper ations.add (
  668                    new  OpenMBeanO perationIn foSupport( createOper ation, 
  669                                      "Create  a new cach e at the s pecified l ocation.",  
  670                                      new Open MBeanParam eterInfo[]
  671                                      {
  672                                               new OpenMB eanParamet erInfoSupp ort("cache Name", "Th e name of  the cache  (and the r oot of the  configura tion file  name)", Si mpleType.S TRING),
  673                                               new OpenMB eanParamet erInfoSupp ort("cache Location",  "The URI  of the cac he locatio n (e.g. 'f ile:///vix /cache' or  'smb://se rver/cache root')", S impleType. STRING),
  674                                               new OpenMB eanParamet erInfoSupp ort("proto typeName",  "The name  of the pr ototype or  blank(e.g . 'VixProt otype', 'T estWithEvi ctionProto type')", S impleType. STRING)
  675                                      }, 
  676                                      SimpleTy pe.STRING,  
  677                                      MBeanOpe rationInfo .ACTION)
  678           );
  679                    
  680                    retu rn operati ons.toArra y(new Open MBeanOpera tionInfoSu pport[oper ations.siz e()]);
  681           }
  682  
  683           @O verride
  684           pu blic Objec t getAttri bute(Strin g attribut e) 
  685           th rows Attri buteNotFou ndExceptio n, MBeanEx ception, R eflectionE xception
  686           {
  687                    if(" knownCache Names".equ als(attrib ute))
  688                    {
  689                             String Builder sb  = new Str ingBuilder ();
  690                             for(Ca che cache  : getKnown Caches())
  691                             {
  692                                      if(sb.le ngth() > 0 )
  693                                               sb.append( ",");
  694                                      sb.appen d(cache.ge tName());
  695                             }
  696                             
  697                             return  sb.toStri ng();
  698                    }
  699                    else
  700                             return  super.get Attribute( attribute) ;
  701           }
  702  
  703           @O verride
  704           pu blic void  setAttribu te(Attribu te attribu te) 
  705           th rows Attri buteNotFou ndExceptio n, Invalid AttributeV alueExcept ion, MBean Exception,  Reflectio nException
  706           {
  707                    supe r.setAttri bute(attri bute);
  708           }
  709  
  710           @O verride
  711           pu blic Objec t invoke(S tring acti onName, Ob ject[] par ams, Strin g[] signat ure) 
  712           th rows MBean Exception,  Reflectio nException
  713           {
  714                    
  715                    if(a ctionName. startsWith (initializ ePrefix))
  716                    {
  717                             String  cacheName  = actionN ame.substr ing(initia lizePrefix .length()) ;
  718                             logger .info("Pro cessing re quest to i nitialize  cache '" +  cacheName  + "'.");
  719                             return  initializ e(getKnown Caches().g et(cacheNa me));
  720                    }
  721                    else  if(action Name.start sWith(enab lePrefix))
  722                    {
  723                             String  cacheName  = actionN ame.substr ing(initia lizePrefix .length()) ;
  724                             logger .info("Pro cessing re quest to e nable cach e '" + cac heName + " '.");
  725                             return  enable(ge tKnownCach es().get(c acheName)) ;
  726                    }
  727                    else  if(action Name.start sWith(disa blePrefix) )
  728                    {
  729                             String  cacheName  = actionN ame.substr ing(initia lizePrefix .length()) ;
  730                             logger .info("Pro cessing re quest to d isable cac he '" + ca cheName +  "'.");
  731                             return  disable(g etKnownCac hes().get( cacheName) );
  732                    }
  733                    else  if(storeO peration.e quals(acti onName))
  734                    {
  735                             String  cacheName  = (String )params[0] ;
  736                             try
  737                             {
  738                                      Cache ca che = getC ache(cache Name);
  739                                      logger.i nfo("Proce ssing requ est to sto re configu ration of  '" + cache Name + "'. ");
  740                                      store(ca che);
  741                             }
  742                             catch  (Exception  x)
  743                             {
  744                                      logger.e rror("Erro r storing  configurat ion of '"  + cacheNam e + "'.");
  745                                      throw ne w MBeanExc eption(x);
  746                             }
  747                             return  "Cache co nfiguratio n stored." ;
  748                    }
  749                    else  if(storeA llOperatio n.equals(a ctionName) )
  750                    {
  751                             try
  752                             {
  753                                      logger.i nfo("Proce ssing requ est to sto re configu ration of  all known  caches.");
  754                                      storeAll ();
  755                             }
  756                             catch  (Exception  x)
  757                             {
  758                                      logger.e rror("Erro r storing  configurat ion to per sistent st orage.", x );
  759                                      throw ne w MBeanExc eption(x);
  760                             }
  761                             return  "All cach e configur ations sto red.";
  762                    }
  763                    else  if(create Operation. equals(act ionName) &
  764                                      signatur e.length = = 3 && 
  765                                      params[0 ] instance of String  && 
  766                                      params[1 ] instance of String  && 
  767                                      params[2 ] instance of String  )
  768                    {
  769                             String  cacheName  = (String )params[0] ;
  770                             String  cacheLoca tion = (St ring)param s[1];
  771                             String  prototype Name = (St ring)param s[2];
  772                             
  773                             try
  774                             {
  775                                      logger.i nfo("Proce ssing requ est to cre ate cache  '" + cache Name + "'  at '" + ca cheLocatio n + "' as  '" + proto typeName +  "'." );
  776                                      getKnown Caches().c reate(cach eName, new  URI(cache Location),  prototype Name);
  777                             } 
  778                             catch  (Exception  x)
  779                             {
  780                                      throw ne w MBeanExc eption(x);
  781                             }
  782                             return  "Cache '"  + cacheNa me + "' cr eated at ' " + cacheL ocation +  "' as '" +  prototype Name + "'. ";
  783                    }
  784                    
  785                    retu rn super.i nvoke(acti onName, pa rams, sign ature);
  786           }
  787  
  788           //  ========= ========== ========== ========== ========== ========== ========== ========== ========== ========== ========== ========== ========== =
  789           
  790           /* *
  791            *  Return a  refererenc e to the c onfigurati on directo ry, creati ng
  792            *  directori es as nece ssary to a ssure it e xists befo re returni ng.
  793            * /
  794           pr ivate File  getConfig urationDir ectory()
  795           {
  796                    Stri ng rootCon figDirName  = System. getenv("vi xconfig");
  797                    if(r ootConfigD irName ==  null)
  798                             rootCo nfigDirNam e = defaul tConfigura tionDirect oryName;
  799                    
  800                    File  rootConfi gDir = new  File(root ConfigDirN ame);
  801                    if(  ! rootConf igDir.exis ts() )
  802                             rootCo nfigDir.mk dirs();
  803  
  804                    // t he cache c onfigurati on is in a  subdirect ory of the  configura tion direc tory
  805                    File  cacheConf igDir = ne w File(roo tConfigDir , cacheCon figuration Subdirecto ryName);
  806                    if(  ! cacheCon figDir.exi sts() )
  807                             cacheC onfigDir.m kdirs();
  808                    
  809                    
  810                    retu rn cacheCo nfigDir;
  811           }
  812  
  813           //  ========= ========== ========== ========== ========== ========== ========== ========== ========== ==========
  814           //  interface  CacheStru ctureChang eListener  realizatio n
  815           //  ========= ========== ========== ========== ========== ========== ========== ========== ========== ==========
  816           pu blic void  cacheStruc tureChange d(Cache ca che)
  817           {
  818                    unre gisterCach eMBeans(ca che);
  819                    regi sterCacheM Beans(cach e);
  820           }
  821           
  822           pu blic void  evictionSt rategyAdde d(Cache ca che, Evict ionStrateg y newEvict ionStrateg y)
  823           {
  824                    try
  825                    {
  826                             regist erEviction StrategyMB ean(cache,  newEvicti onStrategy );
  827                    } 
  828                    catc h (Excepti on x)
  829                    {
  830                             logger .warn(x);
  831                    }
  832           }
  833  
  834           pu blic void  evictionSt rategyRemo ved(Cache  cache, Evi ctionStrat egy oldEvi ctionStrat egy)
  835           {
  836                    try
  837                    {
  838                             unregi sterEvicti onStrategy MBean(cach e, oldEvic tionStrate gy);
  839                    } 
  840                    catc h (Excepti on x)
  841                    {
  842                             logger .warn(x);
  843                    }
  844           }
  845  
  846           pu blic void  regionAdde d(Cache ca che, Regio n newRegio n)
  847           {
  848                    try
  849                    {
  850                             regist erRegionMB ean(cache,  newRegion );
  851                    } 
  852                    catc h (Excepti on x)
  853                    {
  854                             logger .warn(x);
  855                    }
  856           }
  857  
  858           pu blic void  regionRemo ved(Cache  cache, Reg ion oldReg ion)
  859           {
  860                    try
  861                    {
  862                             unregi sterRegion MBean(cach e, oldRegi on);
  863                    } 
  864                    catc h (Excepti on x)
  865                    {
  866                             logger .warn(x);
  867                    }
  868           }
  869  
  870   }