Refine search
public ContextJNDISelector(LoggerContext context) { synchronizedContextMap = Collections.synchronizedMap(new HashMap<String, LoggerContext>()); defaultContext = context; }
private Map<String, String> duplicateAndInsertNewMap(Map<String, String> oldMap) { Map<String, String> newMap = Collections.synchronizedMap(new HashMap<String, String>()); if (oldMap != null) { // we don't want the parent thread modifying oldMap while we are // iterating over it synchronized (oldMap) { newMap.putAll(oldMap); } } copyOnThreadLocal.set(newMap); return newMap; }
public T customAttribute(String key, Object value) { if (mCustomAttributes == null) { mCustomAttributes = Collections.synchronizedMap(new HashMap<String, Object>()); } mCustomAttributes.put(key, value); return (T) this; }
protected List<TaskSummary> collectTasksByPotentialOwners(List<Object[]> tasksByGroups) { Set<Long> tasksIds = Collections.synchronizedSet(new HashSet<Long>()); Map<Long, List<String>> potentialOwners = Collections.synchronizedMap(new HashMap<Long, List<String>>()); for (Object o : tasksByGroups) { Object[] get = (Object[]) o; tasksIds.add((Long) get[0]); if (potentialOwners.get((Long) get[0]) == null) { potentialOwners.put((Long) get[0], new ArrayList<String>()); } potentialOwners.get((Long) get[0]).add((String) get[1]); } if (!tasksIds.isEmpty()) { List<TaskSummary> tasks = (List<TaskSummary>)persistenceContext.queryWithParametersInTransaction("TaskSummariesByIds", persistenceContext.addParametersToMap("taskIds", tasksIds), ClassUtil.<List<TaskSummary>>castClass(List.class)); for (TaskSummary ts : tasks) { ((InternalTaskSummary) ts).setPotentialOwners(potentialOwners.get(ts.getId())); } return tasks; } return new ArrayList<TaskSummary>(); }
// Create cache final int MAX_ENTRIES = 100; Map cache = new LinkedHashMap(MAX_ENTRIES+1, .75F, true) { // This method is called just after a new entry has been added public boolean removeEldestEntry(Map.Entry eldest) { return size() > MAX_ENTRIES; } }; // Add to cache Object key = "key"; cache.put(key, object); // Get object Object o = cache.get(key); if (o == null && !cache.containsKey(key)) { // Object not in cache. If null is not a possible value in the cache, // the call to cache.contains(key) is not needed } // If the cache is to be used by multiple threads, // the cache must be wrapped with code to synchronize the methods cache = (Map)Collections.synchronizedMap(cache);
super.beforeTestsStarted(); else { cacheCfgMap = Collections.synchronizedMap(new HashMap<String, CacheConfiguration[]>()); Ignite ignite = startGrid(i); CacheConfiguration[] cacheCfgs = cacheCfgMap.get(ignite.name());
Collections.synchronizedMap(new LinkedHashMap<>()); PartitionDetails details = new PartitionDetails(); details.fullSpec = fullPartSpec; partitionDetailsMap.put(partPath, details); for (Future<Partition> future : futures) { Partition partition = future.get(); result.put(partition.getSpec(), partition);
private Map<String, Statusable<PAGE_T>> getUserJobs(String username) { return jobs.getOrDefault(username, Collections.synchronizedMap(new HashMap<>())); }
@Override public void addDebugInfo(String key, Object value) { if (mDebugInfo == null) { mDebugInfo = Collections.synchronizedMap(new HashMap<String, Object>()); } mDebugInfo.put(key, value); }
public List<TaskSummary> getTasksAssignedByGroups(List<String> groupIds) { if(groupIds == null || groupIds.isEmpty()){ return Collections.EMPTY_LIST; } List<Object[]> tasksByGroups = (List<Object[]>) persistenceContext.queryWithParametersInTransaction("TasksAssignedAsPotentialOwnerByGroups", persistenceContext.addParametersToMap("groupIds", groupIds), ClassUtil.<List<Object[]>>castClass(List.class)); Set<Long> tasksIds = Collections.synchronizedSet(new HashSet<Long>()); Map<Long, List<String>> potentialOwners = Collections.synchronizedMap(new HashMap<Long, List<String>>()); for (Object o : tasksByGroups) { Object[] get = (Object[]) o; tasksIds.add((Long) get[0]); if (potentialOwners.get((Long) get[0]) == null) { potentialOwners.put((Long) get[0], new ArrayList<String>()); } potentialOwners.get((Long) get[0]).add((String) get[1]); } if (!tasksIds.isEmpty()) { List<TaskSummary> tasks = (List<TaskSummary>) persistenceContext.queryWithParametersInTransaction("TaskSummariesByIds", persistenceContext.addParametersToMap("taskIds", tasksIds), ClassUtil.<List<TaskSummary>>castClass(List.class)); for (TaskSummary ts : tasks) { ((InternalTaskSummary) ts).setPotentialOwners(potentialOwners.get(ts.getId())); } return tasks; } return new ArrayList<TaskSummary>(); }
public InMemoryQueuePersistor() { this.objects = Collections.synchronizedMap(new HashMap<Long, T>()); }
map = CACHE_CLASSES.get(classLoader); if (map == null) { map = Collections.synchronizedMap( new WeakHashMap<String, WeakReference<Class<?>>>()); CACHE_CLASSES.put(classLoader, map); WeakReference<Class<?>> ref = map.get(name); if (ref != null) { clazz = ref.get(); } catch (ClassNotFoundException e) { map.put(name, new WeakReference<Class<?>>(NEGATIVE_CACHE_SENTINEL)); return null; map.put(name, new WeakReference<Class<?>>(clazz)); return clazz; } else if (clazz == NEGATIVE_CACHE_SENTINEL) {
Map<?, Map<String, String>> clientProperties = new HashMap<>(); .synchronizedMap(new HashMap<String, Map<String, String>>()); if (entry.getValue().get("kundera.pu") != null) puNames.append(entry.getValue().get("kundera.pu")); puNames.append(","); emf = Persistence.createEntityManagerFactory("testPU", entityConfigurations.get(clazzName));
public void setContextMap(Map<String, String> contextMap) { lastOperation.set(WRITE_OPERATION); Map<String, String> newMap = Collections.synchronizedMap(new HashMap<String, String>()); newMap.putAll(contextMap); // the newMap replaces the old one for serialisation's sake copyOnThreadLocal.set(newMap); } }
public void testAsyncOperationCache() throws Exception { Map<Integer, AsyncOperation> operations = Collections.synchronizedMap(new AsyncOperationCache(2)); final CountDownLatch countDownLatch = new CountDownLatch(1); AsyncOperation completeLater = new AsyncOperation(0, "test") { operations.put(0, completeLater); operations.put(1, completeNow); operations.put(2, completeSoon);
/** * Registers the mapping of the Java class name to the QName */ public synchronized void registerMapping(QName qname, String javaClassName) { if (javaToQName == null) { javaToQName = Collections.synchronizedMap(new HashMap()); } if (qnameToJava == null) { qnameToJava = Collections.synchronizedMap(new HashMap()); } javaToQName.put(javaClassName, qname); qnameToJava.put(qname, javaClassName); }
validatorMap = Collections.synchronizedMap(new HashMap<Long, BlockHeaderValidator>()); List<Pair<Long, BlockHeaderValidator>> validators = config.getBlockchainConfig(). getConfigForBlock(blockNumber).headerValidators(); for (Pair<Long, BlockHeaderValidator> validator : validators) { if (validator.getLeft() <= getBestKnownBlock().getNumber()) { validatorMap.put(validator.getLeft(), validator.getRight()); BlockHeaderValidator validator = validatorMap.get(blockNumber); if (validator != null) { BlockHeaderRule.ValidationResult result = validator.validate(blockHeader);
/** Cache with no limit */ public ProcessDefinitionInfoCache(CommandExecutor commandExecutor) { this.commandExecutor = commandExecutor; this.cache = Collections.synchronizedMap(new HashMap<String, ProcessDefinitionInfoCacheObject>()); }
map = CACHE_CLASSES.get(classLoader); if (map == null) { map = Collections.synchronizedMap( new WeakHashMap<String, WeakReference<Class<?>>>()); CACHE_CLASSES.put(classLoader, map); WeakReference<Class<?>> ref = map.get(name); if (ref != null) { clazz = ref.get(); } catch (ClassNotFoundException e) { map.put(name, new WeakReference<Class<?>>(NEGATIVE_CACHE_SENTINEL)); return null; map.put(name, new WeakReference<Class<?>>(clazz)); return clazz; } else if (clazz == NEGATIVE_CACHE_SENTINEL) {
/** * Substitutes variables in <code>aString</code> with the environment values in the system properties * * @param aString * the string on which to apply the substitution. * @param systemProperties * the system properties to use * @return the string with the substitution applied. */ public static final synchronized String environmentSubstitute( String aString, Map<String, String> systemProperties ) { Map<String, String> sysMap = new HashMap<String, String>(); synchronized ( sysMap ) { sysMap.putAll( Collections.synchronizedMap( systemProperties ) ); aString = substituteWindows( aString, sysMap ); aString = substituteUnix( aString, sysMap ); aString = substituteHex( aString ); return aString; } }