Package org.jboss.cache.interceptors.base

Examples of org.jboss.cache.interceptors.base.CommandInterceptor


      listener = new TestListener();
      cache = createCacheWithListener(listener);

      ComponentRegistry cr = TestingUtil.extractComponentRegistry(cache);

      CommandInterceptor interceptor = new OptimisticCreateIfNotExistsInterceptor();
      cr.registerComponent(interceptor, OptimisticCreateIfNotExistsInterceptor.class);
      CommandInterceptor nodeInterceptor = new OptimisticNodeInterceptor();
      cr.registerComponent(nodeInterceptor, OptimisticNodeInterceptor.class);
      dummy = new MockInterceptor();
      cr.registerComponent(dummy, MockInterceptor.class);

      interceptor.setNext(nodeInterceptor);
      nodeInterceptor.setNext(dummy);

      TestingUtil.replaceInterceptorChain(cache, interceptor);

      mgr = cache.getConfiguration().getRuntimeConfig().getTransactionManager();
   }
View Full Code Here


   @BeforeMethod
   public void setUp() throws Exception
   {
      cache = createCache();

      CommandInterceptor interceptor = TestingUtil.findInterceptor(cache, OptimisticCreateIfNotExistsInterceptor.class);
      CommandInterceptor nodeInterceptor = TestingUtil.findInterceptor(cache, OptimisticNodeInterceptor.class);
      dummy = new MockInterceptor();

      interceptor.setNext(nodeInterceptor);
      nodeInterceptor.setNext(dummy);

      TestingUtil.replaceInterceptorChain(cache, interceptor);

      mgr = cache.getTransactionManager();
   }
