Examples of ExoCacheConfig


Examples of org.exoplatform.services.cache.ExoCacheConfig

   }

   @SuppressWarnings({"rawtypes", "unchecked"})
   private ExoCache<? extends Serializable, ?> createCacheInstance(String region) throws Exception
   {
      ExoCacheConfig config = configs_.get(region);
      if (config == null)
         config = defaultConfig_;

      // Ensure the configuration integrity
      final ExoCacheConfig safeConfig = config.clone();
      // Set the region as name
      safeConfig.setName(region);
     
      ExoCache simple = null;
      if (factory_ != DEFAULT_FACTORY && safeConfig.getClass().isAssignableFrom(ExoCacheConfig.class) //NOSONAR
         && safeConfig.getImplementation() != null)
      {
         // The implementation exists and the config is not a sub class of ExoCacheConfig
         // we assume that we expect to use the default cache factory
         try
         {
            // We check if the given implementation is a known class
            Class<?> implClass = ClassLoading.loadClass(safeConfig.getImplementation(), this);
            // Implementation is an existing class
            if (ExoCache.class.isAssignableFrom(implClass))
            {
               // The implementation is a sub class of eXo Cache so we use the default factory
               simple = DEFAULT_FACTORY.createCache(safeConfig);              
            }
         }
         catch (ClassNotFoundException e)
         {
            if (LOG.isTraceEnabled())
            {
               LOG.trace("An exception occurred: " + e.getMessage());
            }
         }
      }
      if (simple == null)
      {
         // We use the configured cache factory
         simple = factory_.createCache(safeConfig);
      }
     
      if (managed != null)
      {
         managed.registerCache(simple);
      }
      // If the flag avoid value replication is enabled and the cache is replicated
      // or distributed we wrap the eXo cache instance into an InvalidationExoCache
      // to enable the invalidation
      return safeConfig.avoidValueReplication() && (safeConfig.isRepicated() || safeConfig.isDistributed())
         ? new InvalidationExoCache(simple) : simple;
   }
View Full Code Here

