Class CacheSettingServiceImpl

java.lang.Object
org.exoplatform.settings.cache.CacheSettingServiceImpl
All Implemented Interfaces:
org.exoplatform.commons.api.settings.SettingService

public class CacheSettingServiceImpl extends Object implements org.exoplatform.commons.api.settings.SettingService
Created by The eXo Platform SAS Author : eXoPlatform bangnv@exoplatform.com Nov 15, 2012 CacheSettingServiceImpl is implemented for application which uses cache. CacheSettingServiceImpl contains also settingService for database. In case of saving and removing setting properties, CacheSettingService will effect the change in cache and database. Otherwise, it will search setting properties in cache at first and then in database, that allows to improve performance.
eXo level API
Experimental
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected org.exoplatform.services.cache.future.FutureExoCache<org.exoplatform.commons.api.settings.data.SettingKey,org.exoplatform.commons.api.settings.SettingValue,org.exoplatform.commons.api.settings.SettingService>
     
    protected org.exoplatform.services.cache.ExoCache<org.exoplatform.commons.api.settings.data.SettingKey,org.exoplatform.commons.api.settings.SettingValue>
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    CacheSettingServiceImpl(JPASettingServiceImpl service, org.exoplatform.services.cache.CacheService cacheService)
    Create cache setting service object with service for database and service for cache
  • Method Summary

    Modifier and Type
    Method
    Description
    long
     
    org.exoplatform.commons.api.settings.SettingValue<?>
    get(org.exoplatform.commons.api.settings.data.Context context, org.exoplatform.commons.api.settings.data.Scope scope, String key)
    Get setting value associated with composite key(context, scope, key) This service will search in the cache first and then in the database.
    getContextNamesByType(String contextType, int offset, int limit)
     
    List<org.exoplatform.commons.api.settings.data.Context>
    getContextsByTypeAndScopeAndSettingName(String contextType, String scopeType, String scopeName, String settingName, int offset, int limit)
     
    getEmptyContextsByTypeAndScopeAndSettingName(String contextType, String scopeType, String scopeName, String settingName, int offset, int limit)
     
    Map<org.exoplatform.commons.api.settings.data.Scope,Map<String,org.exoplatform.commons.api.settings.SettingValue<String>>>
    getSettingsByContext(org.exoplatform.commons.api.settings.data.Context context)
     
    Map<String,org.exoplatform.commons.api.settings.SettingValue>
    getSettingsByContextAndScope(String contextType, String contextName, String scopeType, String scopeName)
     
    void
    remove(org.exoplatform.commons.api.settings.data.Context context)
    remove all the value associated with the specified context in cache and database also.
    void
    remove(org.exoplatform.commons.api.settings.data.Context context, org.exoplatform.commons.api.settings.data.Scope scope)
    remove all the value associated with the specified context and specified scope in cache and database also.
    void
    remove(org.exoplatform.commons.api.settings.data.Context context, org.exoplatform.commons.api.settings.data.Scope scope, String key)
    Remove all the value associated with the composite key(context,scope,key) in cache and also in database.
    void
    save(org.exoplatform.commons.api.settings.data.Context context)
     
    void
    set(org.exoplatform.commons.api.settings.data.Context context, org.exoplatform.commons.api.settings.data.Scope scope, String key, org.exoplatform.commons.api.settings.SettingValue<?> value)
    Set the specified value with the key which is composed by context, scope, key.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • settingCache

      protected org.exoplatform.services.cache.ExoCache<org.exoplatform.commons.api.settings.data.SettingKey,org.exoplatform.commons.api.settings.SettingValue> settingCache
    • futureExoCache

      protected org.exoplatform.services.cache.future.FutureExoCache<org.exoplatform.commons.api.settings.data.SettingKey,org.exoplatform.commons.api.settings.SettingValue,org.exoplatform.commons.api.settings.SettingService> futureExoCache
  • Constructor Details

    • CacheSettingServiceImpl

      public CacheSettingServiceImpl(JPASettingServiceImpl service, org.exoplatform.services.cache.CacheService cacheService)
      Create cache setting service object with service for database and service for cache
      Parameters:
      service - Setting service for database
      cacheService - Cache service
      eXo level API
      Experimental
  • Method Details

    • set

      public void set(org.exoplatform.commons.api.settings.data.Context context, org.exoplatform.commons.api.settings.data.Scope scope, String key, org.exoplatform.commons.api.settings.SettingValue<?> value)
      Set the specified value with the key which is composed by context, scope, key. The value will be saved in the cache and the database
      Specified by:
      set in interface org.exoplatform.commons.api.settings.SettingService
      Parameters:
      context - context with which the specified value is to be associated
      scope - scope with which the specified value is to be associated
      key - key with which the specified value is to be associated
      value - value to be associated with the specified key.
      eXo level API
      Experimental
    • get

      public org.exoplatform.commons.api.settings.SettingValue<?> get(org.exoplatform.commons.api.settings.data.Context context, org.exoplatform.commons.api.settings.data.Scope scope, String key)
      Get setting value associated with composite key(context, scope, key) This service will search in the cache first and then in the database.
      Specified by:
      get in interface org.exoplatform.commons.api.settings.SettingService
      Returns:
      Setting value with type of setting property, and null if the cache and the database doesn't contain the value for the composite key
      eXo level API
      Experimental
    • remove

      public void remove(org.exoplatform.commons.api.settings.data.Context context, org.exoplatform.commons.api.settings.data.Scope scope, String key)
      Remove all the value associated with the composite key(context,scope,key) in cache and also in database.
      Specified by:
      remove in interface org.exoplatform.commons.api.settings.SettingService
      Parameters:
      context - context with which the specified value is to be associated. The context type must be USER and context.id must be not null.
      scope - scope with which the specified value is to be associated. The scope.id must be not null.
      key - key with which the specified value is to be associated
      eXo level API
      Experimental
    • remove

      public void remove(org.exoplatform.commons.api.settings.data.Context context, org.exoplatform.commons.api.settings.data.Scope scope)
      remove all the value associated with the specified context and specified scope in cache and database also.
      Specified by:
      remove in interface org.exoplatform.commons.api.settings.SettingService
      Parameters:
      context - context with which the specified value is to be associated. The context type must be USER and context.id must be not null.
      scope - scope with which the specified value is to be associated. The scope.id must be not null.
      eXo level API
      Experimental
    • remove

      public void remove(org.exoplatform.commons.api.settings.data.Context context)
      remove all the value associated with the specified context in cache and database also.
      Specified by:
      remove in interface org.exoplatform.commons.api.settings.SettingService
      Parameters:
      context - context with which the specified value is to be associated. The context type must be USER and context.id must be not null.
      eXo level API
      Experimental
    • countContextsByType

      public long countContextsByType(String contextType)
      Specified by:
      countContextsByType in interface org.exoplatform.commons.api.settings.SettingService
    • getContextNamesByType

      public List<String> getContextNamesByType(String contextType, int offset, int limit)
      Specified by:
      getContextNamesByType in interface org.exoplatform.commons.api.settings.SettingService
    • getSettingsByContext

      public Map<org.exoplatform.commons.api.settings.data.Scope,Map<String,org.exoplatform.commons.api.settings.SettingValue<String>>> getSettingsByContext(org.exoplatform.commons.api.settings.data.Context context)
      Specified by:
      getSettingsByContext in interface org.exoplatform.commons.api.settings.SettingService
    • getContextsByTypeAndScopeAndSettingName

      public List<org.exoplatform.commons.api.settings.data.Context> getContextsByTypeAndScopeAndSettingName(String contextType, String scopeType, String scopeName, String settingName, int offset, int limit)
      Specified by:
      getContextsByTypeAndScopeAndSettingName in interface org.exoplatform.commons.api.settings.SettingService
    • getEmptyContextsByTypeAndScopeAndSettingName

      public Set<String> getEmptyContextsByTypeAndScopeAndSettingName(String contextType, String scopeType, String scopeName, String settingName, int offset, int limit)
      Specified by:
      getEmptyContextsByTypeAndScopeAndSettingName in interface org.exoplatform.commons.api.settings.SettingService
    • save

      public void save(org.exoplatform.commons.api.settings.data.Context context)
      Specified by:
      save in interface org.exoplatform.commons.api.settings.SettingService
    • getSettingsByContextAndScope

      public Map<String,org.exoplatform.commons.api.settings.SettingValue> getSettingsByContextAndScope(String contextType, String contextName, String scopeType, String scopeName)
      Specified by:
      getSettingsByContextAndScope in interface org.exoplatform.commons.api.settings.SettingService