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.apache.synapse.endpoints.RecipientListEndpoint.java

public RecipientListEndpoint(int poolsize) {
    dynamicEndpointPool = Collections.synchronizedMap(new DynamicEndpointPool<String, Endpoint>(poolsize));
    this.currentPool = poolsize;
}

From source file:org.xflatdb.xflat.db.ConvertingTable.java

ConvertingTable(Class<T> type, String name) {
    super(name);//from  w  ww.java2 s .co  m

    this.tableType = type;

    this.accessor = IdAccessor.forClass(type);
    if (!this.accessor.hasId()) {
        //we need to keep a reference to the ID in a weak cache
        idMap = Collections.synchronizedMap(new WeakHashMap<T, String>());
    } else {
        idMap = null;
    }

}

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

public CallBasedInfrastructureImpl() {
    waitingClients = BufferUtils.synchronizedBuffer(new UnboundedFifoBuffer<CallBasedCatpClientConnector>());
    connections = Collections.synchronizedMap(new HashMap<Object, CallBasedCatpConnection>());
    idAllocator = new IdAllocator();
}

From source file:org.zaproxy.zap.extension.ascanrulesAlpha.GitIndexEntryCache.java

/**
 * puts the Git Index and Git Index Entry in a map
 *
 * @param gitIndexUri/*from w ww.  ja va 2 s .  c  om*/
 * @param gitIndexEntryUri
 */
@SuppressWarnings("unchecked")
public synchronized void putIndexEntry(URI gitIndexUri, URI gitIndexEntryUri, String gitSHA1) {
    Map<URI, String> indexEntryMap;
    if (gitIndexMap.containsKey(gitIndexUri)) {
        indexEntryMap = gitIndexMap.get(gitIndexUri);
    } else {
        indexEntryMap = Collections.synchronizedMap(new LRUMap(1000)); // max: 1000 Git index entries (LRU)
    }
    indexEntryMap.put(gitIndexEntryUri, gitSHA1);
    gitIndexMap.put(gitIndexUri, indexEntryMap);
}

From source file:org.eclipse.ecr.core.storage.sql.net.MapperServlet.java

protected synchronized void initialize() {
    if (initialized) {
        return;/*  w  w w  .ja v a2s .co  m*/
    }
    initialized = true;
    repository = RepositoryResolver.getRepository(repositoryName);
    invokers = Collections.synchronizedMap(new HashMap<String, MapperInvoker>());
}

From source file:fr.aliasource.webmail.proxy.impl.TimeOutMap.java

/**
 * @param timeout//from  w ww  . ja  v a 2  s .c  o m
 *            unused elements timeout in milliseconds
 */
public TimeOutMap(long timeout) {
    map = Collections.synchronizedMap(new HashMap<K, TimedItem<V>>());
    this.timeout = timeout;
    executor = Executors.newFixedThreadPool(4);
    Timer t = new Timer();
    t.scheduleAtFixedRate(new Remover(), 1000, timeout);
}

From source file:uk.ac.sanger.cgp.dbcon.core.AbstractPools.java

public AbstractPools() {
    pools = Collections.synchronizedMap(new Hashtable());
    log = LogFactory.getLog(this.getClass());
    configParser = ConfigParser.getDefaultParser();
}

From source file:gov.nih.nci.integration.caaers.invoker.CaAERSAdverseEventServiceInvocationStrategy.java

/**
 * Constructor/*from w  w w. jav a  2  s.  c  o m*/
 * 
 * @param xsltTransformer - XSLTTransformer
 * @param client - CaAERSAdverseEventServiceWSClient
 * @param retryCount - retryCount
 */
public CaAERSAdverseEventServiceInvocationStrategy(XSLTTransformer xsltTransformer,
        CaAERSAdverseEventServiceWSClient client, int retryCount) {
    super();
    this.xsltTransformer = xsltTransformer;
    this.client = client;
    this.retryCount = retryCount;

    final HashMap<String, IntegrationError> msgToErrMapBase = new LinkedHashMap<String, IntegrationError>();
    msgToErrMapBase.put("Invalid Username/Password", IntegrationError._1011);
    msgToErrMapBase.put("could not be created in caAERS", IntegrationError._1014);
    msgToErrMapBase.put("Could not send Message", IntegrationError._1020);

    msgToErrMap = Collections.synchronizedMap(msgToErrMapBase);
}

From source file:cat.albirar.framework.dynabean.impl.DynaBeanImpl.java

private DynaBeanImpl() {
    values = Collections.synchronizedMap(new TreeMap<String, Object>());
    visitor = null;
}

From source file:de.interseroh.report.domain.ParameterForm.java

/**
 * Returns a map of all cascading group and scalar parameters of the
 * ParameterForm. The map do not contain synthetic and simple groups.
 *
 * @return Map<String, Parameter>/*from  w w w  .j a va2s .com*/
 */
public Map<String, Parameter> getParams() {
    if (parameterMap == null) {
        parameterMap = new ParameterToMapVisitor(groups).build();
    }
    return Collections.synchronizedMap(parameterMap);
}