Package org.jboss.cache.marshall

Source Code of org.jboss.cache.marshall.AbstractVersionAwareMarshallerTest

package org.jboss.cache.marshall;

import org.jboss.cache.CacheStatus;
import org.jboss.cache.RegionManager;
import org.jboss.cache.RegionManagerImpl;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.factories.ComponentRegistry;

/**
* @author Manik Surtani (<a href="mailto:manik AT jboss DOT org">manik AT jboss DOT org</a>)
* @since 2.1.0
*/
public abstract class AbstractVersionAwareMarshallerTest
{
   protected ThreadLocal<ComponentRegistry> crTL = new ThreadLocal<ComponentRegistry>();

   protected VersionAwareMarshaller createVAMandRestartCache(String replVersion)
   {
      ComponentRegistry cr = crTL.get();
      Configuration c = cr.getComponent(Configuration.class);
      c.setReplVersionString(replVersion);
      return createVAMandRestartCache(new RegionManagerImpl());
   }

   protected VersionAwareMarshaller createVAMandRestartCache(RegionManager rm)
   {
      ComponentRegistry cr = crTL.get();
      if (cr.getState() == CacheStatus.STARTED) cr.stop();
      cr.registerComponent(rm, RegionManager.class);
      cr.create();
      cr.rewire();
      // force cache mode
      VersionAwareMarshaller m = (VersionAwareMarshaller) cr.getComponent(Marshaller.class);
      m.init();
      m.initReplicationVersions();
      return m;
   }
}
TOP

Related Classes of org.jboss.cache.marshall.AbstractVersionAwareMarshallerTest

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.