ignite-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Guilherme Melo <guilhe...@gmelo.org>
Subject Unable to inject spring configuration on Cachestore
Date Mon, 24 Apr 2017 10:09:23 GMT
Hello,
I am trying to utilize @SpringResource and
@SpringApplicationContextResource, however both are null on my CacheStore,
has anyone encountered this before?

Below is my config:

    @Bean
    public IgniteConfiguration getIgniteConfiguration() {
        IgniteConfiguration cfg = new IgniteConfiguration();
        cfg.setClientMode(false);
        CacheConfiguration orderCache = new CacheConfiguration();
        orderCache.setName("testCache");
        orderCache.setBackups(1);
        orderCache.setCacheMode(CacheMode.PARTITIONED);

orderCache.setCacheWriterFactory(FactoryBuilder.factoryOf(CacheStoreWithInjectedBeans.class));
        orderCache.setReadThrough(true);
        orderCache.setWriteThrough(true);

        cfg.setCacheConfiguration(
                orderCache);
        return cfg;
    }

and the class:

public class CacheStoreWithInjectedBeans implements CacheWriter<String,
String> {
    @SpringResource
    private MyService myService;
    @SpringApplicationContextResource
    private Object appCtx;
    @Override
    public void write(Cache.Entry<? extends String, ? extends String>
entry) throws CacheWriterException {
        myService.apply(entry.getValue());
    }
    @Override
    public void writeAll(Collection<Cache.Entry<? extends String, ? extends
String>> entries) throws CacheWriterException {

    }
    @Override
    public void delete(Object key) throws CacheWriterException {

    }
    @Override
    public void deleteAll(Collection<?> keys) throws CacheWriterException {

    }

}

Cheers,
Guilherme Melo
www.gmelo.org

Mime
View raw message