Package org.infinispan.persistence.spi

Examples of org.infinispan.persistence.spi.CacheWriter


            Set undelegated = new HashSet();//black magic to make sure the store start only gets invoked once
            for (CacheWriter w : writers) {
               w.start();
               if (w instanceof DelegatingCacheWriter) {
                  CacheWriter actual = undelegate(w);
                  actual.start();
                  undelegated.add(actual);
               } else {
                  undelegated.add(w);
               }

               if (configMap.get(w).purgeOnStartup()) {
                  if (!(w instanceof AdvancedCacheWriter))
                     throw new PersistenceException("'purgeOnStartup' can only be set on stores implementing " +
                                                          "" + AdvancedCacheWriter.class.getName());
                  ((AdvancedCacheWriter) w).clear();
               }
            }

            for (CacheLoader l : loaders) {
               if (!undelegated.contains(l))
                  l.start();
               if (l instanceof DelegatingCacheLoader) {
                  CacheLoader actual = undelegate(l);
                  if (!undelegated.contains(actual)) {
                     actual.start();
                  }
               }
            }
         } finally {
            if (xaTx != null) {
View Full Code Here


      Set undelegated = new HashSet();
      for (CacheWriter w : writers) {
         w.stop();
         if (w instanceof DelegatingCacheWriter) {
            CacheWriter actual = undelegate(w);
            actual.stop();
            undelegated.add(actual);
         } else {
            undelegated.add(w);
         }
      }

      for (CacheLoader l : loaders) {
         if (!undelegated.contains(l))
            l.stop();
         if (l instanceof DelegatingCacheLoader) {
            CacheLoader actual = undelegate(l);
            if (!undelegated.contains(actual)) {
               actual.stop();
            }
         }
      }

   }
View Full Code Here

               if (undelegate(l).getClass().getName().equals(storeType))
                  clIt.remove();
            }
            Iterator<CacheWriter> cwIt = writers.iterator();
            while (cwIt.hasNext()) {
               CacheWriter w = cwIt.next();
               if (undelegate(w).getClass().getName().equals(storeType))
                  cwIt.remove();
            }
         } finally {
            storesMutex.writeLock().unlock();
View Full Code Here

            if (storeClass.isInstance(real)) {
               result.add((T) real);
            }
         }
         for (CacheWriter w : writers) {
            CacheWriter real = undelegate(w);
            if (storeClass.isInstance(real))
               result.add((T) real);
         }
         return result;
      } finally {
View Full Code Here

         }
         if (classAnnotation == null) {
            throw log.loaderConfigurationDoesNotSpecifyLoaderClass(cfg.getClass().getName());
         }
         Object instance = Util.getInstance(classAnnotation);
         CacheWriter writer = instance instanceof CacheWriter ? (CacheWriter) instance : null;
         CacheLoader loader = instance instanceof CacheLoader ? (CacheLoader) instance : null;


         if (cfg.ignoreModifications())
            writer = null;

         if (cfg.singletonStore().enabled() && writer != null) {
            writer = (writer instanceof AdvancedCacheWriter) ?
                  new AdvancedSingletonCacheWriter(writer, cfg.singletonStore()) :
                  new SingletonCacheWriter(writer, cfg.singletonStore());
         }

         if (cfg.async().enabled() && writer != null) {
            writer = createAsyncWriter(writer);
            if (loader != null) {
               AtomicReference<State> state = ((AsyncCacheWriter) writer).getState();
               loader = (loader instanceof AdvancedCacheLoader) ?
                     new AdvancedAsyncCacheLoader(loader, state) : new AsyncCacheLoader(loader, state);
            }
         }

         InitializationContextImpl ctx = new InitializationContextImpl(cfg, cache, m, timeService, byteBufferFactory,
                                                                       marshalledEntryFactory);
         if (loader != null) {
            if (loader instanceof DelegatingCacheLoader)
               loader.init(ctx);
            loaders.add(loader);
            configMap.put(loader, cfg);
         }
         if (writer != null) {
            if (writer instanceof DelegatingCacheWriter)
               writer.init(ctx);
            writers.add(writer);
            configMap.put(writer, cfg);
         }

         //the delegates only propagate init if the underlaying object is a delegate as well.
