Example usage for java.util Collections synchronizedMap

List of usage examples for java.util Collections synchronizedMap

Introduction

In this page you can find the example usage for java.util Collections synchronizedMap.

Prototype

public static <K, V> Map<K, V> synchronizedMap(Map<K, V> m) 

Source Link

Document

Returns a synchronized (thread-safe) map backed by the specified map.

Usage

From source file:org.brushingbits.jnap.email.EmailSender.java

public EmailSender(EmailAccountInfo defaultEmailAccount) {
    this.toSendList = Collections.synchronizedList(new ArrayList<Email>());
    this.toRetryList = new HashMap<Email, Integer>();
    this.defaultEmailAccount = defaultEmailAccount;
    this.defaultMailSender = new JavaMailSenderImpl();
    this.mailSenderMap = Collections.synchronizedMap(new HashMap<EmailAccountInfo, JavaMailSenderImpl>());
}

From source file:org.jcf.GraphicObjectHandlerImpl.java

/**
 * ctor to use for a given room and nikname
 * @param nikName room unique nikname // ww  w.  java2  s.co  m
 * @param room room name
 */
GraphicObjectHandlerImpl(String nikName, String room) {
    Assert.notNull(nikName);
    Assert.notNull(room);

    this.room = room;
    this.nikName = nikName;
    objects = Collections.synchronizedMap(new HashMap<Id, GraphicObject>());
    listener = Collections.synchronizedList(new ArrayList<GraphicObjectEventListener>());
    threadLocalGraphicalMessage = new ThreadLocal<GraphicMessage>();
}

From source file:com.scireum.open.cache.ManagedCache.java

@SuppressWarnings("unchecked")
public ManagedCache(String name, int maxSize, long timeToLive, ValueComputer<K, V> valueComputer,
        ValueVerifier<V> verifier, long verificationInterval) {
    this.name = name;
    this.maxSize = maxSize;
    this.verificationInterval = verificationInterval;
    if (maxSize > 0) {
        this.data = Collections.synchronizedMap(new LRUMap(maxSize));
    } else {// w  w w  . ja  va2s. c  o  m
        this.data = Collections.synchronizedMap(new HashMap<K, CacheEntry<K, V>>(maxSize));
    }
    this.timeToLive = timeToLive;
    this.computer = valueComputer;
    this.verifier = verifier;
}

From source file:net.sf.jasperreports.engine.util.SwapFileVirtualizerStore.java

public SwapFileVirtualizerStore(JRSwapFile swap, boolean swapOwner, StreamCompression compression) {
    this.swap = swap;
    this.swapOwner = swapOwner;
    this.handles = Collections.synchronizedMap(new HashMap<String, JRSwapFile.SwapHandle>());
    this.compression = compression;
}

From source file:strat.mining.multipool.stats.service.impl.RequestStatsLoggingServiceImpl.java

@Override
public void currencyTicker(String exchangePlace, String currencyCode) {
    nbCurrencyTicker.incrementAndGet();/*from w w w. jav a  2 s.  c  o m*/

    Map<String, AtomicInteger> currencies = currencyTickerRequest.get(exchangePlace);

    if (currencies == null) {
        currencies = Collections.synchronizedMap(new HashMap<String, AtomicInteger>());
        currencyTickerRequest.put(exchangePlace, currencies);
    }

    AtomicInteger currencyCounter = currencies.get(currencyCode);

    if (currencyCounter == null) {
        currencyCounter = new AtomicInteger(0);
        currencies.put(currencyCode, currencyCounter);
    }

    currencyCounter.incrementAndGet();
}

From source file:com.appeligo.epg.DefaultEpg.java

private DefaultEpg() {
    Configuration config = ConfigUtils.getSystemConfig();
    try {/*from w ww.  j a  va2  s.c  om*/
        HessianProxyFactory factory = new HessianProxyFactory();
        String epgURL = config.getString("epgEndpoint");
        defaultEpgProvider = (EPGProvider) factory.create(EPGProvider.class, epgURL);
    } catch (Exception e) {
        log.fatal("Can't connect to EPG.", e);
    }
    minCachedPrograms = config.getInt("minCachedPrograms", 1000);
    maxCachedPrograms = config.getInt("maxCachedPrograms", 1500);
    log.debug("minCachedPrograms=" + minCachedPrograms + ", maxCachedPrograms=" + maxCachedPrograms);
    programCache = Collections
            .synchronizedMap(new ActiveCache<String, Program>(minCachedPrograms, maxCachedPrograms));
}

From source file:org.agnitas.beans.impl.ImportProfileImpl.java

public ImportProfileImpl() {
    genderMapping = Collections.synchronizedMap(new HashMap<String, Integer>());
    columnMapping = Collections.synchronizedList(new ArrayList<ColumnMapping>());
    keyColumns = new ArrayList<String>();
}

From source file:edu.cuny.cat.comm.QueueBasedInfrastructureImpl.java

public QueueBasedInfrastructureImpl() {
    waitingClients = BufferUtils.synchronizedBuffer(new UnboundedFifoBuffer<QueueBasedCatpClientConnector>());
    connections = Collections.synchronizedMap(new HashMap<Object, QueueBasedCatpConnection>());
    idAllocator = new IdAllocator();
}

From source file:org.apache.hadoop.yarn.server.nodemanager.containermanager.AuxServices.java

public AuxServices() {
    super(AuxServices.class.getName());
    serviceMap = Collections.synchronizedMap(new HashMap<String, AuxiliaryService>());
    serviceMetaData = Collections.synchronizedMap(new HashMap<String, ByteBuffer>());
    // Obtain services from configuration in init()
}

From source file:org.apache.velocity.runtime.resource.ResourceCacheImpl.java

/**
 * @see org.apache.velocity.runtime.resource.ResourceCache#initialize(org.apache.velocity.runtime.RuntimeServices)
 *///from   w w  w  .  j  a  v  a2 s . c o  m
public void initialize(RuntimeServices rs) {
    rsvc = rs;

    int maxSize = rsvc.getInt(RuntimeConstants.RESOURCE_MANAGER_DEFAULTCACHE_SIZE, 89);
    if (maxSize > 0) {
        // Create a whole new Map here to avoid hanging on to a
        // handle to the unsynch'd LRUMap for our lifetime.
        Map lruCache = Collections.synchronizedMap(new LRUMap(maxSize));
        lruCache.putAll(cache);
        cache = lruCache;
    }
    Logger.debug(this,
            "ResourceCache: initialized (" + this.getClass() + ") with " + cache.getClass() + " cache map.");
}