@Produces @ConfigureCache("urban-dictionary-cache") @UrbanDictionaryCache public Configuration specialCacheCfg(InjectionPoint injectionPoint) { log.info("Configuring urban-dictionary-cache..."); return new ConfigurationBuilder() .indexing() .autoConfig(true) .addProperty("default.directory_provider", "ram") .build(); } }
@Produces @ConfigureCache("jboss-books-cache") @JBossBooksCache public Configuration specialCacheCfg(InjectionPoint injectionPoint) { log.info("Configuring jboss-books-cache..."); return new ConfigurationBuilder() .indexing() .autoConfig(true) .addProperty("default.directory_provider", "ram") .build(); } }
@Produces @ConfigureCache("karma-cache") @KarmaCache public Configuration specialCacheCfg(InjectionPoint injectionPoint) { log.info("Configuring karma-cache..."); return new ConfigurationBuilder() .indexing() .autoConfig(true) .addProperty("default.directory_provider", "ram") .build(); } }
@Produces @ConfigureCache("currency-cache") @CurrencyCache public Configuration specialCacheCfg(InjectionPoint injectionPoint) { log.info("Configuring currency-cache..."); return new ConfigurationBuilder() .indexing() .autoConfig(true) .addProperty("default.directory_provider", "ram") .build(); } }
@Produces @ConfigureCache("default-cache") @DefaultCache public Configuration specialCacheCfg(InjectionPoint injectionPoint) { log.info("Configuring default-cache..."); return new ConfigurationBuilder() .indexing() .autoConfig(true) .addProperty("default.directory_provider", "ram") .build(); } }
@Produces @ConfigureCache("faq-cache") @FaqCache() public Configuration specialCacheCfg(InjectionPoint injectionPoint) throws ClassNotFoundException, NoSuchMethodException { log.info("Configuring faq-cache..."); Class classToIndex = null; String defaultValue = (String) FaqCache.class.getMethod("classToIndex").getDefaultValue(); try { classToIndex = Class.forName(injectionPoint.getAnnotated().getAnnotation(FaqCache.class).classToIndex()); } catch (final Exception e) { log.warning("Failed to lookup the class: " + classToIndex + " --> " + e.getMessage()); log.warning("Configuring classToIndex to [" + defaultValue + "]"); classToIndex = Class.forName(defaultValue); } return new ConfigurationBuilder() .indexing() .autoConfig(true) .addIndexedEntity(classToIndex) .index(Index.ALL) .addProperty("default.directory_provider", "ram") .build(); } }
@Test(expectedExceptions = CacheConfigurationException.class, expectedExceptionsMessageRegExp = "ISPN000381: This configuration is not supported for simple cache") public void testIndexing() { new ConfigurationBuilder().simpleCache(true).indexing().index(Index.LOCAL).build(); }
private Configuration nonIndexed() { return new ConfigurationBuilder().indexing().index(Index.NONE) .addProperty("lucene_version", "LUCENE_CURRENT").build(); }
protected EmbeddedCacheManager createVolatileCacheManager() throws Exception { return new DefaultCacheManager( new GlobalConfigurationBuilder().build(), new ConfigurationBuilder() .indexing().index(Index.ALL) .addIndexedEntity(Person.class) .addIndexedEntity(Car.class) .addProperty("default.directory_provider", "local-heap") .addProperty("lucene_version", "LUCENE_CURRENT") .build() ); }
protected EmbeddedCacheManager createCacheManager(int maxEntries) throws Exception { return new DefaultCacheManager( new GlobalConfigurationBuilder().build(), new ConfigurationBuilder() .memory().evictionType(EvictionType.COUNT).size(maxEntries) .persistence().passivation(true) .addSingleFileStore().location(storeDir.getAbsolutePath()).preload(true) .indexing().index(Index.ALL) .addIndexedEntity(Person.class) .addIndexedEntity(Car.class) .addProperty("default.directory_provider", "filesystem") .addProperty("default.indexBase", indexDir.getAbsolutePath()) .addProperty("lucene_version", "LUCENE_CURRENT") .build() ); }