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:com.jaspersoft.jasperserver.api.engine.jasperreports.util.RepositoryCacheMap.java

public RepositoryCacheMap(RepositoryService repository, RepositoryContextManager repositoryContextManager,
        ObjectCache objectCache) {//  w  ww  . j  a va  2s.c  om
    this.repository = repository;
    this.repositoryContextManager = repositoryContextManager;
    this.objectCache = objectCache;
    map = Collections.synchronizedMap(new HashMap());

    lockManager = new LocalLockManager();
}

From source file:strat.mining.stratum.proxy.worker.GetworkRequestHandler.java

public GetworkRequestHandler() {
    this.manager = ProxyManager.getInstance();
    this.workerConnections = Collections.synchronizedMap(new HashMap<InetAddress, GetworkWorkerConnection>());

}

From source file:dk.netarkivet.common.distribute.HTTPRemoteFileRegistry.java

/** Initialise the registry. This includes registering an HTTP server for
 * getting the files from this machine./*from w  w w.j  a va  2s.  c o  m*/
 * @throws IOFailure if it cannot be initialised.
 */
protected HTTPRemoteFileRegistry() {
    port = Settings.getInt(HTTPRemoteFile.HTTPREMOTEFILE_PORT_NUMBER);
    localHostName = SystemUtils.getLocalHostName();
    registeredFiles = Collections.synchronizedMap(new HashMap<URL, FileInfo>());
    random = new Random();
    startServer();
    cleanupHook = new CleanupHook(this);
    Runtime.getRuntime().addShutdownHook(cleanupHook);
}

From source file:eu.stratosphere.client.web.JobSubmissionServlet.java

public JobSubmissionServlet(Configuration nepheleConfig, File jobDir, File planDir) {
    this.client = new Client(nepheleConfig);
    this.jobStoreDirectory = jobDir;
    this.planDumpDirectory = planDir;

    this.submittedJobs = Collections.synchronizedMap(new HashMap<Long, JobGraph>());

    this.rand = new Random(System.currentTimeMillis());
}

From source file:fr.ippon.wip.http.hc.HttpClientResourceManager.java

private HttpClientResourceManager() {
    perUserClientMap = Collections.synchronizedMap(new HashMap<String, HttpClient>());
    perUserCookieStoreMap = Collections.synchronizedMap(new HashMap<String, CookieStore>());
    perUserWindowCredentialProviderMap = Collections
            .synchronizedMap(new HashMap<String, CredentialsProvider>());
    currentPortletRequest = new ThreadLocal<PortletRequest>();
    currentPortletResponse = new ThreadLocal<PortletResponse>();
    currentRequest = new ThreadLocal<RequestBuilder>();

    try {/*w w w. j  av a  2  s  .  co  m*/
        SSLSocketFactory ssf = new SSLSocketFactory(new TrustSelfSignedStrategy(),
                new AllowAllHostnameVerifier());
        Scheme httpsScheme = new Scheme("https", 443, ssf);
        PlainSocketFactory psf = new PlainSocketFactory();
        Scheme httpScheme = new Scheme("http", 80, psf);
        SchemeRegistry registry = new SchemeRegistry();
        registry.register(httpsScheme);
        registry.register(httpScheme);
        connectionManager = new PoolingClientConnectionManager(registry);
        connectionManager.setDefaultMaxPerRoute(10);
        connectionManager.setMaxTotal(100);

        DefaultHttpClient defaultHttpClient = new DefaultHttpClient(connectionManager);

        // automatically redirects all HEAD, GET and POST requests
        defaultHttpClient.setRedirectStrategy(new LaxRedirectStrategy());

        CacheConfig cacheConfig = createAndConfigureCache();

        URL ehCacheConfig = getClass().getResource("/ehcache.xml");
        cacheManager = CacheManager.create(ehCacheConfig);
        Ehcache ehcache = cacheManager.getEhcache("public");
        EhcacheHttpCacheStorage httpCacheStorage = new EhcacheHttpCacheStorage(ehcache);

        CachingHttpClient sharedCacheClient = new CachingHttpClient(defaultHttpClient, httpCacheStorage,
                cacheConfig);
        HttpClientDecorator decoratedClient = new HttpClientDecorator(sharedCacheClient);

        decoratedClient.addPreProcessor(new LtpaRequestInterceptor());
        decoratedClient.addPreProcessor(new StaleIfErrorRequestInterceptor(staleIfErrorTime));
        decoratedClient.addFilter(new IgnoreHttpRequestFilter());

        decoratedClient.addPostProcessor(new TransformerResponseInterceptor());

        rootClient = decoratedClient;

    } catch (Exception e) {
        throw new RuntimeException("Could not initialize connection manager", e);
    }

}

From source file:edu.cuny.cat.market.charging.BestResponseChargingPolicy.java

public BestResponseChargingPolicy() {
    cumulativeProfits = Collections.synchronizedMap(new HashMap<String, Double>());
}

From source file:org.wso2.carbon.device.mgt.core.DeviceManagementPluginRepository.java

public DeviceManagementPluginRepository() {
    this.operationManagerRepository = new OperationManagerRepository();
    providers = Collections
            .synchronizedMap(new HashMap<DeviceTypeServiceIdentifier, DeviceManagementServiceHolder>());
    DeviceManagementServiceComponent.registerStartupListener(this);
}

From source file:com.evolveum.midpoint.prism.parser.PrismBeanInspector.java

private <V, P1, P2, P3> V find3(final Map<P1, Map<P2, Map<P3, V>>> cache, final P1 param1, final P2 param2,
        final P3 param3, final Getter3<V, P1, P2, P3> getter) {
    Map<P2, Map<P3, V>> cache2 = cache.get(param1);
    if (cache2 == null) {
        cache2 = Collections.synchronizedMap(new HashMap());
        cache.put(param1, cache2);//from  w ww. ja v  a 2s . c om
    }
    return find2(cache2, param2, param3, new Getter2<V, P2, P3>() {
        @Override
        public V get(P2 p, P3 q) {
            return getter.get(param1, p, q);
        }
    });
}

From source file:com.amazon.alexa.avs.NotificationManager.java

NotificationManager(NotificationIndicator indicator, SimpleAudioPlayer audioPlayer, BasicHttpClient httpClient,
        FileDataStore<NotificationsStatePayload> dataStore) {
    this.notificationIndicator = indicator;
    this.player = audioPlayer;
    this.assets = Collections.synchronizedMap(new HashMap<String, File>());
    this.indicatorExecutor = Executors.newSingleThreadExecutor();
    this.assetDownloader = Executors.newCachedThreadPool();
    this.allowPersistentIndicator = new AtomicBoolean(true);
    this.httpClient = httpClient;
    this.isSetIndicatorPersisted = new AtomicBoolean(false);
    this.indicatorStatus = Status.NONE;
    this.dataStore = dataStore;
    this.indicatorFutures = Collections.synchronizedSet(new HashSet<Future<?>>());
    this.activeAudioAsset = new AtomicReference<String>("");
    this.resLoader = Thread.currentThread().getContextClassLoader();
}

From source file:strat.mining.stratum.proxy.network.StratumConnection.java

public StratumConnection(Socket socket) {
    this.socket = socket;
    this.objectMapper = new ObjectMapper();
    this.sentRequestIds = Collections.synchronizedMap(new HashMap<Object, JsonRpcRequest>());
    this.throwDisconnectError = true;
    this.disconnectOnParsingError = false;
    this.isFirstLine = true;
}