Example usage for java.util.concurrent CopyOnWriteArrayList CopyOnWriteArrayList

List of usage examples for java.util.concurrent CopyOnWriteArrayList CopyOnWriteArrayList

Introduction

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

Prototype

public CopyOnWriteArrayList() 

Source Link

Document

Creates an empty list.

Usage

From source file:org.onosproject.store.trivial.impl.SimpleFlowRuleStore.java

private List<StoredFlowEntry> getFlowEntries(DeviceId deviceId, FlowId flowId) {
    final ConcurrentMap<FlowId, List<StoredFlowEntry>> flowTable = getFlowTable(deviceId);
    List<StoredFlowEntry> r = flowTable.get(flowId);
    if (r == null) {
        final List<StoredFlowEntry> concurrentlyAdded;
        r = new CopyOnWriteArrayList<>();
        concurrentlyAdded = flowTable.putIfAbsent(flowId, r);
        if (concurrentlyAdded != null) {
            return concurrentlyAdded;
        }//from  ww w .j a  va  2  s .  co m
    }
    return r;
}

From source file:ch.entwine.weblounge.dispatcher.impl.WebloungeDispatcherServlet.java

/**
 * Creates a new instance of the weblounge dispatcher servlet.
 * //from  ww  w  .j  a v a2  s .  c o  m
 * @param environment
 *          the environment
 */
WebloungeDispatcherServlet(Environment environment) {
    this.environment = environment;
    requestListeners = new CopyOnWriteArrayList<RequestListener>();
    dispatcher = new CopyOnWriteArrayList<DispatchListener>();
    requestHandler = new TreeSet<RequestHandler>(new Comparator<RequestHandler>() {
        public int compare(RequestHandler handler1, RequestHandler handler2) {
            int compare = Integer.valueOf(handler2.getPriority())
                    .compareTo(Integer.valueOf(handler1.getPriority()));
            // FIXME if 0 is returned the request handler will not be added?!
            if (compare == 0)
                return 1;
            return compare;
        }
    });
    caches = new HashMap<String, ResponseCache>();
}

From source file:core.com.qiniu.AmazonWebServiceClient.java

/**
 * Constructs a new AmazonWebServiceClient object using the specified
 * configuration./*from  w w w.j a v  a 2 s  . c  om*/
 *
 * @param clientConfiguration The client configuration for this client.
 */
protected AmazonWebServiceClient(ClientConfiguration clientConfiguration, HttpClient httpClient) {
    this.clientConfiguration = clientConfiguration;
    client = new AmazonHttpClient(clientConfiguration, httpClient);
    requestHandler2s = new CopyOnWriteArrayList<RequestHandler2>();
}

From source file:org.mnode.coucou.AbstractQueryTreeTableNode.java

protected final List<Node> getNodes() {
    if (result == null) {
        try {/*from  w ww  .  j  a  va2s. c  o  m*/
            for (String varName : bindVariables.keySet()) {
                query.bindValue(varName, bindVariables.get(varName));
            }
            final NodeIterator nodes = query.execute().getNodes();
            result = new CopyOnWriteArrayList<Node>();
            while (nodes.hasNext()) {
                Node nextNode = nodes.nextNode();
                result.add(nextNode);
            }
        } catch (RepositoryException e) {
            LOG.log(LogEntries.QUERY_ERROR, e, query);
        }
    }
    return result;
}

From source file:org.jahia.services.content.rules.RulesListener.java

public RulesListener() {
    instances.add(this);
    dslFiles = new CopyOnWriteArrayList<Resource>();
    globalObjects = new ConcurrentHashMap<String, Object>();
    inRules = new ThreadLocal<Boolean>();
    modulePackageNameMap = new ConcurrentHashMap<String, String>();
}

From source file:org.ubicompforall.cityexplorer.gui.ImportWebTab.java

/***
 * Extract database URLs from the web-page source code, given as the string text
 * @param text   the web-page source code
 * @return      new web-page source code with multiple "<A HREF='databaseX.sqlite'>databaseX</A>" only
 *//*from  w  w w  .  j a va 2  s.c  o m*/
public static CopyOnWriteArrayList<DB> extractDBs(String text, String SERVER_URL) {
    webDBs = new CopyOnWriteArrayList<DB>(); //To avoid duplicates!
    Matcher m = Pattern.compile("<a.* href=\"([^>]+(sqlite|db|db3))\">([^<]+)</a>", Pattern.CASE_INSENSITIVE)
            .matcher(text);
    while (m.find()) {
        String filename = m.group(1);
        if (filename.charAt(0) == '/') {
            filename = SERVER_URL + filename;
        }
        //webDBs.add( new DB(URL.getParentFile().getParent(), URL.getParentFile().getName(), URL.getName(), m.group(3) ) );
        // group 0 is everything, group 1 is (www.and.so.on)
        try {
            URL url = new URL(filename);
            File file = new File(filename);
            debug(1, "URL is  " + url);
            webDBs.add(new DB(file.getParentFile().getParent(), file.getParentFile().getName(), file.getName(),
                    url));
            debug(1, "Added: " + filename + " " + m.group(3));
        } catch (MalformedURLException e) {
            debug(-1, e.getMessage());
        }
    }
    return webDBs;
}

From source file:com.ksc.KscWebServiceClient.java

@SdkProtectedApi
protected KscWebServiceClient(ClientConfiguration clientConfiguration,
        RequestMetricCollector requestMetricCollector, boolean disableStrictHostNameVerification) {
    this.clientConfiguration = clientConfiguration;
    requestHandler2s = new CopyOnWriteArrayList<RequestHandler2>();
    client = new KSCHttpClient(clientConfiguration, requestMetricCollector, disableStrictHostNameVerification);
}

From source file:org.limewire.mojito.routing.impl.RouteTableImpl.java

private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
    in.defaultReadObject();//  www . ja v a 2  s .c o  m
    listeners = new CopyOnWriteArrayList<RouteTableListener>();

    // Post-Init the Buckets
    for (Bucket bucket : bucketTrie.values()) {
        ((BucketNode) bucket).postInit();
    }
}

From source file:org.deeplearning4j.text.invertedindex.LuceneInvertedIndex.java

@Override
public synchronized List<T> document(int index) {
    List<T> ret = new CopyOnWriteArrayList<>();
    try {//from   ww w  .j  a v  a  2s . co  m
        DirectoryReader reader = readerManager.acquire();
        Document doc = reader.document(index);
        reader.close();
        String[] values = doc.getValues(WORD_FIELD);
        for (String s : values) {
            T word = vocabCache.wordFor(s);
            if (word != null)
                ret.add(word);
        }

    }

    catch (Exception e) {
        e.printStackTrace();
    }
    return ret;
}

From source file:net.sf.jasperreports.engine.fill.JRVirtualizationContext.java

/**
 * Adds a virtualization listener.//from ww  w .j  av  a 2 s.  c  om
 * 
 * @param listener
 */
public void addListener(VirtualizationListener<VirtualElementsData> listener) {
    if (listeners == null) {
        listeners = new CopyOnWriteArrayList<VirtualizationListener<VirtualElementsData>>();
    }

    listeners.add(listener);
}