List of usage examples for java.util Collections synchronizedMap
public static <K, V> Map<K, V> synchronizedMap(Map<K, V> m)
From source file:gov.nih.nci.integration.invoker.CaTissueUpdateRegistrationServiceInvocationStrategy.java
/** * Constructor/*from w ww.j a va2 s . c o m*/ * * @param retryCount - retryCount * @param caTissueParticipantClient - caTissueParticipantClient * @param xsltTransformer - xsltTransformer */ public CaTissueUpdateRegistrationServiceInvocationStrategy(int retryCount, CaTissueParticipantClient caTissueParticipantClient, XSLTTransformer xsltTransformer) { super(); this.retryCount = retryCount; this.caTissueParticipantClient = caTissueParticipantClient; this.xsltTransformer = xsltTransformer; final HashMap<String, IntegrationError> msgToErrMapBase = new LinkedHashMap<String, IntegrationError>(); msgToErrMapBase.put("Error authenticating user", IntegrationError._1019); msgToErrMapBase.put("Exception occurred while performing XSL transformation on Date field.", IntegrationError._1028); msgToErrMapBase.put("CaTissue does not contain a participant with the unique identifier", IntegrationError._1033); msgToErrMapBase.put("Participant does not contain the unique identifier SSN", IntegrationError._1034); msgToErrMapBase.put("Participant does not contain the unique medical identifier", IntegrationError._1035); msgToErrMapBase.put( "Either Title is not selected or Date format is not correct in Collection Protocol Registration", IntegrationError._1098); msgToErrMapBase.put("Exception occurred while XSL transformation.", IntegrationError._1099); msgToErrMapBase.put("Study can't be changed while updating the Participant.", IntegrationError._1106); msgToErrMap = Collections.synchronizedMap(msgToErrMapBase); }
From source file:marytts.server.http.BaseHttpRequestHandler.java
public BaseHttpRequestHandler() { super();// w w w.jav a 2 s . c o m logger = MaryUtils.getLogger("server"); requestMap = Collections.synchronizedMap(new HashMap<String, Object[]>()); }
From source file:com.evolveum.midpoint.prism.parser.PrismBeanInspector.java
private <V, P1, P2> V find2(final Map<P1, Map<P2, V>> cache, final P1 param1, final P2 param2, final Getter2<V, P1, P2> getter) { Map<P2, V> cache2 = cache.get(param1); if (cache2 == null) { cache2 = Collections.synchronizedMap(new HashMap()); cache.put(param1, cache2);// www . j a va 2 s . co m } return find1(cache2, param2, new Getter1<V, P2>() { @Override public V get(P2 p) { return getter.get(param1, p); } }); }
From source file:mitm.djigzo.web.services.security.AuthenticationEntryPointWithRequestParams.java
public AuthenticationEntryPointWithRequestParams(List<String> requestParameters, String loginPageParameter, Map<String, String> loginURLs) { Check.notNull(requestParameters, "requestParameters"); Check.notNull(loginPageParameter, "loginPageParameter"); Check.notNull(loginURLs, "loginURLs"); this.requestParameters = Collections.synchronizedList(new ArrayList<String>(requestParameters)); this.loginPageParameter = loginPageParameter; this.loginURLs = Collections.synchronizedMap(new HashMap<String, String>(loginURLs)); }
From source file:org.alfresco.bm.test.TestRunServicesCache.java
/** * @param dao//from w w w .j a va2 s.co m * provides access to the state of a specific test run */ public TestRunServicesCache(MongoTestDAO dao) { this.dao = dao; this.testService = new TestServiceImpl(dao); this.contexts = new HashMap<String, ClassPathXmlApplicationContext>(13); this.contextAccessTimes = Collections.synchronizedMap(new HashMap<String, Long>(13)); this.contextCleanerTask = new ContextCleanerTask(); this.lock = new ReentrantReadWriteLock(); }
From source file:com.github.aptd.simulation.elements.graph.network.local.CStation.java
/** * ctor/*from w w w.j a v a2 s .com*/ * * @param p_configuration agent configuration * @param p_id station identifier * @param p_longitude longitude * @param p_latitude latitude * @param p_time time refernece */ private CStation(final IAgentConfiguration<IStation<?>> p_configuration, final String p_id, final double p_longitude, final double p_latitude, final List<IPlatform<?>> p_platforms, final ITime p_time) { super(p_configuration, FUNCTOR, p_id, p_longitude, p_latitude, p_time); m_platformoccupation = Collections .synchronizedMap(new HashMap<>(p_platforms != null ? p_platforms.size() : 0)); if (p_platforms != null) p_platforms.forEach(p -> m_platformoccupation.put(p, null)); }
From source file:ti.modules.titanium.geolocation.GeolocationModule.java
public GeolocationModule(TiContext tiContext) { super(tiContext); contextGeoHelpers = Collections.synchronizedMap(new TiWeakMap<TiContext, ArrayList<TiGeoHelper>>()); }
From source file:ch.bender.evacuate.Runner.java
/** * run/*from w w w.j a v a2s.c o m*/ * <p> * @throws Exception */ public void run() throws Exception { checkDirectories(); initExcludeMatchers(); myEvacuateCandidates = new TreeMap<>(); myFailedChainPreparations = Collections.synchronizedMap(new HashMap<>()); myFutures = new HashSet<>(); myExclusionDirCount = 0; myEvacuationDirCount = 0; myExclusionFileCount = 0; myEvacuationFileCount = 0; Files.walkFileTree(myBackupDir, new SimpleFileVisitor<Path>() { /** * @see java.nio.file.SimpleFileVisitor#visitFileFailed(java.lang.Object, java.io.IOException) */ @Override public FileVisitResult visitFileFailed(Path aFile, IOException aExc) throws IOException { if ("System Volume Information".equals((aFile.getFileName().toString()))) { return FileVisitResult.SKIP_SUBTREE; } throw aExc; } @Override public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { return Runner.this.visitFile(file, attrs); } @Override public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException { if ("System Volume Information".equals((dir.getFileName()))) { return FileVisitResult.SKIP_SUBTREE; } return Runner.this.preVisitDirectory(dir, attrs); } }); if (myEvacuateCandidates.size() == 0) { myLog.info("No candidates for evacuation found"); } else { StringBuilder sb = new StringBuilder("\nFound candidates for evacuation:"); myEvacuateCandidates.keySet().forEach(p -> sb.append("\n " + p.toString())); myLog.info(sb.toString()); } if (myDryRun) { myLog.debug("DryRun flag is set. Doing nothing"); return; } if (myFutures.size() > 0) { myLog.debug("Waiting for all async tasks to complete"); CompletableFuture.allOf(myFutures.toArray(new CompletableFuture[myFutures.size()])).get(); } if (myFailedChainPreparations.size() > 0) { for (Path path : myFailedChainPreparations.keySet()) { myLog.error("exception occured", myFailedChainPreparations.get(path)); } throw new Exception("chain preparation failed. See above error messages"); } for (Path src : myEvacuateCandidates.keySet()) { Path dst = myEvacuateCandidates.get(src); Path dstParent = dst.getParent(); if (Files.notExists(dstParent)) { Files.createDirectories(dstParent); // FUTURE: overtake file attributes from src } if (myMove) { try { myLog.debug( "Moving file system object \"" + src.toString() + "\" to \"" + dst.toString() + "\""); Files.move(src, dst, StandardCopyOption.ATOMIC_MOVE); } catch (AtomicMoveNotSupportedException e) { myLog.warn("Atomic move not supported. Try copy and then delete"); if (Files.isDirectory(src)) { myLog.debug("Copying folder \"" + src.toString() + "\" to \"" + dst.toString() + "\""); FileUtils.copyDirectory(src.toFile(), dst.toFile()); myLog.debug("Delete folder \"" + src.toString() + "\""); FileUtils.deleteDirectory(src.toFile()); } else { myLog.debug("Copy file \"" + src.toString() + "\" to \"" + dst.toString() + "\""); FileUtils.copyFile(src.toFile(), dst.toFile()); myLog.debug("Delete file \"" + src.toString() + "\""); Files.delete(src); } } } else { if (Files.isDirectory(src)) { myLog.debug("Copying folder \"" + src.toString() + "\" to \"" + dst.toString() + "\""); FileUtils.copyDirectory(src.toFile(), dst.toFile()); } else { myLog.debug("Copy file \"" + src.toString() + "\" to \"" + dst.toString() + "\""); FileUtils.copyFile(src.toFile(), dst.toFile()); } } } myLog.info("\nSuccessfully terminated." + "\n Evacuated Skipped" + "\n Files : " + StringUtils.leftPad("" + myEvacuationDirCount, 9) + StringUtils.leftPad("" + myExclusionDirCount, 9) + "\n Folders: " + StringUtils.leftPad("" + myEvacuationFileCount, 9) + StringUtils.leftPad("" + myExclusionFileCount, 9)); }
From source file:org.openhab.binding.modbus.internal.ModbusConfiguration.java
public static ModbusSlave getSlave(String slave) { return Collections.synchronizedMap(modbusSlaves).get(slave); }
From source file:org.ops4j.pax.runner.platform.internal.Activator.java
/** * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext) *///from ww w. j av a2 s . c o m public void start(final BundleContext bundleContext) throws Exception { NullArgumentException.validateNotNull(bundleContext, "Bundle context"); m_bundleContext = bundleContext; m_registrations = new HashMap<ServiceReference, ServiceRegistration>(); m_platforms = Collections.synchronizedMap(new HashMap<ServiceReference, PlatformImpl>()); trackPlatformBuilders(); registerManagedService(); LOGGER.debug("Platform extender started"); }