开发者

JBossCache eviction listener

I am new on JBossCache. Reading the user documentation it says that a listener could be added to the Eviction class used, but I wasn't able to found how to do add one to the configuration file, or how that should be added.

I have tried to add an @CacheListener with a method @NodeEvicted, but that method

@CacheListener
public class EvictionListener {

    @NodeEvicted
    public void nodeEvicted(NodeEvent ne) {
        System.out.println("Se borro el nodo");
    }
}

and add it to the cache instance

CacheFactory factory = new DefaultCacheFactory();
this.cache = factory.createCache();

EvictionListener listener = new EvictionListener();
this.cache.create();
this.cache.addCacheListener(listener);

but the sysout isn't executed. For testing it, I am just running a simple Main value. This is the configuration value I am using:

<jbosscache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="urn:jboss:jbosscache-core:config:3.2">


    <transaction transactionManagerLookupClass="org.jboss.cache.transaction.GenericTransactionManagerLookup"/>


    <eviction wakeUpInterval="20">
        <default algorithmClass="org.jboss.cache.eviction.FIFOAlgorithm" wakeUpInterval="20">
            <property name="maxNodes" value="20" />         
    开发者_如何学编程    </default>           
    </eviction>

</jbosscache>


The problem was solved because I wasn't reading the XML configuration file.

I was missing:

factory.createCache(file);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