Examples of org.exoplatform.services.cache.ExoCacheConfig

   }

   @SuppressWarnings("unchecked")
   public void testDistributedCache() throws Exception
   {
      ExoCacheConfig config = new ExoCacheConfig();
      config.setName("MyCacheDistributed");
      config.setMaxSize(5);
      config.setLiveTime(1);
      config.setImplementation("LRU");
      config.setDistributed(true);
      ExoCacheConfig config2 = new ExoCacheConfig();
      config2.setName("MyCacheDistributed2");
      config2.setMaxSize(5);
      config2.setLiveTime(1);
      config2.setImplementation("LRU");
      config2.setDistributed(true);
      AbstractExoCache<Serializable, String> cache1 =
         (AbstractExoCache<Serializable, String>)getExoCacheFactoryInstance().createCache(config);
      MyCacheListener<String> listener1 = new MyCacheListener<String>();
      cache1.addCacheListener(listener1);
      AbstractExoCache<Serializable, String> cache2 =
View Full Code Here

Examples of org.exoplatform.services.cache.ExoCacheConfig

   }

   @SuppressWarnings("unchecked")
   public void testDistributedCacheWithNSValues() throws Exception
   {
      ExoCacheConfig config = new ExoCacheConfig();
      config.setName("MyCacheDistributedWithNSValues");
      config.setMaxSize(5);
      config.setLiveTime(1);
      config.setImplementation("LRU");
      config.setDistributed(true);
      config.setAvoidValueReplication(true);
      ExoCacheConfig config2 = new ExoCacheConfig();
      config2.setName("MyCacheDistributedWithNSValues2");
      config2.setMaxSize(5);
      config2.setLiveTime(1);
      config2.setImplementation("LRU");
      config2.setDistributed(true);
      config2.setAvoidValueReplication(true);
      AbstractExoCache<Serializable, MyNonSerializableValue> acache1 =
         (AbstractExoCache<Serializable, MyNonSerializableValue>)getExoCacheFactoryInstance().createCache(config);
      MyCacheListener<MyNonSerializableValue> listener1 = new MyCacheListener<MyNonSerializableValue>();
      ExoCache<Serializable, MyNonSerializableValue> cache1 = new InvalidationExoCache<Serializable, MyNonSerializableValue>(acache1);
      cache1.addCacheListener(listener1);
View Full Code Here

Examples of org.exoplatform.services.cache.ExoCacheConfig

      return (ExoCache<K, V>)cache;
   }

   synchronized private ExoCache<? extends Serializable, ?> createCacheInstance(String region) throws Exception
   {
      ExoCacheConfig config = configs_.get(region);
      if (config == null)
         config = defaultConfig_;
      ExoCache<? extends Serializable, ?> cache;
      if (config.getImplementation() == null)
      {
         cache = new SimpleExoCache<Serializable, Object>();
      }
      else
      {
         ClassLoader cl = Thread.currentThread().getContextClassLoader();
         Class<ExoCache<? extends Serializable, ?>> clazz =
            (Class<ExoCache<? extends Serializable, ?>>)cl.loadClass(config.getImplementation());
         cache = clazz.newInstance();
      }
      cache.setName(region);
      cache.setLabel(config.getLabel());
      cache.setMaxSize(config.getMaxSize());
      cache.setLiveTime(config.getLiveTime());
      cache.setLogEnabled(config.isLogEnabled());
      if (cache.isLogEnabled())
      {
         cache.addCacheListener(loggingListener_);
      }
View Full Code Here

Examples of org.exoplatform.services.cache.ExoCacheConfig

   }

   @SuppressWarnings({"rawtypes", "unchecked"})
   private ExoCache<? extends Serializable, ?> createCacheInstance(String region) throws Exception
   {
      ExoCacheConfig config = configs_.get(region);
      if (config == null)
         config = defaultConfig_;

      // Ensure the configuration integrity
      final ExoCacheConfig safeConfig = config.clone();
      // Set the region as name
      safeConfig.setName(region);
     
      ExoCache simple = null;
      if (factory_ != DEFAULT_FACTORY && safeConfig.getClass().isAssignableFrom(ExoCacheConfig.class)
         && safeConfig.getImplementation() != null)
      {
         // The implementation exists and the config is not a sub class of ExoCacheConfig
         // we assume that we expect to use the default cache factory
         try
         {
            final ClassLoader cl = Thread.currentThread().getContextClassLoader();
            // We check if the given implementation is a known class
            Class implClass = cl.loadClass(safeConfig.getImplementation());           
            // Implementation is an existing class
            if (ExoCache.class.isAssignableFrom(implClass))
            {
               // The implementation is a sub class of eXo Cache so we use the default factory
               simple = DEFAULT_FACTORY.createCache(safeConfig);              
            }
         }
         catch (ClassNotFoundException e)
         {
            // The implementation could not be found
         }
      }
      if (simple == null)
      {
         // We use the configured cache factory
         simple = factory_.createCache(safeConfig);
      }
     
      if (managed != null)
      {
         managed.registerCache(simple);
      }
      // If the flag avoid value replication is enabled and the cache is replicated
      // or distributed we wrap the eXo cache instance into an InvalidationExoCache
      // to enable the invalidation
      return safeConfig.avoidValueReplication() && (safeConfig.isRepicated() || safeConfig.isDistributed())
         ? new InvalidationExoCache(simple) : simple;
   }
View Full Code Here

Examples of org.exoplatform.services.cache.ExoCacheConfig

   }

   @SuppressWarnings({"rawtypes", "unchecked"})
   private ExoCache<? extends Serializable, ?> createCacheInstance(String region) throws Exception
   {
      ExoCacheConfig config = configs_.get(region);
      if (config == null)
         config = defaultConfig_;

      // Ensure the configuration integrity
      final ExoCacheConfig safeConfig = config.clone();
      // Set the region as name
      safeConfig.setName(region);
     
      ExoCache simple = null;
      if (factory_ != DEFAULT_FACTORY && safeConfig.getClass().isAssignableFrom(ExoCacheConfig.class) //NOSONAR
         && safeConfig.getImplementation() != null)
      {
         // The implementation exists and the config is not a sub class of ExoCacheConfig
         // we assume that we expect to use the default cache factory
         try
         {
            // We check if the given implementation is a known class
            Class<?> implClass = Tools.loadClass(safeConfig.getImplementation(), this);
            // Implementation is an existing class
            if (ExoCache.class.isAssignableFrom(implClass))
            {
               // The implementation is a sub class of eXo Cache so we use the default factory
               simple = DEFAULT_FACTORY.createCache(safeConfig);              
            }
         }
         catch (ClassNotFoundException e)
         {
            if (LOG.isTraceEnabled())
            {
               LOG.trace("An exception occurred: " + e.getMessage());
            }
         }
      }
      if (simple == null)
      {
         // We use the configured cache factory
         simple = factory_.createCache(safeConfig);
      }
     
      if (managed != null)
      {
         managed.registerCache(simple);
      }
      // If the flag avoid value replication is enabled and the cache is replicated
      // or distributed we wrap the eXo cache instance into an InvalidationExoCache
      // to enable the invalidation
      return safeConfig.avoidValueReplication() && (safeConfig.isRepicated() || safeConfig.isDistributed())
         ? new InvalidationExoCache(simple) : simple;
   }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.