2 Replies Latest reply on Mar 27, 2017 9:33 AM by Srini c

    Migration from JBoss cache to Infinispan

    Srini c Newbie

      Hi All,

      We currently use clustered jboss cache for our Hibernate and application cache. Currently we are with Jboss 6 App server and moving to Wildfly. We don't depend on the jboss cache that comes with the application server. We bundle all the

      cache files along with theapplicationn. Part of the App server migration, we are moving from jboss cache to infinispan. The documentation for migration from Jbosscache to infinispan available did not help us out. Requesting if you can guide on migrating from Jboss cache

      to infinispan. Below are the details for loading the cache manger as, the migration starts with the cache manager.

       

       

        <!--

        Configure a JBoss Cache cache manager from the

        jbosscache-[webmodulename].xml file on the runtime classpath. This

        file contains the configurations for all of our caches, including both

        the application cache and the Hibernate cache(s).

        -->

        <bean id="jbossCacheManager"

        class="org.jboss.cache.CacheManagerImpl"

        destroy-method="stop"

        init-method="start">

        <constructor-arg index="0">

                  <bean class="xxxx.model.framework.cache.adaptors.FilteredJBossCacheConfigurationFileFactoryBean">

                      <property name="clusteredConfigurationResource" value="classpath:jbosscache-clustered.xml"/>

                      <property name="containerEnvironment" ref="containerEnvironment"/>

                      <property name="localConfigurationResource" value="classpath:jbosscache-local.xml"/>

                      <property name="moduleName" ref="moduleName"/>

                      <property name="properties">

                          <bean class="java.lang.System" factory-method="getProperties"/>

                      </property>

                  </bean>

        </constructor-arg>

        <constructor-arg index="1">

                  <bean class="xxxx.model.framework.cache.adaptors.JGroupsChannelFactoryBean">

                      <property name="configurationResource" value="classpath:jgroups-stacks.xml"/>

                      <property name="containerEnvironment" ref="containerEnvironment"/>

                      <property name="moduleName" ref="moduleName"/>

                  </bean>

        </constructor-arg>

        </bean>

       

       

       

      /**

      * <p>

      * <code>FilteredJBossCacheConfigurationFileFactoryBean</code> is an

      * implementation of the Spring {@link FactoryBean} interface which dynamically

      * produces a JBoss Cache configuration file from a parameterized base file.

      * </p>

      *

      */

      public class FilteredJBossCacheConfigurationFileFactoryBean extends AbstractFactoryBean

      private File writeConfigurationFile(final StringBuilder content) throws IOException

          {

              // Create the destination file, deleting any pre-existing copy.

              final File filteredFile = new File(containerEnvironment.getTemporaryDirectory(), String

                      .format("jbosscache-%s.xml", moduleName));

              if (filteredFile.exists())

              {

                  filteredFile.delete();

              }

              final FileOutputStream stream = new FileOutputStream(filteredFile);

              try

              {

                  IOUtils.write(content.toString(), stream);

              } finally

              {

                  stream.close();

              }

       

       

              // Flag the externalized file for deletion on JVM exit.

              filteredFile.deleteOnExit();

             

              return filteredFile;

          }

       

      /**

      * <p>

      * <code>JGroupsChannelFactoryBean</code> is an implementation of the Spring

      * {@link FactoryBean} interface which creates and configures a JGroups

      * {@link ChannelFactory} instance.

      * </p>

      */

      public class JGroupsChannelFactoryBean extends AbstractFactoryBean

       

       

          protected Object createInstance() throws Exception

          {

       

       

              // Filter and copy the configuration resource into the application

              // temporary directory.

              final StringBuilder configuration = readConfigurationFile();

              filterConfigurationFile(configuration);

              final File configurationFile = writeConfigurationFile(configuration);

       

       

              // Create and return the channel factory.

              final ChannelFactory result = channelFactoryFactory.createChannelFactory(configurationFile);

              if (LOG.isDebugEnabled())

              {

                  LOG.debug(String.format("Returning channel factory %s configured from [%s].", ObjectUtils

                          .identityToString(result), configurationFile), false);

              }

              return result;

          }