1 Reply Latest reply on Jul 22, 2006 11:12 PM by Manik Surtani

    Habanero: CacheFactory interface

    Manik Surtani Master

      The new programmatic model for constructing an instance of the cache in Habanero utilises a CacheFactory. Typically, here is how it would be done:

      CacheFactory factory = new DefaultCacheFactory(); // users may create a singleton wrapper for this
      
      Cache c = factory.createCache("myCacheService.xml"); // c is now running and ready for use.
      


      Currently the CacheFactory interface is overloaded as such:

      public interface CacheFactory
      {
       /**
       * Creates and starts a {@link org.jboss.cache.Cache} instance
       * @param configFileName the named XML file should exist in the classpath.
       * @return a running {@link org.jboss.cache.Cache} instance
       */
       Cache createCache(String configFileName) throws ConfigurationException;
      
       /**
       * Creates {@link Cache} instance, and optionally starts it.
       * @param configFileName the named XML file should exist in the classpath.
       * @param start if true, the cache is started before returning.
       * @return an optionally running {@link Cache} instance
       */
       Cache createCache(String configFileName, boolean start) throws ConfigurationException;
      
       /**
       * Creates a {@link Cache} instance
       * @param configuration the {@link Configuration} object that is passed in to configure the {@link Cache}.
       * @return a running {@link Cache} instance
       */
       Cache createCache(Configuration configuration) throws ConfigurationException;
      
       /**
       * Creates {@link Cache} instance, and optionally starts it.
       * @param configuration the {@link Configuration} object that is passed in to configure the {@link Cache}.
       * @param start if true, the cache is started before returning.
       * @return an optionally running {@link Cache} instance
       */
       Cache createCache(Configuration configuration, boolean start) throws ConfigurationException;
      }
      


      Is there a need to provide a mechanism to create a cache using an existing (and possibly running) JGroups channel? I.e., something analogous to new TreeCache(myChannel);


        • 1. Re: Habanero: CacheFactory interface
          Manik Surtani Master

          Or does it make more sense to:

          1. Package the microcontainer in JBC
          2. Use the microcontainer for DI for various services and managers
          3. Allow users to inject a running JGroups channel into the MC if they need to create an instance of JBC using an existing and running JGroups channel?

          Naturally, when deploying within AS5, we would already have access to the MC so we wouldn't start a new instance. But for standalone deployments we could always package it.

          Pros
          * Possibly cleaner code base with no direct dependencies.
          * Possibly better and easier to unit test as a consequence
          * Easier for users to configure and set up

          Cons
          * Another library dependency
          * More code modifications

          I'm not suggesting this should be in 2.0.0 - maybe something for later.