You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jcs-users@jakarta.apache.org by "Betten, Thorben" <th...@open-xchange.com> on 2009/02/02 09:53:10 UTC

Re: Question on how to add listeners

Hello,

hm... as far as I understand its usage in source code, the interface
org.apache.jcs.engine.behavior.ICacheObserverneeds to be implemented in order
to provide addCacheListener()methods. But only auxiliary caches seem to
implement this interface:org.apache.jcs.auxiliary.lateral.LateralCacheWatchRepairable
andorg.apache.jcs.auxiliary.remote.RemoteCacheWatchRepairable(and thus its subclasses).


I see no other way to set/add an event queue to a cache region through API.
It's rather created in the constructors of certain auxiliary caches; e.g.

org.apache.jcs.auxiliary.lateral.LateralCacheNoWait:

public class LateralCacheNoWait implements AuxiliaryCache {
 ...
 private ICacheEventQueue q;
 ...
 public LateralCacheNoWait( LateralCache cache ) {
  this.cache = cache;
  ...
  CacheEventQueueFactory fact = new CacheEventQueueFactory();
  this.q = fact.createCacheEventQueue( new CacheAdaptor( cache ), LateralCacheInfo.listenerId, cache
            .getCacheName(), cache.getAuxiliaryCacheAttributes().getEventQueuePoolName(), cache
            .getAuxiliaryCacheAttributes().getEventQueueTypeFactoryCode() );
  ...
 }
 ...
}


Taking all together it seems to be a feature only for auxiliary caches. But maybe this gives you
enough information to deeper dig into JCS' event queues.



Justin Gordon <ju...@yahoo.com> hat am 31. Januar 2009 um 09:26 geschrieben:

> I want to add JSR 107 like listeners to a JCS region. 
> 
> I tried this but it didn't work:
> 
>         ICacheListener cacheEventListener = new JcsCacheEventListenerAdapter(this, myListener);
>         CacheEventQueueFactory factory = new CacheEventQueueFactory();
>         ICacheEventQueue cacheEventQueue = factory.createCacheEventQueue(cacheEventListener,
>                                                                          0,
>                                                                          m_cacheName,
>                                                                          "",
>                                                                          ICacheEventQueue.SINGLE_QUEUE_TYPE);
> 
> 
> This compiles but the listener does not get notified. Is there something I need to do to start the queue?
> 
> Thanks,
> 
> Justin





--
Thorben Betten