View Full Code Here

   {
      Iterator ints = cache.getInterceptorChain().iterator();
      CacheStoreInterceptor csi = null;
      while (ints.hasNext())
      {
         CommandInterceptor i = (CommandInterceptor) ints.next();
         if (i instanceof CacheStoreInterceptor)
         {
            csi = (CacheStoreInterceptor) i;
            break;
         }
View Full Code Here

      final int minSleep = 0;
      final int maxSleep = 1000;
      TestListener listener = new TestListener();
      final CacheSPI<Object, Object> cache = createCacheWithListener(listener);

      CommandInterceptor interceptor = new OptimisticCreateIfNotExistsInterceptor();
      CommandInterceptor dummy = new MockInterceptor();
      interceptor.setNext(dummy);

      TestingUtil.replaceInterceptorChain(cache, interceptor);

      // should just be the root node
View Full Code Here

      final int minSleep = 0;
      final int maxSleep = 500;
      TestListener listener = new TestListener();
      final CacheSPI<Object, Object> cache = createCacheWithListener(listener);

      CommandInterceptor interceptor = new OptimisticCreateIfNotExistsInterceptor();
      CommandInterceptor dummy = new MockInterceptor();
      interceptor.setNext(dummy);

      TestingUtil.replaceInterceptorChain(cache, interceptor);

      final DummyTransactionManager mgr = DummyTransactionManager.getInstance();
View Full Code Here

      return new InterceptorChainFactory();
   }

   private CommandInterceptor createInterceptor(Class<? extends CommandInterceptor> clazz) throws IllegalAccessException, InstantiationException
   {
      CommandInterceptor chainedInterceptor = componentRegistry.getComponent(clazz);
      if (chainedInterceptor == null)
      {
         chainedInterceptor = clazz.newInstance();
         componentRegistry.registerComponent(chainedInterceptor, clazz);
      }
      else
      {
         // wipe next/last chaining!!
         chainedInterceptor.setNext(null);
      }
      return chainedInterceptor;
   }
View Full Code Here

   public InterceptorChain buildInterceptorChain() throws IllegalAccessException, InstantiationException, ClassNotFoundException
   {
      boolean optimistic = configuration.getNodeLockingScheme() == NodeLockingScheme.OPTIMISTIC;
      boolean invocationBatching = configuration.isInvocationBatchingEnabled();
      // load the icInterceptor first
      CommandInterceptor first = invocationBatching ? createInterceptor(BatchingInterceptor.class) : createInterceptor(InvocationContextInterceptor.class);
      InterceptorChain interceptorChain = new InterceptorChain(first);

      // add the interceptor chain to the registry first, since some interceptors may ask for it.
      componentRegistry.registerComponent(interceptorChain, InterceptorChain.class);

      // NOW add the ICI if we are using batching!
      if (invocationBatching)
         interceptorChain.appendIntereceptor(createInterceptor(InvocationContextInterceptor.class));

      // load the cache management interceptor next
      if (configuration.getExposeManagementStatistics())
         interceptorChain.appendIntereceptor(createInterceptor(CacheMgmtInterceptor.class));

      // load the tx interceptor
      interceptorChain.appendIntereceptor(createInterceptor(optimistic ? OptimisticTxInterceptor.class : TxInterceptor.class));

      if (configuration.isUseLazyDeserialization())
         interceptorChain.appendIntereceptor(createInterceptor(MarshalledValueInterceptor.class));
      interceptorChain.appendIntereceptor(createInterceptor(NotificationInterceptor.class));

      switch (configuration.getCacheMode())
      {
         case REPL_SYNC:
         case REPL_ASYNC:
            interceptorChain.appendIntereceptor(optimistic ? createInterceptor(OptimisticReplicationInterceptor.class) : createInterceptor(ReplicationInterceptor.class));
            break;
         case INVALIDATION_SYNC:
         case INVALIDATION_ASYNC:
            interceptorChain.appendIntereceptor(createInterceptor(InvalidationInterceptor.class));
            break;
         case LOCAL:
            //Nothing...
      }

      if (configuration.getNodeLockingScheme() == NodeLockingScheme.MVCC)
      {
         // if MVCC, then the CLI or AI must come before the MVCCLI.
         if (configuration.isUsingCacheLoaders())
         {
            if (configuration.getCacheLoaderConfig().isPassivation())
            {
               interceptorChain.appendIntereceptor(createInterceptor(ActivationInterceptor.class));
            }
            else
            {
               interceptorChain.appendIntereceptor(createInterceptor(CacheLoaderInterceptor.class));
            }
         }
         interceptorChain.appendIntereceptor(createInterceptor(MVCCLockingInterceptor.class));
      }
      else if (configuration.getNodeLockingScheme() == NodeLockingScheme.PESSIMISTIC)
      {
         interceptorChain.appendIntereceptor(createInterceptor(PessimisticLockInterceptor.class));
      }

      if (configuration.isUsingCacheLoaders())
      {
         if (configuration.getCacheLoaderConfig().isPassivation())
         {
            if (configuration.getNodeLockingScheme() != NodeLockingScheme.MVCC)
            {
               interceptorChain.appendIntereceptor(createInterceptor(LegacyActivationInterceptor.class));
               interceptorChain.appendIntereceptor(createInterceptor(LegacyPassivationInterceptor.class));
            }
            else
            {
               interceptorChain.appendIntereceptor(createInterceptor(PassivationInterceptor.class));
            }
         }
         else
         {
            if (configuration.getNodeLockingScheme() != NodeLockingScheme.MVCC)
            {
               interceptorChain.appendIntereceptor(createInterceptor(LegacyCacheLoaderInterceptor.class));
               interceptorChain.appendIntereceptor(createInterceptor(LegacyCacheStoreInterceptor.class));
            }
            else
            {
               interceptorChain.appendIntereceptor(createInterceptor(CacheStoreInterceptor.class));
            }
         }
      }

      if (configuration.isUsingBuddyReplication())
      {
         if (configuration.getNodeLockingScheme() == NodeLockingScheme.MVCC)
            interceptorChain.appendIntereceptor(createInterceptor(DataGravitatorInterceptor.class));
         else
            interceptorChain.appendIntereceptor(createInterceptor(LegacyDataGravitatorInterceptor.class));
      }


      if (optimistic)
      {
         interceptorChain.appendIntereceptor(createInterceptor(OptimisticLockingInterceptor.class));
         interceptorChain.appendIntereceptor(createInterceptor(OptimisticValidatorInterceptor.class));
         interceptorChain.appendIntereceptor(createInterceptor(OptimisticCreateIfNotExistsInterceptor.class));
      }
      // eviction interceptor to come before the optimistic node interceptor
      if (configuration.getEvictionConfig() != null && configuration.getEvictionConfig().isValidConfig())
         interceptorChain.appendIntereceptor(createInterceptor(configuration.isUsingBuddyReplication() ? BuddyRegionAwareEvictionInterceptor.class : EvictionInterceptor.class));

      if (optimistic) interceptorChain.appendIntereceptor(createInterceptor(OptimisticNodeInterceptor.class));
      CommandInterceptor callInterceptor = createInterceptor(CallInterceptor.class);
      interceptorChain.appendIntereceptor(callInterceptor);
      if (log.isTraceEnabled()) log.trace("Finished building default interceptor chain.");
      buildCustomInterceptors(interceptorChain, configuration.getCustomInterceptors());
      return interceptorChain;
   }
View Full Code Here

         before = getAttributeValue(interceptorElement, "before");
         if (!existsAttribute(before)) before = null;
         after = getAttributeValue(interceptorElement, "after");
         if (!existsAttribute(after)) after = null;

         CommandInterceptor interceptor = buildCommandInterceptor(interceptorElement);

         CustomInterceptorConfig customInterceptorConfig = new CustomInterceptorConfig(interceptor, first, last, index, after, before);
         interceptorConfigs.add(customInterceptorConfig);
      }
      return interceptorConfigs;
View Full Code Here

    */
   private CommandInterceptor buildCommandInterceptor(Element element)
   {
      String interceptorClass = getAttributeValue(element, "class");
      if (!existsAttribute(interceptorClass)) throw new ConfigurationException("Interceptor class cannot be empty!");
      CommandInterceptor result;
      try
      {
         result = (CommandInterceptor) Util.loadClass(interceptorClass).newInstance();
      }
      catch (Exception e)
View Full Code Here

         interceptor.setNext(firstInChain);
         firstInChain = interceptor;
         return;
      }
      if (firstInChain == null) return;
      CommandInterceptor it = firstInChain;
      int index = 0;
      while (it != null)
      {
         if (++index == position)
         {
            interceptor.setNext(it.getNext());
            it.setNext(interceptor);
            return;
         }
         it = it.getNext();
      }
      throw new IllegalArgumentException("Invalid index: " + index + " !");
   }
View Full Code Here

TOP

Related Classes of org.jboss.cache.interceptors.base.CommandInterceptor

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.