Package net.sf.ehcache.event

Examples of net.sf.ehcache.event.CacheEventListener


        return;
    }
   
    public void addEventListener(final JetspeedCacheEventListener listener, final boolean local)
    {
        CacheEventListener cacheEventListener = new CacheEventListener()
        {
           public void notifyElementEvicted(Ehcache cache, Element element)
           {
               listener.notifyElementEvicted(EhCacheImpl.this, local, element.getKey(), element.getObjectValue());
           }
View Full Code Here


        ehcache.getCacheEventNotificationService().registerListener(cacheEventListener);
    }
   
    public void removeEventListener(JetspeedCacheEventListener listener, boolean local)
    {
        CacheEventListener cacheEventListener = this.cacheEventListenersMap.remove(listener);
       
        if (cacheEventListener != null)
            ehcache.getCacheEventNotificationService().unregisterListener(cacheEventListener);
    }
View Full Code Here

                                                 RegisteredEventListeners registeredEventListeners) {
        List cacheEventListenerConfigurations = cacheConfiguration.getCacheEventListenerConfigurations();
        for (Object cacheEventListenerConfiguration : cacheEventListenerConfigurations) {
            CacheConfiguration.CacheEventListenerFactoryConfiguration factoryConfiguration =
                    (CacheConfiguration.CacheEventListenerFactoryConfiguration) cacheEventListenerConfiguration;
            CacheEventListener cacheEventListener = createCacheEventListener(factoryConfiguration);
            registeredEventListeners.registerListener(cacheEventListener);
        }
    }
View Full Code Here

     * @param factoryConfiguration
     */
    private static CacheEventListener createCacheEventListener(
            CacheConfiguration.CacheEventListenerFactoryConfiguration factoryConfiguration) {
        String className = null;
        CacheEventListener cacheEventListener = null;
        if (factoryConfiguration != null) {
            className = factoryConfiguration.getFullyQualifiedClassPath();
        }
        if (className == null) {
            LOG.fine("CacheEventListener factory not configured. Skipping...");
View Full Code Here

     * @return true if a <code>CacheReplicator</code> is found in the listeners
     */
    protected boolean isDistributed(Ehcache cache) {
        Set listeners = cache.getCacheEventNotificationService().getCacheEventListeners();
        for (Iterator iterator = listeners.iterator(); iterator.hasNext();) {
            CacheEventListener cacheEventListener = (CacheEventListener) iterator.next();
            if (cacheEventListener instanceof CacheReplicator) {
                return true;
            }
        }
        return false;
View Full Code Here

            copy.registeredEventListeners = new RegisteredEventListeners(copy);
        } else {
            copy.registeredEventListeners = new RegisteredEventListeners(copy);
            Set cacheEventListeners = registeredEventListeners.getCacheEventListeners();
            for (Object cacheEventListener1 : cacheEventListeners) {
                CacheEventListener cacheEventListener = (CacheEventListener) cacheEventListener1;
                CacheEventListener cacheEventListenerClone = (CacheEventListener) cacheEventListener.clone();
                copy.registeredEventListeners.registerListener(cacheEventListenerClone);
            }
        }

View Full Code Here

        return;
    }
   
    public void addEventListener(final JetspeedCacheEventListener listener, final boolean local)
    {
        CacheEventListener cacheEventListener = new CacheEventListener()
        {
           public void notifyElementEvicted(Ehcache cache, Element element)
           {
               listener.notifyElementEvicted(EhCacheImpl.this, local, element.getKey(), element.getObjectValue());
           }
View Full Code Here

        ehcache.getCacheEventNotificationService().registerListener(cacheEventListener);
    }
   
    public void removeEventListener(JetspeedCacheEventListener listener, boolean local)
    {
        CacheEventListener cacheEventListener = (CacheEventListener)this.cacheEventListenersMap.remove(listener);
       
        if (cacheEventListener != null)
            ehcache.getCacheEventNotificationService().unregisterListener(cacheEventListener);
    }
View Full Code Here

       
        /**
         * Always resolves to the same delegate object, no need for thread-sync checks
         */
        private CacheEventListener getDelegate() {
            CacheEventListener d = this.delegate;
            if (d == null) {
                //Need a local reference here to avoid locking around cacheEventListeners reference changes
                final Map<String, CacheEventListener> cel = cacheEventListeners;
                if (cel == null) {
                    //either pre-init or post-destroy, return noop logger
                    return NOOP_CACHE_EVENT_LISTENER;
                }
               
                final CacheEventListener cacheEventListener = cel.get(beanName);
                if (cacheEventListener == null) {
                    //If no listener is found just use the noop listener
                    LOGGER.warn("No CacheEventListener bean found for name '" + beanName + "', using NOOP CacheEventListener instead.");
                    d = NOOP_CACHE_EVENT_LISTENER;
                }
View Full Code Here

            copy.registeredEventListeners = new RegisteredEventListeners(copy);
        } else {
            copy.registeredEventListeners = new RegisteredEventListeners(copy);
            Set cacheEventListeners = registeredEventListeners.getCacheEventListeners();
            for (Object cacheEventListener1 : cacheEventListeners) {
                CacheEventListener cacheEventListener = (CacheEventListener) cacheEventListener1;
                CacheEventListener cacheEventListenerClone = (CacheEventListener) cacheEventListener.clone();
                copy.registeredEventListeners.registerListener(cacheEventListenerClone);
            }
        }

View Full Code Here

TOP

Related Classes of net.sf.ehcache.event.CacheEventListener

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.