3 Replies Latest reply on Apr 20, 2012 8:16 AM by kovica1

    DefaultCacheManager created more than once?

    kovica1

      Hi!

       

      I'm using Glassfish 3.1.2 and Infinispan 5.0.1.

      In my classpath I have infinispan-core and infinispan-cdi jars (with appropriate dependencies).

      I create a default cache manager with this piece of code:

       

      public class Config {
          @Produces
          @Default
          public DefaultCacheManager createDefaultCacheManager() {
              DefaultCacheManager returnCacheManager;
      
              Configuration config = new org.infinispan.config.Configuration();
              config = config.fluent().eviction().strategy(EvictionStrategy.NONE).maxEntries(Integer.MAX_VALUE)
                      .transaction().transactionManagerLookup(new GenericTransactionManagerLookup())
                      .expiration().lifespan(Long.valueOf(-1)).maxIdle(Long.valueOf(-1)).build();
      
      
              returnCacheManager = new DefaultCacheManager(config);
      
              String cacheNames[] = new String[2];
              cacheNames[0] = "cache1";
              cacheNames[1] = "cache2";
              returnCacheManager.startCaches(cacheNames);
      
              return returnCacheManager;
          }
      }
      

       

      Then in my EJB I use it like this:

      @Inject
      private DefaultCacheManager defaultCacheManager;
      

       

      The DefaultCacheManager is created when I first access the CacheBeans bean, which is to be expected, but it also happens that the Config class is also being called durin application execution.

      Is this the correct behaviour? Should I do some checks in my Config class?

      I cannot provide a sample application, because I didn't find any patterns when the Config class is being used multiple times.

       

      I have to say that no application deployment occurs between the first and the second, third, ... Config class usage.

       

      Best regards,

          Kovi