Package org.apache.commons.collections

Examples of org.apache.commons.collections.CursorableLinkedList$ListIter


                                // if we don't have an object cursor
                                if(null == objcursor) {
                                    // if the keycursor has a next value, then use it
                                    if(keycursor.hasNext()) {
                                        key = keycursor.next();
                                        CursorableLinkedList pool = (CursorableLinkedList)(_poolMap.get(key));
                                        objcursor = pool.cursor(pool.size());
                                    } else {
                                        // else close the key cursor and loop back around
                                        if(null != keycursor) {
                                            keycursor.close();
                                            keycursor = _poolList.cursor();
View Full Code Here


     * @param event the event to queue
     */
    public void addWidgetEvent(WidgetEvent event) {
       
        if (this.events == null) {
            this.events = new CursorableLinkedList();
        }
       
        // FIXME: limit the number of events to detect recursive event loops ?
        this.events.add(event);
    }
View Full Code Here

     * @param event the event to queue
     */
    public void addWidgetEvent(WidgetEvent event) {
       
        if (this.events == null) {
            this.events = new CursorableLinkedList();
        }
       
        // FIXME: limit the number of events to detect recursive event loops ?
        this.events.add(event);
    }
View Full Code Here

        _timeBetweenEvictionRunsMillis = timeBetweenEvictionRunsMillis;
        _numTestsPerEvictionRun = numTestsPerEvictionRun;
        _minEvictableIdleTimeMillis = minEvictableIdleTimeMillis;
        _testWhileIdle = testWhileIdle;

        _pool = new CursorableLinkedList();
        startEvictor(_timeBetweenEvictionRunsMillis);
    }
View Full Code Here

        _minEvictableIdleTimeMillis = minEvictableIdleTimeMillis;
        _testWhileIdle = testWhileIdle;

        _poolMap = new HashMap();
        _activeMap = new HashMap();
        _poolList = new CursorableLinkedList();

        startEvictor(_timeBetweenEvictionRunsMillis);
    }
View Full Code Here

    public synchronized Object borrowObject(Object key) throws Exception {
        long starttime = System.currentTimeMillis();
        boolean newlyCreated = false;
        for(;;) {
            CursorableLinkedList pool = (CursorableLinkedList)(_poolMap.get(key));
            if(null == pool) {
                pool = new CursorableLinkedList();
                _poolMap.put(key,pool);
                _poolList.add(key);
            }
            ObjectTimestampPair pair = null;
            // if there are any sleeping, just grab one of those
            try {
                pair = (ObjectTimestampPair)(pool.removeFirst());
                if(null != pair) {
                    _totalIdle--;
                }
            } catch(NoSuchElementException e) { /* ignored */
            }
View Full Code Here

    }

    public synchronized void clear() {
        for(Iterator keyiter = _poolList.iterator(); keyiter.hasNext(); ) {
            Object key = keyiter.next();
            CursorableLinkedList list = (CursorableLinkedList)(_poolMap.get(key));
            for(Iterator it = list.iterator(); it.hasNext(); ) {
                try {
                    _factory.destroyObject(key,((ObjectTimestampPair)(it.next())).value);
                } catch(Exception e) {
                    // ignore error, keep destroying the rest
                }
View Full Code Here

        _totalIdle = 0;
        notifyAll();
    }

    public synchronized void clear(Object key) {
        CursorableLinkedList pool = (CursorableLinkedList)(_poolMap.remove(key));
        if(null == pool) {
            return;
        } else {
            _poolList.remove(key);
            for(Iterator it = pool.iterator(); it.hasNext(); ) {
                try {
                    _factory.destroyObject(key,((ObjectTimestampPair)(it.next())).value);
                } catch(Exception e) {
                    // ignore error, keep destroying the rest
                }
View Full Code Here

        }

        boolean shouldDestroy = false;
        synchronized(this) {
            // grab the pool (list) of objects associated with the given key
            CursorableLinkedList pool = (CursorableLinkedList) (_poolMap.get(key));
            // if it doesn't exist, create it
            if(null == pool) {
                pool = new CursorableLinkedList();
                _poolMap.put(key, pool);
                _poolList.add(key);
            }
            decrementActiveCount(key);
            // if there's no space in the pool, flag the object for destruction
            // else if we passivated succesfully, return it to the pool
            if(_maxIdle >= 0 && (pool.size() >= _maxIdle)) {
                shouldDestroy = true;
            } else if(success) {
                pool.addFirst(new ObjectTimestampPair(obj));
                _totalIdle++;
            }
            notifyAll();
        }
View Full Code Here

                // if we don't have an object cursor
                if(null == _evictionCursor) {
                    // if the _evictionKeyCursor has a next value, then use it
                    if(_evictionKeyCursor.hasNext()) {
                        key = _evictionKeyCursor.next();
                        CursorableLinkedList pool = (CursorableLinkedList)(_poolMap.get(key));
                        _evictionCursor = pool.cursor(pool.size());
                    } else {
                        // else close the key cursor and loop back around
                        if(null != _evictionKeyCursor) {
                            _evictionKeyCursor.close();
                            _evictionKeyCursor = _poolList.cursor();
View Full Code Here

TOP

Related Classes of org.apache.commons.collections.CursorableLinkedList$ListIter

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.