Example usage for java.util.concurrent CopyOnWriteArraySet CopyOnWriteArraySet

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

Introduction

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

Prototype

public CopyOnWriteArraySet() 

Source Link

Document

Creates an empty set.

Usage

From source file:com.megacorp.commerce.ShoppingCart.java

/**
 * @param userId/*from w  w  w.ja  v  a2s  . c  om*/
 */
@JsonCreator
public ShoppingCart(@JsonProperty("userId") String userId) {
    this.userId = userId;
    items = new CopyOnWriteArraySet<String>();
}

From source file:com.ksc.http.DelegatingDnsResolverTest.java

@Before
public void resetClientConfiguration() {
    dnsResolutionCounter = new AtomicInteger(0);
    requestedHosts = new CopyOnWriteArraySet<String>();

    ClientConfiguration clientConfiguration = new ClientConfiguration();
    clientConfiguration.withMaxErrorRetry(0);
    clientConfiguration.withDnsResolver(new DnsResolver() {
        DnsResolver system = new SystemDefaultDnsResolver();

        @Override//  w  ww  . j  ava 2s .co  m
        public InetAddress[] resolve(String host) throws UnknownHostException {
            dnsResolutionCounter.incrementAndGet();
            requestedHosts.add(host);
            return system.resolve(host);
        }
    });

    testedClient = new KSCHttpClient(clientConfiguration);
}

From source file:org.rifidi.edge.core.services.esper.internal.EsperReceiver.java

/**
 * Constructor./*  w  w  w .  j a  v  a2s  .  c  o m*/
 * 
 * @param runtime
 */
public EsperReceiver(final EPRuntime runtime) {
    sensors = new CopyOnWriteArraySet<Sensor>();
    this.runtime = runtime;
}

From source file:org.marketcetera.photon.internal.module.SinkDataManager.java

@Override
public void register(ISinkDataHandler handler, Class<?>... classes) {
    Validate.notNull(handler);//  w  w w .  jav a 2s .co  m
    Validate.noNullElements(classes);
    for (Class<?> clazz : classes) {
        handlers.putIfAbsent(clazz, new CopyOnWriteArraySet<ISinkDataHandler>());
        handlers.get(clazz).add(handler);
    }
}

From source file:ch.algotrader.event.dispatch.MarketDataSubscriptionRegistry.java

public void register(final String strategyName, final long securityId) {

    Validate.notNull(strategyName, "Strategy name is null");

    Set<String> strategySet = this.marketDataSubscriptionMap.get(securityId);
    if (strategySet == null) {
        Set<String> newStrategySet = new CopyOnWriteArraySet<>();
        strategySet = this.marketDataSubscriptionMap.putIfAbsent(securityId, newStrategySet);
        if (strategySet == null) {
            strategySet = newStrategySet;
        }//from   ww  w  . java  2  s.c  o  m
    }
    strategySet.add(strategyName);
}

From source file:com.ebay.pulsar.websocket.WebSocketConnectionManager.java

private WebSocketConnectionManager() {
    sockets = new CopyOnWriteArraySet<MetricWebSocket>();
}

From source file:ch.algotrader.event.EventListenerRegistryImpl.java

@Override
public <T> void register(final EventListener<T> listener, final Class<T> eventType) {

    Validate.notNull(listener, "Listener is null");
    Validate.notNull(eventType, "Event type is null");

    Set<EventListener<?>> listeners = this.listenerMap.get(eventType);
    if (listeners == null) {

        Set<EventListener<?>> newQueue = new CopyOnWriteArraySet<>();
        listeners = this.listenerMap.putIfAbsent(eventType, newQueue);
        if (listeners == null) {
            listeners = newQueue;// w  ww.j a v  a 2  s .c o  m
        }
    }
    listeners.add(listener);
}

From source file:com.espertech.esper.filter.FilterServiceImpl.java

/**
 * Constructor.//from   ww  w.j  a v a2s  .c  om
 */
protected FilterServiceImpl() {
    eventTypeIndex = new EventTypeIndex();
    indexBuilder = new EventTypeIndexBuilder(eventTypeIndex);
    filterServiceListeners = new CopyOnWriteArraySet<FilterServiceListener>();
}

From source file:com.conwet.silbops.api.impl.XJSPSubEndpoint.java

XJSPSubEndpoint() {

    notifListeners = new CopyOnWriteArraySet<>();
    adverListeners = new CopyOnWriteArraySet<>();
    context = null;
}

From source file:Pool.java

private Pool(List<T> stocks) {
    if (stocks == null || stocks.size() == 0) {
        throw new IllegalArgumentException("stocks: " + stocks);
    }//from   w  w  w.j av  a 2s  . c o  m
    this.stock = new CopyOnWriteArrayList<T>();
    this.havings = new CopyOnWriteArraySet<T>();
    for (T stockItem : stocks) {
        stock.add(stockItem);
        havings.add(stockItem);
    }
}