3131import net .sf .ehcache .constructs .blocking .UpdatingSelfPopulatingCache ;
3232import net .sf .ehcache .event .CacheEventListener ;
3333import net .sf .ehcache .store .MemoryStoreEvictionPolicy ;
34-
3534import org .apache .commons .logging .Log ;
3635import org .apache .commons .logging .LogFactory ;
3736
@@ -333,6 +332,21 @@ public void afterPropertiesSet() throws CacheException, IOException {
333332 this .cacheManager .addCache (rawCache );
334333 }
335334
335+ if (this .cacheEventListeners != null ) {
336+ for (CacheEventListener listener : this .cacheEventListeners ) {
337+ rawCache .getCacheEventNotificationService ().registerListener (listener );
338+ }
339+ }
340+ if (this .statisticsEnabled ) {
341+ rawCache .setStatisticsEnabled (true );
342+ }
343+ if (this .sampledStatisticsEnabled ) {
344+ rawCache .setSampledStatisticsEnabled (true );
345+ }
346+ if (this .disabled ) {
347+ rawCache .setDisabled (true );
348+ }
349+
336350 // Decorate cache if necessary.
337351 Ehcache decoratedCache = decorateCache (rawCache );
338352 if (decoratedCache != rawCache ) {
@@ -346,7 +360,7 @@ public void afterPropertiesSet() throws CacheException, IOException {
346360 */
347361 protected Cache createCache () {
348362 // Only call EHCache 1.6 constructor if actually necessary (for compatibility with EHCache 1.3+)
349- Cache cache = (!this .clearOnFlush ) ?
363+ return (!this .clearOnFlush ) ?
350364 new Cache (this .cacheName , this .maxElementsInMemory , this .memoryStoreEvictionPolicy ,
351365 this .overflowToDisk , null , this .eternal , this .timeToLive , this .timeToIdle ,
352366 this .diskPersistent , this .diskExpiryThreadIntervalSeconds , null ,
@@ -356,22 +370,6 @@ protected Cache createCache() {
356370 this .overflowToDisk , null , this .eternal , this .timeToLive , this .timeToIdle ,
357371 this .diskPersistent , this .diskExpiryThreadIntervalSeconds , null ,
358372 this .bootstrapCacheLoader , this .maxElementsOnDisk , this .diskSpoolBufferSize );
359-
360- if (this .cacheEventListeners != null ) {
361- for (CacheEventListener listener : this .cacheEventListeners ) {
362- cache .getCacheEventNotificationService ().registerListener (listener );
363- }
364- }
365- if (this .statisticsEnabled ) {
366- cache .setStatisticsEnabled (true );
367- }
368- if (this .sampledStatisticsEnabled ) {
369- cache .setSampledStatisticsEnabled (true );
370- }
371- if (this .disabled ) {
372- cache .setDisabled (true );
373- }
374- return cache ;
375373 }
376374
377375 /**
0 commit comments