List of usage examples for java.util Collections synchronizedMap
public static <K, V> Map<K, V> synchronizedMap(Map<K, V> m)
From source file:jdbc.pool.CXMLManager.java
protected Map<String, CPoolAttribute> getAllPoolAttributes() { Map<String, CPoolAttribute> poolAttributeMap = Collections .synchronizedMap(new HashMap<String, CPoolAttribute>()); int iSize = xmlPoolConfig.getMaxIndex("pool[@name]"); //returns -1 if does not exists for (int i = 0; i <= iSize; i++) { CPoolAttribute attribute = null; try {// w w w .j a v a 2 s. c o m attribute = getPoolAttribute(i); } catch (ConfigurationException e) { //this should not arise } if (attribute != null) { poolAttributeMap.put(attribute.getPoolName(), attribute); } } return poolAttributeMap; }
From source file:architecture.ee.web.community.stats.ViewCountManager.java
private static Map initQueue() { return Collections.synchronizedMap(new HashMap()); }
From source file:org.apache.abdera.util.AbderaConfiguration.java
/** * Registers StreamWriter implementations using the /META-INF/services/org.apache.abdera.writer.StreamWriter file *///ww w . ja v a 2 s . co m private Map<String, Class<? extends StreamWriter>> initStreamWriters() { Map<String, Class<? extends StreamWriter>> writers = null; Iterable<Class<? extends StreamWriter>> _writers = Discover.locate(STREAM_WRITER, true); writers = Collections.synchronizedMap(new HashMap<String, Class<? extends StreamWriter>>()); for (Class<? extends StreamWriter> writer : _writers) { String name = getName(writer); if (name != null) writers.put(name.toLowerCase(), writer); } writers.put("fom", StreamBuilder.class); return writers; }
From source file:org.opencms.xml.CmsXmlEntityResolver.java
/** * Initializes the internal caches for permanent and temporary system IDs.<p> *//*from w ww. j a v a 2 s.c o m*/ private static void initCaches() { if (m_cacheTemporary == null) { Map<String, byte[]> cacheTemporary = CmsCollectionsGenericWrapper.createLRUMap(1024); m_cacheTemporary = Collections.synchronizedMap(cacheTemporary); Map<String, byte[]> cachePermanent = new HashMap<String, byte[]>(32); m_cachePermanent = Collections.synchronizedMap(cachePermanent); Map<String, CmsXmlContentDefinition> cacheContentDefinitions = CmsCollectionsGenericWrapper .createLRUMap(512); m_cacheContentDefinitions = Collections.synchronizedMap(cacheContentDefinitions); } if (OpenCms.getRunLevel() > OpenCms.RUNLEVEL_1_CORE_OBJECT) { if ((OpenCms.getMemoryMonitor() != null) && !OpenCms.getMemoryMonitor() .isMonitoring(CmsXmlEntityResolver.class.getName() + ".cacheTemporary")) { // reinitialize the caches after the memory monitor is set up Map<String, byte[]> cacheTemporary = CmsCollectionsGenericWrapper.createLRUMap(128); cacheTemporary.putAll(m_cacheTemporary); m_cacheTemporary = Collections.synchronizedMap(cacheTemporary); // map must be of type "LRUMap" so that memory monitor can access all information OpenCms.getMemoryMonitor().register(CmsXmlEntityResolver.class.getName() + ".cacheTemporary", cacheTemporary); Map<String, byte[]> cachePermanent = new HashMap<String, byte[]>(32); cachePermanent.putAll(m_cachePermanent); m_cachePermanent = Collections.synchronizedMap(cachePermanent); // map must be of type "HashMap" so that memory monitor can access all information OpenCms.getMemoryMonitor().register(CmsXmlEntityResolver.class.getName() + ".cachePermanent", cachePermanent); Map<String, CmsXmlContentDefinition> cacheContentDefinitions = CmsCollectionsGenericWrapper .createLRUMap(64); cacheContentDefinitions.putAll(m_cacheContentDefinitions); m_cacheContentDefinitions = Collections.synchronizedMap(cacheContentDefinitions); // map must be of type "LRUMap" so that memory monitor can access all information OpenCms.getMemoryMonitor().register( CmsXmlEntityResolver.class.getName() + ".cacheContentDefinitions", cacheContentDefinitions); } } }
From source file:org.apache.jackrabbit.core.security.JahiaAccessManager.java
/** * {@inheritDoc}//w w w . j av a2 s . c o m */ public void init(AMContext context, AccessControlProvider acProvider, WorkspaceAccessManager wspAccessManager, RepositoryContext repositoryContext, WorkspaceConfig workspaceConfig) throws AccessDeniedException, Exception { if (initialized) { throw new IllegalStateException("already initialized"); } pathPermissionCache = Collections.synchronizedMap( new LRUMap(SettingsBean.getInstance().getAccessManagerPathPermissionCacheMaxSize())); subject = context.getSubject(); resolver = context.getNamePathResolver(); hierMgr = context.getHierarchyManager(); workspaceName = context.getWorkspaceName(); this.repositoryContext = repositoryContext; this.workspaceConfig = workspaceConfig; privilegeRegistry = new JahiaPrivilegeRegistry(context.getSession().getWorkspace().getNamespaceRegistry()); Set<JahiaPrincipal> principals = subject.getPrincipals(JahiaPrincipal.class); if (!principals.isEmpty()) { jahiaPrincipal = principals.iterator().next(); } NamespaceResolver nr = new SessionNamespaceResolver(getSecuritySession()); pr = new DefaultNamePathResolver(nr, true); initialized = true; }
From source file:dk.netarkivet.archive.bitarchive.distribute.BitarchiveServer.java
/** * The server creates an instance of the bitarchive it provides access to * and starts to listen to JMS messages on the incomming jms queue * <p/>//from w w w .ja va 2 s .co m * Also, heartbeats are sent out at regular intervals to the Bitarchive * Monitor, to tell that this bitarchive is alive. * * @throws UnknownID - if there was no heartbeat frequency or temp * dir defined in settings or if the * bitarchiveid cannot be created. * @throws PermissionDenied - if the temporary directory or the file * directory cannot be written */ private BitarchiveServer() throws UnknownID, PermissionDenied { System.setOut( new PrintStream(new LoggingOutputStream(LoggingOutputStream.LoggingLevel.INFO, log, "StdOut: "))); System.setErr( new PrintStream(new LoggingOutputStream(LoggingOutputStream.LoggingLevel.WARN, log, "StdErr: "))); boolean listening = false; // are we listening to queue ANY_BA File serverdir = FileUtils.getTempDir(); if (!serverdir.exists()) { serverdir.mkdirs(); } if (!serverdir.canWrite()) { throw new PermissionDenied("Not allowed to write to temp directory '" + serverdir + "'"); } log.info("Storing temporary files at '" + serverdir.getPath() + "'"); bitarchiveAppId = createBitarchiveAppId(); allBa = Channels.getAllBa(); anyBa = Channels.getAnyBa(); baMon = Channels.getTheBamon(); ba = Bitarchive.getInstance(); con = JMSConnectionFactory.getInstance(); con.setListener(allBa, this); baa = BitarchiveAdmin.getInstance(); if (baa.hasEnoughSpace()) { con.setListener(anyBa, this); listening = true; } else { log.warn("Not enough space to guarantee store -- not listening " + "to " + anyBa.getName()); } // create map for batchjobs batchProcesses = Collections.synchronizedMap(new HashMap<String, Thread>()); // Create and start the heartbeat sender Timer timer = new Timer(true); heartBeatSender = new HeartBeatSender(baMon, this); long frequency = Settings.getLong(ArchiveSettings.BITARCHIVE_HEARTBEAT_FREQUENCY); timer.scheduleAtFixedRate(heartBeatSender, 0, frequency); log.info("Heartbeat frequency: '" + frequency + "'"); // Next logentry depends on whether we are listening to ANY_BA or not String logmsg = "Created bitarchive server listening on: " + allBa.getName(); if (listening) { logmsg += " and " + anyBa.getName(); } log.info(logmsg); log.info("Broadcasting heartbeats on: " + baMon.getName()); }
From source file:esg.node.connection.ESGConnectionManager.java
public void init() { log.info("Initializing ESGFConnectionManager..."); lastDispatchTime = new AtomicLong(-1L); //NOTE://from w w w . j ava 2 s . c om //Just to make sure we have these guys if we decide to re-register. //since we did such a good job cleaning things out with we unregister. //Once could imagine wanting to re-establish the connection manager. if (peers == null) peers = Collections.synchronizedMap(new HashMap<String, ESGPeer>()); if (unavailablePeers == null) unavailablePeers = Collections.synchronizedMap(new HashMap<String, ESGPeer>()); try { props = new ESGFProperties(); periodicallyPingToPeers(); periodicallyRegisterToPeers(); } catch (java.io.IOException e) { System.out.println("Damn, ESGConnectionManager, can't fire up... :-("); log.error(e); } Runtime.getRuntime().addShutdownHook(new Thread() { public void run() { if (ESGConnectionManager.this.shutdownHookLatch) { System.out.println("Running Connection Manager Shutdown Hook"); ESGConnectionManager.this.dispatchUnRegisterToPeers(); System.out.println("Bye!"); } ESGConnectionManager.this.shutdownHookLatch = true; } }); }
From source file:org.eclipse.php.internal.core.model.PerFileModelAccessCache.java
/** * Returns cached result of a function search, or invokes a new search query * /* ww w .ja v a2s . c o m*/ * @param sourceModule * Current source module * @param functionName * The name of the global function * @param monitor * Progress monitor * @return a collection of functions according to a given name, or * <code>null</code> if not found */ public Collection<IMethod> getGlobalFunctions(ISourceModule sourceModule, String functionName, IProgressMonitor monitor) { // https://bugs.eclipse.org/bugs/show_bug.cgi?id=342465 if (functionName == null) { return new ArrayList<IMethod>(); } Collection<IMethod> functions; if (!this.sourceModule.equals(sourceModule)) { // Invoke a new search, since we only cache for the original file in // this class: IScriptProject scriptProject = sourceModule.getScriptProject(); IDLTKSearchScope scope = SearchEngine.createSearchScope(scriptProject); functions = Arrays.asList( PhpModelAccess.getDefault().findFunctions(functionName, MatchRule.EXACT, 0, 0, scope, monitor)); } else { functionName = functionName.toLowerCase(); if (globalFunctionsCache == null) { globalFunctionsCache = Collections.synchronizedMap(new HashMap<String, Collection<IMethod>>()); if (!globalFunctionsCache.containsKey(functionName)) { IScriptProject scriptProject = sourceModule.getScriptProject(); IDLTKSearchScope scope = SearchEngine.createSearchScope(scriptProject); IMethod[] allFunctions = PhpModelAccess.getDefault().findFunctions(functionName, MatchRule.EXACT, 0, 0, scope, monitor); Collection<IMethod> funcList = new ArrayList<IMethod>(allFunctions.length); for (IMethod function : allFunctions) { funcList.add(function); } globalFunctionsCache.put(functionName, funcList); } } functions = globalFunctionsCache.get(functionName); } return filterModelElements(sourceModule, functions, monitor); }
From source file:op.care.med.inventory.PnlInventory.java
private void initPanel() { cpMap = Collections.synchronizedMap(new HashMap<String, CollapsiblePane>()); cpListener = Collections.synchronizedMap(new HashMap<String, CollapsiblePaneAdapter>()); lstInventories = Collections.synchronizedList(new ArrayList<MedInventory>()); mapKey2ClosedToggleButton = Collections.synchronizedMap(new HashMap<String, JToggleButton>()); color1 = SYSConst.yellow1;/*ww w .ja v a2 s. c o m*/ color2 = SYSConst.greyscale; // linemap = Collections.synchronizedMap(new HashMap<MedStockTransaction, JPanel>()); prepareSearchArea(); }
From source file:fr.aliasource.webmail.server.LoginFilter.java
@Override public void init(FilterConfig fConfig) throws ServletException { XTrustProvider.install();//w ww . j a va 2 s . com ajaxCall = new HashSet<String>(); ajaxCall.add("/lc"); ajaxCall.add("/folderManager"); ajaxCall.add("/login"); ajaxCall.add("/logout"); ajaxCall.add("/lemails"); ajaxCall.add("/sca"); ajaxCall.add("/settings"); ajaxCall.add("/sent"); ajaxCall.add("/search"); ajaxCall.add("/flags"); ajaxCall.add("/store"); ajaxCall.add("/contactGroups"); ajaxCall.add("/listContacts"); ajaxCall.add("/attachements"); ajaxCall.add("/download"); ajaxCall.add("/attachementsManager"); ajaxCall.add("/proxy"); FrontEndConfig fec = new FrontEndConfig(); settings = Collections.synchronizedMap(fec.get()); logger.info("ssoProvider: " + settings.get(GetSettings.SSO_PROVIDER)); if (settings.isEmpty()) { logger.error("Empty settings: you need " + "a valid /etc/minig/frontend_conf.ini"); } String klass = new ProxyConfig(settings).getProxyClientFactoryClass(); try { proxyClientFactory = (IProxyClientFactory) Class.forName(klass).newInstance(); } catch (Exception e) { logger.error(e.getMessage(), e); throw new ServletException(e); } }