Example usage for java.util.concurrent ConcurrentLinkedQueue removeAll

List of usage examples for java.util.concurrent ConcurrentLinkedQueue removeAll

Introduction

In this page you can find the example usage for java.util.concurrent ConcurrentLinkedQueue removeAll.

Prototype

public boolean removeAll(Collection<?> c) 

Source Link

Usage

From source file:m.c.m.proxyma.context.ProxyFolderBean.java

/**
 * Add the a plugin to the specified list using the execution priority 
 * to define the position of the plugin into the list.
 * @param pluginName the plugin name to add to the list
 * @param list the list to update.//ww w  .  j  a  v  a 2  s. co  m
 */
private void addPluginUsingExecutionPriority(String pluginName, String baseXPath,
        ConcurrentLinkedQueue<String> list) {
    String pluginPriorityXPath = baseXPath + "[@class='" + pluginName + "']/@executionPriority";
    int pluginPriority = 0;
    try {
        pluginPriority = Integer.parseInt(context.getSingleValueParameter(pluginPriorityXPath));
    } catch (Exception x) {
        log.warning("executionPiority not an integer in \"" + pluginPriorityXPath + "\"");
    }

    //put the new object in the correct position based upon its execution priority
    LinkedList<String> tmpList = new LinkedList(list);

    String currentPlugin = null;
    int currentPluginPriority = 0;
    boolean inserted = false;
    for (int i = 0; (i < tmpList.size() && !inserted); i++) {
        currentPlugin = tmpList.get(i);
        pluginPriorityXPath = baseXPath + "[@class='" + currentPlugin + "']/@executionPriority";
        try {
            currentPluginPriority = Integer.parseInt(context.getSingleValueParameter(pluginPriorityXPath));
        } catch (Exception x) {
            currentPluginPriority = 0;
        }

        if (pluginPriority < currentPluginPriority) {
            tmpList.add(i, pluginName);
            inserted = true;
        }
    }

    //If a place for the plugin was not found the plugin is addedd on the tail
    if (!inserted)
        tmpList.add(pluginName);

    //Update the thread-safe queue
    list.removeAll(tmpList);
    list.addAll(tmpList);
}