[
https://issues.jboss.org/browse/ISPN-3337?page=com.atlassian.jira.plugin....
]
Sebastian Łaskawiec commented on ISPN-3337:
-------------------------------------------
This can be perfectly solved without any code change. Here's an example:
{code}
public class SpringAnnotationConfiguration {
@Configuration
public static class ApplicationConfiguration {
@Bean
public GlobalConfigurationBuilder globalConfigurationBuilder() {
GlobalConfigurationBuilder gcb = new GlobalConfigurationBuilder();
gcb.globalJmxStatistics().allowDuplicateDomains(true);
return gcb;
}
@Bean
public ConfigurationBuilder configurationBuilder() {
ConfigurationBuilder cb = new ConfigurationBuilder();
cb.compatibility().enable();
return cb;
}
@Bean
public SpringEmbeddedCacheManagerFactoryBean
springCache(GlobalConfigurationBuilder gcb, ConfigurationBuilder cb) {
SpringEmbeddedCacheManagerFactoryBean factoryBean = new
SpringEmbeddedCacheManagerFactoryBean();
factoryBean.addCustomGlobalConfiguration(gcb);
factoryBean.addCustomCacheConfiguration(cb);
return factoryBean;
}
@Bean
public CachePlayground playground() {
return new CachePlayground();
}
}
public static class CachePlayground {
@Autowired
private CacheManager cacheManager;
public void add(String key, String value) {
cacheManager.getCache("default").put(key, value);
}
public String getContent(String key) {
return cacheManager.getCache("default").get(key).get().toString();
}
}
public static void main(String[] args) {
ApplicationContext applicationContext = new
AnnotationConfigApplicationContext(ApplicationConfiguration.class);
CachePlayground cachePlayground =
applicationContext.getBean(CachePlayground.class);
cachePlayground.add("Infinispan", "Is cool!");
System.out.println(cachePlayground.getContent("Infinispan"));
//validate if configuration has been set
SpringEmbeddedCacheManager springCacheManager =
applicationContext.getBean(SpringEmbeddedCacheManager.class);
AdvancedCache<?, ?> ac = (AdvancedCache<?, ?>)
springCacheManager.getCache("default").getNativeCache();
System.out.println("Compatibility: " +
ac.getCacheConfiguration().compatibility().enabled());
}
}
{code}
The example above shows that it's possible to create both
{{GlobalConfigurationBuilder}} and {{ConfigurationBuilder}} separately and put them into
{{SpringEmbeddedCacheManagerFactoryBean}}. There's also other approach which gives you
even more flexibility - you might ignore {{SpringEmbeddedCacheManagerFactoryBean}} and
create {{SpringEmbeddedCacheManager}} by your own using an {{EmbeddedCacheManager}}.
Define an approach to allow the injection of Configuration and
GlobalConfiguration beans for overriding
-------------------------------------------------------------------------------------------------------
Key: ISPN-3337
URL:
https://issues.jboss.org/browse/ISPN-3337
Project: Infinispan
Issue Type: Feature Request
Components: Spring Integration
Reporter: Navin Surtani
Assignee: Sebastian Łaskawiec
ISPN-3279 removed the ConfigurationOverrides and GlobalConfigurationOverrides classes in
the Spring module. These classes contained older set() calls in order to override Cache
configurations and given the way that programmatic Configuration currently works in
Infinispan, that approach is not maintainable.
We hence need a clean way to provide (Global) Configuration beans as a newer, cleaner
approach.
--
This message was sent by Atlassian JIRA
(v6.4.11#64026)