31
31
import net .sf .ehcache .constructs .blocking .UpdatingSelfPopulatingCache ;
32
32
import net .sf .ehcache .event .CacheEventListener ;
33
33
import net .sf .ehcache .store .MemoryStoreEvictionPolicy ;
34
-
35
34
import org .apache .commons .logging .Log ;
36
35
import org .apache .commons .logging .LogFactory ;
37
36
@@ -333,6 +332,21 @@ public void afterPropertiesSet() throws CacheException, IOException {
333
332
this .cacheManager .addCache (rawCache );
334
333
}
335
334
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
+
336
350
// Decorate cache if necessary.
337
351
Ehcache decoratedCache = decorateCache (rawCache );
338
352
if (decoratedCache != rawCache ) {
@@ -346,7 +360,7 @@ public void afterPropertiesSet() throws CacheException, IOException {
346
360
*/
347
361
protected Cache createCache () {
348
362
// Only call EHCache 1.6 constructor if actually necessary (for compatibility with EHCache 1.3+)
349
- Cache cache = (!this .clearOnFlush ) ?
363
+ return (!this .clearOnFlush ) ?
350
364
new Cache (this .cacheName , this .maxElementsInMemory , this .memoryStoreEvictionPolicy ,
351
365
this .overflowToDisk , null , this .eternal , this .timeToLive , this .timeToIdle ,
352
366
this .diskPersistent , this .diskExpiryThreadIntervalSeconds , null ,
@@ -356,22 +370,6 @@ protected Cache createCache() {
356
370
this .overflowToDisk , null , this .eternal , this .timeToLive , this .timeToIdle ,
357
371
this .diskPersistent , this .diskExpiryThreadIntervalSeconds , null ,
358
372
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 ;
375
373
}
376
374
377
375
/**
0 commit comments