コード例 #1
0
  /**
   * Constructs a {@link MutableConfiguration} based on another {@link Configuration}.
   *
   * @param configuration the {@link Configuration}
   */
  public MutableConfiguration(Configuration<K, V> configuration) {

    this.keyType = configuration.getKeyType();
    this.valueType = configuration.getValueType();

    listenerConfigurations = new ArrayList<CacheEntryListenerConfiguration<K, V>>();
    for (CacheEntryListenerConfiguration<K, V> definition :
        configuration.getCacheEntryListenerConfigurations()) {
      addCacheEntryListenerConfiguration(definition);
    }

    this.cacheLoaderFactory = configuration.getCacheLoaderFactory();
    this.cacheWriterFactory = configuration.getCacheWriterFactory();

    if (configuration.getExpiryPolicyFactory() == null) {
      this.expiryPolicyFactory = EternalExpiryPolicy.factoryOf();
    } else {
      this.expiryPolicyFactory = configuration.getExpiryPolicyFactory();
    }

    this.isReadThrough = configuration.isReadThrough();
    this.isWriteThrough = configuration.isWriteThrough();

    this.isStatisticsEnabled = configuration.isStatisticsEnabled();

    this.isStoreByValue = configuration.isStoreByValue();

    this.isManagementEnabled = configuration.isManagementEnabled();
  }
コード例 #2
0
 /**
  * Set the {@link Factory} for the {@link ExpiryPolicy}. If <code>null</code> is specified the
  * default {@link ExpiryPolicy} is used.
  *
  * @param factory the {@link ExpiryPolicy} {@link Factory}
  * @return the {@link MutableConfiguration} to permit fluent-style method calls
  */
 public MutableConfiguration<K, V> setExpiryPolicyFactory(
     Factory<? extends ExpiryPolicy> factory) {
   if (factory == null) {
     this.expiryPolicyFactory = EternalExpiryPolicy.factoryOf();
   } else {
     this.expiryPolicyFactory = (Factory<ExpiryPolicy>) factory;
   }
   return this;
 }
コード例 #3
0
 /** Constructs a default {@link MutableConfiguration}. */
 public MutableConfiguration() {
   this.keyType = (Class<K>) Object.class;
   this.valueType = (Class<V>) Object.class;
   this.listenerConfigurations = new ArrayList<CacheEntryListenerConfiguration<K, V>>();
   this.cacheLoaderFactory = null;
   this.cacheWriterFactory = null;
   this.expiryPolicyFactory = EternalExpiryPolicy.factoryOf();
   this.isReadThrough = false;
   this.isWriteThrough = false;
   this.isStatisticsEnabled = false;
   this.isStoreByValue = true;
   this.isManagementEnabled = false;
 }
コード例 #4
0
  public Eh107CompleteConfiguration(
      Configuration<K, V> config,
      final CacheConfiguration<K, V> ehcacheConfig,
      boolean useEhcacheExpiry,
      boolean useEhcacheLoaderWriter) {
    this.ehcacheConfig = ehcacheConfig;
    this.keyType = config.getKeyType();
    this.valueType = config.getValueType();
    this.isStoreByValue = isStoreByValue(config, ehcacheConfig);

    Factory<ExpiryPolicy> tempExpiryPolicyFactory = EternalExpiryPolicy.factoryOf();

    if (config instanceof CompleteConfiguration) {
      CompleteConfiguration<K, V> completeConfig = (CompleteConfiguration<K, V>) config;
      this.isReadThrough = completeConfig.isReadThrough();
      this.isWriteThrough = completeConfig.isWriteThrough();
      this.isStatisticsEnabled = completeConfig.isStatisticsEnabled();
      this.isManagementEnabled = completeConfig.isManagementEnabled();

      if (useEhcacheLoaderWriter) {
        this.cacheLoaderFactory = createThrowingFactory();
        this.cacheWriterFactory = createThrowingFactory();
      } else {
        this.cacheLoaderFactory = completeConfig.getCacheLoaderFactory();
        this.cacheWriterFactory = completeConfig.getCacheWriterFactory();
      }

      tempExpiryPolicyFactory = completeConfig.getExpiryPolicyFactory();
      for (CacheEntryListenerConfiguration<K, V> listenerConfig :
          completeConfig.getCacheEntryListenerConfigurations()) {
        cacheEntryListenerConfigs.add(listenerConfig);
      }
    } else {
      this.isReadThrough = false;
      this.isWriteThrough = false;
      this.isStatisticsEnabled = false;
      this.isManagementEnabled = false;
      this.cacheLoaderFactory = null;
      this.cacheWriterFactory = null;
    }

    if (useEhcacheExpiry) {
      tempExpiryPolicyFactory = createThrowingFactory();
    }

    this.expiryPolicyFactory = tempExpiryPolicyFactory;
  }