View Full Code Here

            Set undelegated = new HashSet();//black magic to make sure the store start only gets invoked once
            for (CacheWriter w : writers) {
               w.start();
               if (w instanceof DelegatingCacheWriter) {
                  CacheWriter actual = undelegate(w);
                  actual.start();
                  undelegated.add(actual);
               } else {
                  undelegated.add(w);
               }

               if (configMap.get(w).purgeOnStartup()) {
                  if (!(w instanceof AdvancedCacheWriter))
                     throw new CacheLoaderException("'purgeOnStartup' can only be set on stores implementing " +
                                                          "" + AdvancedCacheWriter.class.getName());
                  ((AdvancedCacheWriter) w).clear();
               }
            }

            for (CacheLoader l : loaders) {
               if (!undelegated.contains(l))
                  l.start();
               if (l instanceof DelegatingCacheLoader) {
                  CacheLoader actual = undelegate(l);
                  if (!undelegated.contains(actual)) {
                     actual.start();
                  }
               }
            }
         } finally {
            if (xaTx != null) {
View Full Code Here

      Set undelegated = new HashSet();
      for (CacheWriter w : writers) {
         w.stop();
         if (w instanceof DelegatingCacheWriter) {
            CacheWriter actual = undelegate(w);
            actual.stop();
            undelegated.add(actual);
         } else {
            undelegated.add(w);
         }
      }

      for (CacheLoader l : loaders) {
         if (!undelegated.contains(l))
            l.stop();
         if (l instanceof DelegatingCacheLoader) {
            CacheLoader actual = undelegate(l);
            if (!undelegated.contains(actual)) {
               actual.stop();
            }
         }
      }

   }
View Full Code Here

               if (undelegate(l).getClass().getName().equals(storeType))
                  clIt.remove();
            }
            Iterator<CacheWriter> cwIt = writers.iterator();
            while (cwIt.hasNext()) {
               CacheWriter w = cwIt.next();
               if (undelegate(w).getClass().getName().equals(storeType))
                  cwIt.remove();
            }
         } finally {
            storesMutex.writeLock().unlock();
View Full Code Here

            if (storeClass.isInstance(real)) {
               result.add((T) real);
            }
         }
         for (CacheWriter w : writers) {
            CacheWriter real = undelegate(w);
            if (storeClass.isInstance(real))
               result.add((T) real);
         }
         return result;
      } finally {
View Full Code Here

         ConfigurationFor annotation = cfg.getClass().getAnnotation(ConfigurationFor.class);
         if (annotation == null) {
            throw log.loaderConfigurationDoesNotSpecifyLoaderClass(cfg.getClass().getName());
         }
         Object instance = Util.getInstance(annotation.value());
         CacheWriter writer = instance instanceof CacheWriter ? (CacheWriter) instance : null;
         CacheLoader loader = instance instanceof CacheLoader ? (CacheLoader) instance : null;


         if (cfg.ignoreModifications())
            writer = null;

         if (cfg.singletonStore().enabled() && writer != null) {
            writer = (writer instanceof AdvancedCacheWriter) ?
                  new AdvancedSingletonCacheWriter(writer, cfg.singletonStore()) :
                  new SingletonCacheWriter(writer, cfg.singletonStore());
         }

         if (cfg.async().enabled() && writer != null) {
            writer = createAsyncWriter(writer);
            if (loader != null) {
               AtomicReference<State> state = ((AsyncCacheWriter) writer).getState();
               loader = (loader instanceof AdvancedCacheLoader) ?
                     new AdvancedAsyncCacheLoader(loader, state) : new AsyncCacheLoader(loader, state);
            }
         }

         InitializationContextImpl ctx = new InitializationContextImpl(cfg, cache, m, timeService, byteBufferFactory,
                                                                       marshalledEntryFactory);
         if (loader != null) {
            loader.init(ctx);
            loaders.add(loader);
            configMap.put(loader, cfg);
         }
         if (writer != null) {
            writer.init(ctx);
            writers.add(writer);
            configMap.put(writer, cfg);
         }

         //the delegates only propagate init if the underlaying object is a delegate as well.
View Full Code Here

TOP

Related Classes of org.infinispan.persistence.spi.CacheWriter

Copyright © 2018 www.massapicom. 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.