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

org.ehcache.jsr107.Eh107ReverseConfiguration Maven / Gradle / Ivy

There is a newer version: 3.10.8
Show newest version
/*
 * Copyright Terracotta, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.ehcache.jsr107;

import org.ehcache.Cache;

import java.io.ObjectStreamException;

import javax.cache.configuration.CacheEntryListenerConfiguration;

/**
 * Eh107ReverseConfiguration
 */
class Eh107ReverseConfiguration extends Eh107Configuration {
  
  private static final long serialVersionUID = 7690458739466020356L;
  
  private final transient Cache cache;
  private final boolean readThrough;
  private final boolean writeThrough;
  private final boolean storeByValueOnHeap;
  private boolean managementEnabled = false;
  private boolean statisticsEnabled = true;

  Eh107ReverseConfiguration(Cache cache, boolean readThrough, boolean writeThrough, boolean storeByValueOnHeap) {
    this.cache = cache;
    this.readThrough = readThrough;
    this.writeThrough = writeThrough;
    this.storeByValueOnHeap = storeByValueOnHeap;
  }

  @Override
  public boolean isReadThrough() {
    return readThrough;
  }

  @Override
  public boolean isWriteThrough() {
    return writeThrough;
  }

  @Override
  public boolean isStatisticsEnabled() {
    return statisticsEnabled;
  }

  @Override
  public void setStatisticsEnabled(boolean enabled) {
    this.statisticsEnabled = enabled;
  }

  @Override
  public boolean isManagementEnabled() {
    return managementEnabled;
  }

  @Override
  public void setManagementEnabled(boolean enabled) {
    this.managementEnabled = enabled;
  }

  @Override
  public void addCacheEntryListenerConfiguration(CacheEntryListenerConfiguration cacheEntryListenerConfiguration) {
    // Nothing to do - we do not maintain / expose them
  }

  @Override
  public void removeCacheEntryListenerConfiguration(CacheEntryListenerConfiguration cacheEntryListenerConfiguration) {
    // Nothing to do - we do not maintain / expose them
  }

  @Override
  public  T unwrap(Class clazz) {
      return Unwrap.unwrap(clazz, this, cache.getRuntimeConfiguration());
  }

  @Override
  public Class getKeyType() {
    return cache.getRuntimeConfiguration().getKeyType();
  }

  @Override
  public Class getValueType() {
    return cache.getRuntimeConfiguration().getValueType();
  }

  @Override
  public boolean isStoreByValue() {
    return storeByValueOnHeap;
  }

  private Object writeReplace() throws ObjectStreamException {
    throw new UnsupportedOperationException("Serialization of Ehcache provider configuration classes is not supported");
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy