All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.cedarsoft.gdao.caching.CachingService Maven / Gradle / Ivy

There is a newer version: 1.6.3
Show newest version
package com.cedarsoft.gdao.caching;

import com.cedarsoft.gdao.GenericService;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

/**
 *
 */
public class CachingService extends CachingDao implements GenericService {
  public CachingService( @NotNull GenericService backingService ) {
    super( backingService );
  }

  @NotNull
  protected GenericService getBackingService() {
    return ( GenericService ) super.getBackingDao();
  }

  @Nullable
  public  R perform( @NotNull final ServiceCallback callback ) {
    R returnValue = getBackingService().perform( callback );
    cache.getLock().writeLock().lock();
    try {
      cache.clear();
      cache.addAll( getBackingService().findAll() );
    } finally {
      cache.getLock().writeLock().unlock();
    }
    return returnValue;
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy