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

akka.stream.alpakka.geode.internal.GeodeCache.scala Maven / Gradle / Ivy

Go to download

Alpakka is a Reactive Enterprise Integration library for Java and Scala, based on Reactive Streams and Akka.

There is a newer version: 2.0.2
Show newest version
/*
 * Copyright (C) 2016-2018 Lightbend Inc. 
 */

package akka.stream.alpakka.geode.internal

import akka.stream.alpakka.geode.GeodeSettings
import akka.stream.alpakka.geode.internal.pdx.DelegatingPdxSerializer
import org.apache.geode.cache.client.{ClientCache, ClientCacheFactory}
import org.apache.geode.pdx.PdxSerializer

/**
 * Base of all geode client.
 *
 */
abstract class GeodeCache(geodeSettings: GeodeSettings) {

  private lazy val serializer = new DelegatingPdxSerializer(geodeSettings.pdxCompat)

  protected def registerPDXSerializer[V](pdxSerializer: PdxSerializer, clazz: Class[V]): Unit =
    serializer.register(pdxSerializer, clazz)

  /**
   * This method will overloaded to provide server event subscription.
   *
   * @return
   */
  protected def configure(factory: ClientCacheFactory): ClientCacheFactory

  /**
   * Return ClientCacheFactory:
   * 
    *
  • with PDX support
  • *
  • configured by sub classes
  • *
  • customized by client application
  • *
* */ final protected def newCacheFactory(): ClientCacheFactory = { val factory = configure(new ClientCacheFactory().setPdxSerializer(serializer)) geodeSettings.configure.map(_(factory)).getOrElse(factory) } lazy val cache: ClientCache = newCacheFactory().create() def close(keepAlive: Boolean = false): Unit = cache.close(keepAlive) }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy