List of usage examples for java.util Collections synchronizedMap
public static <K, V> Map<K, V> synchronizedMap(Map<K, V> m)
From source file:com.aol.advertising.qiao.util.cache.PersistentCache.java
private void _init() throws Exception { openDB();//from ww w . j a va2s .c o m // disk store diskMap = new PersistentMap<K, PersistentValueWrapper<K, V>>(database, javaClassCatalog, dataBinding, true, diskHighWaterMark, diskLowWaterMark, diskReapingInitDelaySecs, diskReapingIntervalSecs); diskMap.setId(id); diskMap.setRefreshExpiryOnAccess(refreshExpiryOnAccess); diskMap.addEvictionListener(this); diskMap.addUpdateListener(this); if (scheduler != null) diskMap.setTimer(scheduler); diskMap.init(); // memory cache cache = Collections.synchronizedMap( new LinkedHashMap<K, PersistentValueWrapper<K, V>>(initialCapacity, loadFactor, true) { private static final long serialVersionUID = 827276680854179618L; @Override protected boolean removeEldestEntry(Entry<K, PersistentValueWrapper<K, V>> eldest) { return size() > maxCapacity; } }); }
From source file:com.evolveum.icf.dummy.resource.DummyResource.java
DummyResource() { allObjects = Collections.synchronizedMap(new LinkedHashMap<String, DummyObject>()); accounts = Collections.synchronizedMap(new LinkedHashMap<String, DummyAccount>()); groups = Collections.synchronizedMap(new LinkedHashMap<String, DummyGroup>()); privileges = Collections.synchronizedMap(new LinkedHashMap<String, DummyPrivilege>()); scriptHistory = new ArrayList<ScriptHistoryEntry>(); accountObjectClass = new DummyObjectClass(); groupObjectClass = new DummyObjectClass(); privilegeObjectClass = new DummyObjectClass(); syncStyle = DummySyncStyle.NONE;//w ww .java 2 s. com deltas = new ArrayList<DummyDelta>(); latestSyncToken = 0; }
From source file:op.care.values.PnlValues.java
private void initPanel() { cpMap = Collections.synchronizedMap(new HashMap<String, CollapsiblePane>()); linemap = Collections.synchronizedMap(new HashMap<ResValue, JPanel>()); mapType2Values = Collections.synchronizedMap(new HashMap<String, ArrayList<ResValue>>()); // mapCollapsed = Collections.synchronizedMap(new HashMap<String, Boolean>()); // balances = Collections.synchronizedMap(new HashMap<LocalDate, Pair<BigDecimal, BigDecimal>>()); EntityManager em = OPDE.createEM();/*from w w w. jav a2 s . c o m*/ Query query = em.createQuery("SELECT t FROM ResValueTypes t WHERE t.valType != :valtype ORDER BY t.text"); query.setParameter("valtype", ResValueTypesTools.LIQUIDBALANCE); lstValueTypes = Collections.synchronizedList(new ArrayList<ResValueTypes>(query.getResultList())); // lstValueTypes.remove(LIQUIDBALANCE); em.close(); // color1 = SYSConst.blue1; // color2 = SYSConst.greyscale; }
From source file:org.zaproxy.zap.extension.selenium.ExtensionSelenium.java
@Override public void init() { super.init(); seleniumApi = new SeleniumAPI(getOptions()); addonFilesChangedListener = new AddonFilesChangedListenerImpl(); webDriverProviders = Collections.synchronizedMap(new HashMap<String, SingleWebDriverProvider>()); providedBrowsers = Collections.synchronizedMap(new HashMap<String, ProvidedBrowser>()); addBuiltInProvider(Browser.CHROME);/*from w w w . j ava 2 s. c o m*/ addBuiltInProvider(Browser.CHROME_HEADLESS); addBuiltInProvider(Browser.FIREFOX); addBuiltInProvider(Browser.FIREFOX_HEADLESS); addBuiltInProvider(Browser.HTML_UNIT); addBuiltInProvider(Browser.PHANTOM_JS); addBuiltInProvider(Browser.SAFARI); providedBrowserUIList = new ArrayList<>(); buildProvidedBrowserUIList(); }
From source file:org.hyperic.hq.measurement.agent.server.MeasurementCommandsServer.java
public MeasurementCommandsServer() { this.verAPI = new MeasurementCommandsAPI(); this.scheduleThread = null; this.scheduleObject = null; this.senderThread = null; this.senderObject = null; this.storage = null; this.validProps = Collections.synchronizedMap(new HashMap()); this.bootConfig = null; this.schedStorage = null; this.pluginManager = null; this.log = LogFactory.getLog(MeasurementCommandsServer.class); this.ctPluginManager = null; this.ltPluginManager = null; this.trackerThread = null; this.trackerObject = null; this.topnScheduler = null; for (String element : this.verAPI.propSet) { // Simply setup true object values for properties we know about this.validProps.put(element, this); }/*from ww w . j a v a 2s .c om*/ }
From source file:org.apache.cocoon.components.flow.WebContinuation.java
/** * Set an attribute of this continuation * //from w ww .j a v a 2 s. c o m * @param name the attribute name * @param value its value */ public void setAttribute(String name, Object value) { if (this.attributes == null) { this.attributes = Collections.synchronizedMap(new HashMap()); } this.attributes.put(name, value); }
From source file:org.jenkinsmvn.jenkins.api.JenkinsClient.java
private void init() throws IOException { GetJsonObject<Node> retriever = createObjectRetriever(Node.class); node = retriever.getObject(getPath(API_JSON_PATH)); List<Job> jobs = node.getJobs(); if (CollectionUtils.isNotEmpty(jobs)) { Map<String, Job> tmp = new LinkedHashMap<String, Job>(jobs.size()); for (Job job : jobs) { tmp.put(job.getName(), job); }//from w w w.j a va 2 s. c o m jobsCache = Collections.unmodifiableMap(tmp); jobsDetailCache = Collections.synchronizedMap(new HashMap<String, JobDetails>(jobs.size())); } }
From source file:org.opencastproject.oaipmh.server.OaiPmhRepositoryServlet.java
/** * Called by the ConfigurationAdmin service. * This method actually sets up the server. *//*from w ww . j a v a2s .c o m*/ public synchronized void updated(Dictionary properties) throws ConfigurationException { logger.info("Updated"); checkDictionary(properties, componentContext); // collect properties final String path = getCfg(properties, CFG_MOUNT_PATH); final SearchService searchService = (SearchService) componentContext.locateService("searchService"); logger.info("Using search service " + searchService); final String baseUrl = getContextProperty(componentContext, PROP_SERVER_URL) + path; final String repositoryName = getCfg(properties, CFG_REPOSITORY_NAME); final String adminEmail = getContextProperty(componentContext, PROP_ADMIN_EMAIL); final Integer resultLimit = getCfgAsInt(properties, CFG_RESULT_LIMIT); final HttpService httpService = (HttpService) componentContext.locateService("httpService"); // register servlet try { // ... and unregister first if necessary if (currentServletAlias != null) httpService.unregister(currentServletAlias); httpService.registerServlet(path, this, null, null); currentServletAlias = path; logger.info("Registering OAI-PMH server under " + path); } catch (Exception e) { throw new RuntimeException("Error registering OAI-PMH servlet", e); } // create repository repository = new OaiPmhRepository() { private Map resumptionTokens = Collections.synchronizedMap(new LRUMap(100)); @Override public Granularity getRepositoryTimeGranularity() { return Granularity.DAY; } @Override public String getBaseUrl() { return baseUrl; } @Override public String getRepositoryName() { return repositoryName; } @Override public SearchService getSearchService() { return searchService; } @Override public String getAdminEmail() { return adminEmail; } @Override public String saveQuery(ResumableQuery query) { String token = DigestUtils.md5Hex(Double.toString(Math.random())); resumptionTokens.put(token, query); return token; } @Override public Option<ResumableQuery> getSavedQuery(String resumptionToken) { return option(((ResumableQuery) resumptionTokens.get(resumptionToken))); } @Override public int getResultLimit() { return resultLimit; } @Override public List<MetadataProvider> getMetadataProviders() { return metadataProviders; } }; }
From source file:fr.immotronic.ubikit.pems.enocean.impl.DeviceManagerImpl.java
public DeviceManagerImpl(PemLauncher pem, DatabaseManager databaseManager, EnoceanSerialAdapter enoceanSerialAdapter/*, LicenseManager licenseManager*/) { this.databaseManager = databaseManager; this.pem = pem; higherAbstractionLevelEventGate = pem.getHigherAbstractionLevelEventGate(); this.enoceanSerialAdapter = enoceanSerialAdapter; devices = Collections.synchronizedMap(new HashMap<Integer, EnoceanDevice>()); additionalUIDs = Collections.synchronizedMap(new HashMap<Integer, Integer>()); actuatorControllers = new EnoceanControllerDevice[0x80]; // 0x80 match the maximum number of IDs for a TCM120/320/300 transceiver actuatorCount = 0;//w w w . j a v a 2 s. c o m //this.licenseManager = licenseManager; loadKnownDevicesFromDatabase(databaseManager.getAllItems()); }
From source file:naming.resources.ProxyDirContext.java
/** * Builds a proxy directory context using the given environment. *//* ww w . j av a 2 s. c o m*/ public ProxyDirContext(Hashtable env, DirContext dirContext) { this.env = env; this.dirContext = dirContext; if (dirContext instanceof BaseDirContext) { // Initialize parameters based on the associated dir context, like // the caching policy. if (((BaseDirContext) dirContext).isCached()) { cache = Collections.synchronizedMap(new LRUMap(cacheSize)); cacheTTL = ((BaseDirContext) dirContext).getCacheTTL(); cacheObjectMaxSize = ((BaseDirContext) dirContext).getCacheObjectMaxSize(); } } hostName = (String) env.get(HOST); contextName = (String) env.get(CONTEXT); }