Example usage for org.apache.commons.collections FastArrayList add

List of usage examples for org.apache.commons.collections FastArrayList add

Introduction

In this page you can find the example usage for org.apache.commons.collections FastArrayList add.

Prototype

public boolean add(Object element) 

Source Link

Document

Appends the specified element to the end of this list.

Usage

From source file:org.apache.torque.manager.AbstractBaseManager.java

/**
 *
 * @param listener A new listener for cache events.
 *//*from   ww w  . j a  v  a  2 s.  c  o m*/
public void addCacheListenerImpl(CacheListener<? extends Persistent> listener) {
    List<String> keys = listener.getInterestedFields();
    for (String key : keys) {
        // Peer.column names are the fields
        if (validFields != null && validFields.containsKey(key)) {
            FastArrayList listeners = listenersMap.get(key);
            if (listeners == null) {
                listeners = createSubsetList(key);
            }

            boolean isListenerNew = true;
            Iterator<?> j = listeners.iterator();
            while (j.hasNext()) {
                Object listener2 = ((WeakReference<?>) j.next()).get();
                //                    if (listener2 == null)
                //                    {
                //                        // do a little cleanup while checking for dupes
                //                        // not thread-safe, not likely to be many nulls
                //                        // but should revisit
                //                        //j.remove();
                //                    }
                //                    else
                if (listener2 == listener) {
                    isListenerNew = false;
                    break;
                }
            }
            if (isListenerNew) {
                listeners.add(new WeakReference<CacheListener<? extends Persistent>>(listener));
            }
        }
    }
}